Exemple #1
0
// Probe probes the video card and return a struct of specifications for it
func Probe() CardSpecs {
	cs := CardSpecs{}
	gl.GetIntegerv(gl.MAX_TEXTURE_SIZE, &cs.MaxTextureSize)
	gl.GetIntegerv(gl.MAX_TEXTURE_IMAGE_UNITS, &cs.MaxTextureImageUnits)
	cs.ShaderVersion = gl.GoStr((gl.GetString(gl.SHADING_LANGUAGE_VERSION)))

	return cs
}
Exemple #2
0
// Convenience function for glGetIntegerv
func GetInteger4(pname uint32) (v0, v1, v2, v3 int) {
	var values = []int32{0, 0, 0, 0}
	gl.GetIntegerv(pname, &values[0])
	v0 = int(values[0])
	v1 = int(values[1])
	v2 = int(values[2])
	v3 = int(values[3])
	return
}
Exemple #3
0
// RenderString must be called on the render thread.  x and y are the initial position of the pen,
// in screen coordinates, and height is the height of a full line of text, in screen coordinates.
func (d *Dictionary) RenderString(str string, x, y, height float64) {
	if str == "" {
		return
	}
	// No synchronization necessary because everything is run serially on the render thread anyway.
	if d.strs == nil {
		d.strs = make(map[string]strData)
	}
	data, ok := d.strs[str]
	if !ok {
		data = d.bindString(str)
		d.strs[str] = data
	}

	render.EnableShader("glop.font")
	defer render.EnableShader("")

	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, d.atlas.texture)
	location, _ := render.GetUniformLocation("glop.font", "tex")
	gl.Uniform1i(location, 0)
	gl.BindSampler(0, d.atlas.sampler)

	location, _ = render.GetUniformLocation("glop.font", "height")
	gl.Uniform1f(location, float32(height))

	var viewport [4]int32
	gl.GetIntegerv(gl.VIEWPORT, &viewport[0])
	location, _ = render.GetUniformLocation("glop.font", "screen")
	gl.Uniform2f(location, float32(viewport[2]), float32(viewport[3]))

	location, _ = render.GetUniformLocation("glop.font", "pen")
	gl.Uniform2f(location, float32(x)+float32(viewport[0]), float32(y)+float32(viewport[1]))

	location, _ = render.GetUniformLocation("glop.font", "textColor")
	gl.Uniform3f(location, d.color[0], d.color[1], d.color[2])

	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.BindVertexArray(data.varrays[0])
	gl.DrawArrays(gl.TRIANGLES, 0, data.count)
}
Exemple #4
0
//GetCurrentTexture2D returns the currently bound texture2D, or 0 is none is bound
func GetCurrentTexture2D() gl2.Texture2D {
	whichID := int32(0)
	gl.GetIntegerv(gl.TEXTURE_BINDING_2D, &whichID)
	return gl2.Texture2D(whichID)
}