Re: Traditional full screen support with Alt+Tab?

2017-01-08 Thread Benjamin Moran
Pyglet doesn't capture any keypresses by default, but I usually just add 
the additional events like so:
@window.event
def on_key_press(key, mod):
if key == pyglet.window.key.ENTER and mod == pyglet.window.key.MOD_ALT: 
..
..

if window.fullscreen is True:
window.set_fullscreen(fullscreen=False)
else:
window.set_fullscreen(fullscreen=True)





On Monday, January 9, 2017 at 8:18:53 AM UTC+9, Charles wrote:
>
> It's been a while since I have been able to program again, however I just 
> tried this and the alt tab combination is not actually registered by pyglet 
> (Windows 7).
>
> On Saturday, December 3, 2016 at 4:46:37 PM UTC-6, magu...@gmail.com 
> wrote:
>>
>> What you can do is capture the alt-tab keys and use 
>> window.set_fullscreen(False) to return to the desktops native resolution, 
>> then you could use window.minimize() to miminize it to the task bar or just 
>> leave it around. I've tried a few other approaches using 
>> window.on_activate() and window.on_deactivate() for when the window gains 
>> and looses focus, though I found the results were a little janky when it 
>> came to scaling properly, others may be able to get better results. As it 
>> stands in my current example when you tab back the window won't be in 
>> fullscreen mode, but a simple alt+enter solves that. Example:
>>
>> import pyglet
>> from pyglet.window import key
>> from pyglet.gl import *
>>
>> class example(pyglet.window.Window):
>> def __init__(self):
>> super(example, self).__init__(640, 480, resizable=False, 
>> fullscreen=True, caption="Test")
>> self.clear()
>>
>> #fullscreen aspect ratio
>> self.aspect = [self.width/640.0,self.height/480.0]
>>
>> pyglet.clock.get_fps()
>> self.fps_display = pyglet.clock.ClockDisplay()
>>
>> pyglet.clock.schedule_interval(self.update, .01)
>>
>>
>> def update(self,dt):
>> #draw screen
>> self.draw()
>>
>>
>> def draw(self):
>> self.clear()
>> self.fps_display.draw()
>>   
>>
>> def on_key_press(self,symbol,modifiers):
>> if symbol == key.ESCAPE:
>> self.close()
>> #fullscreen toggle
>> if symbol == key.ENTER:
>> if modifiers & key.MOD_ALT:
>> #if fullscreen off, turn on and scale the screen
>> if self.fullscreen == False:
>> window.set_fullscreen(True)
>> 
>> glScalef(window.width/640.0,window.height/480.0,1.0)#2.25x, 
>> 1.875y
>> self.aspect[0] = window.width/640.0
>> self.aspect[1] = window.height/480.0
>> print 'PONG',self.aspect
>> #if its on, turn it off and un-scale the screen
>> else:
>> window.set_fullscreen(False)
>> glScalef((window.width/640.0)/self.aspect[0],(window.
>> height/480.0)/self.aspect[1],1.0)
>>
>> #tab out of fullsceen
>> if symbol == key.TAB:
>> if modifiers & key.MOD_ALT:
>> if self.fullscreen == True:
>> window.set_fullscreen(False)
>> glScalef((window.width/640.0)/self.aspect[0],(window.
>> height/480.0)/self.aspect[1],1.0)
>> self.minimize()
>>
>>
>> if __name__ == '__main__':
>> window = example()
>> pyglet.app.run()
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.


Re: zsprites, or sorting sprites with the z buffer

2017-01-08 Thread 'Charles' via pyglet-users
It's been a long time since I checked this thread, but it looks like there 
has been quite a lot of progress since I last looked. I have tested the 
test branch and so far I have found the ordering to work without issues.

I guess my questions on the latest changes are:
1) Are there any limitations for this? I know last I looked and tested the 
z sprite issues, there were some alpha and transparency issues.

2) Have you done any benchmarks on ordered groups compared to this method? 
How does having a lot of different sprites (hundreds) on various order 
levels affect performance?

Thanks for your work guys!

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.


Re: Traditional full screen support with Alt+Tab?

2017-01-08 Thread 'Charles' via pyglet-users
It's been a while since I have been able to program again, however I just 
tried this and the alt tab combination is not actually registered by pyglet 
(Windows 7).

On Saturday, December 3, 2016 at 4:46:37 PM UTC-6, magu...@gmail.com wrote:
>
> What you can do is capture the alt-tab keys and use 
> window.set_fullscreen(False) to return to the desktops native resolution, 
> then you could use window.minimize() to miminize it to the task bar or just 
> leave it around. I've tried a few other approaches using 
> window.on_activate() and window.on_deactivate() for when the window gains 
> and looses focus, though I found the results were a little janky when it 
> came to scaling properly, others may be able to get better results. As it 
> stands in my current example when you tab back the window won't be in 
> fullscreen mode, but a simple alt+enter solves that. Example:
>
> import pyglet
> from pyglet.window import key
> from pyglet.gl import *
>
> class example(pyglet.window.Window):
> def __init__(self):
> super(example, self).__init__(640, 480, resizable=False, 
> fullscreen=True, caption="Test")
> self.clear()
>
> #fullscreen aspect ratio
> self.aspect = [self.width/640.0,self.height/480.0]
>
> pyglet.clock.get_fps()
> self.fps_display = pyglet.clock.ClockDisplay()
>
> pyglet.clock.schedule_interval(self.update, .01)
>
>
> def update(self,dt):
> #draw screen
> self.draw()
>
>
> def draw(self):
> self.clear()
> self.fps_display.draw()
>   
>
> def on_key_press(self,symbol,modifiers):
> if symbol == key.ESCAPE:
> self.close()
> #fullscreen toggle
> if symbol == key.ENTER:
> if modifiers & key.MOD_ALT:
> #if fullscreen off, turn on and scale the screen
> if self.fullscreen == False:
> window.set_fullscreen(True)
> 
> glScalef(window.width/640.0,window.height/480.0,1.0)#2.25x, 
> 1.875y
> self.aspect[0] = window.width/640.0
> self.aspect[1] = window.height/480.0
> print 'PONG',self.aspect
> #if its on, turn it off and un-scale the screen
> else:
> window.set_fullscreen(False)
> glScalef((window.width/640.0)/self.aspect[0],(window.
> height/480.0)/self.aspect[1],1.0)
>
> #tab out of fullsceen
> if symbol == key.TAB:
> if modifiers & key.MOD_ALT:
> if self.fullscreen == True:
> window.set_fullscreen(False)
> glScalef((window.width/640.0)/self.aspect[0],(window.
> height/480.0)/self.aspect[1],1.0)
> self.minimize()
>
>
> if __name__ == '__main__':
> window = example()
> pyglet.app.run()
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.