Results 1 to 4 of 4

Thread: Bizzare glColor3f() problem

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    2

    Bizzare glColor3f() problem

    Hi, I'm drawing a series of points using the following code:

    Code :
    //draw each pixel between the two points
    glColor3f( m_nRed, m_nGreen, m_nBlue );
    glBegin( GL_POINTS );
    for( float j=fX1; j<=fX2; j++ )
    {
    	glVertex3i( j, m_fCurrentYvalue, 0 );
    }
    glEnd();

    I have a weird bug when using the following values:

    Code :
    glColor3f( 150, 50, 250 );

    This draws all the points as white. I have to change the '150' value to '0' in order for it to draw anything but white.

    Any ideas?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2007
    Location
    Brighton, UK
    Posts
    161

    Re: Bizzare glColor3f() problem

    Since you're using the float version of glColor, you should provide it with values in the range 0..1

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2008
    Posts
    2

    Re: Bizzare glColor3f() problem

    Whoah, thanks. That works like a charm.

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2008
    Location
    France
    Posts
    15

    Re: Bizzare glColor3f() problem

    Or if you want to keep integer values, you should use
    glColor3i();

    Remember, the way functions names behave in openGL, it's very practical since a lot of functions gives a lot of informations just in their names.

    ie : glVertex3f(); means : glVertex stands for 'I will draw a vertex', '3' stands for 3 arguments , 'f' stands for float ...

    See what i mean ?
    miaou !

Similar Threads

  1. glColor3f(,,) wash out?
    By darkrappey in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-27-2006, 03:30 AM
  2. GlColor3f and Gl_Decal
    By VasRoG in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-10-2005, 11:13 AM
  3. Bizzare depth buffer problem
    By Virusx86 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-24-2003, 01:10 PM
  4. Bizzare texture seam problem on LOD terrain.
    By ceenda in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 05-24-2002, 03:54 PM
  5. Parameter in glColor3f 1, 0, 0 by Example...
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-01-2001, 05:29 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