Texturing a sphere

Started by msacco, June 18, 2018, 14:30:14

Previous topic - Next topic

msacco


msacco

Quote from: KaiHH on June 20, 2018, 19:39:32
No problem. Here is a demo using the somewhat latest reasonable version of OpenGL to render a rotating, textured sphere:
  https://github.com/LWJGL/lwjgl3-demos/commit/4304297afc6275f791d8b3e2850b740b6cfcdb4f
See the Java and shader files in that commit. It uses OpenGL 3.2 Core Profile functions. There hasn't been much improvement in later OpenGL versions for such simple things as rendering a textured sphere. It's still always:
- create a vertex and (optionally) index/element buffer
- create a shader program
- setup vertex specification with these buffers and the vertex attributes imported by the shader program
- enable/bind shader
- call draw functions

That seems much more complex than opengl 1-2 :D Do you have to use vao/vbos and shaders in opengl 3-4? And do you think this tutorial is good for learning new opengl? https://legacy.gitbook.com/download/pdf/book/lwjglgamedev/3d-game-development-with-lwjgl Thanks a lot for the example! (tho I can't really get it to work, but I can still read it)

KaiHH

Just import the repository as Maven project into your favorite IDE and everything will be settled for you automatically.
QuoteDo you have to use vao/vbos and shaders in opengl 3-4?
Yes.

msacco

Quote from: KaiHH on June 21, 2018, 09:11:53
Just import the repository as Maven project into your favorite IDE and everything will be settled for you automatically.
QuoteDo you have to use vao/vbos and shaders in opengl 3-4?
Yes.

The usage of lightning in new opengl is same as using lightning in old opengl? cause I wanna try to do some currently on my old oopengl code, but if its different than I guess there's no point in learning that.

KaiHH

You probably meant "lighting". And yes, it is TOTALLY different. There is no fixed-function API anymore to specify light parameters such as position, color, specularity, etc. You have to write GLSL shaders for that.

msacco

Quote from: KaiHH on June 22, 2018, 12:07:11
You probably meant "lighting". And yes, it is TOTALLY different. There is no fixed-function API anymore to specify light parameters such as position, color, specularity, etc. You have to write GLSL shaders for that.

Yep, I guess the "lightning" came as an habit ^_^ hmm, is it harder in new opengl or harder? Because from what I've heard, you should have more control of the lighting in opengl, you know if its meant for both new opengl or old opengl? I don't want something too complex, just make an object spread light to nearby objects in all directions.

KaiHH

Quote from: msacco on June 22, 2018, 17:40:02
is it harder in new opengl or harder?
Neither. It is harder. ;-)

Quote from: msacco on June 22, 2018, 17:40:02
Because from what I've heard, you should have more control of the lighting in opengl
You do have more control with shaders, obviously, since you can implement your own custom lighting and shading models with simple linear algebra and arithmetic while not having to rely on fixed-function pipeline flat and phong shading which you merely control parameters of.

But it sure has a learning curve attached to it. You know that you also do not have to use OpenGL >= 3. You can still perfectly use what you always used with OpenGL <= 2 and the fixed-function pipeline. It is not going to go away anytime soon. All drivers still perfectly support "legacy" OpenGL which might be absolutely sufficient for what you might want to do, if you do not want to invest into learning modern OpenGL and GLSL.

msacco

Quote from: KaiHH on June 22, 2018, 17:51:19
Quote from: msacco on June 22, 2018, 17:40:02
is it harder in new opengl or harder?
Neither. It is harder. ;-)

Quote from: msacco on June 22, 2018, 17:40:02
Because from what I've heard, you should have more control of the lighting in opengl
You do have more control with shaders, obviously, since you can implement your own custom lighting and shading models with simple linear algebra and arithmetic while not having to rely on fixed-function pipeline flat and phong shading which you merely control parameters of.

