Skip to content

Examples

Changkun Ou edited this page Sep 6, 2021 · 1 revision

This page shows examples built using polyred. See more in the examples folder.

Hello world

The following code snippet shows a minimum example:

package main

import (
	"poly.red/camera"
	"poly.red/gui"
	"poly.red/light"
	"poly.red/model"
	"poly.red/render"
	"poly.red/scene"
)

func main() {
	// Create a scene graph
	s := scene.NewScene()

	// Create and add a point light and a bunny to the scene graph
	s.Add(light.NewPoint(), model.StanfordBunny())

	// Create a camera for the rendering
	c := camera.NewPerspective()

	// Create a renderer and specify scene and camera
	r := render.NewRenderer(render.Scene(s), render.Camera(c))

	// Render and show the result in a window
	gui.Show(r.Render())
}

The above example should results in the following picture (not yet):

Clone this wiki locally