Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

FixedFunctionRenderContext Class Reference

#include <rendcontext.h>

Inheritance diagram for FixedFunctionRenderContext:

Inheritance graph
Collaboration diagram for FixedFunctionRenderContext:

Collaboration graph
List of all members.

Public Member Functions

 FixedFunctionRenderContext ()
 FixedFunctionRenderContext (const Mesh::Material *)
virtual void makeCurrent (const Mesh::Material &)
virtual void setVertexArrays (const Mesh::VertexDescription &desc, void *vertexData)

Private Attributes

bool blendOn
bool specularOn

Constructor & Destructor Documentation

FixedFunctionRenderContext::FixedFunctionRenderContext const Mesh::Material  ) 
 

Definition at line 138 of file rendcontext.cpp.

00138                                                                                     :
00139     RenderContext(_material),
00140     blendOn(false),
00141     specularOn(false)
00142 {
00143 }

FixedFunctionRenderContext::FixedFunctionRenderContext  ) 
 

Definition at line 130 of file rendcontext.cpp.

00130                                                        :
00131     RenderContext(),
00132     blendOn(false),
00133     specularOn(false)
00134 {
00135 }


Member Function Documentation

void FixedFunctionRenderContext::makeCurrent const Mesh::Material  )  [virtual]
 

Implements RenderContext.

Definition at line 147 of file rendcontext.cpp.

References Texture::bind(), blendOn, ResourceManager< T >::find(), RenderContext::getRenderPass(), GetTextureManager(), Texture::hasAlpha(), InvalidResource, and specularOn.

00148 {
00149     if (getRenderPass() == PrimaryPass)
00150     {
00151         Texture* t = NULL;
00152         if (m.maps[Mesh::DiffuseMap] != InvalidResource)
00153             t = GetTextureManager()->find(m.maps[Mesh::DiffuseMap]);
00154 
00155         if (t == NULL)
00156         {
00157             glDisable(GL_TEXTURE_2D);
00158         }
00159         else
00160         {
00161             glEnable(GL_TEXTURE_2D);
00162             t->bind();
00163         }
00164 
00165         glColor4f(m.diffuse.red(),
00166                   m.diffuse.green(),
00167                   m.diffuse.blue(),
00168                   m.opacity);
00169 
00170         bool blendOnNow = false;
00171         if (m.opacity != 1.0f || (t != NULL && t->hasAlpha()))
00172             blendOnNow = true;
00173 
00174         if (blendOnNow != blendOn)
00175         {
00176             blendOn = blendOnNow;
00177             if (blendOn)
00178             {
00179                 glEnable(GL_BLEND);
00180                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00181                 glDepthMask(GL_FALSE);
00182             }
00183             else
00184             {
00185                 glDisable(GL_BLEND);
00186                 glDepthMask(GL_TRUE);
00187             }
00188         }
00189 
00190         if (m.specular == Color::Black)
00191         {
00192             float matSpecular[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
00193             float zero = 0.0f;
00194             glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular);
00195             glMaterialfv(GL_FRONT, GL_SHININESS, &zero);
00196             specularOn = false;
00197         }
00198         else
00199         {
00200             float matSpecular[4] = { m.specular.red(),
00201                                      m.specular.green(),
00202                                      m.specular.blue(),
00203                                      0.0f };
00204             glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular);
00205             glMaterialfv(GL_FRONT, GL_SHININESS, &m.specularPower);
00206             specularOn = true;
00207         }
00208 
00209         {
00210             float matEmissive[4] = { m.emissive.red(),
00211                                      m.emissive.green(),
00212                                      m.emissive.blue(),
00213                                      0.0f };
00214             glMaterialfv(GL_FRONT, GL_EMISSION, matEmissive);
00215         }
00216     }
00217     else if (getRenderPass() == EmissivePass)
00218     {
00219         Texture* t = NULL;
00220         if (m.maps[Mesh::EmissiveMap] != InvalidResource)
00221             t = GetTextureManager()->find(m.maps[Mesh::EmissiveMap]);
00222 
00223         if (t == NULL)
00224         {
00225             glDisable(GL_TEXTURE_2D);
00226         }
00227         else
00228         {
00229             glEnable(GL_TEXTURE_2D);
00230             t->bind();
00231         }
00232     }
00233 }

void FixedFunctionRenderContext::setVertexArrays const Mesh::VertexDescription desc,
void *  vertexData
[virtual]
 

Implements RenderContext.

Definition at line 237 of file rendcontext.cpp.

References setStandardVertexArrays().

00238 {
00239     setStandardVertexArrays(desc, vertexData);
00240 }


Member Data Documentation

bool FixedFunctionRenderContext::blendOn [private]
 

Definition at line 98 of file rendcontext.h.

Referenced by makeCurrent().

bool FixedFunctionRenderContext::specularOn [private]
 

Definition at line 99 of file rendcontext.h.

Referenced by makeCurrent().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:20 2006 for Celestia by  doxygen 1.4.1