00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #include "SoFCBackgroundGradient.h"
00027
00028 using namespace Gui;
00029
00030 SO_NODE_SOURCE(SoFCBackgroundGradient);
00031
00032 void SoFCBackgroundGradient::finish()
00033 {
00034 atexit_cleanup();
00035 }
00036
00040 SoFCBackgroundGradient::SoFCBackgroundGradient()
00041 {
00042 SO_NODE_CONSTRUCTOR(SoFCBackgroundGradient);
00043 fCol.setValue(0.5f, 0.5f, 0.8f);
00044 tCol.setValue(0.7f, 0.7f, 0.9f);
00045 mCol.setValue(1.0f, 1.0f, 1.0f);
00046 }
00047
00051 SoFCBackgroundGradient::~SoFCBackgroundGradient()
00052 {
00053 }
00054
00055
00056 void SoFCBackgroundGradient::initClass(void)
00057 {
00058 SO_NODE_INIT_CLASS(SoFCBackgroundGradient,SoNode,"Node");
00059 }
00060
00061 void SoFCBackgroundGradient::GLRender (SoGLRenderAction *action)
00062 {
00063 glMatrixMode(GL_PROJECTION);
00064 glPushMatrix();
00065 glLoadIdentity();
00066 glOrtho(-1,1,-1,1,-1,1);
00067 glMatrixMode(GL_MODELVIEW);
00068 glPushMatrix();
00069 glLoadIdentity();
00070 glPushAttrib(GL_ENABLE_BIT);
00071 glDisable(GL_DEPTH_TEST);
00072 glDisable(GL_LIGHTING);
00073 glDisable(GL_TEXTURE_2D);
00074
00075 glBegin(GL_TRIANGLE_STRIP);
00076 if (mCol[0] < 0) {
00077 glColor3f(fCol[0],fCol[1],fCol[2]); glVertex2f(-1, 1);
00078 glColor3f(tCol[0],tCol[1],tCol[2]); glVertex2f(-1,-1);
00079 glColor3f(fCol[0],fCol[1],fCol[2]); glVertex2f( 1, 1);
00080 glColor3f(tCol[0],tCol[1],tCol[2]); glVertex2f( 1,-1);
00081 }
00082 else {
00083 glColor3f(fCol[0],fCol[1],fCol[2]); glVertex2f(-1, 1);
00084 glColor3f(mCol[0],mCol[1],mCol[2]); glVertex2f(-1, 0);
00085 glColor3f(fCol[0],fCol[1],fCol[2]); glVertex2f( 1, 1);
00086 glColor3f(mCol[0],mCol[1],mCol[2]); glVertex2f( 1, 0);
00087 glEnd();
00088 glBegin(GL_TRIANGLE_STRIP);
00089 glColor3f(mCol[0],mCol[1],mCol[2]); glVertex2f(-1, 0);
00090 glColor3f(tCol[0],tCol[1],tCol[2]); glVertex2f(-1,-1);
00091 glColor3f(mCol[0],mCol[1],mCol[2]); glVertex2f( 1, 0);
00092 glColor3f(tCol[0],tCol[1],tCol[2]); glVertex2f( 1,-1);
00093 }
00094 glEnd();
00095
00096 glPopAttrib();
00097 glPopMatrix();
00098 glMatrixMode(GL_PROJECTION);
00099 glPopMatrix();
00100 glMatrixMode(GL_MODELVIEW);
00101 }
00102
00103 void SoFCBackgroundGradient::setColorGradient(const SbColor& fromColor,
00104 const SbColor& toColor)
00105 {
00106 fCol = fromColor;
00107 tCol = toColor;
00108 mCol[0] = -1.0f;
00109 }
00110
00111 void SoFCBackgroundGradient::setColorGradient(const SbColor& fromColor,
00112 const SbColor& toColor,
00113 const SbColor& midColor)
00114 {
00115 fCol = fromColor;
00116 tCol = toColor;
00117 mCol = midColor;
00118 }