void display(void) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(64.0, aspect, zNear, zFar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.0,0.0,-sdepth); glRotatef(-stheta, 1.0, 0.0, 0.0); glRotatef(sphi, 0.0, 0.0, 1.0); glTranslatef(-(float)((grid+1)/2-1), -(float)((grid+1)/2-1), 0.0); getFaceNorms(); getVertNorms(); switch (displayMode) { case WIREFRAME: drawWireframe(); break; case HIDDENLINE: drawHiddenLine(); break; case FLATSHADED: drawFlatShaded(); break; case SMOOTHSHADED: drawSmoothShaded(); break; case TEXTURED: drawTextured(); break; } if (drawFaceNorms) { getFaceNormSegs(); drawFaceNormals(); } glutSwapBuffers(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
bool Renderer::drawText(const char *str, float x, float y, const float charWidth, const float charHeight, const FontID font, const SamplerStateID samplerState, const BlendStateID blendState, const DepthStateID depthState){ if (font == FONT_NONE) return false; uint n = 6 * getTextQuads(str); if (n == 0) return true; if (n > fontBufferCount){ fontBuffer = (TexVertex *) realloc(fontBuffer, n * sizeof(TexVertex)); fontBufferCount = n; } fillTextBuffer(fontBuffer, str, x, y, charWidth, charHeight, font); drawTextured(PRIM_TRIANGLES, fontBuffer, n, fonts[font].texture, samplerState, blendState, depthState); return true; }