difference between...

This is a discussion on difference between... within the Game Programming forums, part of the General Programming Boards category; What is the difference between Code: GLfloat and GLclampf and Code: GLdouble and GLclampd and isn't GLboolean == to an ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    difference between...

    What is the difference between
    Code:
    GLfloat and GLclampf
    and
    Code:
    GLdouble and GLclampd
    and isn't GLboolean == to an GLubyte. So it isn't really a boolean right? and is there a difference between
    Code:
    GLuint and GLenum and GLbitfield
    I am just bored reading throught The OpenGl Programming guide and came across the table on chapter one. Thank you

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Straight from the gl.h

    Code:
     typedef unsigned int GLenum;
     typedef unsigned char GLboolean;
     typedef unsigned int GLbitfield;
     typedef signed char GLbyte;
     typedef short GLshort;
     typedef int GLint;
     typedef int GLsizei;
     typedef unsigned char GLubyte;
     typedef unsigned short GLushort;
     typedef unsigned int GLuint;
     typedef float GLfloat;
     typedef float GLclampf;
     typedef double GLdouble;
     typedef double GLclampd;
     typedef void GLvoid;
    They are just so you might clarify what you are using the variable for (i.e. being clamping). Just some possibly helpful typedefs is all.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    I avoid typedefs myself.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    That's nice.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Banned
    Join Date
    Dec 2003
    Posts
    367
    I present to Eber Kain the No Typedef Award.

    Print it onto a iron-on for a cool t-shirt and show off to other people. You could be all like "Yeah, bludstayne gave me this awesome No Typedef award because I am awesome and awesome awards go to awesome people!" Dude, the chicks will chase you in a No Typedef Award shirt. You could set it as your wallpaper, make a mousepad, coffee mug, boxers, you name it!

    Put it on your resume`
    Attached Images Attached Images  

  6. #6
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    >I present to Eber Kain the No Typedef Award.

    LOL. That is so Govtcheez-like.

    >I avoid typedefs myself.

    They can be good in many instances. For example, if you were developing a game and you had a data type called MY_INT defined as such:

    typedef int MY_INT;

    And then you wanted to change all instances of MY_INT to be unsigned, you could do it by changing one line of code.

    typedef unsigned int MY_INT;

    That way you wouldnt have to go through your code and change all types of "int" to "unsigned int".
    My Website

    "Circular logic is good because it is."

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Two words for why typedef can be useful:
    Function Pointers

  8. #8
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    from the OpenGL 1.5 spec... section 2.3 or page 22

    http://www.opengl.org/documentation/...5/glspec15.pdf

    Code:
    GL Type   Minimum     Description
              Bit Width
    boolean      1        Boolean
    byte         8        signed 2ís complement binary integer
    ubyte        8        unsigned binary integer
    short       16        signed 2ís complement binary integer
    ushort      16        unsigned binary integer
    int         32        signed 2ís complement binary integer
    uint        32        unsigned binary integer
    sizei       32        Non-negative binary integer size
    enum        32        Enumerated binary integer value
    intptr    ptrbits     signed 2ís complement binary integer
    sizeiptr  ptrbits     Non-negative binary integer size
    bitfield    32        Bit field
    float       32        Floating-point value
    clampf      32        Floating-point value clamped to [0, 1]
    double      64        Floating-point value
    clampd      64        Floating-point value clamped to [0, 1]

  9. #9
    Banned
    Join Date
    Dec 2003
    Posts
    367
    Typedef's are very nice for platform independence too. OpenGL uses typedef's for this reason. A variable type might not be the same size on two different platforms. For example, an int maybe be 16 bit, 24 bit, 32 bit, or whatever size the platform defines it as. If you use OpenGL's typedef's, you are pretty much guaranteed a certain size.

    Really, what is wrong with typedef's? Used properly, they come in handy. This reminds me of the "DO NOT USE GOTO STATEMENTS OR YOUR SOUL WILL BURN IN HELL" zealots.

  10. #10
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    Quote Originally Posted by DavidP
    They can be good in many instances. For example, if you were developing a game and you had a data type called MY_INT defined as such:

    typedef int MY_INT;

    And then you wanted to change all instances of MY_INT to be unsigned, you could do it by changing one line of code.

    typedef unsigned int MY_INT;

    That way you wouldnt have to go through your code and change all types of "int" to "unsigned int".
    That is an instance where typedefs would be usefull. But dont you think that projects should be planned out enough ahead of time for you to know what kinds of data types should be used where?

    Making that sort of change may be no faster than changing what needed to be changed, using an unsigned value where you had a signed value may effect calculations and add bugs where a program previousally had none.

    We should all strive to do things the right way the first time and avoid this type of thing.


    There is nothing wrong with typedefs, whenever I started programming I used them some. But I find that my code is more readable for myself and others whenever I dont use them.

  11. #11
    ---
    Join Date
    May 2004
    Posts
    1,379
    Eber Kain has some good points there.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding the difference in two times
    By muthus in forum C++ Programming
    Replies: 4
    Last Post: 01-24-2008, 06:36 PM
  2. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 11:26 AM
  3. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 03:27 AM
  4. Replies: 6
    Last Post: 08-27-2006, 12:09 AM
  5. Difference between macro and pass by reference?
    By converge in forum C++ Programming
    Replies: 2
    Last Post: 02-26-2002, 05:20 AM

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