Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Galaxy_X

OpenGL new to opengl: question about colors

This topic is 5846 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

Hi, I''m stuck with a simple color problem:
  

int RenderScene(GLvoid)					
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();				
    Camera.LookAt(); 
    DrawFloor(); //Draw a floor than texture it

    DrawGLRect(45.0f,y1Pos);  //Draw a 3D rect than texture it

    DrawGLRect(-47.0f,y2Pos); //same

    
    glPushMatrix();                             
    glTranslatef(xSpeed, ySpeed, 0.0f);		 
    DrawSphere();					
    glPopMatrix();       // room will not move          

	
    DrawRoom();//mess up the entire scene!!!!!!!!!!!!!!!!!!!!!!

	       // DrawRoom will be blended when I fixed

               // the problem    

    return TRUE;
}

void DrawRoom()
{
  glBegin(GL_QUADS);
       //psuedo

       setColor(red)
       do the drawing thing
   glEnd();
}

  
DrawRoom color''s spills over to my Floor and Rectangles, so what you get is a textured floor + red. Putting DrawRoom in the beginning of RenderScene also messed the entire thing up!!! any suggestions??

Share this post


Link to post
Share on other sites
Advertisement
I''m guessing here that you want the floor to be textures AND red an the rest should be normally textured. Quite simple.

After you use a glColor4f (or whatever variant you use) and you draw the room, call glColor4f again with all 1.0f to reset the colors back to normal.



Sander Maréchal
[Lone Wolves Production][Articles][GD Emporium][E-mail]

Share this post


Link to post
Share on other sites
You can also use glPushAttrib(GL_CURRENT_BIT) before you draw the floor and then use glPopAttrib() to restore the color.

Share this post


Link to post
Share on other sites

  • 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!