[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Clone/game request: Chain of Command
Yes, I've done that, as at that time it was the only way to get textures
loaded. Talk about an inefficient of doing it...
And you still have to fight with cameras and viewports to get the 2D
graphics shown, and getting something look correct (1:1 pixel content wrt
the original data) can be tricky.
As with most programming it's only hard to *find out* how to do it. Not
hard actually to do.
e.g. to draw with 1:1 pixel content (using a numeric array as input
rather than the inefficient texture step) its very simple:
glRasterPos2i(xPos,yPos)#set position to start
glDrawPixelsub(GL_RGB, numArray)
where numArray is an RGB Numeric array of shape (X,Y,3). glDrawPixels
does no scaling so you always get 1:1. Using the version 'ub' above
means that you give your data as unsigned bytes.
If you're mixing and matching 2D and 3D then you also want to precede
the above 2 lines with the following. (NB This is the "fighting with
cameras and viewports" that you mention):
#go to 2D mode
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glLoadIdentity()
glOrtho( 0, winSize[0], winSize[1], 0, 0, 1 ) #sets the 0,0 to be
top-left
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
...and follow the 2 lines with:
#return to previous drawing mode
glMatrixMode( GL_PROJECTION )
glPopMatrix()
glMatrixMode( GL_MODELVIEW )
but none of this counts as hard to do - just maybe hard to discover!
I agree with stuart - once you learn how to use openGL you end up with a
lot more power.
--
Jon Peirce
Nottingham University
http://www.psychology.nottingham.ac.uk/staff/jwp/