2D Split Screen?
I''m working on a 2D sprite-based game using OpenGL, and wonder if anyone has any information on making a split-screen like display. I''d prefer to use one view port, so I can fairly easily make a sprite struct, and have a screen value. If its position is in is corrosponding screen, draw it. If not, don''t. But then arises the problem if part of it is viewable on one of the screens, how do I clip it? Any ideas? There''s probably a simple solution I''m not thinking of...
Thanks!
You might be able to use a scissor buffer (I think that''s what it''s called). I''ll brb if I can find anything.
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
Here we are... Scissor testing should do what you want. NeHe's lesson #24 covers its usage. You might want to use find to get to the right spot.
[edited by - Thunder_Hawk on June 18, 2003 6:43:31 PM]
[edited by - Thunder_Hawk on June 18, 2003 6:43:31 PM]
There are several ways to do a split screen
1. NeHe Lesson 42
2. Render both screens to different textures, then draw the textures on the screen.
3. Render one screen with one sissors on 1/2 of the screen, then render the other screen with the other 1/2 of the screen using glSissors
4. Give up
---
"you are the poet laureat (sp?) of programming. ALL HAIL!!!" -capn_midnight
A Link for programming drunks
1. NeHe Lesson 42
2. Render both screens to different textures, then draw the textures on the screen.
3. Render one screen with one sissors on 1/2 of the screen, then render the other screen with the other 1/2 of the screen using glSissors
4. Give up
---
"you are the poet laureat (sp?) of programming. ALL HAIL!!!" -capn_midnight
A Link for programming drunks
Hey, thanks a bunch. The scissor function was just what I needed, and it couldn''t be easier.
quote:Original post by dede
3. Render one screen with one sissors on 1/2 of the screen, then render the other screen with the other 1/2 of the screen using glSissors
Actually you could probably get away with only one because you''ll probably need to draw a background for each side.
Food for thought: The texture idea would probably be the slowest, but you could do some neat things with it (like cookie cutter shapes or rotating screens).
______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
..and if you want non-rectangular areas, then you can use the stencil buffer to make irregularly shaped mask regions instead of the scissor test.
Scissor test works on pretty much everything and is fast though, so if that is good enough stick with that.
Scissor test works on pretty much everything and is fast though, so if that is good enough stick with that.
or you MAY be able to specify a viewport for each side of the screnen you want to render to:
void glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
the folowing persumes a resolution of 640 * 480
you may need to set up your projection marix for each change of the viewport. if you want to split horizontally use the heght value to draw to the top half of the screen then shit to draw the bottom half.
void glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
the folowing persumes a resolution of 640 * 480
glViewport (0, 0, 320, 480); //draw or left hand sided stuffglViewport (320, 0, 320, 480); //draw right hand sided stuff
you may need to set up your projection marix for each change of the viewport. if you want to split horizontally use the heght value to draw to the top half of the screen then shit to draw the bottom half.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement