Why can not I see my sphere?

Hi,

I am trying to move from openGL 1 to 4. As a test, I want to see a sphere centred at 0,0,0. For this, I write all my vertexes in an array and also, all the colours related to each vertex in an other array. Then, I create my matrix transformations (the old lookat and perspective) and finally, I call gldrawelements which will use my shaders. Because the code, although basic, is a bit large to be published here, I have upload all the project here https://ufile.io/a6b6e (it is written in java with eclipse and JOGL, I didn’t include the JOGL library). As you will see, I cannot see any sphere. In opengl 1, if I use that code for creating the vertexes of the sphere and also, I use the same parameters for perspective and lookat I can see the sphere. What am I doing wrong?

By the way, I was getting the transformations from here: GluLookAt code - OpenGL Wiki and here GluPerspective code - OpenGL Wiki although I saw that they are a bit different from the ones declared in glm glm/matrix_transform.inl at master · g-truc/glm · GitHub

use glDrawArrays if you are not using indices

Thank you, but that didn’t solve the problem. I see strange things. Each time I run the app, I can see different shapes and colors :frowning:

This most certainly means that wrong data settle in the buffers or that you are accessing unassigned parts of your buffers (or even going out of bounds).

Follow this tutorial and you will pro opengl programmer in no time.