Background color

Now, my background color has a single one. I want its the color to change from up to fall down or left-right. If I write a tedius code to calculate a position where the color is, and specify one color at one position. If I divide my background into 800x600 point, I have to calculate for 800x600 times,and whole calculation is called again each time the scene is drawn. If anyone has any fuction or algorithm,please help me.

Hi, dont really understand what your saying, but set the background color with glClearColor(1.0f,1.0f,1.0f,1.0f) or whatever color you want. Then when you clear the buffer with glClear it will go to that color.

EDIT: Oh you want to do some sort of gradient color fill? Actually I think I might have done this in one of my old projects. Ill get back to you.

EDIT: No sorry I dont have what I thought I did. It is easy to create a texture of what you want in a paint program, then just load it in and map it to a quad. Size the quad so it fills the screen. There is some .bmp and .tga loading code on Note this is one way to do, and it is just from the top of my head. Im sure there are other ways. The advanced coders on this forum may have a better solution. Hope this helps.

Old GLman

[This message has been edited by Old GLman (edited 03-16-2002).]

[This message has been edited by Old GLman (edited 03-16-2002).]

If you want a linear gradient you can just draw a quad as the background (turn off z-writes first) and use smooth shading to create the gradient.

Thank for all commend,But I can do it as shown below




   glVertex2d(m_dMinX,m_dMinY);//lower left
   glVertex2d(m_dMaxX,m_dMinY);//lower right
   glVertex2d(m_dMaxX,m_dMaxY);//upper right
   glVertex2d(m_dMinX,m_dMaxY);//upper left


I switch from 3D to 2D and create my background on 2D scene and switch to 3D again for drawing any other object.