PDA

View Full Version : How do I initialize a full screen window using OpenGL under Win32 ?



rohin
12-01-2000, 02:51 PM
Help !

How do I initialize a full screen window with OpenGL using Win32, with out the task bar being active ?

I know how to initialize a full screen window, but the windows taks bar is always active and pops up when the mouse cursor is moved over it. I would like to disable the windows taks bar so that I have a plain simple double buffered full screen on wich to work, with out the windows task bar interfering.

Anybody got any ideas ?


[This message has been edited by rohin (edited 12-05-2000).]

Glossifah
12-01-2000, 04:50 PM
Are you initializing a fullscreen window using ChangeDisplaySettings(DEVMODE, CDS_FULLSCREEN)?

Glossifah

rohin
12-01-2000, 05:39 PM
Hi, thanks for the reply.

No, I am initializing the window using a pretty standard pixel format and window frame class.

Do I need to use ChangeDisplaySettings ?

I will go and have a look at ChangeDisplaySettings(DEVMODE, CDS_FULLSCREEN). I am going to go to bed now though cos its 5:35 am and I hav'nt slept yet :-) I am starting to slur my typing...I have just read the question that I posted, and I see that I have left out quite I few words that should be in there to make up compleat sentences...Its time for bed. :-)

Here is the code I normaly use.

//---------------------------------------------------------------------------
// Win32 entry point
//---------------------------------------------------------------------------

int WINAPI WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG Msg;
WNDCLASS WndClass;

// Register the frame class

WndClass.style = 0;
WndClass.lpfnWndProc = (WNDPROC) MainWndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = hInstance;
WndClass.hIcon = LoadIcon (hInstance, szAppName);
WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
WndClass.lpszMenuName = szAppName;
WndClass.lpszClassName = szAppName;

if (!RegisterClass (&WndClass))
return FALSE;

// Create the frame

ghWnd = CreateWindow (
szAppName,
"3D Tron",
WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
WIDTH,
HEIGHT,
NULL,
NULL,
hInstance,
NULL
);

// Make sure the window was created

if (!ghWnd)
return FALSE;

// Show and update main window

ShowCursor (FALSE);
ShowWindow (ghWnd, SW_MAXIMIZE);
UpdateWindow (ghWnd);

// Set aplication priority

SetPriority (Priority);

// Initialize character font data

InitCFData (CFMap);
InitCFDisplayLists (&CFBase, CFMap);

// Execute main program loop

while (!AppExitFlag)
{
// Process all pending Win32 messages

if (Priority==3)
SetPriority(2);

while (PeekMessage(&Msg, NULL, 0,0, PM_NOREMOVE) == TRUE)
{
if (GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage (&Msg);
DispatchMessage (&Msg);
}
else
{
return TRUE;
}
}
if (Priority==3)
SetPriority(3);

// Process main loop procedure

MainLoopBody();
}

return TRUE;
}

//---------------------------------------------------------------------------
// Main window procedure
//---------------------------------------------------------------------------

LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LONG lRet = 1;
PAINTSTRUCT ps;
RECT Rect;

