Jump to content
  • Advertisement
Sign in to follow this  
AutoBot

OpenGL wglChoosePixelFormatARB Problem

This topic is 2607 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody, hopefully someone here can help me out with this issue I'm having with WGL. I've tried to get a pixel format back from wglChoosePixelFormatARB, but it comes up with no results, when it should based on the attributes I provided. I've created a simple window test program that isolates this issue to the GLEW 1.6 library, which is what I'm using:


#ifndef GLEW_STATIC
#define GLEW_STATIC
#endif

#include <GL\glew.h>
#include <GL\wglew.h>

static const TCHAR g_szAppName[] = TEXT("Pixel Format Test");
static const TCHAR g_szClassName[50] = TEXT("OGL_CLASS");

static const int g_nWinWidth = 800;
static const int g_nWinHeight = 600;

HWND g_hWnd;
HGLRC g_hRC;
HDC g_hDC;
HINSTANCE g_hInstance;
WNDCLASS g_windClass;
RECT g_windowRect;
bool g_ContinueRendering;

///////////////////////////////////////////////////////////////////////////////
// Callback functions to handle all window functions this app cares about.
// Once complete, pass message on to next app in the hook chain.
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

///////////////////////////////////////////////////////////////////////////////
// Main program function, called on startup
// Test the window setup, then exit
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
TCHAR *szBuffer;

bool bRun = true;

int nWindowX = 0;
int nWindowY = 0;
int *nPixelFormat = NULL;
PIXELFORMATDESCRIPTOR pfd;

DWORD dwExtStyle;
DWORD dwWindStyle;

HINSTANCE g_hInstance = GetModuleHandle(NULL);

// setup window class
g_windClass.lpszClassName = g_szClassName; // Set the name of the Class
g_windClass.lpfnWndProc = (WNDPROC)WndProc;
g_windClass.hInstance = g_hInstance; // Use this module for the module handle
g_windClass.hCursor = LoadCursor(NULL, IDC_ARROW);// Pick the default mouse cursor
g_windClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);// Pick the default windows icons
g_windClass.hbrBackground = NULL; // No Background
g_windClass.lpszMenuName = NULL; // No menu for this window
g_windClass.style = CS_HREDRAW | CS_OWNDC | // set styles for this class, specifically to catch
CS_VREDRAW; // window redraws, unique DC, and resize
g_windClass.cbClsExtra = 0; // Extra class memory
g_windClass.cbWndExtra = 0; // Extra window memory

// Register the newly defined class
if(!RegisterClass( &g_windClass ))
bRun = false;

dwExtStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwWindStyle = WS_OVERLAPPEDWINDOW;

g_windowRect.left = nWindowX;
g_windowRect.right = nWindowX + 800;
g_windowRect.top = nWindowY;
g_windowRect.bottom = nWindowY + 600;

// Setup window width and height
AdjustWindowRectEx(&g_windowRect, dwWindStyle, FALSE, dwExtStyle);

//Adjust for adornments
int nWindowWidth = g_windowRect.right - g_windowRect.left;
int nWindowHeight = g_windowRect.bottom - g_windowRect.top;

// Create window
g_hWnd = CreateWindowEx(dwExtStyle, // Extended style
g_szClassName, // class name
g_szAppName, // window name
dwWindStyle |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,// window stlye
nWindowX, // window position, x
nWindowY, // window position, y
nWindowWidth, // height
nWindowHeight, // width
NULL, // Parent window
NULL, // menu
g_hInstance, // instance
NULL); // pass this to WM_CREATE

// now that we have a window, setup the pixel format descriptor
g_hDC = GetDC(g_hWnd);

// Set a dummy pixel format so that we can get access to wgl functions
SetPixelFormat( g_hDC, 1,&pfd);
// Create OGL context and make it current
g_hRC = wglCreateContext( g_hDC );
wglMakeCurrent( g_hDC, g_hRC );

