Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Color Questions

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    2

    Color Questions

    Hello!

    I am working on converting a simple VC++ game with colored blocks on the screen (not tetris). The Windows program was coded using MFC. My goal is to port the program over the Xcode and OS X. Most of the program code is pretty simple to convert; however, I'm stumped on something that I thought would be very simple.

    In several functions in the original program the return type is a color reference (COLORREF). There is also a variable declared as type COLORREF. Essentially, the COLORREF object is a unsigned integer value representing the color.

    Is there something in OpenGL that corresponds to COLORREF?

    Thanks!!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Color Questions

    A pointer to 4 component GLubyte ?
    Look at the glColor4*v here :
    http://www.opengl.org/sdk/docs/man/xhtml/glColor.xml

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2010
    Posts
    2

    Re: Color Questions


    I had originally considered using glColor3f. However, when I declare a variable or a function using it ...

    glColor3f m_arrColors[4];

    I receive the following error: "glColor3f does not name a type."

    #include "Cstdlib"
    #include "CSSameGameBoard.h"
    #include "GLUT/glut.h"
    #include "OpenGL/gl.h"
    #include "OpenGL/glu.h"
    #include "math.h"

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Color Questions

    Ventre Saint-Gris.

    What to say ... maybe try to learn the basics of C programming ? And then actually read the documentation I linked ?

    glColor3f is a *function* not a *type*, as you compiler said. GLFloat is the type.

    Try this instead :
    Code :
    GLfloat myColor[4];
    // do not forget to fill color component with values between 0.0 and 1.0, example : 
    myColor[0]= 0.5; // red value
    myColor[1]= 0.1; // green value
    myColor[1]= 0.9; // blue value
    myColor[3]= 1.0; // alpha value (1 is opaque, 0 transparent, not sure if you need it)
    // say to opengl "from now, draw with myColor !"
    glColor4fv(myColor);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •