Hi all. Usually, my computer is set to 1024x768, 32 bits. My code works ok, but when I switch to 16 bits, everything crashes. On one machine, it happens when I do this:
if(wglMakeCurrent(hdc, hrc) == false)
ShowMessage("Could not MakeCurrent");
What’s disturbing is that both “hdc” and “hrc” are correct (they are produced by
hdc = GetDC();
SetPixelFormatDescriptor();
hrc = wglCreateContext(hdc);
)
Bad things (“project raised exception class C0000090”) happen inside wglMakeCurrent. Here’s my SetPixelFormat routine:
void __fastcall TFormMain::SetPixelFormatDescriptor()
{
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24, // 16 doesn't work either
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
32, // other values don't work either
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0
};
PixelFormat = ChoosePixelFormat(hdc, &pfd);
if (!SetPixelFormat(hdc, PixelFormat, &pfd)) ShowMessage("Pixel format not set");
}
I have Windows 2000 professional, SP4, code composed in Borland C++ Builder 6.0, Riva TNT-2. On another machine (same config, Ge-Force FX 5600) I get through the initialization, but everything crashes (same error code) on function “glRasterPos3f”.
It seems that it shouldn’t be so… When my monitor is set to 32 bits (true color), all is fine. Could anyone please point me out - why does this happen, or what could be done to fix this?
(Added later: I found an interesting thing. When I am running NeHe tutorials, made in Borland C++ Builder, I get the bad behavior as described above. But when I run the same tutorial, made in MS Visual C++, everything’s all right. One more mistery…)