I have recently migrated from Windows to Linux (Debian, 64-bit) and am trying to get a GPGPU development environment up and running, so I am testing a program which worked under Windows.
Compiling and linking goes fine, but when I run the program I get some odd errors. I am using glew and freeglut.
First snippet: OpenGL only
i = 1;
info = PROGRAM_NAME;
glutInitContextVersion(4,2);
glutInit(&i, &info);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(W_SIZEX, W_SIZEY);
glutInitWindowPosition(W_POSX, W_POSY);
glutCreateWindow(info);
glClearColor(1.0,1.0,1.0,0);
/**/
printf("Before glewInit: %i\n", glGetError());
/**/
printf("glewInit returns: %i\n", glewInit());
/**/
printf("After glewInit: %i\n", glGetError());
/**/
From which I get the following output:
Before glewInit: 0
glewInit returns: 0
After glewInit: 1280
This is an invalid enum error. I don’t know what’s causing it, but I suspect it might be related to the next error I get, later in the program’s execution.
Second snippet: OpenCL-OpenGL interop
/* BUFFERS */
(*BFR).C[0] = clCreateBuffer(*CTX, CL_MEM_READ_WRITE, SD, 0, 0);
(*BFR).C[1] = clCreateBuffer(*CTX, CL_MEM_READ_WRITE, SD, 0, &i);
dcl(i);
glGenBuffers(2, (*BFR).G);
glBindBuffer(GL_ARRAY_BUFFER, (*BFR).G[0]);
glBufferData(GL_ARRAY_BUFFER, SI, 0, GL_DYNAMIC_DRAW);
(*BFR).D[0] = clCreateFromGLBuffer(*CTX, CL_MEM_WRITE_ONLY, (*BFR).G[0], &i);
dcl(i);
glBindBuffer(GL_ARRAY_BUFFER, 0);
Here, the dcl(int) method just decodes the CL error code. When I run this, I get a CL_INVALID_GL_OBJECT error from clCreateFromGLBuffer(). However, OpenGL has no issues generating, binding or unbinding the buffers in question. The OpenCL context is apparently valid, generating no errors on creation or query. Everything works in VS2010 on Windows 7 64-bit.
Compilation Details
Here are the relevant includes:
/* OPENGL */
#include "GL/glew.h"
#include "GL/freeglut.h"
/* OPENCL */
#include "CL/cl.h"
#include "CL/cl_gl.h"
I am using GCC and linking like so:
gcc -w -I./include CLGL.c -o ~/Templates/GOL-CLGL/run/a.out -lGLEW -lGLU -lglut -lGL -lOpenCL;
Compilation and linking results in no errors (plenty of warnings about pointer abuse but I doubt that’s the culprit).
I’m currently out of ideas on how to debug this. Can anyone suggest further steps?
I had this issue recently too so here is the answer:
OpenGL: glGetError() returns invalid enum after call to glewInit()
So you can discard that error .