Thanks for the help guys, I’ve made a bit of progress but am now stumped on something else along the same lines. I managed to get something going from a combination of things I read on NeHe, Humus etc. However while I now get no errors it’s not performing as expected.
What I’m actually after is an output of unclamped float values (32-bits per component if poss) from the fragment shader and my code looks something like this at the moment:
First I set a PIXELFORMATDESCRIPTOR
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
128,
32, 0, 32, 0, 32, 0,
32,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
and set a basic pixel format with no WGL stuff (apparently you have to do this first??):
void SetupPixelFormat( HDC hDC )
{
int nPixelFormat;
nPixelFormat = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, nPixelFormat, &pfd );
}
Then I sort out the context:
hRC = wglCreateContext( hDC ); // Create the rendering context
wglMakeCurrent( hDC, hRC ); // Make the rendering context
Next I setup the WGL stuff (just before the texture / shaders setup stuff, I’ve also tried placing it afterwards):
bool SetupWGLPixelFormat( HDC hDC )
{
int nPixelFormat;
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress( "wglChoosePixelFormatARB" );
if ( !wglChoosePixelFormatARB )
{
MessageBox( NULL, "wglChoosePixelFormatARB not supported", "Error! (SetupWGLPixelFormat)", MB_OK );
return false;
}
BOOL bValidPixFormat;
UINT nMaxFormats = 1;
UINT nNumFormats;
float pfAttribFList[] = { 0, 0 };
int piAttribIList[] = { WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB, 128,
WGL_RED_BITS_ARB, 32,
WGL_GREEN_BITS_ARB, 32,
WGL_BLUE_BITS_ARB, 32,
WGL_ALPHA_BITS_ARB, 32,
WGL_DEPTH_BITS_ARB, 16,
WGL_STENCIL_BITS_ARB, 0,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
0, 0 };
bValidPixFormat = wglChoosePixelFormatARB( hDC, piAttribIList, pfAttribFList, nMaxFormats, &nPixelFormat, &nNumFormats );
if ( !bValidPixFormat )
{
MessageBox( NULL, "Invalid Pixel Format", "Error! (SetupWGLPixelFormat)", MB_OK );
return false;
}
SetPixelFormat( hDC, nPixelFormat, &pfd );
return true;
}
Then I attempt to turn off clamping:
glClampColorARB( GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE );
glClampColorARB( GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE );
glClampColorARB( GL_CLAMP_READ_COLOR_ARB, GL_FALSE );
Before finally dumping values out with:
glReadPixels( 0, 0, WINDOWWIDTH, WINDOWHEIGHT, GL_RGBA, GL_FLOAT, fPixels );
glReadPixels( 0, 0, WINDOWWIDTH, WINDOWHEIGHT, GL_DEPTH_COMPONENT, GL_FLOAT, fDepth );
The problem is the values are still clamped……I’m told this is possible in GL so I must be missing something.
Hope these questions aren’t too daft but I’m jumping in at the deep end a bit with OpenGL having only used DirectX previously. So there’s a bit of a combination of internet trawling and guesswork in the code.
Thanks again.