PDA

View Full Version : Maximized window creation using OPENGL



scoobypopeye
07-14-2006, 08:38 AM
Hi,

I would like to know how to create a window in vc++ using opengl in maximized mode (NOT fullscreen mode) and disable properties like minimize, resize, etc. (everything for an OPENGL window)

Thanks,
Naresh

Relic
07-14-2006, 08:46 AM
Set the correct window styles for the buttons, or lack thereof:
http://msdn.microsoft.com/library/defaul...indowStyles.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStyles.asp)

Call ShowWindow() with SW_SHOWMAXIMIZED
http://msdn.microsoft.com/library/defaul.../ShowWindow.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/ShowWindow.asp)

scoobypopeye
07-14-2006, 09:05 AM
thanks for the links... These properties can be set only when I have a handle to the window. However, the window was created using OPENGL and it returns a unique number that identifies the window. How do I retrieve the handle for the window using the unique number?

Relic
07-14-2006, 09:23 AM
Sorry, this doesn't make sense.
OpenGL doesn't know of any windows.
The platform (operating system) specific functions wgl... or glx... functions tie window managers and OpenGL functionality together.

If you do not have control about how a window has been created you cannot change the window styles. But you said you want to "create a window in vc++" so you must have these informations.

scoobypopeye
07-14-2006, 09:52 AM
OK. I am not able to understand much of what you say. Let me explain what I want clearly...

// Create image window
glutInitWindowSize(cols, rows);
glutInitWindowPosition((ScreenWidth - cols) /2, (ScreenHeight - rows) /2);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow(filename);

The above code is what I wrote for creating a window. I want this window to start in maximized mode when it enters glutMainLoop();

Tin Whisker
07-14-2006, 10:19 AM
Relic is talking about using the Win32 API to deal with the windows stuff. You didn't mention you were using GLUT (kind of important).

Anyways, dunno, never tried it. I think you want glutFullScreen:
http://www.opengl.org/documentation/specs/glut/spec3/spec3.html

Relic
07-14-2006, 10:28 AM
So you're using the GLUT library to create the window (not OpenGL, you see).

GLUT abstracts the operating system calls like Microsoft's Win32 API call CreateWindow() so that the same GLUT source can be compiled under Windows or Linux, just the underlying Window manager calls are completely different.

What I was assuming is you have a Windows program using the Win32 API directly to create a window and know what window styles are.
I don't know if you can set the necessary window styles via any GLUT interface.

If you want to have a small minimal windows sample you'll find examples on the internet.
These are an Ok start: http://nehe.gamedev.net/
(though I prefer demo apps which do not render in the idle loop).

scoobypopeye
07-14-2006, 10:35 AM
Tin, I assumed GLUT was implied in OPENGL. sorry for that!
The glutFullScreen function is to render the window in fullscreen like games (without the titlebar, buttons, etc.) I want the window to be just maximized (like what it is when we hit the maximize button on any windowed application.

scoobypopeye
07-14-2006, 10:48 AM
Sorry abt that confusion, Relic. I have been following the nehe's tutorials. They have been really useful.

Do you mean to say that a GLUT based window cannot be maximized? I have searched on google but couldn't get sufficient info.

Tin Whisker
07-14-2006, 12:16 PM
Sorry, Scoob. :)

You can definitely maximize the window through the Windows API. Look at GetActiveWindow and SetWindowPos, for example. Though I consider it kinda ugly to mix GLUT and Win32 calls. I'd go ahead and go all the way with windows at this point, but suit yourself.

You could also just get the desktop dimensions and create the window with those dimensions to begin with. Look at GetSystemMetrics with SM_(CX/CY)SCREEN.

scoobypopeye
07-14-2006, 01:10 PM
Tin, GlutCreateWindow is executed when the control enters the GlutMainLoop(); so any change to the window through Windows API commands will not be effected on the desired window. I tried using the commands but didn't work...

The purpose of the window is to load an image and highlight points on the image where the mouse left button is clicked. I think it is easier to work with OpenGL to do the graphics and stuff. Thats why I am resorting to use it.

I am using the GetSystemMetrics to get the ScreenWidth, ScreenHeight used in the code above.

V-man
07-15-2006, 07:07 AM
GLUT is not OpenGL. It is a library written by someone to help making crossplatform code. The Red Book uses it for that reason. Some people use Linux, some Macs, some Unix, some FreeBSD. Before GLUT, there was AUX. The first Red book used it.

GLUT is old and hasn't been updated for a long time. There are SDL, freeGLUT, Qt, wxWindows and probably others that can do a better job.

Zengar
07-16-2006, 04:47 AM
You also should have a look on GLFW - this is by far the best toolkit I know about! It does not support multiple windows thought (but it's not that important anyway).

ZbuffeR
07-16-2006, 07:20 AM
I find GLFW very nice too. Small simple quick and efficient.