if (g_hDC == 0 ||
g_hDC == 0)
{
bRun = false;
MessageBox(NULL,
TEXT("!!! An error accured creating an OpenGL window.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// Setup GLEW which loads OGL function pointers
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
bRun = false;
wsprintf (szBuffer, TEXT ("Error: %s\n"), glewGetErrorString(err));
MessageBox(NULL,
szBuffer,
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// Now that extensions are setup, delete window and start over picking a real format.
wglMakeCurrent(NULL, NULL);
wglDeleteContext(g_hRC);
ReleaseDC(g_hWnd, g_hDC);
DestroyWindow(g_hWnd);

AdjustWindowRectEx(&g_windowRect, dwWindStyle, FALSE, dwExtStyle);

// Create the window again
g_hWnd = CreateWindowEx(dwExtStyle, // Extended style
g_szClassName, // class name
g_szAppName, // window name
dwWindStyle |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,// window stlye
nWindowX, // window position, x
nWindowY, // window position, y
nWindowWidth, // height
nWindowHeight, // width
NULL, // Parent window
NULL, // menu
g_hInstance, // instance
NULL); // pass this to WM_CREATE

g_hDC = GetDC(g_hWnd);

int nPixCount = 0;

// Specify the important attributes we care about
int pixAttribs[] = { WGL_SUPPORT_OPENGL_ARB, 1, // Must support OGL rendering
WGL_DRAW_TO_WINDOW_ARB, 1, // pf that can run a window
WGL_ACCELERATION_ARB, 1, // must be HW accelerated
WGL_COLOR_BITS_ARB, 24, // 8 bits of each R, G and B
WGL_DEPTH_BITS_ARB, 16, // 16 bits of depth precision for window
WGL_DOUBLE_BUFFER_ARB, GL_TRUE, // Double buffered context
WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, // MSAA on
WGL_SAMPLES_ARB, 8, // 8x MSAA
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, // pf should be RGBA type
0}; // NULL termination

// Ask OpenGL to find the most relevant format matching our attribs
// Only get one format back.
wglChoosePixelFormatARB(g_hDC, pixAttribs, NULL, 1, nPixelFormat, (UINT*)&nPixCount);

if(nPixelFormat == NULL)
{
MessageBox(NULL,
TEXT("!!! An error occurred trying to find a MSAA pixel format with the requested attribs.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

// Try again without MSAA
pixAttribs[15] = 1;
wglChoosePixelFormatARB(g_hDC, pixAttribs, NULL, 1, nPixelFormat, (UINT*)&nPixCount);

if(nPixelFormat == NULL)
{
// Couldn't find a format, perhaps no 3D HW or drivers are installed
g_hDC = 0;
g_hDC = 0;
bRun = false;
MessageBox(NULL,
TEXT("!!! An error occurred trying to find a pixel format with the requested attribs.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}
}

if(nPixelFormat != NULL)
{
// Check for MSAA
int attrib[] = { WGL_SAMPLES_ARB };
int nResults = 0;
wglGetPixelFormatAttribivARB(g_hDC, *nPixelFormat, 0, 1, attrib, &nResults);

// Got a format, now set it as the current one
SetPixelFormat( g_hDC, *nPixelFormat, &pfd );

GLint attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
0 };

g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);
if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.3 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 2;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.2 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 1;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.1 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 0;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.0 context.\n!!! OpenGL 3.0 and higher are not supported on this system.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}
}
}
}

wglMakeCurrent( g_hDC, g_hRC );
}

if (g_hDC == 0 ||
g_hDC == 0)
{
bRun = false;
MessageBox(NULL,
TEXT("!!! An error occured creating an OpenGL window."),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// If everything went as planned, display the window
if( bRun )
{
ShowWindow( g_hWnd, SW_SHOW );
SetForegroundWindow( g_hWnd );
SetFocus( g_hWnd );
g_ContinueRendering = true;
}

//Cleanup OGL RC
if(g_hRC)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(g_hRC);
g_hRC = NULL;
}

// release the DC
if(g_hDC)
{
ReleaseDC(g_hWnd, g_hDC);
g_hDC = NULL;
}

// Destroy the window
if(g_hWnd)
{
DestroyWindow(g_hWnd);
g_hWnd = NULL;;
}

// Delete the window class
UnregisterClass(g_szClassName, g_hInstance);
g_hInstance = NULL;

return 0;
}

I have no clue what could be causing this problem. I could spend hours of hair-pulling trying to find some sort of syntax error, but I'd rather that one of the WGL experts here help me out. :)

I'm using Visual C++ 2010 Express, as well as an nVidia GeForce 8500GT with Windows 7, and have even reinstalled to the latest drivers in order to fix this problem, but to no avail. And the freeglut library starts up fine, but obviously I have other motives for using WGL.

Keep in mind that I've installed the glew dll in system32 and have linked to glew32s.lib, glu32.lib, and opengl32.lib to prevent linking trouble. In the case that this is a linking issue, here's the build log, which includes only a few warnings, but compiles successfully anyway:
[font="Consolas"][size="1"][font="Consolas"][size="1"]1>------ Rebuild All started: Project: Windows GL 2, Configuration: Debug Win32 ------

1> main.cpp

1>c:\users\...\documents\visual studio 2010\projects\windows gl 2\windows gl 2\main.cpp(127): warning C4700: uninitialized local variable 'szBuffer' used

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

1> Windows GL 2.vcxproj -> c:\users\...\documents\visual studio 2010\Projects\Windows GL 2\Debug\Windows GL 2.exe

========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

[font="Arial"]The errors that the program recieves are as follows:

[/font][font="Arial"]!!! An error occured trying to find a MSAA pixel format with the requested attribs.
!!! An error occured trying to find a pixel format with the requested attribs.
!!! An error occured creating an OpenGL window.

Thanks to anyone who can help me out with this, can't wait to do a lot more with OpenGL once this problem is cleared up.[/font][/font][/font]

Share this post


Link to post
Share on other sites
Advertisement
You cannot set pixelformat to values you like. You should call ChoosePixelFormat() with "your" format and Windows will return the closest match.

What is retrieved by ChoosePixelFormat() forward to SetPixelFormat() and it will work!

Share this post


Link to post
Share on other sites
ChoosePixelFormat worked, thanks! But why didn't wglChoosePixelFormatARB work? How can I turn MSAA on and off now?

Here's the resulting code. I've commented out the wglChoosePixelFormatARB, as well as the MSAA error checking, since I don't know how to enable/disable MSAA with a pfd:


#ifndef GLEW_STATIC
#define GLEW_STATIC
#endif

#include <GL\glew.h>
#include <GL\wglew.h>

static const TCHAR g_szAppName[] = TEXT("Pixel Format Test");
static const TCHAR g_szClassName[50] = TEXT("OGL_CLASS");

static const int g_nWinWidth = 800;
static const int g_nWinHeight = 600;

HWND g_hWnd;
HGLRC g_hRC;
HDC g_hDC;
HINSTANCE g_hInstance;
WNDCLASS g_windClass;
RECT g_windowRect;
bool g_ContinueRendering;

///////////////////////////////////////////////////////////////////////////////
// Callback functions to handle all window functions this app cares about.
// Once complete, pass message on to next app in the hook chain.
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

///////////////////////////////////////////////////////////////////////////////
// Main program function, called on startup
// Test the window setup, then exit
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
TCHAR *szBuffer;

bool bRun = true;

int nWindowX = 0;
int nWindowY = 0;
int nPixelFormat;
PIXELFORMATDESCRIPTOR pfdDummy;

DWORD dwExtStyle;
DWORD dwWindStyle;

HINSTANCE g_hInstance = GetModuleHandle(NULL);

// setup window class
g_windClass.lpszClassName = g_szClassName; // Set the name of the Class
g_windClass.lpfnWndProc = (WNDPROC)WndProc;
g_windClass.hInstance = g_hInstance; // Use this module for the module handle
g_windClass.hCursor = LoadCursor(NULL, IDC_ARROW);// Pick the default mouse cursor
g_windClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);// Pick the default windows icons
g_windClass.hbrBackground = NULL; // No Background
g_windClass.lpszMenuName = NULL; // No menu for this window
g_windClass.style = CS_HREDRAW | CS_OWNDC | // set styles for this class, specifically to catch
CS_VREDRAW; // window redraws, unique DC, and resize
g_windClass.cbClsExtra = 0; // Extra class memory
g_windClass.cbWndExtra = 0; // Extra window memory

// Register the newly defined class
if(!RegisterClass( &g_windClass ))
bRun = false;

dwExtStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
dwWindStyle = WS_OVERLAPPEDWINDOW;

g_windowRect.left = nWindowX;
g_windowRect.right = nWindowX + 800;
g_windowRect.top = nWindowY;
g_windowRect.bottom = nWindowY + 600;

// Setup window width and height
AdjustWindowRectEx(&g_windowRect, dwWindStyle, FALSE, dwExtStyle);

//Adjust for adornments
int nWindowWidth = g_windowRect.right - g_windowRect.left;
int nWindowHeight = g_windowRect.bottom - g_windowRect.top;

// Create window
g_hWnd = CreateWindowEx(dwExtStyle, // Extended style
g_szClassName, // class name
g_szAppName, // window name
dwWindStyle |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,// window stlye
nWindowX, // window position, x
nWindowY, // window position, y
nWindowWidth, // height
nWindowHeight, // width
NULL, // Parent window
NULL, // menu
g_hInstance, // instance
NULL); // pass this to WM_CREATE

// now that we have a window, setup the pixel format descriptor
g_hDC = GetDC(g_hWnd);

// Set a dummy pixel format so that we can get access to wgl functions
SetPixelFormat( g_hDC, 1,&pfdDummy);
// Create OGL context and make it current
g_hRC = wglCreateContext( g_hDC );
wglMakeCurrent( g_hDC, g_hRC );

if (g_hDC == 0 ||
g_hDC == 0)
{
bRun = false;
MessageBox(NULL,
TEXT("!!! An error accured creating an OpenGL window.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// Setup GLEW which loads OGL function pointers
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
bRun = false;
wsprintf (szBuffer, TEXT ("Error: %s\n"), glewGetErrorString(err));
MessageBox(NULL,
szBuffer,
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// Now that extensions are setup, delete window and start over picking a real format.
wglMakeCurrent(NULL, NULL);
wglDeleteContext(g_hRC);
ReleaseDC(g_hWnd, g_hDC);
DestroyWindow(g_hWnd);

AdjustWindowRectEx(&g_windowRect, dwWindStyle, FALSE, dwExtStyle);

// Create the window again
g_hWnd = CreateWindowEx(dwExtStyle, // Extended style
g_szClassName, // class name
g_szAppName, // window name
dwWindStyle |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,// window stlye
nWindowX, // window position, x
nWindowY, // window position, y
nWindowWidth, // height
nWindowHeight, // width
NULL, // Parent window
NULL, // menu
g_hInstance, // instance
NULL); // pass this to WM_CREATE

g_hDC = GetDC(g_hWnd);

int nPixCount = 1;

//// Specify the important attributes we care about
//int pixAttribs[] = { WGL_SUPPORT_OPENGL_ARB, 1, // Must support OGL rendering
// WGL_DRAW_TO_WINDOW_ARB, 1, // pf that can run a window
// WGL_ACCELERATION_ARB, 1, // must be HW accelerated
// WGL_COLOR_BITS_ARB, 24, // 8 bits of each R, G and B
// WGL_DEPTH_BITS_ARB, 16, // 16 bits of depth precision for window
// WGL_DOUBLE_BUFFER_ARB, GL_TRUE, // Double buffered context
// WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, // MSAA on
// WGL_SAMPLES_ARB, 8, // 8x MSAA
// WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, // pf should be RGBA type
// 0}; // NULL termination

//// Ask OpenGL to find the most relevant format matching our attribs
//// Only get one format back.
//wglChoosePixelFormatARB(g_hDC, pixAttribs, NULL, 1, &nPixelFormat, (UINT*)&nPixCount);

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};

nPixelFormat = ChoosePixelFormat(g_hDC, &pfd);

//if(nPixelFormat == NULL)
//{
// MessageBox(NULL,
// TEXT("!!! An error occurred trying to find a MSAA pixel format with the requested attribs.\n"),
// TEXT("ERROR"),
// MB_OK|MB_ICONEXCLAMATION);

// // Try again without MSAA
// pixAttribs[15] = 1;
// wglChoosePixelFormatARB(g_hDC, pixAttribs, NULL, 1, &nPixelFormat, (UINT*)&nPixCount);

if(nPixelFormat == NULL)
{
// Couldn't find a format, perhaps no 3D HW or drivers are installed
g_hDC = 0;
g_hDC = 0;
bRun = false;
MessageBox(NULL,
TEXT("!!! An error occurred trying to find a pixel format with the requested attribs.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}
//}

if(nPixelFormat != NULL)
{
// Check for MSAA
int attrib[] = { WGL_SAMPLES_ARB };
int nResults = 0;
wglGetPixelFormatAttribivARB(g_hDC, nPixelFormat, 0, 1, attrib, &nResults);

// Got a format, now set it as the current one
SetPixelFormat( g_hDC, nPixelFormat, &pfd );

GLint attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
0 };

g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);
if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.3 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 2;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.2 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 1;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.1 context.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);

attribs[3] = 0;
g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);

if (g_hRC == NULL)
{
MessageBox(NULL,
TEXT("!!! Could not create an OpenGL 3.0 context.\n!!! OpenGL 3.0 and higher are not supported on this system.\n"),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}
}
}
}

wglMakeCurrent( g_hDC, g_hRC );
}

if (g_hDC == 0 ||
g_hDC == 0)
{
bRun = false;
MessageBox(NULL,
TEXT("!!! An error occured creating an OpenGL window."),
TEXT("ERROR"),
MB_OK|MB_ICONEXCLAMATION);
}

// If everything went as planned, display the window
if( bRun )
{
ShowWindow( g_hWnd, SW_SHOW );
SetForegroundWindow( g_hWnd );
SetFocus( g_hWnd );
g_ContinueRendering = true;
}

//Cleanup OGL RC
if(g_hRC)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(g_hRC);
g_hRC = NULL;
}

// release the DC
if(g_hDC)
{
ReleaseDC(g_hWnd, g_hDC);
g_hDC = NULL;
}

// Destroy the window
if(g_hWnd)
{
DestroyWindow(g_hWnd);
g_hWnd = NULL;;
}

// Delete the window class
UnregisterClass(g_szClassName, g_hInstance);
g_hInstance = NULL;

return 0;
}

