Problem With Fullscreen GL...

Hey, this is a weird problem and I am wondering if it is XP-related. This is the first game I started coding on XP from scratch, and although my OpenGL sources are nearly identical to my other GL sources, I seem to have a problem. When I start the app and it goes fullscreen, it won’t truly go fullscreen. It creates the window and viewport, but you can see the titlebar and window sides. It’s like you stretched a window to the max extents of your monitor and right over the task-bar.

It also will not display my triangles or anything! I have the clear color set to gray (all four values at 0.5) yet the background of the window is green. I’m going to post my drawing routine which is being called every loop of the program, but is not rendering jack.

//Here’s my initialization function

bool InitGL()
{
if(!LoadTextures())
return false;

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

MainLog(“OpenGL initialized!”);
return true;
}

//And here’s the rendering function

void DrawScreen()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(Player.Position.X, Player.Position.Y, -8.0, Player.Position.X, Player.Position.Y, 0.0, 0.0, 1.0, 0.0);
glNormal3f(0.0, 1.0, 0.0);

for(short int BlockLoop = 0; BlockLoop < Map->numBlocks; BlockLoop++)
{
glBindTexture(GL_TEXTURE_2D, Map->Texture[Map->Block[BlockLoop].TexID]);
glBegin(GL_TRIANGLES);

glTexCoord2i(0, 1);
glVertex3i(Map->Block[BlockLoop].X, Map->Block[BlockLoop].Y, 0.250);
glTexCoord2i(1, 1);
glVertex3i((Map->Block[BlockLoop].X + 64), Map->Block[BlockLoop].Y, 0.250);
glTexCoord2i(0, 0);
glVertex3i(Map->Block[BlockLoop].X, (Map->Block[BlockLoop].Y + 64), 0.250);

glTexCoord2i(0, 0);
glVertex3i(Map->Block[BlockLoop].X, (Map->Block[BlockLoop].Y + 64), 0.250);
glTexCoord2i(1, 1);
glVertex3i((Map->Block[BlockLoop].X + 64), Map->Block[BlockLoop].Y, 0.250);
glTexCoord2i(1, 0);
glVertex3i((Map->Block[BlockLoop].X + 64), (Map->Block[BlockLoop].Y + 64), 0.250);

glEnd();
}

glBindTexture(GL_TEXTURE_2D, 1);
glBegin(GL_TRIANGLES);
glTexCoord2i(0, 1);
glVertex3f(Player.Position.X - 16, Player.Position.Y - 16, 0.0);
glTexCoord2i(1, 1);
glVertex3f(Player.Position.X + 16, Player.Position.Y - 16, 0.0);
glTexCoord2i(0, 0);
glVertex3f(Player.Position.X - 16, Player.Position.Y + 16, 0.0);
glEnd();

SwapBuffers(WinData.DeviceContext);
glFlush();
return;
}

Any ideas why this thing won’t work? I am ready to blame XP 100%, but before I go flame MS, I thought I’d let some others look at the code and see if I was screwing up somewhere along the line.

EDIT

Forgot to mention, this is going to wind up being a side-scrolling game, which is why I am using gluLookAt() the way I am. And that last section of code is for testing purposes. It should render a triangle on the middle of the screen at all times, but not even it shows up.

[This message has been edited by Sephiroth (edited 06-05-2003).]

Just post your Window creation function

As requested, the window creation function! I note what certain global vars are above the function, and I have checked them to be sure they are set.

//Global variables
WinData.Bits = 16;
WinData.Width = 1024;
WinData.Height = 768;

