Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendering to a texture (How ?)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Heretic   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 August 2001 - 02:22 PM

How can I render a scene to a texture using OGL ?

Sponsor:

#2 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 20 August 2001 - 04:39 PM

u can copy a part or all the screen to a texture with glCopyTexSubImage2D(..)
to update an already existing texture with pixels (from any source) use glTexSubImage2D(..)

#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 21 August 2001 - 04:22 PM

That''s slooooowwwww... Almost all newer 3D hardware use shared framebuffer and texture memory. That means, that you could *directly* render to a texture, without having to copy data around. I think there is a function in D3D that supports this, but I''m not sure (i don''t use D3D). There must be a way to do this under OpenGL ? Some extension perhaps ?

- JL


#4 outRider   Members   -  Reputation: 852

Like
Likes
Like

Posted 21 August 2001 - 04:36 PM

Try looking into pixel buffers (aka pbuffers). http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_pbuffer.txt

Maybe that''ll give you what you need.

#5 Maximus   Members   -  Reputation: 124

Like
Likes
Like

Posted 22 August 2001 - 12:35 AM

Ok this works for me (and ISNT slow, for me anyway), and should work for you ok:


int teximgnum = 0;

void InitRenderTexture()
{
glGenTextures(1, teximgnum);
glBindTexture(GL_TEXTURE_2D, teximgnum);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0);
}

void RenderScene()
{
RenderTextureScene(); // render scene to be displayed on a texture
glBindTexture(GL_TEXTURE_2D, teximgnum);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);

RenderView(); // render real scene
}

#6 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 22 August 2001 - 09:32 AM

glCopyTexSubImage2D(..) shouldnt be slow at all, but u need the same data formats in the screen as with the texture (so theres no expensive converting)

btw theres an arb_render_to_texture extension on the horizon

#7 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 August 2001 - 09:12 AM

> glCopyTexSubImage2D(..) shouldnt be slow at all,

Ofcourse it is slow, even with the same data formats. The frambuffer data has to be transfered over the AGP bus down to host memory and back to the 3D card as a texture. Even if this is done as a simple block transfer (no processing, same data format) it still needs the data to be transfered over the AGP bus twice per texture each frame.

> btw theres an arb_render_to_texture extension on the horizon

This would be the ultimate solution. Do you have any more detailed info on this one ?

- JL





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS