예제 #1
0
파일: tb.go 프로젝트: krattai/monoflow
// drawScene renders the scene consisting of one VAO.
func (tb *tbtag) drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.UseProgram(tb.shaders)
	gl.Uniform1i(tb.sampler, 0)
	gl.ActiveTexture(gl.TEXTURE0 + 0)
	gl.BindTexture(gl.TEXTURE_2D, tb.texture.Tid)
	gl.BindVertexArray(tb.vao)
	tb.mvp32 = renderMatrix(tb.ortho, tb.mvp32)
	gl.UniformMatrix4fv(tb.mvpref, 1, false, tb.mvp32.Pointer())
	gl.DrawElements(gl.TRIANGLES, int32(len(tb.faces)), gl.UNSIGNED_BYTE, gl.Pointer(nil))

	// cleanup
	gl.ActiveTexture(0)
	gl.UseProgram(0)
	gl.BindVertexArray(0)
}
예제 #2
0
파일: opengl.go 프로젝트: krattai/monoflow
// Implements Renderer interface.
func (gc *opengl) Render(v *Vis) {
	if v.Mesh != nil && v.Shader != nil {
		gl.BindVertexArray(v.Mesh.Vao)
		gl.UseProgram(v.Shader.Program)
		gc.bindShaderUniforms(v)
		gl.DrawElements(gl.TRIANGLES, int32(len(v.Mesh.F)), gl.UNSIGNED_SHORT, gl.Pointer(nil))

		// cleanup.
		gl.ActiveTexture(gl.TEXTURE0)
		gl.UseProgram(0)
		gl.BindVertexArray(0)
	}
}
예제 #3
0
파일: opengl.go 프로젝트: krattai/monoflow
// Implements Renderer interface.
func (gc *opengl) MapTexture(tid int, t *data.Texture) {
	tmap := map[int]uint32{
		0: gl.TEXTURE0,
		1: gl.TEXTURE1,
		2: gl.TEXTURE2,
		3: gl.TEXTURE3,
		4: gl.TEXTURE4,
		5: gl.TEXTURE5,
		6: gl.TEXTURE6,
		7: gl.TEXTURE7,
		8: gl.TEXTURE8,
		9: gl.TEXTURE9,
	}
	gl.ActiveTexture(tmap[tid])
	gl.BindTexture(gl.TEXTURE_2D, t.Tid)
}