new to opengl: question about colors

Started by
1 comment, last by Galaxy_X 21 years, 9 months ago
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??
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]

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

You can also use glPushAttrib(GL_CURRENT_BIT) before you draw the floor and then use glPopAttrib() to restore the color.
~neoztar "Any lock can be picked with a big enough hammer"my website | opengl extensions | try here firstguru of the week | msdn library | c++ faq lite

This topic is closed to new replies.

Advertisement