In drawstuff.h:
DS_API void dsSetOrthographicProjection( int w, int h);
DS_API void dsResetPerspectiveProjection();
DS_API void dsRenderBitmapString(float x, float y, char *string);
In drawstuff.cpp:
void dsSetOrthographicProjection(int w, int h)
{
// switch to projection mode
glMatrixMode(GL_PROJECTION);
// save previous matrix which contains the
//settings for the perspective projection
glPushMatrix();
// reset matrix
glLoadIdentity();
// set a 2D orthographic projection
gluOrtho2D(0, w, 0, h);
// invert the y axis, down is positive
glScalef(1, -1, 1);
// mover the origin from the bottom left corner
// to the upper left corner
glTranslatef(0, -h, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}
void dsResetPerspectiveProjection()
{
glPopMatrix();
// set the current matrix to GL_PROJECTION
glMatrixMode(GL_PROJECTION);
// restore previous settings
glPopMatrix();
// get back to GL_MODELVIEW matrix
glMatrixMode(GL_MODELVIEW);
}
void dsRenderBitmapString(float x, float y,char *string)
{
char *c;
// set position to start drawing fonts
glRasterPos2f(x, y);
// loop all the characters in the string
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(GLUT_BITMAP_8_BY_13 , *c);
}
}
How to use:
static void simLoop (int pause)
{
//simulation and rendering here.
dsSetColor(0.0,1.0,1.0);
dsSetOrthographicProjection(1408,900);
dsRenderBitmapString(30,15,string to print);
dsResetPerspectiveProjection();
> --
>
> You received this message because you are subscribed to the Google Groups "ode-users" group.
> To post to this group, send email to
ode-...@googlegroups.com.
> To unsubscribe from this group, send email to
ode-users+...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/ode-users?hl=en.
>
>
>