[ode-users] Can a string be printed out in the simulation window?

27 views
Skip to first unread message

ygz0515

unread,
Nov 23, 2009, 8:55:13 AM11/23/09
to ode-...@googlegroups.com

hello everyone,
I want to print out a string to show the simulation time, in the
simulation window. Have anyone tried to do this? How to do?

--
View this message in context: http://old.nabble.com/Can-a-string-be-printed-out-in-the-simulation-window--tp26478445p26478445.html
Sent from the ODE mailing list archive at Nabble.com.

Rodrigo Hernandez

unread,
Nov 23, 2009, 10:26:55 PM11/23/09
to ode-...@googlegroups.com

There is currently nothing in place to do this, you'd have to write it
yourself, as this is outside the scope of ODE, however it would be a
nice to have.

While looking at Stan Melax code for Polychop
(http://www.melax.com/polychop) I noticed he implemented a rather simple
way to print text on the OpenGL window,
you may want to look it up and if so inclined, anyone is encouraged to
incorporate the text drawing code into drawstuff, Stan released that
code under very lax terms,
("do what ever you want with it" to paraphrase), so there should be no
issues.

Mikhail Zoline

unread,
Nov 24, 2009, 8:54:09 AM11/24/09
to ode-...@googlegroups.com
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.
>
>
>

Rodrigo Hernandez

unread,
Nov 24, 2009, 9:02:21 PM11/24/09
to ode-...@googlegroups.com

There you go, thanks Mikhail :)

however, we don't really want to link against glut, might have to
implement glutBitmapCharacter locally.

Thanks again.

Rodrigo Hernandez

unread,
May 22, 2011, 4:41:48 PM5/22/11
to Christian Schluchter, ode-...@googlegroups.com

I do not know, you should ask in the email list, CCing it.

On 5/20/2011 4:40 PM, Christian Schluchter wrote:
> Has anybody implemented a way of writing on the screen without glut by
> now?
>
> If not, what would be the easiest way to link against glut? Would I
> have to do that in the config file, and where?
>
> Any help would be greatly appreciated,
> Christian
>
>
>
> On Nov 24 2009, 10:02 pm, Rodrigo Hernandez<kwiz...@aeongames.com>

>>>> For more options, visit this group athttp://groups.google.com/group/ode-users?hl=en.

Reply all
Reply to author
Forward
0 new messages