iDevGames Forums
PBuffer & Render to Texture (read & write) - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: PBuffer & Render to Texture (read & write) (/thread-5899.html)



PBuffer & Render to Texture (read & write) - habicht - Feb 7, 2005 06:09 AM

Hi,

I'm trying to render into a pbuffer subbuffer (e.g. WGL_FRONT_LEFT_ARB) and at the same time I want to use subbuffers of the pbuffer (WGL_BACK_LEFT_ARB, WGL_AUX0_ARB) as texture uniforms for my fragment program. I don't even know if that's possible, but I think I read about that somewhere.

This is roughly how I thought it could work:
(using a GeForce 6800 GT)

Code:
_oFPBuffer.activate();
...

glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);
glGenTextures(1, _iTexRead);
glBindTexture(GL_TEXTURE_2D, _iTexRead);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
...

glDrawBuffer(WGL_FRONT_LEFT_ARB);

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, _iTexRead);

if( !wglBindTexImageARB(&_oFPBuffer, WGL_BACK_LEFT_ARB) )
{ ... error ... }

glUniform1iARB(_iTexUnitDiagN1, 2);
...

glBegin(GL_QUADS);
{ ... }
glEnd();

glActiveTexture(GL_TEXTURE2);
wglReleaseTexImageARB(&_oFPBuffer, WGL_BACK_LEFT_ARB);
...

For the next pass I want to render into the buffer that I used for reading in this pass. Accordingly I want to read the buffer that has the results from the previous pass.

wglBindTexImageARB(...) always results (GetLastError()) in error code 3221684230 which is neither ERROR_INVALID_OPERATION, ERROR_INVALID_DATA, nor ERROR_INVALID_WINDOW_HANDLE.

I use the following attributes for my pbuffer:

Code:
int attribList[] =
{
  WGL_SUPPORT_OPENGL_ARB,       true,
  WGL_RED_BITS_ARB,             32,
  WGL_GREEN_BITS_ARB,           32,
  WGL_BLUE_BITS_ARB,            32,
  WGL_ALPHA_BITS_ARB,           32,
  WGL_STENCIL_BITS_ARB,         8,
  WGL_DEPTH_BITS_ARB,           24,
  WGL_FLOAT_COMPONENTS_NV,      true,
  WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
  WGL_DRAW_TO_PBUFFER_ARB,      true,
  WGL_DOUBLE_BUFFER_ARB,        true,
  WGL_AUX_BUFFERS_ARB,          true,
  0,
};

and the following pbuffer related extensions in my program:

Code:
"GL_NV_float_buffer " \
"WGL_ARB_pixel_format " \
"WGL_ARB_pbuffer " \
"WGL_ARB_render_texture " \
"WGL_ARB_extension_string "

Any idea how I can get this working?

Thanks a lot!


PBuffer & Render to Texture (read & write) - OneSadCookie - Feb 7, 2005 12:12 PM

apparently the aqua theme doesn't help at all, after all Smile


PBuffer & Render to Texture (read & write) - TomorrowPlusX - Feb 7, 2005 12:40 PM

OneSadCookie Wrote:apparently the aqua theme doesn't help at all, after all Smile

You mean to scare away windows programmers? I was wondering about the aqua theme...


PBuffer & Render to Texture (read & write) - arekkusu - Feb 7, 2005 02:28 PM

Maybe some day we'll all be using EXT_framebuffer_object, but for now the specifics of pixel formats and window/pbuffer drawables are highly OS-specific. So this question is better asked on the Windows OpenGL forum. iDevGames is Macintosh-centric.


PBuffer & Render to Texture (read & write) - habicht - Feb 7, 2005 05:33 PM

Ooops! Maybe I was already too tired yesterday... :-)