コード例 #1
0
ファイル: raytracer.go プロジェクト: sweco-secfbr/octatron
func setupGL() int32 {
	gl.Disable(gl.DEPTH_TEST)
	gl.ClearColor(0.7, 0.7, 0.7, 1)

	program, _ := loadResources()

	gl.BindFragDataLocation(program, 0, gl.Str("outputColor\x00"))
	cameraMatrixUniform := gl.GetUniformLocation(program, gl.Str("cameraMatrix\x00"))
	octUniform := gl.GetUniformLocation(program, gl.Str("oct\x00"))
	gl.Uniform1i(octUniform, 0)

	gl.Viewport(0, 0, winWidth, winHeight)

	var vao uint32
	gl.GenVertexArrays(1, &vao)
	gl.BindVertexArray(vao)

	quadVertexBufferData := []float32{
		-1, -1, 0,
		1, -1, 0,
		-1, 1, 0,
		-1, 1, 0,
		1, -1, 0,
		1, 1, 0,
	}

	var vbo uint32
	gl.GenBuffers(1, &vbo)
	gl.BindBuffer(gl.ARRAY_BUFFER, vbo)
	gl.BufferData(gl.ARRAY_BUFFER, len(quadVertexBufferData)*4, gl.Ptr(quadVertexBufferData), gl.STATIC_DRAW)

	vertAttrib := uint32(gl.GetAttribLocation(program, gl.Str("inputPosition\x00")))
	gl.EnableVertexAttribArray(vertAttrib)
	gl.VertexAttribPointer(vertAttrib, 3, gl.FLOAT, false, 0, gl.PtrOffset(0))

	return cameraMatrixUniform
}
コード例 #2
0
// VertexAttribOffset implements the opengl.OpenGl interface.
func (native *OpenGl) VertexAttribOffset(index uint32, size int32, attribType uint32, normalized bool, stride int32, offset int) {
	gl.VertexAttribPointer(index, size, attribType, normalized, stride, gl.PtrOffset(offset))
}