Thanks for helping out Dark Photon. This is my video specifications:
>>echo $DISPLAY
:0.0
>>glxinfo | grep ':'
name of display: :0.0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: ATI
server glx version string: 1.4
server glx extensions:
client glx vendor string: ATI
client glx version string: 1.4
client glx extensions:
GLX version: 1.4
GLX extensions:
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Radeon HD 5800 Series
OpenGL version string: 4.1.11005 Compatibility Profile Context
OpenGL shading language version string: 4.10
OpenGL extensions:
91 GLXFBConfigs:
I tried your testprogram and it worked fine. Red square appeared and was clickable. My guess is the problem lies in glDrawElements, since glRectf() worked. Here’s some of my code, I removed a lot of unnecessary code, our goal is to draw lots of cubes in different patterns but right now I’m just putting out 1 cube. I did not include the shaders as they are very inactive at the moment, just doing the matrix multiplications. So let me know if you need more, I thought I’d keep it simple at first.
void init(void)
{
dumpInfo();
// GL inits
glClearColor(0.0,0.1,0.2,0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
printError("GL inits");
initKeymapManager();
// Load and compile shader
program = loadShaders("fract.vert", "fract.frag");
printError("init shader");
// Allocate and activate Vertex Array Objects
glGenVertexArrays(1, &vertexArrayID);
glBindVertexArray(vertexArrayID);
// Allocate Vertex Buffer Objects
glGenBuffers(1, &vertexBufferID);
glGenBuffers(1, &indexBufferID);
// VBO for vertex data
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferID);
glBufferData(GL_ARRAY_BUFFER, numVertices*sizeof(GLfloat), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(glGetAttribLocation(program, "in_Position"), 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(glGetAttribLocation(program, "in_Position"));
printError("init vertices");
//VBO for index data
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndices*sizeof(GLubyte), cubeIndices, GL_STATIC_DRAW);
//Add a cube to object list
Cube obj;
memcpy(obj.v, vertices, numVertices*sizeof(GLfloat));
obj.vertexArrayObjID = vertexArrayID;
obj.vertexBufferObjID = vertexBufferID;
obj.indexBufferObjID = indexBufferID;
mylist = list_create(obj);
createCube(obj,mylist); // Uploads a cube object to the shader, I belive alot of above is unnecessary but im not in a position to
}
void display(){
keyboardMovement();
GLfloat spacing[3] = {0, 0, 0};
GLfloat color[3] = {0.2, 0.4, 0.1};
// clear the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Transformation matrices
GLfloat camera[16], rot[16], trans[16], totalMatrix[16];
lookAt( cameraPosX, cameraPosY, cameraPosZ, // Camera pos
lookAtPosX, lookAtPosY, lookAtPosZ, // Look at pos
0.0, 1.0, 0.0, // Up vector
camera);
printError("pre display");
// Initialize matrices
T(0, 0, 0, trans);
// Cube
drawCubes(mylist,spacing,camera,projectionMatrix,trans,0,1,color);
}
/*
This is a work in progress so it might be a bit hard to understand.
What it does: Draws an object from cubelist 'n' times, with a distance of 'spacing' from each other. Offset is always 1 atm.
cm - camera matrix, pm - projection matrix, tm - translation matirx.
*/
void drawCubes(const CubeList *l, GLfloat* spacing, GLfloat *cm, GLfloat *pm, GLfloat* tm, int offset, int n, GLfloat *color){
CubeList *tl = l;
Cube c;
int i,j;
GLfloat total_m[16], camera_m[16], projection_m[16], translation_m[16], local_trans[16], colorstep[3];
memcpy(camera_m, cm, 16*sizeof(GLfloat));
memcpy(projection_m, pm, 16*sizeof(GLfloat));
GLfloat cspacing[] = {0,0,0};
for(i=0;i<3;i++){
colorstep[i] = (1.0-color[i])/n;
}
//Step to the right offset
for (i=0;i<offset;i++)
{
if(tl != NULL)
tl = tl->next;
}
//Draw n elements
for(i=0;i<n;i++)
{
if(tl != NULL){
c = list_get_cube(tl);
//Transformations
memcpy(translation_m, tm, 16*sizeof(GLfloat));
T(cspacing[0],cspacing[1],cspacing[2], local_trans);
Mult(translation_m,local_trans,translation_m);
Mult(camera_m, translation_m, total_m);
Mult(projection_m, total_m, total_m);
//Upload to shader
glUniformMatrix4fv(glGetUniformLocation(program, "totalMatrix"), 1, GL_TRUE, total_m);
glUniform3f(glGetUniformLocation(program, "inColor"), color[0], color[1] ,color[2]);
glBindVertexArray(c.vertexArrayObjID); // Select VAO
glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_BYTE, 0L);
for(j=0;j<3;j++){
color[j] += colorstep[j];
cspacing[j] += spacing[j];
}
}
}
}
Peace