JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
11.1k stars 2.81k forks source link

Debugging presented last #399

Open meemknight opened 4 months ago

meemknight commented 4 months ago

Hello, I am a big fan of your tutorials but there is something that I think would be worth changing. I'm talking about debugging. On the web and on YouTube people only show the old OpenGL debugging thing, which is just horrible to use, so I searched for a better way and found it on your website in the debugging section, I'm talking about the modern error reporting features from OpenGL (glEnable(GL_DEBUG_OUTPUT)). But it seems to me like no one knows about it. I have seen many teachers from many universities and many OpenGL enjoyers, not use it, relying on the old debugging way, like The Cherno shows with a macro to call gl checks for every function, or not using it at all. And I think it is extremely important to be able to see what you are doing wrong for something as unforgiving as OpenGL where any error means a black screen usually. So I know for you this would feel like a big change and, and the tutorial probably makes more sense in a way as it is now, but I would want to suggest moving the debugging chapter very early, so people know about the modern debugging feature of OpenGL, and use it while coding. I think this could save them many hours of debugging. So please, if you agree with me, maybe consider moving that chapter earlier, or maybe hint at least in the first lessons that it is an important chapter and people should do it very early. Thanks!

LuckyIntel commented 4 months ago

Have you tried checking khronos.org for docs?They literally have an well-explained example of how to use debugs with glEnable(GL_DEBUG_OUTPUT) oh, by the way enabling debug outputs doesn't mean that you can start debugging straight away, you should still do some work to get these mesages that created by GL_DEBUG_OUTPUT feature.Here is the official docs for OpenGL from Khronos:

https://www.khronos.org/opengl/wiki/Debug_Output

If you need further help, i'll be there.

Edit : Remember learnopengl.com is an old tutorial so it can lack of some new stuff.In learnopengl.com you normally load GLAD like this :

if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; return -1; }

but you can actually do this and save a few lines of code(while sacrificing the error checking) with just this:

gladLoadGL()

So yes learnopengl.com can lack of some modern stuff.You might need to also check for other docs when needed.

meemknight commented 4 months ago

The issue is not about that, LearnOpenGL.com actually has all the information needed. My problem is that this information is extremely useful for beginners, and it would help beginners a lot, but it is presented last instead of very early. I have completed almost all of the tutorials here before finding out about this section. It would have saved me so much time had I known that propper error reporting exists in OpenGL!

LuckyIntel commented 4 months ago

The feature you want it to be added is supported for 4.3 and/or greater versions. LearnOpenGL anyways run their tutorials with OpenGL 3.3. As i said with this version, you can expect some lack of modern stuff.

Resources: https://www.khronos.org/opengl/wiki/Debug_Output Core in version: 4.6 (Latest) Core since version: 4.3 (Minimum)

meemknight commented 4 months ago

Ok, but I don't think there is anyone today with a PC that doesn't support 4.3. Or even if it is (I suppose Apple) The feature is still presented in the tutorials, So why not present it early to help the 99% of people that could use it?

LuckyIntel commented 4 months ago

There are PCs that doesn't support OpenGL 4.3, some PCs still run on lower-end hardware. For better compatbility you can stick with old-style debugging however if you're determined about using new debug system you might need to sacrifice compatibility. Newer versions of OpenGL performs better with new graphics cards while it's vice versa for older versions. Also wdym the feature is still presented in the tutorials?

meemknight commented 4 months ago

The old debugging system is also presented. My whole point is that I would want it to be presented very well because it is very useful. People do this tutorial in order and basically have to learn OpenGL without knowing that there are debugging features before they get there.

LuckyIntel commented 4 months ago

You mean this : https://learnopengl.com/In-Practice/Debugging

?

meemknight commented 4 months ago

yes

LuckyIntel commented 4 months ago

I mean compatibility is first. Like new debugging just wouldn't even work on Apple devices so it's best to teach it later.

Edit : OS X doesn't have GL_DEBUG_OUTPUT sadly.

meemknight commented 4 months ago

The chapter is still there and it even starts with the old debugging version. I don't think there is any reason not to move it earlier and mention that the modern version won't work for Apple, if it isn't mentioned already

meemknight commented 4 months ago

If it doesn't even work on apple they will just skip that part anyway

LuckyIntel commented 4 months ago

Yes, it is mentioned that it doesn't work for Apple OS X devices. Well yes they can skip that part and stick to the older versions, as that's what they are doing. I don't see any problem here.

meemknight commented 4 months ago

I hope the author will see this. I think that chapter was the most useful thing I learned about OpenGL. Using an API where any mistake leads to a black screen is difficult so having error reporting is a game changer