Rendering to Texture/DIB

Hi all, can someone point me to a page where to find samples on rendering to texture (better if using DIB and no MFC) ?
I can’t find anything on search engines…

Bye

rIO

There are several ways to get render-to-texture functionatliy with OpenGL, but it depends what your requirements are.

One possibility is to render into the backbuffer as you would normally, then set glReadBuffer(GL_BACK) and use glCopyTexSubImage2D() to copy the contents into a texture.

Another possibility is to use pbuffers (WGL_ARB_pbuffer) in conjunction with the WGL_make_current_read extension. You would render into the pbuffer, and then make the pbuffer your read buffer and your app DC the write buffer. You then use glTexSubImage2D() to copy from the pbuffer into your texture.

There are other ways too…note that all of them require a copy from a rendering surface to a texture. There is currently no OpenGL extension that I know of that avoids the copy. However, some drivers accelerate glCopyTexSubImage2D() so that it gets reasonable performance.

Hope this helps…

I’m quite sure there is a way to render directly to a DIB (only under win of course), without copying the buffer, of course, if rendering to a dib, you must then make a texture using subimage out of the DIB data…

But I just can’t get it work, that’s why I’m looking for a sample on the net…

There is also a sample on MSDN Library, but it uses MFC, and I nedd a sample without MFC…

Thanks anyway for the interest.

Yes there is, by creating a windows bitmap, then setting its hdc pixelformat with the PFD_DRAW_TO_DIB flag, BUT, i think there is no windows card that accelerates it (so its useless). Something like this would be great if accelerated.