PDA

View Full Version : Pbuffer PROBLEMS



Ffelagund
12-10-2003, 11:03 PM
Hello, i am spending a lot of time with the setup of the pbuffers, and i don't know why they doesn't work very good. There is my problems: first: I make a window of 800x600 (Windows XP) and then i make a pbuffer (512x512) based on the hdc of that window, i render ONE triangle to the pbuffer, copy the pbuffer content via glCopyTexSubImage2D to a texture, change the current context and draw a quad in the window, with the texture binded to him. In my system, i get 40 fps (amd duron 1Ghz, WildCat VP 560), and in all other systems that i had tried (usually Geforce Ti 4xxx) i get... 3 fps!
i only draw one triangle and one quad! and glcopytexsubimage can't be too slow!
I am desesperated, i have checked the renderers, the pixel formats, all that i can think, and i had found no solution.

Other problem (and probably related to the other problem) is that when i call wglChoosePixelFormat in my app, EVER returns 0 (no pixel match) but if search manually all pixel formats with wglGetPixelFormatAttribivARB i can find a pixel format that match with my requeriments, and i can use it via wglCreatePbufferARB with no errors (except the above problems).

What thing am i doing bad?
I am desesperated.

P.D: forgive my bad english please http://www.opengl.org/discussion_boards/ubb/smile.gif

Mazy
12-10-2003, 11:25 PM
a Copy from a Pbuffer to a texture is very slow on nVidia cards

look at this thread http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/010964.html

Ffelagund
12-11-2003, 12:03 AM
ummm... i see...
But i still have one problem, why in my app i can't get a pixel format, and other demos that i had tested, can get it?


[This message has been edited by Ffelagund (edited 12-11-2003).]

rgpc
12-11-2003, 12:15 AM
As Mazy said there are issues with using glCopyTexSubImage2D() with pbuffers. The solution to this issue was found to be that you must not specify the attributes required for Render to Texture if you are not actually using Render To Texture.



WGL_TEXTURE_FORMAT_ARB;
WGL_TEXTURE_RGBA_ARB;

WGL_TEXTURE_TARGET_ARB;
WGL_TEXTURE_2D_ARB;



As for your ChoosePixelFormat problem are you referring to pbuffers or windows? Perhaps a code sample would give us some more clues (ie. You are probably doing something wrong that we should be able to spot by looking at your code)

Ffelagund
12-11-2003, 12:32 AM
The choosepixelformat problems are in the pbuffer. There are my code resumed:
//window creation
hWnd = CreateWindowEx(blablabla);
memset(&m_pfd,0,sizeof(PIXELFORMATDESCRIPTOR));
m_pfd.nSize=sizeof(PIXELFORMATDESCRIPTOR);
m_pfd.nVersion=1;
m_pfd.dwFlags= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
m_pfd.iPixelType=PFD_TYPE_RGBA;
m_pfd.cColorBits=m_config.m_colorBits;
m_pfd.cAlphaBits=m_config.m_alphaBits;
m_pfd.cDepthBits=m_config.m_depthBits;
m_pfd.cStencilBits=m_config.m_stencilBits;
m_pfd.iLayerType=PFD_MAIN_PLANE;

if (!(m_hDC=GetDC(hWnd)))
return false;

if (!(m_pixelFormat=ChoosePixelFormat(m_hDC,&m_pfd)))
return false;

if(!SetPixelFormat(m_hDC,m_pixelFormat,&m_pfd))
return false;

if (!(m_hRC=wglCreateContext(m_hDC)))
return false;

if(!wglMakeCurrent(m_hDC,m_hRC))
return false;

//--------------------------
//code for pbuffer creation
m_hDC = wglGetCurrentDC();
m_hRC = wglGetCurrentContext();
int piAttributes[]=
{
WGL_DRAW_TO_PBUFFER_ARB,
WGL_COLOR_BITS_ARB,
WGL_ALPHA_BITS_ARB,
WGL_DEPTH_BITS_ARB,
WGL_STENCIL_BITS_ARB
};

int piValues[5];
UINT count = 0;
int pixelformat=1;
int IAttribList[]={ WGL_DRAW_TO_PBUFFER_ARB, 1,
WGL_COLOR_BITS_ARB, m_config.m_colorBits,
WGL_ALPHA_BITS_ARB, m_config.m_alphaBits,
WGL_DEPTH_BITS_ARB, depth,
WGL_STENCIL_BITS_ARB, m_config.m_stencilBits};


