Advertisement

OpenGL tutorials

Started by September 18, 2016 11:06 AM
3 comments, last by ingframin 8 years, 2 months ago

I would like to have any recommended books, websites, etc that teaches the MODERN OpenGL. Unlike most websites now, where they teach the old OpenGL...

Please feed me with your recommendations.

Unlike most websites now, where they teach the old OpenGL...


Yep i immediately go back when i see old OpenGL code.
Here http://learnopengl.com/ This site helped me a lot and it only teaches modern OpenGL.
Advertisement

I'm not sure where you can find good websites on that for free. I know there are some out there that attempt it. I ended up not really using any of the websites out there like Rastertek. I already kind of knew what I was doing from previous experience with XNA and DX11. And then I went through Game Institute's OGL videos and figured out the rest. I'm still learning OGL 4.5, but I've got the basics down.

My website, VirtuallyProgramming.com, has a working OGL 4.5 Visual Studio 2015 project compiled for Windows using GLSL. It uses a few libraries like GLM, GLFW, and FreeImage (I think it was). I hope to eventually get some OGL tutorials out there, but I've had too much going on that was higher priority (I'm taking art classes right now and learning 3D modeling). As time has permitted, I have been putting that OGL 4.5 engine together. It's a translation of my DX11 game engine which is a bit more complete. The DX engine supports loading models from Blender using a custom Python scripted exporter that exports into my custom model format file. Then the C++ code reads the file and builds the model. My next project related to this is to get that code converted over to my OGL engine so that I can start bringing in models from Blender instead of hand coding them. Most of the code is copy and paste, but there are some differences in the way OGL draws things and such since the Model class knows how to draw itself.

And I might mention that it's all Object Oriented.

I usually try to include everything in the project files including shader code, that custom Blender Python script, and any art assets and such. So, it tends to be pretty complete although with the OGL stuff, you have to get those libraries setup and working on your own. But you probably already have GLM and GLFW setup anyway unless you're using something else like GLUT. I had tried to go with a different image library for loading image files for textures and it would not work with my Object Oriented code. I think it was FreeImage that I got to work or maybe FreeImagePlus. I would have to go back and look.

But I posted that source code for the OGL project so that people could see a working example to read through and see how it works.

Here is a video of what the OGL project code currently does so that you can look and see if that's what you are interested in or not waste your time if that's not what you're interested in. No point in spending a lot of time trying to get it to compile if it's not what you're looking for.

Normally I try to comment my code to ridiculous levels so that it's easy for someone reading through the code to learn what I'm doing. I haven't had the time to do that on my OGL project as much as I would like. I'm not sure if I finished doing it on my DX 11 project, but I think I got a lot further with getting it properly commented.

Over the past several years I keep jumping from system to system. I would have probably stuck with XNA if Microsoft hadn't abandoned it. I still kind of love it although, for ease of use, OGL actually has a lot in common with XNA once you get the libraries going. I decided to switch to DX11 and had to spend awhile learning that. I had planned on eventually going on to learn OGL and thought learning DX11 would make it easier to learn OGL and it did. I find DX 11 to be a lot more difficult than OGL, although that's largely because I don't use libraries with DX. I only used C++, HLSL, and the Windows SDK (and DX of course). Otherwise, I built it myself. That mostly involved the custom model importer rather than using Assimp. But it also included communication with the Windows operating system which is basically what GLFW handles in OGL.

After DX11, I decided I wanted to do OGL 4.5 instead. So, once again I had to relearn everything from scratch. Now, I'm wanting to change to SPIRV and Vulkan and so I've been studying that. And I'm enrolled in a 3D modeling class which is consuming most of my time. So, I have very little time to dedicate to learning these things now, let alone making tutorials on it. But I've had to over and over again relearn everything I already knew. It's kind of holding me back from really moving forward, but it does give me a wide range of abilities. Maybe if I can use OGL 4+ for teaching and tutorials and learn Vulkan I can just stick with that. I've thought about learning DX12, but I may just read books on it and call it a day on that without actually coding it, mostly just to have a better understanding of Vulkan and to be able to understand any DX12 tutorial code and such.

Anyway, you might want to download my OGL project and see if you can get it to compile and then see what you can learn from it. It's designed to be a lot like XNA. Basically, it's what XNA would give you out of the box except that XNA is managed code with C# and this is unmanaged C++. And XNA has a built in model class (which I have in my DX engine but have not yet got into my OGL engine) and a built in Sprite class.

But the overall design is like XNA where you are intended to make your game by modifying the Game class and the other classes are classes that you should never have to touch unless you want to change them. It's basically boiler plate code that you copy to start every project.

And the Game class has a built in game loop where it calls each function/method in the Game class for you each frame. The Initialize method is where you put code that runs at startup once. The Load class is where you put code for loading art assets. The Draw function is where all the code that draws stuff on the screen each frame goes. The Update function is where all the other code goes that runs every frame that does not draw stuff (the logic of your game). Of course you create your own classes and call them rather than having and Update or Draw function that's ten bajillion lines of code. The model class, for example, knows how to draw itself. So, the draw function merely tells the model to draw itself with a single line of code. In a more advanced program it might call a model manager that tells all the models to draw themselves.