But it sure has a learning curve attached to it. You know that you also do not have to use OpenGL >= 3. You can still perfectly use what you always used with OpenGL <= 2 and the fixed-function pipeline. It is not going to go away anytime soon. All drivers still perfectly support "legacy" OpenGL which might be absolutely sufficient for what you might want to do, if you do not want to invest into learning modern OpenGL and GLSL.

Well Im doing it for my own fun atm, it would be amazing if I'll be able to work with it as a game developer or something similar in the future, but that's usually something you need tons of expeirence to do as far as I can see. I've just heard from many people that older opengl is not something that should still be used and that it is better to learn opengl, and it might make some sense as well, as if I learn something, might as well just learn the modern version than the older one. Im still very confused about all of this, so I really don't know, Some say that learning older gl first is bad, and some says the opposite.

KaiHH

Well, everyone can only express their own opinions based on their own experience and the path they chose.
If you really want to learn it and not achieve some immediate goal with finishing your planet rendering program, then my opinion is: start learning modern OpenGL.
I myself started learning the legacy/old fixed-function pipeline OpenGL in 2007 and transitioned to more "modern" OpenGL 2.0 (VBOs and shaders) two years later. This has been at the expense of many many maaaaaaaany hours of googling the web left and right and up and down for OpenGL-related resources, articles, papers, specifications, forum posts, blog articles, literally everything, building dozens of little test and demo programs and throwing them away after reading how that all can be done better. If you get hooked by the thrill of learning it, and the small moments when it makes "click" in your head, then there's no stopping you anymore. :)
The hardest thing but also the most fun is to get an accurate mental model of the object model, state management and the rendering pipeline in modern OpenGL.
In modern OpenGL you just have a few core concepts/objects that you use for everything (VAO, buffer objects, textures, samplers, shaders and framebuffer objects). Then there are the different shader stages doing different things. Sooo many things to explore.
So, start digging around and building your own mental model of modern OpenGL. :)
I guess, at the beginning literally every starting point is a good point.

msacco

Quote from: KaiHH on June 22, 2018, 19:47:52
Well, everyone can only express their own opinions based on their own experience and the path they chose.
If you really want to learn it and not achieve some immediate goal with finishing your planet rendering program, then my opinion is: start learning modern OpenGL.
I myself started learning the legacy/old fixed-function pipeline OpenGL in 2007 and transitioned to more "modern" OpenGL 2.0 (VBOs and shaders) two years later. This has been at the expense of many many maaaaaaaany hours of googling the web left and right and up and down for OpenGL-related resources, articles, papers, specifications, forum posts, blog articles, literally everything, building dozens of little test and demo programs and throwing them away after reading how that all can be done better. If you get hooked by the thrill of learning it, and the small moments when it makes "click" in your head, then there's no stopping you anymore. :)
The hardest thing but also the most fun is to get an accurate mental model of the object model, state management and the rendering pipeline in modern OpenGL.
In modern OpenGL you just have a few core concepts/objects that you use for everything (VAO, buffer objects, textures, samplers, shaders and framebuffer objects). Then there are the different shader stages doing different things. Sooo many things to explore.
So, start digging around and building your own mental model of modern OpenGL. :)
I guess, at the beginning literally every starting point is a good point.

I think I will try finishing what Im currently doing(almost finished except for lighting and correct scaling/3d camera movement) using old opengl, then I will learn and try to do the same, but in modern opengl, once thing that really bugs me, is that I know that in modern opengl you need to upload something only once to the gpu to render it, unlike now, where I want to do something that renders many any objects all at once, but it simply causes huge fps drops so I can't really do it. Obviously, there are tons of ways to go around it, but for someone like me, I don't really know how to do it yet, so thats where I kinda feel the limitations atm. Hopefully I will have enough time for that, as I start a degree soon and maybe a new job, so that might be a bit stressful :x
Anyway, I really appreciate all your answers and help, that was so helpful and you have no idea how much I've been tought through you.