Window

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Window

Post 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
Attachments
Window.jpg
Window.jpg (41.69 KiB) Viewed 27977 times
Window.zip
(37.56 KiB) Downloaded 1165 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post 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.
iterationGAMES.com
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Re: Window

Post 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. ;)
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Re: Window

Post 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
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Window

Post 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>
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Window

Post 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.
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Re: Window

Post 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
Imerion
Posts: 200
Joined: Sun Feb 09, 2014 4:42 pm

Re: Window

Post 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.
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Window

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