[SDL] 2D above OpenGL graphics
kuon - Nicolas Goy - 時期精霊
kuon at goyman.com
Mon Nov 20 01:43:10 PST 2006
Nuno Santos wrote:
> Hi,
>
> Yes, i was meaning that! I see!
>
> My first goal in that direction was to include some text above my
> scenes! Do you recommend me the same strategy?
>
> Cheers,
>
> Nuno
>
Hoy.
Opengl can be a very good 2d api.
Just do:
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho2d(0, screenWidth, 0, screenHeight);
glMatrixMode(GL_MODELVIEW);
// some 2d drawing like
glRasterPos2i(100, 100); // draw at position 100 100 pixel
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, 'H'); // Will draw a H at 100
100, for more advanced text handling or if you don't wanna link with
glut, check the opengl.org site for font rastering, SDL also provide
true type library.
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
Some tips:
Always draw your 2d (interface or anything) AFTER the scene.
Disable as much option as you can (man glPushAttrib) like depth test,
blending (you need it if image has alpha value), texture, lighting...
before drawing the 2d layer.
Regards
--
Kuon
CEO - Goyman.com SA
http://www.goyman.com/
"Computers should not stop working when the users' brain does."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3271 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061120/69e390b5/attachment.bin
More information about the SDL
mailing list