bool CreateGLWindow()
{
GLuint PixelFormat;
PIXELFORMATDESCRIPTOR pfd;
DEVMODE dmScreenSettings;

memset(&dmScreenSettings, 0, sizeof(DEVMODE));
dmScreenSettings.dmSize = sizeof(DEVMODE);
dmScreenSettings.dmPelsWidth = WinData.Width;
dmScreenSettings.dmPelsHeight = WinData.Height;
dmScreenSettings.dmBitsPerPel = WinData.Bits;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

if(ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
{
MessageBox(NULL, “Cannot set fullscreen mode.”, “Startup Video Error”, MB_OK | MB_ICONSTOP);
ErrorLog(“OpenGL.cpp: Could not set fullscreen mode.”);
return false;
}

if((WinData.Handle = CreateWindow(WIN_CLASS_NAME, WIN_TITLE, WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, WinData.Width, WinData.Height, NULL, NULL, WinData.Instance, NULL)) == NULL)
{
ErrorLog(“OpenGL.cpp: Could not create the primary window.”);
return false;
}

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = WinData.Bits;
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;

if((WinData.DeviceContext = GetDC(WinData.Handle)) == NULL)
{
KillGLWindow();
ErrorLog(“OpenGL.cpp: Could not get a device context.”);
return false;
}

if((PixelFormat = ChoosePixelFormat(WinData.DeviceContext, &pfd)) == NULL)
{
KillGLWindow();
ErrorLog(“OpenGL.cpp: Can’t find a suitable pixel format.”);
return false;
}

if(!SetPixelFormat(WinData.DeviceContext, PixelFormat, &pfd))
{
KillGLWindow();
ErrorLog(“OpenGL.cpp: Can’t set the pixel format.”);
return false;
}

if((WinData.RenderContext = wglCreateContext(WinData.DeviceContext)) == NULL)
{
KillGLWindow();
ErrorLog(“OpenGL.cpp: Can’t create a GL rendering context.”);
return false;
}

if(!wglMakeCurrent(WinData.DeviceContext, WinData.RenderContext))
{
KillGLWindow();
ErrorLog(“OpenGL.cpp: Can’t activate the GL rendering context.”);
return false;
}

ShowCursor(false);
ShowWindow(WinData.Handle, SW_SHOW);
SetForegroundWindow(WinData.Handle);
SetFocus(WinData.Handle);
ResizeScreen(WinData.Width, WinData.Height);

MainLog(“OpenGL viewport created!”);
return true;
}

Thanks for the help, I appreciate it.

Still can’t make this work, and I’ve tried several things, including turning off culling to see if I had somehow been drawing the triangles in reverse, but that didn’t help. I also still can’t make it go fullscreen. It basically just stretches a window to the max extents of the desktop (over the task-bar and all). I think that if I can make it go fullscreen like it should be doing, it will render, but I can’t figure out what is wrong with the code. I copied the code and pasted it into another app and compiled and it goes fullscreen. So what the F*CK is Windows doing to keep this ONE app from doing the same?

Use WS_POPUP to create a window without decoration (borders, title bar, sys menu). Ie,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_POPUP

Also try using CS_OWNDC in the ‘style’ field of the window class. Might help.

It has CS_OWNDC in it’s class style. also horizontal and vertical redrawing. I’ll try the popup style, but with my plain windoze experience I don’t see how it’ll help.

Actually, it did PARTIALLY help. It now goes fullscreen but the background is still solid green instead of gray, and I can’t see anything.

I’ve just checked back with my stuff, here’s how I create my fullscreen windows:

HWND
GLWindowFactory::make()
{
	HWND ret;
#ifdef _DEBUG
	ret=CreateWindowEx(0,
#else
	ret=CreateWindowEx(WS_EX_TOPMOST|WS_EX_APPWINDOW,
#endif
		(LPCTSTR)window_class_atom,"censored secret application",
		WS_POPUP|WS_VISIBLE,
		0,0,width,height,NULL,NULL,instance,NULL);
	ShowWindow(ret,SW_SHOWNORMAL);

	return(ret);
}

The only true difference I see is WS_VISIBLE (which should send the appropriate ‘SHOW’ message to the window, upon creation, so I’m being a bit redundant here with the explicit ShowWindow), and the omission of the WS_CLIP* stuff.

Anyway, this works just fine for me.

window_class_atom is setup this way:

	memset(&window_class,0,sizeof(window_class));
	window_class.style=CS_OWNDC;
	window_class.lpfnWndProc=DefWindowProc;
	window_class.lpszClassName="censored secret application";
	window_class.hInstance=instance;

	window_class_atom=RegisterClass(&window_class);

You didn’t clear the pfd with
memset(&pfd,0,sizeof pfd);

Try that before you initialize it.

It was not zeroing out the PFD that was my color problem, but I still don’t see any rendered or unrendered triangles.

Show the code where you setup your projection matrix. It’s impossible for anyone to tell you if you’re drawing outside the viewing volume without that information.