On 22 June 2012 21:51, Amy <[email protected]> wrote:
> Has anyone messed around with an app/game that uses a split screen?
> (I'm thinking similar to how Sonic the Hedgehog 2 was implemented)

I'm not familiar with the game in question, but I believe what you
want to do is draw two versions of the game in two halves of the
window where the two versions will typically show different regions of
the game world?

If you're needing some ideas about how to go about doing this, the
broad concepts you need are modifying the viewport and setting a
scissor region on the screen to prevent overdraw.

The default pyglet viewport is set up by the default pyglet Window
class on_resize handler (reproduced below sans dostring):

    def on_resize(self, width, height):
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        gl.glOrtho(0, width, 0, height, -1, 1)
        gl.glMatrixMode(gl.GL_MODELVIEW)

Modifying the corner coordinates in the glViewport and glOrtho calls
should allow you to draw to separate viewports on the screen.

To prevent overdraw you should then invoke glScissor with the
coordinates of your sub-window viewports. It takes the same
coordinates as glViewport. You do need to enable scissoring by calling
glEnable(GL_SCISSOR_TEST). I would typically do that like this:

    for each viewport
            ... set up viewport ...
            glPushAttrib(GL_ENABLE_BIT|GL_SCISSOR_BIT)
            glEnable(GL_SCISSOR_TEST)
            glScissor( ... coordinates ...)
            ... perform drawing ...
            glPopAttrib()


     Richard

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to