summaryrefslogtreecommitdiffstats
path: root/balls.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-26 22:28:58 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-26 22:28:58 -0400
commit245fcc0a20772c42cceb51288d4e48c5edac147b (patch)
treee7e8d0ac82e390fdf1822fd3d695ac4dfec7dfea /balls.c
parent6bcea67ac5a1f46dc145aac8adabd2e9e0d733eb (diff)
downloadballs-245fcc0a20772c42cceb51288d4e48c5edac147b.zip
replace CIRCLE_SEGS+2 with CIRCLE_POINTS
Diffstat (limited to 'balls.c')
-rw-r--r--balls.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/balls.c b/balls.c
index 905f918..ae5eb67 100644
--- a/balls.c
+++ b/balls.c
@@ -17,7 +17,10 @@
#define FRAGMENT_SHADER "balls.frag"
enum { WIDTH = 640, HEIGHT = 480 };
-enum { NBALLS = 4, CIRCLE_SEGS = 16 };
+enum {
+ NBALLS = 4,
+ CIRCLE_POINTS = 16+2, /* +2 for center point and last point which overlaps with first point. */
+};
void initGL(int argc, char *argv[]);
void initCL(void);
@@ -169,7 +172,7 @@ configureSharedData(void) {
/* Create vertex buffer. */
glGenBuffers(1, &vertexVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
- glBufferData(GL_ARRAY_BUFFER, NBALLS*(CIRCLE_SEGS+2)*2*sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW);
+ glBufferData(GL_ARRAY_BUFFER, NBALLS*CIRCLE_POINTS*2*sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(0);
@@ -202,7 +205,7 @@ execKernel(void) {
if (err < 0)
sysfatal("Couldn't acquire the GL objects.\n");
- localSize = CIRCLE_SEGS+2;
+ localSize = CIRCLE_POINTS;
globalSize = NBALLS * localSize;
err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &globalSize, &localSize, 0, NULL, &kernelEvent);
if (err < 0)
@@ -315,7 +318,7 @@ display(void) {
glBindVertexArray(vertexVAO);
for (i = 0; i < NBALLS; i++)
- glDrawArrays(GL_TRIANGLE_FAN, i*(CIRCLE_SEGS+2), CIRCLE_SEGS+2);
+ glDrawArrays(GL_TRIANGLE_FAN, i*CIRCLE_POINTS, CIRCLE_POINTS);
glBindVertexArray(0);
glutSwapBuffers();