PDA

View Full Version : Printf statement not working inside GLfunctions



04-21-2002, 02:50 AM
I'm not able to print the values of variables inside a opengl function(for debugging purposes).

Printf statement works perfectly but it prints either zero or some junk value.

ex:
xcur,ycur-global varables

window_display()
.......
printf("values of %3.2f %3.2f", &xcur,&ycur);
.....

same type of statements not working in keyboard function and other functions

Is there any special setting or special function to do that?

thanks & regards

Owlet
04-21-2002, 04:31 AM
You're passing a pointer to the variables to printf as opposed to the variables themselves. You have

printf(..., &xcur, &ycur);

it should be

printf(..., xcur, ycur);

Perhaps you got confused with scanf, which does require you to pass pointers?

Owlet

[This message has been edited by Owlet (edited 04-21-2002).]

DFrey
04-21-2002, 04:34 AM
If that code example is from your code, then it has problems, because that code above is trying print pointers as floats. Simple get rid of those &'s and it should work fine, assuming those variables really are floats of some type.

Bob
04-21-2002, 05:21 AM
which does require you to pass pointers?

scanf. And you're right, no &'s in printf.

04-21-2002, 05:27 AM
oh god, thanks guys.Actually I'm kinda confused since i started using opengl.

once again, thanks guys