One problem you will get into is understanding GLSL. That's pretty important and totally different than C++ or OGL. That's where the real drawing work gets done. For that, I might recommend my HLSL video series on my YouTube channel. The HLSL series is obviously not GLSL. And it's done with XNA and HLSL. Doing HLSL for DX11 is not that much different and so the videos basically go over the differences. Unfortunately, I do not have a GLSL video series. My plan, if I ever get the time, is to make a GLSL video as another chapter in the HLSL video series, because otherwise I would end up remaking the same videos. Most of shader programming is just math. So, it doesn't matter what language you program the math in; the math will still be the same math. And that's a lot of what the HLSL video series goes through. I get pretty deep into the math and so you may want to watch my Vector and Matrix videos first (in that order) if you don't know Linear Algebra. They are about 3 hours just for the two math videos, but I'm trying to cram a semester of Linear Algebra for game programmers into 3 hours of video. There's a whole lot to learn here.

And the GLSL shader I use in my OGL project I posted is basically the exact same shader as the HLSL shader at the end of the HLSL series. I tried to use the same variable names and what not to make it easier to compare the two. The biggest difference between the two off the top of my head is that Uniforms in GLSL are basically Constant Buffers in HLSL. And GLSL thankfully doesn't mess around with registers the way HLSL does although I think that makes the way you call GLSL a little different when you pass variables in.

But if this is your first time trying to learn OGL for 3D, I might recommend Game Institute, if you have a little money to spend. For $19 a month (or less if you commit to more time), you can get access to a wide range of 3D game programming tutorials. I learned from their OGL tutorial, which is modern OGL. They do it with linear programming rather than Object Oriented Programming, much like most tutorials you will likely find. But that may be easier to understand starting off, especially if you're not used to OOP. But they basically take you through how to make most everything that's in my OGL game engine project including camera and models. Not to mention, for that $19 a month you get access to other useful videos such as how to use Blender (Max and Maya as well), how to program DX11, and just a whole slew of other stuff. Just the OGL stuff is worth $19 a month and you get access to a lot more than that. There's also videos on Unity and Unreal Engine as well I believe. Their OGL lessons are pretty good although there were a couple of points where I thought he failed to explain things. I was able to work through it because I already knew DX and XNA. But for someone just learning, those could be sticking points. But just get online and ask people for help if you get stuck. There shouldn't be too many sticking points in their OGL lessons. 2 or 3 in something like 10 hours of video.

My stuff is free and I'm pretty proud of it. But you get what you pay for. Because mine is free, it's only about half finished and I don't have time to make half of the video tutorials I've wanted to. So, something like Game Institute is well worth the money.

Also, eventually you'll have to read Red Book, since it's pretty much the owner's manual for OGL. (Or is that orange book. I'm color blind. Oh no, wait. This would probably be Orange Book. You're probably going to have to read that eventually too although there's a lot more books out there on GLSL than on OGL. I'd still recommend my HLSL series and then compare it to the GLSL shader in my project since most of these shader books will take you around the world in order to get to the other side of the street; the shader I teach in my video series cuts straight to the point and teaches you the one shader that you will need 98% of the time and can easily be extended to cover you more like 99% of the time. Actually, I haven't included normal mapping in the series yet, but you can easily extend that shader to support normal mapping. It would have been the next video I would have done in the series except I changed to OGL and had to start over.)

Most everything you find will take you around the world to get you across the street. One problem I seem to see a lot in the OGL world, is that everyone gets focused on OGL rather than on making games. My engine, my videos, the Game Institute OGL course, and most tutorials you find, are only teaching you how to get "stuff" on the screen and have some control over it. That's where you start making games. One of the reason I loved XNA, is it cut out all that nonsense and gave you this straight out of the box, so that you could immediately focus on game programming from day one. That's why I learned so much from it. I learned so much from it that it turned out to be a great stepping stone towards learning DX11, which I thought was far more difficult than OGL. Hopefully, I will one day get videos on my YouTube channel that cut to the chase and get you into video game programming as quickly as possible without worrying about every little setting possible in OGL. Hopefully in the next year I'll at least get my OGL engine code basically finished and then do a video on my YouTube channel stepping through every single line of code and explaining it.

I just looked over that

Unlike most websites now, where they teach the old OpenGL...


Yep i immediately go back when i see old OpenGL code.
Here http://learnopengl.com/ This site helped me a lot and it only teaches modern OpenGL.

I just looked over that website. Very nice. I would recommend that over my own stuff because he (or she) really kind of holds your hand through it. I might recommend my Vector and Matrix videos still, if you have any trouble understanding those subjects and how they apply to 3D programming. After you finish the stuff on LearnOpenGL, then you might want to go through my HLSL series for a little more depth on the subject. And last you might want to download my OGL engine project to compare the shader there with my HLSL tutorial. Plus, if you want to do Object Oriented Programming, you can see from my project what that might look like since I think they are doing inline coding instead of OOP.

But over all, at a glance, that looks like a really good website to get you started on OGL. I may even put a link to that on my website in the OGL section. Thanks Aliasc!

I would like to add http://open.gl and on YouTube the tutorials of thebennybox.
However after following a couple of tutorials I realized that OpenGL gets much more clear once you know a bit of computer graphics.
If you are not on a budget I strongly recommend you to buy "Fundamentals of computer graphics" from Marschner and Shirley or a similar book.

This topic is closed to new replies.

Advertisement