Jump to content

How to toggle fullscreen in C++


Era
 Share

Recommended Posts

I am supporting this game through kickstarter so I do not have access to all the forums yet so I am posting here. (Sorry if this is the wrong spot, but no access to the programming area).

 

So I was playing with the trial and was banging my head against the wall on how to toggle fullscreen, well I figured it out and thought I would share here for others that are having a hard time.

 

void Settings::SetFullScreen(bool isFullscreen)
{
 if (isFullscreen != _vidSettings._fullscreen)
 {
   _vidSettings._fullscreen = isFullscreen;
   GetCore()->window->Release();
   if (isFullscreen)
   {
  GetCore()->window = Window::Create(
    _vidSettings._title,
    0,
    0,
    _vidSettings._res.x,
    _vidSettings._res.y,
    Window::FullScreen);
   }
   else
   {
  GetCore()->window = Window::Create(
    _vidSettings._title,
    0,
    0,
    _vidSettings._res.x,
    _vidSettings._res.y,
    Window::Titlebar);
   }
   GetCore()->context = Context::Create(GetCore()->window);
 }
}

 

I have a class I pass around to everyone that pretty much just contains pointers to window, context, world, and camera that is what the GetCore() is (well it is a function that returns the core pointer but that is a personal coding style)

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...