Fullscreen problem?

The following code works when I’m not in fullscreen mode. But nothing shows up in fullscreen. The color buffer isn’t even cleared properly.

void Questionnaire: :DrawQuestionConsole() const
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0,0,640,480);
glOrtho(0,640,0,480,-20,20);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glColor3f(1.0f,1.0f,1.0f);
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

graphics->printText(15,400,"A:",GLUT_BITMAP_HELVETICA_18);
graphics->printText(15,350,"B:",GLUT_BITMAP_HELVETICA_18);
graphics->printText(15,300,"C:",GLUT_BITMAP_HELVETICA_18);
graphics->printText(15,250,"D:",GLUT_BITMAP_HELVETICA_18);
graphics->printText(15,50,"Press A, B, C, or D",GLUT_BITMAP_HELVETICA_18);

}

void Graphics: :printText (int X_text_pos, int Y_text_pos, char *message, void *font)
{
int len;
int i;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,-20,20);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glRasterPos2f(X_text_pos, Y_text_pos);
len = (int) strlen (message);
for (i=0; i<len; i++)
glutBitmapCharacter(font, message[i]);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}

The code I use for going fullscreen is:

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{

hInst = hInstance; // Store instance handle in our global variable
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory’s Cleared
dmScreenSettings.dmSize = sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = 16; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

if(ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
MessageBox(NULL,“YOUR VIDEO CARD SUCKS.”,“ERROR”,MB_OK|MB_ICONQUESTION);
return FALSE;
}

hWnd = CreateWindow("WIN_CLASS",NULL,
					WS_POPUP |
					WS_VISIBLE |
					WS_MAXIMIZE |
					WS_CLIPCHILDREN |
					WS_CLIPSIBLINGS,
					0,0,												640,480
					NULL,NULL,
					hInstance,
					NULL);

if (!hWnd)
return FALSE;

ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}

What is going wrong? I know that my buffering swapping, message handling code is correct because these functions are part of a driving simulator that works perfectly. I suspect that there are some issues with orthographics projections and fullscreen windows that I am not aware of.

Mr. Stick

[This message has been edited by poop on a stick (edited 08-23-2000).]

Is this all, or did you forget to post the code where you create a context and select pixelformat?

Here is my code where I set up a device context and the pixel format descriptor:

//////////////////////////////////////////////////////////////////////////////////////////////
// //
// Function: InitWGL() //
//////////////////////////////////////////////////////////////////////////////////////////////
void InitWGL()
{
hdc_wgl = GetDC(hWnd);
if(hdc_wgl == NULL)
MessageBox(hWnd,“GetDC Error”,“ERROR”,MB_OK);
SetDCPixelFormat();
hrc_wgl = wglCreateContext(hdc_wgl);
if(hrc_wgl == NULL)
{
MessageBox(hWnd,“wglCreateContext Error”,“ERROR”,MB_OK);
fio << "wglCreateContext Error: " << GetLastError() << endl;
}
if(wglMakeCurrent(hdc_wgl,hrc_wgl) == FALSE)
MessageBox(hWnd,“wglMakeCurrent Error”,“ERROR”,MB_OK);
}
//////////////////////////////////////////////////////////////////////////////////////////////
// //
// Function: SetDCPixelFormat() //
//////////////////////////////////////////////////////////////////////////////////////////////
void SetDCPixelFormat()
{
int nPixelFormat;

static PIXELFORMATDESCRIPTOR pfd = {
	sizeof(PIXELFORMATDESCRIPTOR),
	1,
	PFD_DRAW_TO_WINDOW |
	PFD_SUPPORT_OPENGL |
	PFD_DOUBLEBUFFER,
	PFD_TYPE_RGBA,
	24,
	0,0,0,0,0,0,
	0,0,
	0,0,0,0,0,
	8,
	0,
	0,
	PFD_MAIN_PLANE,
	0,
	0,0,0};

nPixelFormat = ChoosePixelFormat(hdc_wgl, &pfd);
// Error checking makes code look like crap.
if(!nPixelFormat)
{
	MessageBox(NULL,"ChoosePixelFormat Error","Error",MB_OK);
	fio &lt;&lt; "ChoosePixelFormat Error: " &lt;&lt; GetLastError() &lt;&lt; endl;
}

if(!SetPixelFormat(hdc_wgl, nPixelFormat, &pfd))
{
	MessageBox(NULL,"SetPixelFormat Error","Error",MB_OK);
	fio &lt;&lt; "SetPixelFormat Error: " &lt;&lt; GetLastError() &lt;&lt; endl;
}

}

A common error that people make when
they start to program OpenGL under Win95
is that they forget the simple rule:
One window, one thread, one OpenGL RC active.
When a switching to full screen, you have to
use a new RC for the full screen window and
dont forget to switch off the RC you used
previously for the normal window.
Perhaps this is the case here?

Originally posted by Voytec:
When a switching to full screen, you have to use a new RC for the full screen window and dont forget to switch off the RC you used
previously for the normal window. Perhaps this is the case here?

I don’t think this is the case, since I create the RC after I switch to fullscreen(I call InitInstance(…) before I call InitWGL()). The weird thing is that my setup code works for perspective projections, but not for this orthogonal projection.

poop