Exemple #1
0
func (r *Receiver) Draw(window *glfw.Window) {
	// fmt.Println("render", r.SimulationTime.Elapsed)
	bg := gtk.SoftBlack
	gl.ClearColor(bg[0], bg[1], bg[2], bg[3])
	gl.Enable(gl.DEPTH_TEST)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)

	r.Shaders.UseProgram(PROGRAM_FILL)
	gl.Uniform4fv(r.FillLoc.Color, 1, &gtk.SkyBlue[0])
	gl.Uniform1f(r.FillLoc.Depth, gl.Float(r.Constants.PlayerViewFar))
	r.Shaders.UseProgram(PROGRAM_SCENE)
	gl.Uniform1f(r.SceneLoc.ElapsedSeconds, gl.Float(r.SimulationTime.Elapsed))
	gl.Uniform1f(r.SceneLoc.Glow, 0)
	gl.UniformMatrix4fv(r.SceneLoc.Projection, 1, gl.FALSE, gtk.MatArray(r.Data.Projection))
	gl.UniformMatrix4fv(r.SceneLoc.Cameraview, 1, gl.FALSE, gtk.MatArray(r.Data.Cameraview))
	gl.UniformMatrix4fv(r.SceneLoc.Inception, 1, gl.FALSE, gtk.MatArray(r.Data.Inception))
	mv := glm.Ident4d()
	gl.UniformMatrix4fv(r.SceneLoc.Portalview, 1, gl.FALSE, gtk.MatArray(mv))
	gl.UniformMatrix4fv(r.SceneLoc.Worldview, 1, gl.FALSE, gtk.MatArray(mv))
	// gtk.AttachTexture(r.SceneLoc.Tex0, gl.TEXTURE0, gl.TEXTURE_2D, r.Data.Tex0)
	// gtk.AttachTexture(r.SceneLoc.Tex1, gl.TEXTURE1, gl.TEXTURE_2D, r.Data.Tex1)
	gtk.PanicOnError()

	r.DrawPortalScene(mv, 0, 1)
	r.Invalid = false
}
Exemple #2
0
func (r *Receiver) Draw(window *glfw.Window) {
	bg := gtk.SoftBlack
	gl.ClearColor(bg[0], bg[1], bg[2], bg[3])
	gl.Enable(gl.DEPTH_TEST)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT)

	r.Shaders.UseProgram(ProgramScene)
	gl.UniformMatrix4fv(r.SceneLoc.Projection, 1, gl.FALSE, gtk.MatArray(r.Data.Projection))
	gl.UniformMatrix4fv(r.SceneLoc.Cameraview, 1, gl.FALSE, gtk.MatArray(r.Data.Cameraview))
	gtk.PanicOnError()
	gtk.DrawModel(glm.Ident4d(), r.Data.Scene, r.SceneLoc.Worldview, r.SceneLoc.Position, r.Data.Vao)
	// p := r.Data.Scene.Children[0].Transform.Mul4x1(r.Car.Center)
	// m := glm.Translate3Dd(math.Ceil(p[0]/5)*5,0,math.Ceil(p[2]/5)*5)
	// gtk.DrawModel(m, r.Data.Scene.Children[1], r.SceneLoc.Worldview, r.SceneLoc.Position, r.Data.Vao)
}