glColor*b not working

Started by
1 comment, last by Ioachim Berselius 16 years, 9 months ago
I'm writing a simple 2D action-adventure game using OpenGL for graphics, I'm just using the old 1.1 functions, since it's easier for me to do that as I want just simple functionality. The problem I encountered is that the functions Color3b, Color4b, and their vector version just set the color to black. I'm using C# in Visual Studio 2005, Tao Framework 2.0 and have an nVidia Geforce FX 5200 on Windows XP
public void Draw()
{
    Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
               
    foreach (ISprite sp in currentSprites)
    {
        
        Gl.glBegin(Gl.GL_QUADS);                
        Gl.glColor3b(sp.Color.R, sp.Color.G, sp.Color.B);
        Gl.glVertex2d(sp.Location.X,  sp.Location.Y);                
        Gl.glVertex2d(sp.Location.X + sp.Size.Width,  sp.Location.Y );                
        Gl.glVertex2d(sp.Location.X + sp.Size.Width,  (sp.Location.Y + sp.Size.Height));
        Gl.glVertex2d(sp.Location.X ,  (sp.Location.Y + sp.Size.Height));
        Gl.glEnd();
    }

    Sdl.SDL_GL_SwapBuffers();            
}
The float, double, integer and short versions work as they should. Is this a bug in the OpenGL implementation so I'll have to use other version of glColor? Thanks in advance for the advice
Advertisement
What values do the components of sp.Color have? Did you try hardcoded colors e.g. glColor3b(64, 64, 64)?

Note that signed values are mapped to the interval [-1,1] so try glColor3ub instead.

If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Yup, that was it... It looks like the signed versions only take in account the positive values, they set the all values greater than 127 to zero

Thank you!

This topic is closed to new replies.

Advertisement