OGL Question

This is a discussion on OGL Question within the C++ Programming forums, part of the General Programming Boards category; I've noticed a function in OpenGL that has f after each parameter like so - glVertex3f(1.0f,1.0f,1.0f); - does anybody know ...

  1. #1
    russell
    Guest

    OGL Question

    I've noticed a function in OpenGL that has f after each parameter like so - glVertex3f(1.0f,1.0f,1.0f); - does anybody know what the f's mean and why the need to put them there and also what difference it would make without them?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    It means float.
    I don't think there's any difference between 1.0 and 1.0f, but there is a difference between 1 and 1f.
    In the first example, both are floats. In the second, the first is an int and the second is a float.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    Type conversion to float. If you donīt convert, the numbers is treated as double.

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    OpenGL follows a naming convention for all of its functions...
    Example from "OpenGL Superbible 2nd edition":

    glColor3f(...);

    This means it's part of the gl library
    This is referred to the "root command"
    This is the number of arguments
    This is the type of arguments, as Magos said

    Without the postfixes on numbers like 1.0f, they are created as the first type which can hold the specified value. So you're basically saying, create the value 1.0 and make it the size of a float.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 06:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 01:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21