Results 1 to 5 of 5

Thread: Printf statement not working inside GLfunctions

  1. #1
    Guest

    Printf statement not working inside GLfunctions

    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

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2001
    Location
    College Station
    Posts
    19

    Re: Printf statement not working inside GLfunctions

    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).]

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Printf statement not working inside GLfunctions

    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.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Printf statement not working inside GLfunctions

    which does require you to pass pointers?
    scanf. And you're right, no &'s in printf.

  5. #5
    Guest

    Re: Printf statement not working inside GLfunctions

    oh god, thanks guys.Actually I'm kinda confused since i started using opengl.

    once again, thanks guys

Similar Threads

  1. OpenGL Attrib Pointer Not Working Inside Class Method
    By BenSwolo in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-26-2018, 12:42 AM
  2. break/return statement inside loop reacts unexpectedly
    By Kleinkind87 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-10-2017, 11:09 AM
  3. Code not working when inside class constructor?
    By Todegal in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-24-2017, 10:50 AM
  4. glDrawElements inside if statement
    By fiodis in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-13-2012, 02:42 PM
  5. Troubleshooting via printf?
    By The.Scotsman in forum OpenCL
    Replies: 1
    Last Post: 06-06-2012, 02:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean