Render Targets / Render to Texture

BlitzMax Forums/OpenGL Module/Render Targets / Render to Texture

TeraBit(Posted 2005) [#1]
Hi,

Does anyone have any idea how to to render to a texture (Use a texture as a render target).

I can already render to the backbuffer and Copy it into a texture, but it is a bit of a hassle (and slow) if you're doing it back and forward.


LarsG(Posted 2005) [#2]
didn't Vertex do something like this in his DreiDe engine?


N(Posted 2005) [#3]
http://www.opengl.org/documentation/extensions/EXT_framebuffer_object.txt


TeraBit(Posted 2005) [#4]
Thanks.

I've seen this definition before, but I was hoping someone has seen some demonstration code. I always find it easier to see what is going on from a demo than from abstract descriptions.

Also I don't think the GL module of blitz has these extensions mapped.

didn't Vertex do something like this in his DreiDe engine?


I did have a look through the source, but didn't see it.


Vertex(Posted 2005) [#5]
	Method GrabBackBuffer(X:Int=0, Y:Int=0)
		Local Target:Int

		If Self.RenderMode & DDD_TEXTURE_CUBEMAP Then
			Target = GL_TEXTURE_CUBE_MAP_POSITIVE_X+Self.CubeFace
		Else
			Target = GL_TEXTURE_2D
		EndIf

		glBindTexture(Target, Self.TextureID)
		glCopyTexImage2D(Target, 0, GL_RGBA, X, Y, Self.Size[0], Self.Size[1], 0)
	End Method


cu olli


TeraBit(Posted 2005) [#6]
Hi Vertex,

Thanks. I've put together a set of routines that render to the backbuffer then copy to a texture. I was looking to use the FrameBuffer Objects extension, but it's not listed in the BlitzMax OpenGL module (yet).

It looks like the extension I'm interested in is OpenGL 2.0+ specific, So I may have to stick to the copyrect way of doing it for now. :/


Hotcakes(Posted 2005) [#7]
What you're looking for should be in the GLEW extensions (everything from OpenGL 1.3 onwards)...