Share this post


Link to post
Share on other sites
32-bit z-buffer setting is what makes trouble to you! :)

Set freely WGL_COLOR_BITS_ARB to 32 bit, but never set to WGL_DEPTH_BITS_ARB !!! I suggest 24, unless you are dealing with very very old graphics card.

I don't know any graphics card that supports 32-bit depth buffer under Windows (I have no experience with other operating systems).

Also, set WGL_SAMPLES_ARB to arbitrary value, e.g. 16 (if you deal with mighty card, or 4-8 if your card is not such) and try to wglChoosePixelFormatARB(). If it returns valid value and the number of supported formats is greater or equal 1, than you can use returned pixel format. If there is no format supporting 16x AA, then reduce value and try again.

Share this post


Link to post
Share on other sites

32-bit z-buffer setting is what makes trouble to you! :)

Set freely WGL_COLOR_BITS_ARB to 32 bit, but never set to WGL_DEPTH_BITS_ARB !!! I suggest 24, unless you are dealing with very very old graphics card.

I don't know any graphics card that supports 32-bit depth buffer under Windows (I have no experience with other operating systems).

Both ATI and nVidia support 32 bit depth buffer for a few years now. Check all your pixelformats and I'm sure you'll find one.

Share this post


Link to post
Share on other sites
I've found the problem. The WGL_ACCELERATION_ARB attribute needed to be set to WGL_FULL_ACCELERATION_ARB, not 1. Glad that it was only a syntax error.

