Пример #1
0
func NewFrameBuffer(width, height int) (this *FrameBuffer) {
	this = &FrameBuffer{gl.GenFramebuffer(), gl.GenTexture(), gl.GenTexture()}

	this.Resize(width, height)

	var outer gl.Framebuffer
	{
		params := []int32{0}
		gl.GetIntegerv(gl.FRAMEBUFFER_BINDING, params)
		outer = gl.Framebuffer(params[0])
	}

	this.Framebuffer.Bind()
	gl.FramebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_RECTANGLE, this.RenderTexture, 0)
	gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_RECTANGLE, this.DepthTexture, 0)
	outer.Bind()

	if gl.CheckFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE {
		this.Delete()
		panic("framebuffer incomplete")
	}

	return
}
Пример #2
0
func TexturesTest() {
	out := make([]int32, 1)
	gl.GetIntegerv(gl.MAX_TEXTURE_IMAGE_UNITS, out)
	maxUnits := int(out[0])

	for i := 0; i < maxUnits; i++ {
		gl.ActiveTexture(gl.GLenum(gl.TEXTURE0 + i))

		gl.GetIntegerv(gl.TEXTURE_BINDING_1D, out)
		texture := gl.Texture(out[0])
		if texture != 0 {
			fmt.Println("unit: ", i, " texture1d: ", texture)
		}

		gl.GetIntegerv(gl.TEXTURE_BINDING_2D, out)
		texture = gl.Texture(out[0])
		if texture != 0 {
			fmt.Println("unit: ", i, " texture2d: ", texture)
		}

		gl.GetIntegerv(gl.TEXTURE_BINDING_RECTANGLE, out)
		texture = gl.Texture(out[0])
		if texture != 0 {
			fmt.Println("unit: ", i, " textureRect: ", texture)
		}

		gl.GetIntegerv(gl.TEXTURE_BINDING_CUBE_MAP, out)
		texture = gl.Texture(out[0])
		if texture != 0 {
			fmt.Println("unit: ", i, " textureCube: ", texture)
		}

		gl.GetIntegerv(gl.TEXTURE_BINDING_3D, out)
		texture = gl.Texture(out[0])
		if texture != 0 {
			fmt.Println("unit: ", i, " texture3d: ", texture)
		}
	}

	gl.ActiveTexture(gl.TEXTURE0)
}