summaryrefslogtreecommitdiffstats
path: root/kue/cue.cpp
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2024-08-07 19:13:02 +0300
committerMavridis Philippe <mavridisf@gmail.com>2024-08-07 19:23:24 +0300
commit04b5a62b8d9f5ff8240f25361046f2a5d58e8262 (patch)
tree98b126454cdf68d544e138d7e8b31d5fd45b72c2 /kue/cue.cpp
parent83ba00b7e569587d50383ff06a70148042ca780e (diff)
downloadtdegames-feat/kue.tar.gz
tdegames-feat/kue.zip
Add Kue billiards gamefeat/kue
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kue/cue.cpp')
-rw-r--r--kue/cue.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/kue/cue.cpp b/kue/cue.cpp
new file mode 100644
index 00000000..561ad89a
--- /dev/null
+++ b/kue/cue.cpp
@@ -0,0 +1,74 @@
+#include <math.h>
+#include <tqcolor.h>
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#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();
+}