OpenGL 3D Game Tutorial 3: Rendering with Index Buffers

preview_player
Показать описание
LWJGL tutorial series on how to create a 3D Java game with OpenGL!

This week we learn a more efficient way to render our quad using an index buffer.

Common Problems

- Make sure that you use the new vertex positions array - it is different from last episode!

-Creating the display must be the first thing you do in the main method. Don't try initializing the RawModel first.

If you get the " Cannot use offsets when Element Array Buffer Object is disabled" error, check the following:

-Check that you are calling the "bindIndicesVBO()" from the "loadToVao()" method.

-Don't unbind the index buffer anywhere! Each VAO has one special slot for an index buffer, and unbinding the index buffer will remove it from that slot.

Рекомендации по теме
Комментарии
Автор

*Common Problems:*

- Make sure that you use the new vertex positions array - it is different from last episode!

-In the loadToVao() method the last parameter of the RawModel constructor has now changed to *indices.length* instead of "positions.length/3". Make sure you've made this change!

If you get the " Cannot use offsets when Element Array Buffer Object is disabled" error, check the following:

-Creating the display must be the first thing you do in the main method. Don't try initializing the RawModel first.

-Check that you are calling the "bindIndicesVBO()" from the "loadToVao()" method.

-Don't unbind the index buffer anywhere! Each VAO has one special slot for an index buffer, and unbinding the index buffer will remove it from that slot.

ThinMatrix
Автор

You are much better than other YouTubers!
You EXPLAIN!

butterhead
Автор

The first 6.5 minutes of this video was one of the best explanations of such a complex concept that I've seen. Congratulations :)

MC-pgmw
Автор

This took me a while to figure out. Hopefully this helps a bit.
1) Every model is a VAO. (you can think of it abstractly this way)
2) The properties and information of said model are VBOS's.
3) The EBO (Element Array Buffer) does not need a VAO allocation as OpenGL automatically binds it to the currently bound VAO. By using DrawElements, OpenGL automatically knows to use the EBO.
4) You must render all VAO's with a shader of choice, meaning you can have multiple shaders for different VAO's, or VAO groups (Like moddels, terrain, skybox, ...)
5) Thin matrix is amazing, but he goes quite fast haha

djamparo
Автор

This series is amazing. I've been looking for a 3D game tutorial and I found NOTHING until I came across your channel. I want to thank you as you have really helped me. You are awesome! Keep up with the AMAZING work.

samuelhess
Автор

I haven't touched OpenGL in a while and was searching through tutorials to jog my memory. Yours are amazing. I love the way you structure your code and break everything down. There is nothing worse than 1 large chunk of code!Thanks for the time you have put into this.

Amanda-zxeh
Автор

I love this series. Thank you so much for sharing your knowledge with us and for free! It feels amazing to grasp everything you're saying and I'm understanding everything so easily which makes it even more fun.

I love programming but I never really got into 3D game programming before, so I really wanted to know how a game is created from start to finish. I can write all of these classes you've explained on my own now because you explained it to me in a such a great, concise way and I understand it all. And I even imported different versions of OpenGL so you don't have to keep typing "GL30, GL11", etc, every time you want to use a feature from a different version.

Keep up the great work. You're my go-to teacher for OpenGL.

Take care. :D

EnlightenedSprite
Автор

Top quality tutorial. The amount of views these get is bloody ridiculous, you deserve so much more recognition for what you do.

marshmalloney
Автор

I really like how you say that there is no particular reason by choosing certain things. Its that kind of extra information that helps understanding way better, thank you very much.

conrad
Автор

I didn't understand this a year ago when I watched this. Amazing how some experience makes things make WAY more sense.

JonBruce-BlueDev
Автор

I had no idea about this series. It seems you've gone quite deep into LWJGL with these tutorials! I wish I found this earlier, before having to go through tonnes of articles and other tutorials. Thanks mate.

jsd
Автор

I love your tutorials! They explain everything so clearly! I tried looking around on the internet for lwjgl tutorials, but most of them use the fixed pipeline, which can't even be used on mobile devices with opengl es. The tutorials that I did find that were good were also incomplete because the writer gave up or something. But I am glad there is someone out there who cares enough to make a complete, awesome tutorial with lwjgl.

erikthegodeatingpenguin
Автор

Straight to the point, informative and most importantly easy to understand on such a complex subject. I dig it!

fudgeracoon
Автор

You're very great at explaining in these tutorials. I've subscribed.

xEGEN
Автор

float[] vertices = {
-0.5f, 0.5f, 0,
-0.5f, -0.5f, 0,
0.5f, -0.5f, 0,
0.5f, 0.5f, 0f
};

int[] indices = {
0, 1, 3,
3, 1, 2
};


You're welcome.

lesliejtay
Автор

Completely new to openGL, but man u got some talent to explain this!
Thx for all your efforts in making these videos!

And gratz on the paint skillz :)

nilsboudenoodt
Автор

I am primarly a .net developer, (I develop LOB apps and Mobile apps for a living), but I got really interested in Graphics and Game Development recently. I picked OpenTK as my low level binding library to OpenGL from .net. I've been reading books and I've followed other tutorials on OpenGl. But they are not as well thought and developed as yours, So I started following your whole series porting everything to OpenTK with C#, and so far, not everything translates 1 to 1 with OpenTk and C# but thanks to the excellent way you explain and teach the concepts, I've been successful in replicating your results.
So in short, just wanted to say thanks for your effort and expect to see me around your Patreon group for sure.

wolv
Автор

Just a little correction - glClearColor should be called before glClear to set the colour BEFORE it's used to clear the color buffer bit.  (You can verify this by putting another glClearColor with a different colour before it and you'll find the one after isn't used.)

Currently the code in the tutorial would technically flash once, first in the default clear colour then switch on the next frame to the set glClearColor.

I enjoy your videos - they're very clear with the illustrations too.

comdudeskip
Автор

"In the case of the quad" Idk why for some strange reason, that sounds satisfying to hear...


Great tutorials btw

cubiccentral
Автор

This can't be better explained. Thank you very much!

julioverne