Page 1 of 1

Window

Posted: Tue Feb 01, 2011 5:21 pm
by Kjell
8)

On-the-fly fullscreen / zoom toggling using stock ZGE ( Windows-only ). Press F4 to toggle between windowed & fullscreen mode and F2 / F3 to make the window smaller / bigger.

K

Posted: Tue Feb 01, 2011 11:06 pm
by jph_wacheski
Very nice! I was just wundering about this, and boom here it is. Yes this would be quite usefull to integrate into the runner IMHO. Thanks for posting this.

Re: Window

Posted: Wed Aug 05, 2015 11:48 pm
by Imerion
Sorry, I realize this is a very old thread. But I just came across the need to switch to/from fullscreen mode from within my app. I'm planning on adding it to my options menu. Can this be done? I checked the example, but it seemed a bit too complicated, not to mention I'd love if it could work with Linux as well. :)

I had hoped App.FullScreen = 1; would be enough, but no luck. ;)

Re: Window

Posted: Thu Aug 06, 2015 7:13 pm
by Kjell
Hi Imerion,

Unfortunately this never made it in. I've send Ville source code ( examples ) for this multiple times over the years .. most recently in 2014 ( including support for Aero snap ), but no cigar. Not sure what else i can do :(

K

Re: Window

Posted: Fri Aug 07, 2015 1:50 pm
by VilleK
Hi guys,

I made a quick attempt at fixing this. Instead of using the Fullscreen property I use the ScreenMode property.

First download latest beta: http://www.zgameeditor.org/files/ZGameEditor_beta.zip

Then try this project (press space to switch between fullscreen and windowed):

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" ScreenMode="1" FileVersion="2">
  <OnUpdate>
    <KeyPress Keys=" " RepeatDelay="1">
      <OnPressed>
        <ZExpression>
          <Expression>
<![CDATA[App.ScreenMode= (App.ScreenMode==0) ? 1 : 0;
App.ClearColor.R=1-App.ClearColor.R;]]>
          </Expression>
        </ZExpression>
      </OnPressed>
    </KeyPress>
  </OnUpdate>
  <OnRender>
    <RenderSprite/>
  </OnRender>
</ZApplication>

Re: Window

Posted: Sat Aug 08, 2015 12:17 pm
by VilleK
Updated example above and fixed a bug related to keypress states when switching screenmode. If you want to test then download beta again.

Note that App.WindowHandle gets recreated so if you use this somehow (passing it to external library perhaps) then you need to do this again after switching screenmode.

Re: Window

Posted: Sat Aug 08, 2015 1:14 pm
by Kjell
Hej Ville,

I assume that the current approach is just temporarily? Since .. this way you can't use a custom window resolution ( aside from it being a rather unintuitive way to toggle fullscreen ).

Also, why are you recreating the window ( you're not recreating the OpenGL context as well i hope )? You can simply update the window size & style instead ( as demonstrated in the examples i send ) ..

http://dl.dropboxusercontent.com/u/1412036/Window.zip

K

Re: Window

Posted: Mon Aug 10, 2015 2:08 pm
by Imerion
Thanks for adding an implementation for this! It works fine, but unfortunately I needed a custom window resolution. (Since all the built-in ones are non-widescreen.)
I tried to use 1024x768 since it's close to what I use in the game (1024x576). That way everything is displayed, but with black bars at top and bottom.
Switching to fullscreen this way works fine, and after switching the game uses my full screen resolution (giving me a wide 1366x768), but after that I can't seem to switch back to 1024x768 windowed. It simply doesn't do anything after that.

Re: Window

Posted: Tue Aug 11, 2015 8:26 am
by VilleK
Imerion wrote:I needed a custom window resolution. (Since all the built-in ones are non-widescreen.)
Ah, that list of resolutions needs to be updated.

@Kjell: You know I always try to implement features in the simplest way possible :). The reasons are both to save development time and runtime size. So the solution I chose here only required me to add a few lines of code, whereas if I tried to use your examples it would require me to add more code and would be trickier to make cross-platform. In the end, I still may use your code, but this is a first effort.