switch (uMsg){


// On create window

case WM_CREATE:

ghDC = GetDC (hWnd);
if (!InitPixelFormat(ghDC))
PostQuitMessage (0);

// Initialize OpenGL

ghRC = wglCreateContext (ghDC);
wglMakeCurrent (ghDC, ghRC);
GetClientRect (hWnd, &Rect);
InitOpenGL ((GLsizei) Rect.right, (GLsizei) Rect.bottom);

// Initialize application

InitApplication();

break;


// On activate

case WM_ACTIVATE:
{
if (LOWORD(wParam)==WA_INACTIVE)
{
wglMakeCurrent (ghDC, NULL);
ShowWindow (hWnd, SW_MINIMIZE);
OldPriority = Priority;
Priority = 0;
SetPriority (Priority);
}
else
{
wglMakeCurrent(ghDC, ghRC);
ShowWindow(hWnd, SW_MAXIMIZE);
Priority = OldPriority;
SetPriority (Priority);
}
} break;


// On window repaint

case WM_PAINT:

BeginPaint (hWnd, &ps);
EndPaint (hWnd, &ps);

break;


// On window resize

case WM_SIZE:

GetClientRect (hWnd, &Rect);
ResizeViewport ((GLsizei) Rect.right, (GLsizei) Rect.bottom);

break;


// On window close

case WM_CLOSE:

if (ghRC)
wglDeleteContext (ghRC);

if (ghDC)
ReleaseDC (hWnd, ghDC);

ghRC = 0;
ghDC = 0;

DestroyWindow (hWnd);

break;


// On window destroy

case WM_DESTROY:

if (ghRC)
wglDeleteContext (ghRC);

if (ghDC)
ReleaseDC (hWnd, ghDC);

PostQuitMessage (0);

break;

Bla...
.
Bla...
.
Bla...
.
e.t.c.
.

.

thanks

Rohin

Glossifah
12-01-2000, 07:11 PM
Give that a try. Here's the two pages you'll need to get started:
http://msdn.microsoft.com/library/psdk/gdi/devcons_7gz7.htm
http://msdn.microsoft.com/library/psdk/gdi/prntspol_8nle.htm

Also note, when you create the DEVMODE structure, you should populate it with EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, *devMode) and then create a new temporary DEVMODE structure the same way, to restore the those settings when your app closes.

Glossifah

Succinct
12-03-2000, 11:22 PM
Here's my important line of code, but it still does the same things (task bar popping up, system tray icons appearing randomly...)

what could be wrong?!



if( ChangeDisplaySettings( &dmScreenSettings,CDS_FULLSCREEN ) != DISP_CHANGE_SUCCESSFUL )
{


uggh....

at least we're not alone in our boat...

http://www.opengl.org/discussion_boards/ubb/biggrin.gif

-Succinct

pATChes11
12-04-2000, 10:39 AM
hehe I use VB6 for my OpenGL work... lots easier. Try using MFC, too. It just might save you a lot of time :P

rohin
12-04-2000, 10:48 PM
Glossifah, thanks for the reply, I have not had time to do any experiments, but I will get onto the job today, thanks.

Succinct, Iím glad to know Iím not alone. :-)

pATChes11, thanks ! I am sure it easer to implement many OpenGL application in VB, but Iíd prefer to use C/C++ since I am preparing some demoís to go with a resume for a new game company that I would like to work for. Like most hard-core game companies they use C/C++ and Assembler for their products. C++ is preferred for game coding today because it provides a greater degree of low level system control than other high level languages which is required for the development of most successful high performance games. C++ also provides a greater degree of platform independence than many other languages, short of Java, which is useful since many game development companies today attempt to produce versions of there products for both the Windows and Apple Mac platforms, and in an increasing number of cases Linux. Game companies also reuse a lot of there code across hardware platforms like between PCís and consoles. At this point in time, C++ offers the best compromise between low level power and cross platform independence. We are all interested to see how Java evolves, maybe in the future, if we stretch our imagination a little, we might see Java becoming an option for game development, maybe. VB is one of the best choices of language for the development of business oriented platform dependant database applications, although, personally for that sort of application, I am a fan of Pascal (Delphi), and the Borland DB engine. VB is not really the best choice for game coding, although I must agree that certain things are much easer to do in VB, but what you gain in ease of use you loose in low level power and flexibility.

I used to be heavily into 3D GFX coding about 6 years ago, but I gave it up when I went to university, since I had no time left and also there was at that time no future for game coders in South Africa where I live, as there were no game companies at that time. But a new game company, http://www.i-imagine.com/
, has just sprung in SA up this year, and they are looking for 3D coders, so I have decided to dust out the spider webs and try to get back into the Ďgameí, excuse the pun. But quite a bit has changed in the last 6 years. Every body is using 3D APIís like DirectX, OpenGL and Glide, and even higher level engines like the quake and unreal engines. I-imaging requires coders with experience in any or the afore mentioned APIís, C/C++, and Assembler. So this is why I really need to learn how to get OpenGL to cooperate with C++.

[This message has been edited by rohin (edited 12-06-2000).]