// Drawable initials ----------------------------------------------------------- #include "drawable_initials.h" #include "utils.h" #include #include using namespace std; // Static class members -------------------------------------------------------- int Initials::DisplayListId = -1; // Constructor ----------------------------------------------------------------- Initials::Initials(const double pX, const double pY, const double pZ) : Drawable(pX, pY, pZ) { if (DisplayListId < 0) { DisplayListId = glGenLists(1); glNewList(DisplayListId, GL_COMPILE); { render(); } glEndList(); } } // Draw ------------------------------------------------------------------------ void Initials::draw() { glPushMatrix(); glColor3fv(color); glTranslatef(x, y, z); glCallList(DisplayListId); glPopMatrix(); } // Render ---------------------------------------------------------------------- void Initials::render() { glPushMatrix(); glScalef(5.0, 5.0, 5.0); // p glColor3f(1.0, 0.0, 0.0); glRectf(-6.0, 5.0, -5.0, -4.5); draw_circle(-3.5, 2.5, 2.5, 36); glColor3f(0.0, 0.0, 0.0); draw_circle(-3.5, 2.5, 1.5, 36); // j glColor3f(0.0, 1.0, 0.0); glRectf(-0.5, 5.0, 0.5, -2.5); draw_circle(0.0, 6.0, 0.5, 36); draw_semicircle(-2.0, -2.0, 2.5, 36, -1); glColor3f(0.0, 0.0, 0.0); draw_semicircle(-2.0, -2.0, 1.5, 36, -1); // b glColor3f(0.0, 0.0, 1.0); glRectf( 1.0, 9.5, 2.0, 0.0); draw_circle( 3.5, 2.5, 2.5, 36); glColor3f(0.0, 0.0, 0.0); draw_circle( 3.5, 2.5, 1.5, 36); glPopMatrix(); } // vim: set sts=4 sw=4 ts=8 ft=cpp: --------------------------------------------