clurender.c

00001 #include <clu.h>
00002 
00003 /*
00004   This method will modify the GL state machine so that meshes are
00005   rendered "correctly" according to their properties and the CL
00006   features currently enabled. For example, texturing will be enabled
00007   for meshes with textures. At the end of the function, the
00008   enabled/disabled...ness is reset to the state when the method was
00009   entered.
00010 */
00011 GLvoid cluRenderMesh(CLmesh* mesh)
00012 {
00013     GLboolean lighting_flag;
00014     GLboolean textured_flag;
00015 
00016     glPushAttrib(GL_ENABLE_BIT);
00017 
00018     /* determine if we should perform lighting */
00019     lighting_flag = GL_TRUE;
00020 
00021     lighting_flag &= clIsEnabled(CL_MATERIAL |
00022                                   CL_NORMALS);
00023 
00024     lighting_flag &= CL_BOOLEAN(mesh->normals);
00025     lighting_flag &= mesh->material_index != -1;
00026 
00027     /* determine if we should perform texturing */
00028     textured_flag = GL_TRUE;
00029 
00030     textured_flag &= clIsEnabled(CL_TEXTURE
00031                                  | CL_TEXTURE_ENV_MODE
00032                                  | CL_TEXCOORDS);
00033 
00034     textured_flag &= CL_BOOLEAN(mesh->texcoords);
00035     textured_flag &= mesh->texture_index != -1;
00036     
00037     clRenderMesh(mesh);
00038 
00039     glPopAttrib();
00040 }
00041 
00042 GLvoid cluRenderModel(CLmodel* model)
00043 {
00044     unsigned int i;
00045 
00046     for (i = 0; i < model->num_meshes; i++)
00047         cluRenderMesh(model->meshes[i]);
00048 }
00049 

Generated on Thu Dec 27 13:53:42 2007 for CLU by  doxygen 1.4.6