Screen Coordinates with OpenGL + SDL

Started by
1 comment, last by V-man 15 years, 4 months ago
Hi, this is my first post but i have been following this forum and nehe tutorials for a while. I have a project using SDL and OpenGL, and I'm trying to write some messages on the screen. I know I can't use SDL Surface Bliting because I'm using OpenGl. And I tried some suggestions I found over the internet about using textures with the letters, but this only works in world coordinates and not on the screen. I also tried unsing glProject and glUnproject to compute a 2d location, but it didn't worked. Could anyone help me? I can post a zip with the current code if someone wants to take a look at it. Thanks! Merry Christmas
Advertisement
I'm assuming you are simply trying to overlay some regular 2D text on the screen - in much the same way as a game with a HUD. If this is the case, one simple way is to create a separate pass. In that pass define a regular 2D orographic view and display the text.
http://www.opengl.org/wiki/index.php/FAQ#How_to_render_in_pixel_space
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement