Newbie Quetsion: Fullscreen/Window Toggle Without GLUT

Member
Posts: 201
Joined: 2002.06
Post: #1
How do you get full screen without GLUT? And what is the best way to toggle between full screen and a window without GLUT?
Quote this message in a reply
Tobi
Unregistered
 
Post: #2
You could use BeginFullScreen(), EndFullScreen() which should be easy to handle.
Example:
Code:
Ptr restoreState;
WindowRef fullscreenWindow;

int main(int argc, char *argv[])
{
OSErr err;
RGBColor black={0,0,0};
short desiredWidth=800;
short desiredHeight=600;

//Create an OpenGL context first. And then go fullscreen:
err=BeginFullScreen(&restoreState, NULL, &desiredWidth, &desiredHeight, &fullscreenWindow, &black, 0);

//Attach the context to fullscreenWindow using aglSetDrawable()
//You need to resize the viewport correctly after this. You probably know it from GLUT.

///........

//Then if you want to leave fullscreen:

EndFullScreen(restoreState, 0);
//Then attach the context to a window using aglSetDrawable() again and reshape the viewport.

return 0;
}

You can also use RezLib to handle the fullscreen stuff which is much better and has more features. It can be used in 9,X and Carbon I think. Perhaps there is something missing in the code but in general it works perfectly for me and the people I'm testing with.

-Tobi
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
BeginFullscreen seems to be a bit buggy on X -- not 100% sure of the details, read the mac-games-dev list archives before you tie yourself to it.

DrawSprocket is an easy way to switch resolutions on both 9 & X, and on X, CoreGraphics is even easier.

RezLib is very nice, and probably the best solution if you want to write the same code for both 9 & X.
Quote this message in a reply
Tobi
Unregistered
 
Post: #4
In any case, if you are writing Carbon code, be sure you have CarbonLib 1.6 or BeginFullScreen and the RezLib functions will freeze the screen in classic or have framerates like 1 frame per minute.

-Tobi
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #5
Okay, now I get it. Thanks!
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #6
Quote:Originally posted by Tobi
err=BeginFullScreen(&restoreState, NULL, &desiredWidth, &desiredHeight, &fullscreenWindow, &black, 0);
What does the &black do? I have used BeginFullScreen before but I always left that argument as nil.
Quote this message in a reply
Tobi
Unregistered
 
Post: #7
Quote:What does the &black do? I have used BeginFullScreen before but I always left that argument as nil.

You can specify a color for that fullscreen WindowRef that BeginFullScreen() creates. If you pass nil or NULL it will use black. For OpenGL it doesn't really matter what background color it has because you do all the drawing in GL.
So it's actually quite stupid to make it point to an RGBColor that is black instead of just passing NULL or nil Smile

-Tobi
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #8
What is wrong with BeginFullscreen? I can't find anything in the mac-games-dev list archives that says anything about bugs. Anybody know the details here?
Quote this message in a reply
Feanor
Unregistered
 
Post: #9
See here: MacGameWiki. -- FÎanor
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
I have a quote from Zwilnik saying it doesn't switch to the requested resolution -- but my recollection is that it will do anything that the displays control panel would let you choose for your desktop, ie 800x600 or bigger, 16- or 32-bit color. Other resolutions (ie 640x480x8), it will choose the closest it's happy with.

That's all just off the top of my head, though, it's only as good as my memory.
Quote this message in a reply
Member
Posts: 201
Joined: 2002.06
Post: #11
That makes sense. I have gotten used to CoreGraphics by now anyway. I really was just looking for how to attach the context to different views.
Quote this message in a reply
Tobi
Unregistered
 
Post: #12
I don't know if there is anything wrong with BeginFullScreen() but all it does is change the resolution and take over the screen.
You cannot change the bit depth with it.
If you want to change both resolution and bit depth you should use RezLib or CoreGraphics.

I've looked into the source of RezLib. It actually calls BeginFullScreen() itself when it is used in Mac OS Classic so I don't think there is anything bad with this function.

-Tobi
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SDL. How to hide fullscreen window e40pud 1 4,093 Mar 11, 2010 01:23 PM
Last Post: cmiller
  Copying from OpenGL window to other window Ingemar 7 4,893 Nov 4, 2006 03:50 AM
Last Post: OneSadCookie
  Fullscreen/Window Setup/toggle skyhawk 10 4,923 Oct 13, 2006 04:05 PM
Last Post: skyhawk
  Fullscreen/Window using same context Matrix 20 9,436 Feb 28, 2005 02:18 PM
Last Post: arekkusu
  fullscreen-window mode switch NYGhost 10 5,470 Feb 10, 2005 09:52 AM
Last Post: NYGhost