Post by 8XenoTrogdor8 on Feb 9, 2005 2:21:45 GMT -5
So, apparently simultaneous multiplayer games that use different sections of the same screen are possible...
This program splits the screen into two down the middle using scissoring. If you press the left or right arrow key, it will stop rendering iether the left or right screens. (you may notice a slight gain in the speed of the pyramid still rendering). If the up or down arrow keys are pressed, whichever pyramid(s) are active will tip.
Please set the screen size to 640*480 before using! otherwise the screen might not look right...
using GlScissor (X1, Y1, X2, Y2), OpenGL limits the drawing of anything afterward to that section of the window. (X1, Y1, X2, Y2 form a rectangle where X1 is any X pixel from the left of the screen, Y is any Y pixel from the bottom of the screen, X2 is the width of the window (from X1) and Y2 is the hieght of the window (from Y1). At least I think so anyway...).
So then you can make multiplayer games! Or just limit drawing area to speed up rendering...
This program splits the screen into two down the middle using scissoring. If you press the left or right arrow key, it will stop rendering iether the left or right screens. (you may notice a slight gain in the speed of the pyramid still rendering). If the up or down arrow keys are pressed, whichever pyramid(s) are active will tip.
Please set the screen size to 640*480 before using! otherwise the screen might not look right...
Dim Tip1, Tip2, Turn1, Turn2, I
GlEnable (GL_SCISSOR_TEST) ' Enable "Scissoring".
While True
if not ScanKeyDown (VK_LEFT) then
GlScissor (0, 0, 320, 480) ' Modify only the left half of the screen.
GlClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
GlLoadIdentity ()
GlTranslatef (-1, 0, -3)
GlRotatef (Turn1, 0, 1, 0)
GlRotatef (Tip1, 0, 0, 1)
Gosub DrawTriangle
Turn1 = Turn1 + 1
if ScanKeyDown (VK_UP) then Tip1 = Tip1 + 1 endif
if ScanKeyDown (VK_DOWN) then Tip1 = Tip1 - 1 endif
SwapBuffers ()
endif
if not ScanKeyDown (VK_RIGHT) then
GlScissor (320, 0, 320, 480) ' Modify only the right side of the screen.
GlClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
GlLoadIdentity ()
GlTranslatef (1, 0, -3)
GlRotatef (Turn2, 0, 1, 0)
GlRotatef (Tip2, 0, 0, 1)
Gosub DrawTriangle
Turn2 = Turn2 + 1
if ScanKeyDown (VK_UP) then Tip2 = Tip2 + 1 endif
if ScanKeyDown (VK_DOWN) then Tip2 = Tip2 - 1 endif
SwapBuffers ()
endif
Wend
DrawTriangle:
glBegin(GL_TRIANGLES)
glColor3f(1,0,0) : glVertex3f( 0, 1, 0)
glColor3f(0,1,0) : glVertex3f(-1,-1, 1)
glColor3f(0,0,1) : glVertex3f( 1,-1, 1)
glColor3f(1,0,0) : glVertex3f( 0, 1, 0)
glColor3f(0,0,1) : glVertex3f( 1,-1, 1)
glColor3f(0,1,0) : glVertex3f( 1,-1,-1)
glColor3f(1,0,0) : glVertex3f( 0, 1, 0)
glColor3f(0,1,0) : glVertex3f( 1,-1,-1)
glColor3f(0,0,1) : glVertex3f(-1,-1,-1)
glColor3f(1,0,0) : glVertex3f( 0, 1, 0)
glColor3f(0,0,1) : glVertex3f(-1,-1,-1)
glColor3f(0,1,0) : glVertex3f(-1,-1, 1)
glEnd()
Return
using GlScissor (X1, Y1, X2, Y2), OpenGL limits the drawing of anything afterward to that section of the window. (X1, Y1, X2, Y2 form a rectangle where X1 is any X pixel from the left of the screen, Y is any Y pixel from the bottom of the screen, X2 is the width of the window (from X1) and Y2 is the hieght of the window (from Y1). At least I think so anyway...).
So then you can make multiplayer games! Or just limit drawing area to speed up rendering...