Jump to content

Looking for Lua resolution change solution.


Einlander
 Share

Recommended Posts

I want to be able to change the resolution of the game while I debug it. I have a very inelegant solution where I set the old window to nil and create a new window and get it's context.

 

What I came up with:

 

function App:Start()
   self.Fullscreen = false
end

function App:Loop()
   if (self.window:KeyDown(Key.F8)) and (self.Fullscreen == false) then
       self.window:Hide()
       self.window=Window:Create(self.title, 0, 0, 1920, 1080, Window.FullScreen)
       self.context=Context:Create(self.window,0)
       self.context:SetColor(0,0,0)
       self.context:Clear()
       self.context:Sync()
       self.context:SetColor(1,1,1)
       self.Fullscreen = true
   end
end

*add the code in the right functions

 

This will switch the window fullscreen, but the old window is still lurking about. Is there a way to close the window or would I need to make a topic in the suggestions sub forum?

 

Bonus: My setup for debug and relase

 

function App:Start()
   --Create a window
   if DEBUG then
       self.window=Window:Create(self.title)
   else
       self.window=Window:Create(self.title, 0, 0, 1920, 1080, Window.FullScreen)
   end
end

function App:Loop()
   self.context:SetBlendMode(Blend.Alpha)
   if DEBUG then
       self.context:SetColor(1,0,0,1)
       self.context:DrawText("Debug Mode",2,2)
       self.context:SetColor(1,1,1,1)
       self.context:DrawStats(2,22)
       self.context:SetBlendMode(Blend.Solid)
   else
       self.context:SetColor(1,1,1,1)
       self.context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
       self.context:SetBlendMode(Blend.Solid)
   end
   --Refresh the screen
   if DEBUG then
       self.context:Sync(false)
   else
       self.context:Sync(true)
   end
end

 

*add the code in the right functions

 

This one runs debug in a window and release fullscreen

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...