Beispiel #1
0
static void fshader_select (int select_in)
{
  
  FShader*      s;
  Env*          e;
   
  fshader_selected = select_in - FSHADER_BASE;
  if (fshader_selected == -1 || !CVarUtils::GetCVar<bool> ("render.textured")) {
    cgGLDisableProfile (cgp_fragment);
    return;
  }
  if (!CVarUtils::GetCVar<bool> ("render.shaders"))
    return;
  s = &fshader_list[fshader_selected];
  e = EnvGet ();
  cgGLEnableProfile (cgp_fragment);
  cgGLBindProgram (s->program);
  if (select_in == FSHADER_CLOUDS) {
    GLrgba c = (e->color[ENV_COLOR_SKY] + e->color[ENV_COLOR_HORIZON]) / 2.0f;
    cgGLSetParameter3f (s->fogcolor, c.red, c.green, c.blue);
  } else
    cgGLSetParameter3f (s->fogcolor, e->color[ENV_COLOR_FOG].red, e->color[ENV_COLOR_FOG].green, e->color[ENV_COLOR_FOG].blue);
  cgGLSetTextureParameter (s->texture, TextureIdFromName ("clouds.png"));
  cgGLSetParameter4f (s->data, wind, e->cloud_cover, 1 - e->star_fade, 0);
  cgGLEnableTextureParameter (s->texture);

}
Beispiel #2
0
void CapsuleGraphicsObject::render()
{
	glShadeModel(GL_SMOOTH);

	if(g_shaderSys)
		g_shaderSys->enableProfiles();
	if(g_defaultVertexShader) {
		g_defaultVertexShader->bind();
	}
	if(g_defaultFragmentShader)
		g_defaultFragmentShader->bind();

	glPushMatrix();
	glEnable(GL_NORMALIZE);
	glScalef(radius,length,radius);
	if(g_defaultVertexShader) {
		cgGLSetParameter4f(g_defaultVertexShader->getParameter("lightPos"), g_lightPos.x,g_lightPos.y,g_lightPos.z,1); //move to bind place
		cgGLSetMatrixParameterfc(g_defaultVertexShader->getParameter("view"),g_viewMat);
		cgGLSetStateMatrixParameter( g_defaultVertexShader->getParameter("worldViewProj"), CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
		cgGLSetStateMatrixParameter( g_defaultVertexShader->getParameter("worldView"), CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
		cgUpdateProgramParameters(g_defaultVertexShader->getProgram());
	}

	glColor3f(1,1,1);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,0,verts);
	glEnableClientState(GL_NORMAL_ARRAY);
	glNormalPointer(GL_FLOAT,0,normals);
	glDrawArrays(GL_TRIANGLES,0,nVerts);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisable(GL_NORMALIZE);
	glPopMatrix();

	//sphere caps
	glPushMatrix();
	glTranslatef(0,length/2,0);
	sphere->render();
	glPopMatrix();
	glPushMatrix();
	glTranslatef(0,-length/2,0);
	sphere->render();
	glPopMatrix();

	if(g_shaderSys)
		g_shaderSys->disableProfiles();
}
Beispiel #3
0
void Material::bind()
{
	//bytt til egen shader
	if(m_shaderSys)
		m_shaderSys->enableProfiles();
	
	if(m_vertexShader) {
		m_vertexShader->bind();
		cgGLSetStateMatrixParameter(m_vertexShader->getParameter("worldViewProj"), CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
		cgGLSetStateMatrixParameter(m_vertexShader->getParameter("worldView"), CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
		cgGLSetParameter4f(m_vertexShader->getParameter("lightPos"), g_lightPos.x,g_lightPos.y,g_lightPos.z,1);
		cgGLSetMatrixParameterfc(m_vertexShader->getParameter("view"),g_viewMat);
		cgUpdateProgramParameters(m_vertexShader->getProgram());
	}
	if(m_fragmentShader) {
		m_fragmentShader->bind();
		cgGLSetParameter3f(m_fragmentShader->getParameter("col"),m_color.x,m_color.y,m_color.z);
		cgUpdateProgramParameters(m_fragmentShader->getProgram());
	}
}
Beispiel #4
0
static void vshader_select (int select)
{
  
  VShader*      s;
  GLvector      p;
  Env*          e;
  GLrgba        c;
  float         val1, val2;
     
  vshader_selected = select;
  if (!CVarUtils::GetCVar<bool> ("render.shaders"))
    return;
  if (select == VSHADER_NONE) {
    cgGLDisableProfile (cgp_vertex);
    return;
  }
  val1 = val2 = 0.0f;
  if (select == VSHADER_TREES || select == VSHADER_GRASS) 
    val1 = wind;
  if (select == VSHADER_CLOUDS) 
    val1 = wind / 5;
  s = &vshader_list[select];
  e = EnvGet ();
  cgGLEnableProfile (cgp_vertex);
  cgGLBindProgram (s->program);
  cgGLSetParameter3f (s->lightpos, -e->light.x, -e->light.y, -e->light.z);
  c = e->color[ENV_COLOR_LIGHT];
  cgGLSetParameter3f (s->lightcol, c.red, c.green, c.blue);
  c = e->color[ENV_COLOR_AMBIENT] * glRgba (0.2f, 0.2f, 1.0f);
  cgGLSetParameter3f (s->ambientcol, c.red, c.green, c.blue);
  p = AvatarCameraPosition ();
  cgGLSetParameter3f (s->eyepos, p.x, p.y, p.z);
  cgGLSetStateMatrixParameter(s->matrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MODELVIEW_MATRIX);
  cgGLSetParameter2f (s->fog, e->fog.rmin, e->fog.rmax);
  cgGLSetParameter4f (s->data, SceneVisibleRange (), SceneVisibleRange () * 0.05, val1, val2);
  glColor3f (1,1,1);

}
Beispiel #5
0
void BoxGraphicsObject::render(void)
{
	if(g_shaderSys)
		g_shaderSys->enableProfiles();
	if(g_defaultVertexShader) {
		g_defaultVertexShader->bind();
	}
	if(g_defaultFragmentShader)
		g_defaultFragmentShader->bind();


	glPushMatrix();
	glEnable(GL_NORMALIZE);
	glScalef(width,height,depth);

	if(g_defaultVertexShader) {
		cgGLSetParameter4f(g_defaultVertexShader->getParameter("lightPos"), g_lightPos.x,g_lightPos.y,g_lightPos.z,1); //move to bind place
		cgGLSetMatrixParameterfc(g_defaultVertexShader->getParameter("view"),g_viewMat);
		cgGLSetStateMatrixParameter( g_defaultVertexShader->getParameter("worldViewProj"), CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
		cgGLSetStateMatrixParameter( g_defaultVertexShader->getParameter("worldView"), CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
		cgUpdateProgramParameters(g_defaultVertexShader->getProgram());
	}

	glColor3f(1,1,1);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,0,boxVerts);
	glEnableClientState(GL_NORMAL_ARRAY);
	glNormalPointer(GL_FLOAT,0,boxNormals);
	glDrawArrays(GL_QUADS,0,24);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisable(GL_NORMALIZE);
	glPopMatrix();

	if(g_shaderSys)
		g_shaderSys->disableProfiles();
}
static void gl_cg_set_uniform_parameter(
      void *data,
      struct uniform_info *param,
      void *uniform_data)
{
   CGparameter location;
   cg_shader_data_t *cg        = (cg_shader_data_t*)data;

   if (!param || !param->enabled)
      return;

   if (param->lookup.enable)
   {
      char ident[64];
      CGprogram prog = 0;

      switch (param->lookup.type)
      {
         case SHADER_PROGRAM_VERTEX:
            prog = cg->prg[param->lookup.idx].vprg;
            break;
         case SHADER_PROGRAM_FRAGMENT:
         default:
            prog = cg->prg[param->lookup.idx].fprg;
            break;
      }

      if (param->lookup.add_prefix)
         snprintf(ident, sizeof(ident), "IN.%s", param->lookup.ident);
      location = cgGetNamedParameter(prog, param->lookup.add_prefix ? ident : param->lookup.ident);
   }
   else
   {
      struct uniform_cg *cg_param = (struct uniform_cg*)uniform_data;
      location = cg_param->loc;
   }

   switch (param->type)
   {
      case UNIFORM_1F:
         cgGLSetParameter1f(location, param->result.f.v0);
         break;
      case UNIFORM_2F:
         cgGLSetParameter2f(location, param->result.f.v0, param->result.f.v1);
         break;
      case UNIFORM_3F:
         cgGLSetParameter3f(location, param->result.f.v0, param->result.f.v1,
               param->result.f.v2);
         break;
      case UNIFORM_4F:
         cgGLSetParameter4f(location, param->result.f.v0, param->result.f.v1,
               param->result.f.v2, param->result.f.v3);
         break;
      case UNIFORM_1FV:
         cgGLSetParameter1fv(location, param->result.floatv);
         break;
      case UNIFORM_2FV:
         cgGLSetParameter2fv(location, param->result.floatv);
         break;
      case UNIFORM_3FV:
         cgGLSetParameter3fv(location, param->result.floatv);
         break;
      case UNIFORM_4FV:
         cgGLSetParameter3fv(location, param->result.floatv);
         break;
      case UNIFORM_1I:
         /* Unimplemented - Cg limitation */
         break;
   }
}
Beispiel #7
0
	void	IOGLBaseShader::SetUniform(const CString& strName, const Math::CVector4D& vValue){
		cgGLSetParameter4f(this->GetParameter(strName), vValue.X, vValue.Y, vValue.Z, vValue.W);
	}
Beispiel #8
0
void GLWindow::paintGL()
{
	glClearColor( 8/256.0, 5/256.0, 76/256.0, 0.0 );
	glClear( GL_COLOR_BUFFER_BIT );

	if( !mTextureValid )
		return;

	if( !mUseCG && (mColorMode==AlphaChannel) ){
		glDisable( mTextureMode );
		glDisable( GL_BLEND );
		glColor3f( 1.0, 1.0, 1.0 );
		glBegin( GL_QUADS );
		glVertex2f( tex_x, tex_y );
		glVertex2f( tex_x + tex_w, tex_y );
		glVertex2f( tex_x + tex_w, tex_y + tex_h );
		glVertex2f( tex_x, tex_y + tex_h );
		glEnd();

		glEnable( mTextureMode );
		glEnable( GL_BLEND );
		glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA );
		glColor3f( 0.0, 0.0, 0.0 );
	} else {
		glDisable( mTextureMode );
		glDisable( GL_BLEND );
		glColor3f( 1.0, 1.0, 1.0 );

		glEnable( mTextureMode );
		glEnable( GL_BLEND );
		glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA );
		glColor3f( 0.0, 0.0, 0.0 );

		float r = (mColorMode==RedChannel) ? 1.0 : 0.0;
		float g = (mColorMode==GreenChannel) ? 1.0 : 0.0;
		float b = (mColorMode==BlueChannel) ? 1.0 : 0.0;
		float a = (mColorMode==AlphaChannel) ? 1.0 : 0.0;

		if( mColorMode==AllChannel )
			r = g = b = 1.0;

#ifdef COMPILE_CG
		if( mUseCG ){
			cgGLSetParameter4f( cgColorClampParam, r, g, b, a );
			cgGLEnableProfile( cgFragmentProfile );
			//glColor4f( 1.0, 1.0, 1.0, 1.0 );
		}else
#endif
			glColor4f( r, g, b, a );
		glDisable(GL_BLEND);
	}

	glBindTexture(mTextureMode, mCurrentTexture.handle);

	glTexParameteri(mTextureMode,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering
	glTexParameteri(mTextureMode,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering

	glBegin( GL_QUADS );
	glTexCoord2f( 0.0, 0.0 );
	glVertex2f( tex_x, tex_y );
	glTexCoord2f( mCurrentTexture.umax, 0.0 );
	glVertex2f( tex_x + tex_w, tex_y );
	glTexCoord2f( mCurrentTexture.umax, mCurrentTexture.vmax );
	glVertex2f( tex_x + tex_w, tex_y + tex_h );
	glTexCoord2f( 0.0, mCurrentTexture.vmax );
	glVertex2f( tex_x, tex_y + tex_h );
	glEnd();
}
Beispiel #9
0
void Sarge::Render() {
	
	
	
	cgGLBindProgram(vsSargeProgram);
	cgGLEnableProfile(vsSargeProfile);
	CheckForCgError("sarge", "enabling vertex program");
	
	
	cgGLBindProgram(psSargeProgram);
	cgGLEnableProfile(psSargeProfile);
	CheckForCgError("sarge", "enabling pixel program");

//	mSkydome->getSunPos()

	//Vector3 tmpsun = mWorldMode->getSkydome().getSunPos();

	cgGLSetParameter4f(lightPosition, 0.0, 20.0, 0.0, 1.0);
	//cgGLSetParameter4f(lightPosition, tmpsun.GetX(), tmpsun.GetY(), tmpsun.GetZ(), 1.0);
	cgGLSetParameter3f(eyevector, 0.0, 0.0, 5.0);

	cgGLEnableTextureParameter(normalmap);
	cgGLEnableTextureParameter(decalmap);

	/*
	glActiveTextureARB(GL_TEXTURE0_ARB);
	//glEnable(GL_TEXTURE_2D);
	//glBindTexture(GL_TEXTURE_2D, sargeNormalTexture.TextureID);
	glActiveTextureARB(GL_TEXTURE1_ARB);
	//glEnable(GL_TEXTURE_2D);
	//glBindTexture(GL_TEXTURE_2D, sargeColorTexture.TextureID);
	glActiveTextureARB(GL_TEXTURE2_ARB);
	glActiveTextureARB(GL_TEXTURE3_ARB);
	glActiveTextureARB(GL_TEXTURE4_ARB);
	*/

	glDisable(GL_LIGHTING);
	
	


	//Pixel Parameters
	//      cgGLEnableTextureParameter(text1);

	glPushMatrix();

	cgGLSetStateMatrixParameter(lightViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);

	glTranslatef(mPos.GetX(), mPos.GetY(), mPos.GetZ());
	glRotatef(-mTheta * 180/PI - 90, 0, 1, 0);
	glRotatef(90, 1, 0, 0);
	//glScalef(0.6,0.6,0.6);

	cgGLSetStateMatrixParameter(modelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);

	
	
	
	mDriverParticleSystem.Render();
	if(burned) glColor3f(0, 0, 0);
	else glColor3f(1, 1, 1);
	mMeshObject.GLDraw();
	glColor3f(1, 1, 1);
	

	glPopMatrix();
	
	glEnable(GL_LIGHTING);

	
	cgGLDisableProfile(vsSargeProfile);
	cgGLDisableProfile(psSargeProfile);


	
	/*
	//glDisable(GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glDisable(GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE2_ARB);
	glDisable(GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE3_ARB);
	glDisable(GL_TEXTURE_2D);
	glActiveTextureARB(GL_TEXTURE4_ARB);
	glDisable(GL_TEXTURE_2D);
	*/
	
	glActiveTextureARB(GL_TEXTURE0_ARB);

	if(frozen)
	{	FreezeEffectBegin();
			glTranslatef(mPos.GetX(), mPos.GetY(), mPos.GetZ());
			glRotatef(-mTheta * 180/PI - 90, 0, 1, 0);
			glScalef(2.5,2.5,2.5);
			 cgGLSetStateMatrixParameter(vsFreezeEffectMVMatrix, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
		FreezeEffectEnd(); 

		if(freezeCounter > (16.0f/3.0f) && freezeCounter <= 8.0f)
		{
			glPushMatrix();
				mFreezeParticleSystem.Render(mPos.GetX(), mPos.GetY(), mPos.GetZ(),-mTheta * 180/PI - 90, 0, 1, 0);
			glPopMatrix();
		}
	}
	
	
}
void ObjMeshGPUDeformer::RenderMaster(int masterMode, void * data)
{
  glActiveTextureARB(GL_TEXTURE0_ARB); 
  glDisable(GL_TEXTURE_2D);

  cgGLEnableProfile(VertexProfile);

  if (masterMode == 0)
  {
    cgGLBindProgram(VertexPass2Program);

    if (renderingMode & OBJMESHRENDER_TEXTURE)
    {
      cgGLEnableProfile(FragmentProfile);
      cgGLBindProgram(FragmentPass2Program);
    }

    cgGLSetStateMatrixParameter(ModelViewProjParam,
      CG_GL_MODELVIEW_PROJECTION_MATRIX,
      CG_GL_MATRIX_IDENTITY);

    cgGLSetStateMatrixParameter(ModelViewITParam,
      CG_GL_MODELVIEW_MATRIX,
      CG_GL_MATRIX_INVERSE_TRANSPOSE);

    cgGLSetParameter4f(LightPos1Param, lightPos[0], lightPos[1], lightPos[2], 1);  
    cgGLSetParameter4f(LightPos2Param, lightPos[4], lightPos[5], lightPos[6], 1);  
    cgGLSetParameter4f(LightPos3Param, lightPos[8], lightPos[9], lightPos[10], 1);  
    cgGLSetParameter4f(LightPos4Param, lightPos[12], lightPos[13], lightPos[14], 1); 
    cgGLSetParameter1f(Light1IntensityParam, lightIntensity[0]);  
    cgGLSetParameter1f(Light2IntensityParam, lightIntensity[1]);  
    cgGLSetParameter1f(Light3IntensityParam, lightIntensity[2]);  
    cgGLSetParameter1f(Light4IntensityParam, lightIntensity[3]);  

    cgGLSetParameter1f(AmbientIntensityParam, ambientIntensity);  
  }

  if (masterMode == 1)
  {
    cgGLBindProgram(VertexPass2ProgramShadow);

    cgGLSetStateMatrixParameter(ModelViewProjShadowParam,
      CG_GL_MODELVIEW_PROJECTION_MATRIX,
      CG_GL_MATRIX_IDENTITY);

    double intensity = *(double*)data;
    cgGLSetParameter1f(ShadowIntensityParam, intensity);
  }

  if (renderingMode & OBJMESHRENDER_TEXTURE)
  {
    cgGLEnableProfile(FragmentProfile);
    cgGLBindProgram(FragmentPass2Program);
  }

  cgGLSetStateMatrixParameter(ModelViewProjParam,
    CG_GL_MODELVIEW_PROJECTION_MATRIX,
    CG_GL_MATRIX_IDENTITY);

  cgGLSetStateMatrixParameter(ModelViewITParam,
    CG_GL_MODELVIEW_MATRIX,
    CG_GL_MATRIX_INVERSE_TRANSPOSE);

  cgGLSetParameter4f(LightPos1Param, lightPos[0], lightPos[1], lightPos[2], 1);  
  cgGLSetParameter4f(LightPos2Param, lightPos[4], lightPos[5], lightPos[6], 1);  
  cgGLSetParameter4f(LightPos3Param, lightPos[8], lightPos[9], lightPos[10], 1);  
  cgGLSetParameter4f(LightPos4Param, lightPos[12], lightPos[13], lightPos[14], 1); 
  cgGLSetParameter1f(Light1IntensityParam, lightIntensity[0]);  
  cgGLSetParameter1f(Light2IntensityParam, lightIntensity[1]);  
  cgGLSetParameter1f(Light3IntensityParam, lightIntensity[2]);  
  cgGLSetParameter1f(Light4IntensityParam, lightIntensity[3]);  

  cgGLSetParameter1f(AmbientIntensityParam, ambientIntensity);  

  glBindTexture(GL_TEXTURE_2D, vertexDeformationTextureID);
  BindRT();

  for(int groupNo=0; groupNo<numGroups; groupNo++)
  {
    const ObjMesh::Group * groupHandle = mesh->getGroupHandle(groupNo);
    int materialIndex = groupHandle->getMaterialIndex();
    const ObjMesh::Material * materialHandle = mesh->getMaterialHandle(materialIndex);

    float alpha = (float)(materialHandle->getAlpha());

    Vec3d Ka = materialHandle->getKa();
    float Kav[4] = { (float)Ka[0], (float)Ka[1], (float)Ka[2], alpha };

    Vec3d Kd = materialHandle->getKd();
    float Kdv[4] = { (float)Kd[0], (float)Kd[1], (float)Kd[2], alpha };

    Vec3d Ks = materialHandle->getKs();
    float Ksv[4] = { (float)Ks[0], (float)Ks[1], (float)Ks[2], alpha };

    float shininess = materialHandle->getShininess();

    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Kav);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Kdv);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Ksv);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);

    float zero[4] = { 0, 0, 0, 0 };
    cgGLSetParameter4fv(KaParam, ambientEnabled ? Kav : zero);
    cgGLSetParameter4fv(KdParam, diffuseEnabled ? Kdv : zero);
    cgGLSetParameter4fv(KsParam, specularEnabled ? Ksv : zero);
    cgGLSetParameter1f(shininessParam, shininess);

    if ((renderingMode & OBJMESHRENDER_TEXTURE) && (materialHandle->hasTextureFilename()))
    {
      ObjMeshRender::Texture * textureHandle = meshRender->getTextureHandle(materialIndex);
      GLuint tname = textureHandle->getTexture();
      glActiveTextureARB(GL_TEXTURE1_ARB); 
      glBindTexture(GL_TEXTURE_2D, tname);
      glEnable(GL_TEXTURE_2D);
    }

    #ifdef OBJMESHGPUDEFORMER_USING_VBOS
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboID[5*groupNo+0]);
      glEnableClientState(GL_VERTEX_ARRAY);
      glVertexPointer(3, GL_FLOAT, 0, 0);

      if (vboNormalEnabled[groupNo])
      {
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboID[5*groupNo+1]);
        glEnableClientState(GL_NORMAL_ARRAY);
        glNormalPointer(GL_FLOAT, 0, 0);
      }

      glClientActiveTextureARB(GL_TEXTURE0_ARB);
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboID[5*groupNo+2]);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
      glTexCoordPointer(2, GL_FLOAT, 0, 0);

      if (vboTex1Enabled[groupNo])
      {
        glClientActiveTextureARB(GL_TEXTURE1_ARB);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboID[5*groupNo+3]);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glTexCoordPointer(2, GL_FLOAT, 0, 0);
      }

      glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboID[5*groupNo+4]);
      glDrawElements(GL_TRIANGLES, 3 * numGroupTriangles[groupNo], GL_UNSIGNED_INT, 0);

      // turn off VBOs
      glDisableClientState(GL_VERTEX_ARRAY);
      if (vboNormalEnabled[groupNo])
        glDisableClientState(GL_NORMAL_ARRAY);
      glClientActiveTextureARB(GL_TEXTURE0_ARB);
      glDisableClientState(GL_TEXTURE_COORD_ARRAY);
      if (vboTex1Enabled[groupNo])
      {
        glClientActiveTextureARB(GL_TEXTURE1_ARB);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
      }
      glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

    #else
      glCallList(displayListStart + groupNo);
    #endif

    if ((masterMode == 0) && (renderingMode & OBJMESHRENDER_TEXTURE) && (materialHandle->hasTextureFilename()))
    {
      glDisable(GL_TEXTURE_2D);
      glActiveTextureARB(GL_TEXTURE0_ARB); 
    }
  }

  UnbindRT();

  if ((masterMode == 0) && (renderingMode & OBJMESHRENDER_TEXTURE))
    cgGLDisableProfile(FragmentProfile);

  cgGLDisableProfile(VertexProfile);
}