Rendering to Texture

Hi, I’m new to opengl and need enlightening for my project.

I want to render a scene and use it as a texture map for another object. But I tried, but my code doesn’t seem to be copying that scene to the texture and I don’t know why is this so.

Any help or sample codes that I can refer?

Try a search for “opengl render to texture”.

Here’s a great site for OpenGL demos:
http://download.developer.nvidia.com/developer/SDK/Individual_Samples/samples.html

In any case, it’s a good idea to start with a working example, then build upon it. That way you start with a solid base and there’s less to debug.

Hope it helps.

Hello!
I was thinking in render the scene and the use glCopyPixels(). Is there a better approach?

glReadPixels() is a good option???

I was thinking in render the scene and the use glCopyPixels(). Is there a better approach?
Depending on your hardware, you can use frame buffer objects (FBO) or pixel buffers (Pbuffer):
http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
http://www.opengl.org/registry/specs/ARB/wgl_pbuffer.txt

After context initialization, call glGetString with GL_EXTENSIONS to get a list of supported extensions on your particular hardware. The FBO extension is by far the preferred route–it’s supported on most all modern hardware and it’s judged by many to be much more pleasant to work with :wink:

There are good demos of both reachable through the link above, and there are countless others online.

Hope it helps.

Edit: fixed link