   pbuffer with problems
  Hey,I''m playing around with the pbuffer and it''s not working properbly... When I load it to a texture and map the texture onto something it''s all messed up...Here is my entiry init code for pbuffer ->DECLARE_HANDLE(HPBUFFERARB);#define WGL_ARB_extensions_string 1typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);#define WGL_pixel_format 1typedef bool (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);#define WGL_SUPPORT_OPENGL_ARB0x2010#define WGL_DRAW_TO_PBUFFER_ARB0x202D#define WGL_BIND_TO_TEXTURE_RGB_ARB0x2070#define WGL_BIND_TO_TEXTURE_RGBA_ARB0x2071#define WGL_RED_BITS_ARB0x2015#define WGL_GREEN_BITS_ARB0x2017#define WGL_BLUE_BITS_ARB0x2019#define WGL_ALPHA_BITS_ARB0x201B#define WGL_DEPTH_BITS_ARB0x2022#define WGL_DOUBLE_BUFFER_ARB0x2011#define WGL_ARB_pbuffer 1typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);typedef bool (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);typedef bool (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);#define WGL_TEXTURE_FORMAT_ARB0x2072#define WGL_TEXTURE_RGBA_ARB0x2076#define WGL_TEXTURE_RGB_ARB0x2075#define WGL_TEXTURE_TARGET_ARB0x2073#define WGL_TEXTURE_2D_ARB0x207A#define WGL_MIPMAP_TEXTURE_ARB0x2074#define WGL_PBUFFER_LARGEST_ARB0x2033#define WGL_PBUFFER_WIDTH_ARB0x2034#define WGL_PBUFFER_HEIGHT_ARB0x2035#define WGL_PBUFFER_LOST_ARB0x2036#define WGL_FRONT_LEFT_ARB0x2083#define WGL_FRONT_RIGHT_ARB0x2084#define WGL_BACK_LEFT_ARB0x2085#define WGL_BACK_RIGHT_ARB0x2086#define WGL_ARB_render_texture 1typedef bool (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);typedef bool (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);typedef bool (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int * piAttribList);PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL;PFNWGLCREATEPBUFFERARBPROCwglCreatePbufferARB= NULL;PFNWGLGETPBUFFERDCARBPROCwglGetPbufferDCARB= NULL;PFNWGLRELEASEPBUFFERDCARBPROCwglReleasePbufferDCARB= NULL;PFNWGLDESTROYPBUFFERARBPROCwglDestroyPbufferARB= NULL;PFNWGLQUERYPBUFFERARBPROCwglQueryPbufferARB= NULL;PFNWGLCHOOSEPIXELFORMATARBPROCwglChoosePixelFormatARB = NULL;PFNWGLBINDTEXIMAGEARBPROCwglBindTexImageARB= NULL;PFNWGLRELEASETEXIMAGEARBPROCwglReleaseTexImageARB= NULL;PFNWGLSETPBUFFERATTRIBARBPROCwglSetPbufferAttribARB= NULL;bool LoadExtensions(){wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");char *ext = NULL;if (wglGetExtensionsStringARB)ext = (char *)wglGetExtensionsStringARB(wglGetCurrentDC());elsereturn false;if (strstr(ext, "WGL_ARB_pbuffer") == NULL)return false;else {wglCreatePbufferARB    = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB");wglGetPbufferDCARB= (PFNWGLGETPBUFFERDCARBPROC) wglGetProcAddress("wglGetPbufferDCARB");wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC) wglGetProcAddress("wglReleasePbufferDCARB");wglDestroyPbufferARB   = (PFNWGLDESTROYPBUFFERARBPROC) wglGetProcAddress("wglDestroyPbufferARB");wglQueryPbufferARB= (PFNWGLQUERYPBUFFERARBPROC) wglGetProcAddress("wglQueryPbufferARB");if (!wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB ||!wglDestroyPbufferARB || !wglQueryPbufferARB)return false;}if (strstr(ext, "WGL_ARB_pixel_format") == NULL)return false;else {wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");if (!wglChoosePixelFormatARB)return false;}if (strstr(ext, "WGL_ARB_render_texture") == NULL)return false;else {wglBindTexImageARB= (PFNWGLBINDTEXIMAGEARBPROC) wglGetProcAddress("wglBindTexImageARB");wglReleaseTexImageARB  = (PFNWGLRELEASETEXIMAGEARBPROC) wglGetProcAddress("wglReleaseTexImageARB");wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC) wglGetProcAddress("wglSetPbufferAttribARB");if (!wglBindTexImageARB || !wglReleaseTexImageARB || !wglSetPbufferAttribARB)return false;}return true;}typedef struct _SPbuffer {HPBUFFERARBhPBuffer;HDChDC;HGLRChRC;GLsizeiwidth;GLsizeiheight;} SPbuffer;SPbuffer gPbuffer;bool CreatePbuffer(SPbuffer *pbuffer, GLint width, GLint height){pbuffer->hPBuffer= NULL;pbuffer->width= width;pbuffer->height= height;HDC hDC = wglGetCurrentDC();GLint pfAttrib[] = {WGL_SUPPORT_OPENGL_ARB, true,WGL_DRAW_TO_PBUFFER_ARB, true,WGL_BIND_TO_TEXTURE_RGBA_ARB, true,WGL_RED_BITS_ARB, 8,WGL_GREEN_BITS_ARB, 8,WGL_BLUE_BITS_ARB, 8,WGL_ALPHA_BITS_ARB, 8,WGL_DEPTH_BITS_ARB, 24,WGL_DOUBLE_BUFFER_ARB, false,0 };GLint pixelFormat;GLuint count = 0;wglChoosePixelFormatARB(hDC, (const GLint*)pfAttrib, NULL, 1, &pixelFormat, &count); if (count == 0)return false;GLint pbAttrib[] = {WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,WGL_MIPMAP_TEXTURE_ARB, 1,WGL_PBUFFER_LARGEST_ARB, 1,0 };pbuffer->hPBuffer= wglCreatePbufferARB(hDC, pixelFormat, width, height, pbAttrib);pbuffer->hDC= wglGetPbufferDCARB(pbuffer->hPBuffer);pbuffer->hRC= wglCreateContext(pbuffer->hDC);if (!pbuffer->hPBuffer)return false;GLint w, h;wglQueryPbufferARB(pbuffer->hPBuffer, WGL_PBUFFER_WIDTH_ARB, &w);wglQueryPbufferARB(pbuffer->hPBuffer, WGL_PBUFFER_HEIGHT_ARB, &h);if (w != width || h != height)return false;return true;}GLvoid CreateDynamicTexture(GLuint dynamicTexture){glGenTextures(1, &dynamicTexture);glBindTexture(GL_TEXTURE_2D, dynamicTexture);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_FLOAT, 0);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);}bool LoadPbuffer(SPbuffer pbuffer){GLint lost = 0;wglQueryPbufferARB(pbuffer.hPBuffer, WGL_PBUFFER_LOST_ARB, &lost);if (lost != 0)return false;if (!wglMakeCurrent(pbuffer.hDC, pbuffer.hRC))return false;glClearColor(0.0f, 1.0f, 1.0f, 1.0f);glEnable(GL_TEXTURE_2D);glEnable(GL_DEPTH_TEST);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(45.0f, (GLfloat)pbuffer.width / (GLfloat)pbuffer.height, 0.1f, 4000.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);return true;}bool StopPbuffer(SOpenGL wOpenGL){if (!wglMakeCurrent(wOpenGL.hDC, wOpenGL.hRC))return false;SetViewPort(wOpenGL.winWidth, wOpenGL.winHeight);return true;}And here is how I load the texture ->glBindTexture(GL_TEXTURE_2D, gDynamicTexture);if (!wglBindTexImageARB(gPbuffer.hPBuffer, WGL_FRONT_LEFT_ARB)){MessageBox(NULL, "Couldn''t Load Texture From Pbuffer", "Error", MB_OK);PostMessage(wOpenGL.hWnd, WM_QUIT, 0, 0);} 
  I have the same problem.Is it true that you have to upload all the textures that you want to use in the PBuffer (if you want to use them in the PBuffer AND in the normal rc you have to upload them twice??!!)(Sorry that i couldn''t help you with my post :D)cu ;quote:Original post by guts  Is it true that you have to upload all the textures that you want to use in the PBuffer (if you want to use them in the PBuffer AND in the normal rc you have to upload them twice??!!) This sounds too stupid to be true...   "C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"  ;  Well I tried to render my entire scene to a PBuffer, bind this Buffer onto a blank texture but it didn''t work.By loading all my textures before creating the buffer the texture was just white, but when i tried creating my pbuffer and then loading all my textures there were strange artifects on the texture) ...However it didn''t work :D 