From 6e27c253ed7f1af0e1cb94fff016538015628bed Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 26 Oct 2024 21:30:45 -0400 Subject: initialize position --- balls.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'balls.c') diff --git a/balls.c b/balls.c index cc3e7ec..f80c901 100644 --- a/balls.c +++ b/balls.c @@ -144,7 +144,8 @@ initCL(void) { void configureSharedData(void) { - int err; + int err, i; + GLfloat positions[2 * NBALLS]; /* Create position array. */ glGenVertexArrays(1, &positionVAO); @@ -155,9 +156,13 @@ configureSharedData(void) { glBindVertexArray(vertexVAO); /* Create position buffer. */ + for (i = 0; i < 2*NBALLS; i += 2) { + positions[i] = -0.5f; + positions[i+1] = -0.25f; + } glGenBuffers(1, &positionVBO); glBindBuffer(GL_ARRAY_BUFFER, positionVBO); - glBufferData(GL_ARRAY_BUFFER, 2 * NBALLS * sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*NBALLS*sizeof(GLfloat), positions, GL_DYNAMIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); @@ -197,6 +202,7 @@ execKernel(void) { if (err < 0) sysfatal("Couldn't acquire the GL objects.\n"); + /* +1 because last point must be coincident with first point. */ globalSize = CIRCLE_SEGS+1; err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &globalSize, NULL, 0, NULL, &kernelEvent); if (err < 0) -- cgit v1.2.3