PDA

View Full Version : Why can not I see my sphere?



wololooo
01-28-2017, 12:58 PM
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: https://www.khronos.org/opengl/wiki/GluLookAt_code and here https://www.khronos.org/opengl/wiki/GluPerspective_code although I saw that they are a bit different from the ones declared in glm https://github.com/g-truc/glm/blob/master/glm/gtc/matrix_transform.inl

Hellice
01-28-2017, 02:35 PM
use glDrawArrays (https://www.opengl.org/sdk/docs/man/html/glDrawArrays.xhtml) if you are not using indices

wololooo
01-28-2017, 04:40 PM
use glDrawArrays (https://www.opengl.org/sdk/docs/man/html/glDrawArrays.xhtml) 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 :(

Silence
01-29-2017, 04:50 AM
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 :(

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).

Hellice
01-29-2017, 05:28 AM
Follow this tutorial (https://learnopengl.com/#!Introduction) and you will pro opengl programmer in no time.