Thanks for all the help anyway! I'm sure I'll be back with more problems, count on that. ;)

Share this post


Link to post
Share on other sites

Both ATI and nVidia support 32 bit depth buffer for a few years now. Check all your pixelformats and I'm sure you'll find one.


Would you be so kind and direct me to some pixel format that supports 32-bit depth buffer, double buffering and OpenGL version greater than 1.1?


I'm a very pragmatic guy, so I'm not relaying on what is written elsewhere. I have tried to get useful 32-bit depth buffer configuration and I failed.

Yes, there are even 3 pixel formats with 32-bit depth buffer and double buffering (93, 97, and 101), but they are probably for software renderers, because they supports only GL 1.1.

So I must repeat again: I HAVEN'T FOUND ANY GRAPHICS CARD (DRIVER) THAT SUPPORTS PIXEL FORMAT WITH 32-bit DEPTH BUFFER.

Nevertheless, 32-bit depth buffer is not such a great thing. 24-bits have just enough precision for all rendering I have to deal with.

Share this post


Link to post
Share on other sites
I am probably wrong about nVidia. Checking on my current laptop, I'm not seeing any hw accelerated 32 bit depth support, which is weird. My old ATI in my desktop did support it.
On the web, all I found is this http://homepage.mac.com/arekkusu/bugs/GLInfo.html
and if you scroll down to the Depth Buffer Modes (bpp) section, you'll see 0, 16, 24, 32 for the ATI/AMD cards
but the nVidia cards are 0, 16, 24.

I wonder if nVidia really does support 32 bit depth textures or if it fakes it with 24 bit.

Nevertheless, 32-bit depth buffer is not such a great thing. 24-bits have just enough precision for all rendering I have to deal with.[/quote]
Yes, the difference between the 2 is very small. It won't really help with depth fighting but since GPU tend to prefer 32 bit chunks rather than 24 bit, they pad the left over 8 bit with either junk or if you ask for a stencil buffer, they make a D24S8 buffer. I really expected my machine to give some 32 bit support but I guess not.

Share this post


Link to post
Share on other sites
I'm sorry I was rude. :(

Since the first release of GF cards, I have got only NVIDIA cards, so I don't know if AMD supports it, but I really doubt.



Even on Fermi based cards there is no hardware accelerated pixel formats with 32-bit depth buffer. But never mind, I just have to stress that setting 32-bit depth will cause failure of wglChoosePixelFormatARB on all NV cards.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!