Hello Guest

How to draw a 3d sphere with lwjgl 3?

  • 2 Replies
  • 8285 Views
How to draw a 3d sphere with lwjgl 3?
« on: June 13, 2018, 23:38:01 »
Hello, I want to make a 3d sphere in jwjgl, and I searched a lot for it, but just couldn't find anything that really works, because it seems that everything you search for on the internet is very old and using lwjgl 2. Can anyone help me with that? Is there a good way to do it? Or do I just need to draw an array of circles or something? Thanks.

*

Offline KaiHH

  • ****
  • 334
Re: How to draw a 3d sphere with lwjgl 3?
« Reply #1 on: June 14, 2018, 07:59:58 »
The easiest solution is to use the "longitude and latitude loops" approach to compute the vertices/positions on the sphere.
Here is a good solution: https://stackoverflow.com/questions/7687148/drawing-sphere-in-opengl-without-using-glusphere#answer-31326534
You just need to fill a vertex buffer with the those vertices or use immediate mode rendering.
Of course you will not find a dedicated tutorial "How to render a sphere with VBO and shaders or without shaders with OpenGL 2.0 and also OpenGL 3.2 and 3.3 and 4.1 and 4.2 and 4.3 using exactly LWJGL 3.1.6 and 3.1.7".
After all, you are using OpenGL and not LWJGL. You should be searching tutorials explicitly for OpenGL and NOT LWJGL. Translating the C OpenGL calls to LWJGL should be easy.

*

Offline spasi

  • *****
  • 2258
    • WebHotelier
Re: How to draw a 3d sphere with lwjgl 3?
« Reply #2 on: June 14, 2018, 09:28:11 »
For simple test geometry you can use the par_shapes bindings. You can easily create spheres, cylinders, etc with it. See the ParShapesDemo for sample code. Alternatively, you can create a sphere (or any other mesh you want) in your favorite DCC application, export it, then load it in the LWJGL application with the Assimp bindings.