void COGL::ResetClientStates (void) { for (int i = 4; i; ) { DisableClientStates (1, 1, 1, GL_TEXTURE0 + --i); glEnable (GL_TEXTURE_2D); OglBindTexture (0); if (i) glDisable (GL_TEXTURE_2D); } memset (m_states.clientStates, 0, sizeof (m_states.clientStates)); }
bool RendererLegacy::DrawTriangles(const VertexArray *v, Material *m, PrimitiveType t) { if (!v || v->position.size() < 3) return false; m->Apply(); EnableClientStates(v); glDrawArrays(t, 0, v->GetNumVerts()); m->Unapply(); DisableClientStates(); return true; }
int COGL::EnableClientStates (int bTexCoord, int bColor, int bNormals, int nTMU) { if (nTMU >= GL_TEXTURE0) SelectTMU (nTMU, true); if (!bNormals) DisableClientState (GL_NORMAL_ARRAY); else if (!EnableClientState (GL_NORMAL_ARRAY, -1)) { DisableClientStates (0, 0, 0, -1); return 0; } if (!bTexCoord) DisableClientState (GL_TEXTURE_COORD_ARRAY); else if (!EnableClientState (GL_TEXTURE_COORD_ARRAY, -1)) { DisableClientStates (0, 0, 0, -1); return 0; } if (!bColor) DisableClientState (GL_COLOR_ARRAY); else if (!EnableClientState (GL_COLOR_ARRAY, -1)) { DisableClientStates (bTexCoord, 0, 0, -1); return 0; } return EnableClientState (GL_VERTEX_ARRAY, -1); }
bool RendererLegacy::DrawSurface(const Surface *s) { if (!s || !s->GetVertices() || s->GetNumIndices() < 3) return false; const Material *m = s->GetMaterial().Get(); const VertexArray *v = s->GetVertices(); const_cast<Material*>(m)->Apply(); EnableClientStates(v); glDrawElements(s->GetPrimtiveType(), s->GetNumIndices(), GL_UNSIGNED_SHORT, s->GetIndexPointer()); const_cast<Material*>(m)->Unapply(); DisableClientStates(); return true; }