BOOL b = wglChoosePixelFormatARB(m_hDC, IAttribList, NULL, 1,&pixelformat, &count);
// this is the problematic choosepixelformat. It EVER return 0 to 'b', and NEVER gives me a pixel format

m_hBuffer = wglCreatePbufferARB(m_hDC, m_pixelFormat, m_config.m_width, m_config.m_height, NULL);
m_hDC = wglGetPbufferDCARB(m_hBuffer);
m_hRC = wglCreateContext(m_hDC);

//-----------------------------------
//i choose the pixel format manually by this way:

for(int i=0;i<54;++i)
{
a = wglGetPixelFormatAttribivARB(m_hDC,i,0,5, piAttributes, piValues);
if(a)
{
if(piValues[0])
{
if((piValues[1]>=m_config.m_colorBits)&&(piValues[2]>=m_config.m_alphaBits)&&
(piValues[3]>=m_config.m_depthbits)&&(piValues[4]>=m_config.m_stencilBits))
pixelformat=i;
}
}
}
}
// i use this pixelformat in wglCreatePbufferARB and works fine

//sorry for the dirty code but this is a resume made above many funcions dispersed by my program
[This message has been edited by Ffelagund (edited 12-11-2003).]

[This message has been edited by Ffelagund (edited 12-11-2003).]

ZbuffeR
12-11-2003, 02:06 AM
What are the exact values you use for your m_config.m_xxxBits ?
By the way, I now recommend using RenderToTexture extension if supported instead of copyTexSubImage, for quite high pbuffer resolution (eg. 512x512).

Ffelagund
12-11-2003, 02:13 AM
My card doesn't support that extension (it's a 3DLabs Wildcat VP560), so glCopyTexSubImage2D are my only possibility.

the m_config values are:
m_config.m_width=512;
m_config.m_height=512;
m_config.m_colorBits=24;
m_config.m_alphaBits=8;
m_config.m_stencilBits=8;
m_config.m_depthBits=16;

Mazy
12-11-2003, 02:21 AM
im not sure how choosepixelformat does, but i dont think thats a valid mode on most cards.. the pixelformats ive seen have a bitlength match between (color+alpha) and (depth+stencil) so 24bit depth,8 bit stencil might do the trick

Ffelagund
12-11-2003, 02:31 AM
I had tried this too, and doesn't work.

If i get all pixel formats, and check all of them manually, i find a pixelformat that match with my requeriments (that is, make my custom ChoosePixelFormat), and i can use it to create the pbuffer.
I had downloaded some pbuffer demos, and debugging them, i can see that choosepixelformat works in that apps (but not in mine).
I don't know what are wrong in my app :p

rgpc
12-11-2003, 02:38 AM
Try this...



int IAttribList[]={ WGL_DRAW_TO_PBUFFER_ARB, 1,
WGL_COLOR_BITS_ARB, m_config.m_colorBits + m_config.m_alphaBits,
WGL_DEPTH_BITS_ARB, depth,
WGL_STENCIL_BITS_ARB, m_config.m_stencilBits};


I think you are meant to either specify COLOR_BITS=32 or R=8, G=8, B=8 and A=8. The other thing is to check if your card actually supports Hardware stencil (I'm not familiar with it but that's something that springs to mind...)

Ffelagund
12-11-2003, 03:00 AM
Nothing :p .
I only get a pixel format, if i call ChoosePixelformat by this way:

BOOL b = wglChoosePixelFormatARB(m_hDC, NULL, NULL, 1,&pixelformat, &count);

but this returns to me the pixel format n# 1 (totally inadecuated to my requisites)

P.D: i had tried a lot of IAttribList combinations, and ever returns to me 0.

Mazy
12-11-2003, 03:13 AM
shouldnt the list be ended by a 0,0 ?

Ffelagund
12-11-2003, 03:25 AM
Sorry, sorry sorry i am the biggest silly, idiot and confused programmer (if i can refer me by this way) ths exists in the opengl community.
I'm not finished the list with 0,0...


P.D: I'll open a flower shop before this revelation...