diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:13:02 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:23:24 +0300 |
commit | 04b5a62b8d9f5ff8240f25361046f2a5d58e8262 (patch) | |
tree | 98b126454cdf68d544e138d7e8b31d5fd45b72c2 /kue/disc.cpp | |
parent | 83ba00b7e569587d50383ff06a70148042ca780e (diff) | |
download | tdegames-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/disc.cpp')
-rw-r--r-- | kue/disc.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/kue/disc.cpp b/kue/disc.cpp new file mode 100644 index 00000000..2b6946e5 --- /dev/null +++ b/kue/disc.cpp @@ -0,0 +1,46 @@ +#include <GL/gl.h> +#include <GL/glu.h> + +#include <math.h> + +#include "disc.h" + +// The pre-allocated number of our display list +const int DISC_DISPLAY_LIST = 3; +// The disc radius currently cached in our display list +double disc_list_radius = 0.0; + +void disc::draw(double x, double y, double r) +{ + glPushMatrix(); + + // Move to the specified location + glTranslatef(x, y, 0.0001); + + // Have we cached this radius + if ((r == disc_list_radius) && (glIsList(DISC_DISPLAY_LIST) == GL_TRUE)) + { + // Yes, just call the display list + glCallList(DISC_DISPLAY_LIST); + } + else + { + // Nope, make a new quadric object + GLUquadricObj *quad = gluNewQuadric(); + + // Make a new display list + glNewList(DISC_DISPLAY_LIST, GL_COMPILE_AND_EXECUTE); + // Draw the disc + gluDisk(quad, 0.0, r, 10, 1); + // End the display list + glEndList(); + + // Update the cached value + disc_list_radius = r; + + // Delete the quadric object + gluDeleteQuadric(quad); + } + + glPopMatrix(); +} |