Hello there…
I’ve written a program that uses the wgl_arb_render_texture extension to render something to a pbuffer. After doing so, I want to use the pbuffer that I have just rendered to as a texture in two different OpenGL rendering windows (contexts).
So far no problems; I can render to the pbuffer and render two quads in both rendering windows using the pbuffer-based texture that I have just generated.
I want to use mip mapping for the textures in both rendering Windows using the GL_SGIS_generate_mipmap extension; the mip maps need to be generated whenever the pbuffer-texture is updated. And this is where things go wrong…
When I’m finished rendering something to my texture, I do the following (I’m using Borland Delphi 7, “Texture” is of type GLUInt, RTT_SIZE is the width / height of my texture in pixels):
…
glBindTexture(GL_TEXTURE_2D, Texture);
//Generate the actual mip maps:
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, RTT_SIZE, RTT_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, Texture);
…
First of all, I don’t know if I have to call “glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE)” every time, but that’s probably not a problem.
And as far as the formats (GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE) in the glTexImage2D()-call are concerned: I don’t know (yet) if these are the right formats, but I will figure them out (I hope).
The problem is the “Texture” parameter that I would like to pass to the glTexImage2D()-call; I know that my texture “lives” in the “Texture” variable (and in the actual PBuffer, which I can access through Delphi’s THandle), but I cannot simply “point” glTexImage2D to it by passing it as a pointer to glTexImage2D like this:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, RTT_SIZE, RTT_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, Texture);
Or this (mind the “@”, Delphi’s memory location operator):
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, RTT_SIZE, RTT_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, @Texture);
Of course, I would not like to copy the image from the texture (pbuffer) into an auxiliary array only in order to be able to pass it to glTexImage2D; there must be some better (and more efficient) way; after all, the texture already resides in the “Texture” variable / in the pbuffer.
Any ideas on how to accomplish this? Some help would be greatly appreciated. Thanks in advance.
GRTZ,
(Sn)Ik.
[This message has been edited by VuurSnikkel (edited 03-04-2004).]