Jump to content
  • Advertisement
Sign in to follow this  
Ioachim Berselius

OpenGL glColor*b not working

This topic is 4044 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!