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

rendcontext.cpp File Reference

#include "rendcontext.h"
#include "texmanager.h"
#include "gl.h"
#include "glext.h"
#include "vecgl.h"

Include dependency graph for rendcontext.cpp:

Go to the source code of this file.

Enumerations

enum  { TangentAttributeIndex = 6 }

Functions

static void setExtendedVertexArrays (const Mesh::VertexDescription &desc, const void *vertexData)
static void setStandardVertexArrays (const Mesh::VertexDescription &desc, void *vertexData)
static void setVertexArrays (const Mesh::VertexDescription &desc)

Variables

static Mesh::Material defaultMaterial
static int GLComponentCounts [Mesh::FormatMax]
static GLenum GLComponentTypes [Mesh::FormatMax]
static GLenum GLPrimitiveModes [Mesh::PrimitiveTypeMax]


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
TangentAttributeIndex 

Definition at line 48 of file rendcontext.cpp.

00048      {
00049     TangentAttributeIndex = 6,
00050 };


Function Documentation

void setExtendedVertexArrays const Mesh::VertexDescription desc,
const void *  vertexData
[static]
 

Definition at line 331 of file rendcontext.cpp.

References Mesh::VertexAttribute::format, GLComponentCounts, GLComponentTypes, glx::glDisableVertexAttribArrayARB, glx::glEnableVertexAttribArrayARB, glx::glVertexAttribPointerARB, Mesh::VertexAttribute::offset, and TangentAttributeIndex.

Referenced by VP_FP_RenderContext::setVertexArrays(), and VP_Combiner_RenderContext::setVertexArrays().

00333 {
00334     const Mesh::VertexAttribute& tangent  = desc.getAttribute(Mesh::Tangent);
00335     const char* vertices = reinterpret_cast<const char*>(vertexData);
00336 
00337     switch (tangent.format)
00338     {
00339     case Mesh::Float3:
00340         glx::glEnableVertexAttribArrayARB(TangentAttributeIndex);
00341         glEnableClientState(GL_NORMAL_ARRAY);
00342         glx::glVertexAttribPointerARB(TangentAttributeIndex,
00343                                       GLComponentCounts[(int) tangent.format],
00344                                       GLComponentTypes[(int) tangent.format],
00345                                       GL_FALSE,
00346                                       desc.stride,
00347                                       vertices + tangent.offset);
00348         break;
00349     default:
00350         glx::glDisableVertexAttribArrayARB(TangentAttributeIndex);
00351         break;
00352     }
00353 }

void setStandardVertexArrays const Mesh::VertexDescription desc,
void *  vertexData
[static]
 

Definition at line 262 of file rendcontext.cpp.

References Mesh::VertexAttribute::format, GLComponentCounts, GLComponentTypes, and Mesh::VertexAttribute::offset.

Referenced by VP_FP_RenderContext::setVertexArrays(), VP_Combiner_RenderContext::setVertexArrays(), and FixedFunctionRenderContext::setVertexArrays().

00264 {
00265     const Mesh::VertexAttribute& position  = desc.getAttribute(Mesh::Position);
00266     const Mesh::VertexAttribute& normal    = desc.getAttribute(Mesh::Normal);
00267     const Mesh::VertexAttribute& color0    = desc.getAttribute(Mesh::Color0);
00268     const Mesh::VertexAttribute& texCoord0 = desc.getAttribute(Mesh::Texture0);
00269 
00270     // Can't render anything unless we have positions
00271     if (position.format != Mesh::Float3)
00272         return;
00273 
00274     // Set up the vertex arrays
00275     glEnableClientState(GL_VERTEX_ARRAY);
00276     glVertexPointer(3, GL_FLOAT, desc.stride,
00277                     reinterpret_cast<char*>(vertexData) + position.offset);
00278 
00279     // Set up the normal array
00280     switch (normal.format)
00281     {
00282     case Mesh::Float3:
00283         glEnableClientState(GL_NORMAL_ARRAY);
00284         glNormalPointer(GLComponentTypes[(int) normal.format],
00285                         desc.stride,
00286                         reinterpret_cast<char*>(vertexData) + normal.offset);
00287         break;
00288     default:
00289         glDisableClientState(GL_NORMAL_ARRAY);
00290         break;
00291     }
00292 
00293     // Set up the color array
00294     switch (color0.format)
00295     {
00296     case Mesh::Float3:
00297     case Mesh::Float4:
00298     case Mesh::UByte4:
00299         glEnableClientState(GL_COLOR_ARRAY);
00300         glColorPointer(GLComponentCounts[color0.format],
00301                        GLComponentTypes[color0.format],
00302                        desc.stride,
00303                        reinterpret_cast<char*>(vertexData) + color0.offset);
00304         break;
00305     default:
00306         glDisableClientState(GL_COLOR_ARRAY);
00307         break;
00308     }
00309 
00310     // Set up the texture coordinate array
00311     switch (texCoord0.format)
00312     {
00313     case Mesh::Float1:
00314     case Mesh::Float2:
00315     case Mesh::Float3:
00316     case Mesh::Float4:
00317         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
00318         glTexCoordPointer(GLComponentCounts[(int) texCoord0.format],
00319                           GLComponentTypes[(int) texCoord0.format],
00320                           desc.stride,
00321                           reinterpret_cast<char*>(vertexData) + texCoord0.offset);
00322         break;
00323     default:
00324         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
00325         break;
00326     }
00327 }

static void setVertexArrays const Mesh::VertexDescription desc  )  [static]
 

Definition at line 78 of file rendcontext.cpp.

00079 {
00080 }


Variable Documentation

Mesh::Material defaultMaterial [static]
 

Definition at line 17 of file rendcontext.cpp.

Referenced by RenderContext::RenderContext(), and RenderContext::setMaterial().

int GLComponentCounts[Mesh::FormatMax] [static]
 

Initial value:

{
     1,  
     2,  
     3,  
     4,  
     4,  
}

Definition at line 38 of file rendcontext.cpp.

Referenced by setExtendedVertexArrays(), and setStandardVertexArrays().

GLenum GLComponentTypes[Mesh::FormatMax] [static]
 

Initial value:

 
{
     GL_FLOAT,          
     GL_FLOAT,          
     GL_FLOAT,          
     GL_FLOAT,          
     GL_UNSIGNED_BYTE,  
}

Definition at line 29 of file rendcontext.cpp.

Referenced by setExtendedVertexArrays(), and setStandardVertexArrays().

GLenum GLPrimitiveModes[Mesh::PrimitiveTypeMax] [static]
 

Initial value:

 
{
    GL_TRIANGLES,
    GL_TRIANGLE_STRIP,
    GL_TRIANGLE_FAN,
    GL_LINES,
    GL_LINE_STRIP,
    GL_POINTS
}

Definition at line 19 of file rendcontext.cpp.

Referenced by RenderContext::drawGroup().


Generated on Sat Jan 14 22:31:07 2006 for Celestia by  doxygen 1.4.1