[SDL] 2D above OpenGL graphics
Nicolas Goy - kuon - 時期精
Nicolas Goy - kuon - 時期精
Mon Nov 27 10:57:20 PST 2006
On 23 Nov 2006, at 02:10, Nuno Santos wrote:
> Ok,
>
> I now got something, but my 3D gets very weird and almost doest
> shows up.
>
> I would love to have this font rastering on while the 3D stuff is
> under it.
>
> Is it possible?
>
> I also don't know what is happening with that code.
>
> This is what i got:
>
> void renderScene(void) {
> glClearColor(0.0f,0.0f,0.0f,0.0f);
> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>
> eyeX = sin(angle);
> eyeZ = -cos(angle);
>
> glLoadIdentity();
>
> gluLookAt((eyeX*c.ex)*zoom,c.ey+eyeY,(eyeZ*c.ez)*zoom,
> c.cx,c.cy,c.cz,
> 0.0f,1.0f,0.0f);
>
>
> glMatrixMode(GL_MODELVIEW);
> glPushMatrix();
> glLoadIdentity();
> glMatrixMode(GL_PROJECTION);
> glPushMatrix();
> glLoadIdentity();
>
> glOrtho( 0, 640, 0, 480, 0.0, 1.0 );
>
>
> glMatrixMode(GL_MODELVIEW);
> // some 2d drawing like
>
> glRasterPos2i(50, 50); // draw at position 0 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();
>
>
> glutSwapBuffers();
> }
>
>
>
> Em Nov 22, 2006, às 6:31 PM, Sami Näätänen escreveu:
>
>> glOrtho( 0, width, 0, height, 0.0, 1.0 );
>
> _
Just a note to the list, I helped Nuno privately.
For reference, the error in the above code is
glMatrixMode(GL_MODELVIEW);
missing just after glClear. I usualy set the matrixMode I want to
use, that's why I don't restore it after my 2d "context".
the glOrtho2d was a typo, it's glOrtho or gluOrtho2D.
Best 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/pkcs7-signature
Size: 2434 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061127/bd9900fe/attachment.bin
More information about the SDL
mailing list