#include #include #include #include #include "cue.h" #include "texture.h" const int CUE_DISPLAY_LIST = 4; const int TIP_DISPLAY_LIST = 5; const double RADIUS = 0.00286; void cue::draw(double x, double y, double angle, KueTexture &texture, const TQColor &tip_color) { glPushMatrix(); // Go to the specified location glTranslated(x, y, RADIUS); // Rotate to the specificed angle glRotated(angle, 0.0, 0.0, 1.0); // And tip the cue upwards glRotated(80, 0.0, 1.0, 0.0); // Have we built the cue display list? if (!glIsList(CUE_DISPLAY_LIST) == GL_TRUE) { // Make a new quadtic object GLUquadricObj *qobj = gluNewQuadric(); // We need normals and texturing for lighting and textures gluQuadricNormals(qobj, GLU_SMOOTH); gluQuadricTexture(qobj, GL_TRUE); // Make a new display list glNewList(TIP_DISPLAY_LIST, GL_COMPILE); // Draw the tip gluCylinder(qobj, RADIUS / 2.5, RADIUS / 2.5, 0.003, 10, 10); // End the tip list glEndList(); // Make a new display list glNewList(CUE_DISPLAY_LIST, GL_COMPILE); // Draw the main part of the cue glTranslated(0.0, 0.0, 0.003); gluCylinder(qobj, RADIUS / 2.5, RADIUS / 1.5, 0.047, 10, 10); // End the cue list glEndList(); // Draw the quadric gluDeleteQuadric(qobj); } KueTexture::null().makeCurrent(); glColor3d( tip_color.red() / 255.0, tip_color.green() / 255.0, tip_color.blue() / 255.0 ); glCallList(TIP_DISPLAY_LIST); texture.makeCurrent(); glColor3d(1.0, 1.0, 1.0); glCallList(CUE_DISPLAY_LIST); glPopMatrix(); }