Exemple #1
0
func (glRenderer *OpenglRenderer) enableCullFace(cullFace bool) {
	if cullFace == glRenderer.cullFace {
		return
	}
	if cullFace {
		gl.Enable(gl.CULL_FACE)
	} else {
		gl.Disable(gl.CULL_FACE)
	}
	glRenderer.cullFace = cullFace
}
Exemple #2
0
func (glRenderer *OpenglRenderer) enableDepthTest(depthTest bool) {
	if depthTest == glRenderer.depthTest {
		return
	}
	if depthTest {
		gl.Enable(gl.DEPTH_TEST)
	} else {
		gl.Disable(gl.DEPTH_TEST)
	}
	glRenderer.depthTest = depthTest
}
Exemple #3
0
func (p *GeometryPass) DrawPass(scene *Scene) {
	p.Buffer.Bind()
	p.Buffer.Clear()

	p.Material.Use()

	/* Draw scene */
	gl.Disable(gl.BLEND)
	scene.Draw("geometry", p.Material.Shader)
	gl.Enable(gl.BLEND)

	p.Buffer.Unbind()
}
Exemple #4
0
func (glRenderer *OpenglRenderer) renderPostEffect(pe postEffect) {
	gl.UseProgram(pe.program)
	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, pe.textureId)
	gl.Disable(gl.CULL_FACE)
	gl.BindBuffer(gl.ARRAY_BUFFER, glRenderer.postEffectVbo)

	setupUniforms(pe.shader)

	vertAttrib := uint32(gl.GetAttribLocation(pe.program, gl.Str("vert\x00")))
	gl.EnableVertexAttribArray(vertAttrib)
	gl.VertexAttribPointer(vertAttrib, 2, gl.FLOAT, false, 4*4, gl.PtrOffset(0))
	texCoordAttrib := uint32(gl.GetAttribLocation(pe.program, gl.Str("vertTexCoord\x00")))
	gl.EnableVertexAttribArray(texCoordAttrib)
	gl.VertexAttribPointer(texCoordAttrib, 2, gl.FLOAT, false, 4*4, gl.PtrOffset(2*4))

	gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
	gl.DisableVertexAttribArray(texCoordAttrib)
}
func draw(w *glfw.Window) {

	//Get the horizontal split size of the window
	sizex, sizey := w.GetSize()

	var eyesize mgl32.Vec2
	eyesize[0] = float32(sizex / 2.0)
	eyesize[1] = float32(sizey)

	gl.Enable(gl.SCISSOR_TEST)

	gl.Scissor(0, 0, int32(eyesize[0]), int32(eyesize[1]))
	gl.ClearColor(1, 0, 0, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.Scissor(int32(eyesize[0]), 0, int32(eyesize[0]), int32(eyesize[1]))
	gl.ClearColor(0, 0, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.Disable(gl.SCISSOR_TEST)

}