OpenGL (C#) 2D Game Tutorial #2 - VAOs, VBOs & Shaders

preview_player
Показать описание
This is the second episode in my OpenGL 2D Game tutorial series. In this video we'll be talking about the basics of how to render something - what VAOs, VBOs and shaders are.

Vertex data:

float[] vertices =
{
-0.5f, 0.5f, 1f, 0f, 0f, // top left
0.5f, 0.5f, 0f, 1f, 0f,// top right
-0.5f, -0.5f, 0f, 0f, 1f, // bottom left

0.5f, 0.5f, 0f, 1f, 0f,// top right
0.5f, -0.5f, 0f, 1f, 1f, // bottom right
-0.5f, -0.5f, 0f, 0f, 1f, // bottom left
};

Shaders:

string vertexShader = @"#version 330 core
layout (location = 0) in vec2 aPosition;
layout (location = 1) in vec3 aColor;
out vec4 vertexColor;

void main()
{
}";

string fragmentShader = @"#version 330 core
out vec4 FragColor;
in vec4 vertexColor;

void main()
{
FragColor = vertexColor;
}";

0:00 Introduction
0:15 What are VAOs & VBOs?
2:15 Initializing VAO & VBO
8:40 What are Shaders?
10:57 Initializing Shaders
12:20 Summary and what's next?

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

wow every damn explanation ive looked only you and the cherno explained it the best. you drawing it out made it even a thousand times easier. thank u

dannggg
Автор

It's great to learn the modern OpenGl library. Thank you!

shedanalkur
Автор

Please continue the series, these are so good.

roostermaind
Автор

I stuck when C# doesnt allow me to use Pointer but your video saves me. Thank you so much!

manhhuybui
Автор

Half way through the second video i realize, the reason most of the opengl functions have slightly different names for me is that this is a tutorial for C# and i'm in C++...

theelf
Автор

Thanks so much for these, you are incredible!

Hailfire
Автор

Thanks for the tutorial! It would be really helpful if you could upload the code somewhere though, because for some reason the colors on the rectangle aren't rendering for me. I've gone through the entire video twice, and gone through every piece of visible code three times, and my code appears to match it exactly, yet I'm getting no color.

The rectangle itself is getting drawn however, which I checked by changing the glClearColor to red. Any help would be appreciated.

Articorse
Автор

Actually done a similar project back then. Now, 'cause uni, doing another and using your tips to improve this project. Thank you, buddie. It's always good find a cppbro ;)

gabrielporto
Автор

for whatever reason, i have a white rectangle, and its been there since before implementing the shader

topbrasshimself
Автор

[05:10] - Doesn't "vertices[0]" result the same desired value as going the 'pointer-to-address' route?
Instead of doing v + index, just vertices[i (+ index)]? Why do you prefer the pointer way?
Is this just a cool way of shortening the code? Or are you just too used to C++?

lukenukem
Автор

Can u explain a few things. I am still very confused
1. What is an attribute list?
2. What does it mean to bind something? For example, u created a vao and vbo and then immediately unbinded it. And then in the game loop, u bind it every time before u draw
3. Does a vao hold the layout of how a vbo is structured? If so, then does it basically hold different settings per say of vbo?
4. When we put data into a vbo, is it only possible to have 1 vbo? I was reading the documentation and it says that the vbo can only have 1 same type like gl_array_buffer. Does this mean we can only create 1 vertex buffer in gpu?

anonymoussloth
Автор

Nice tutorial thanks, you know how i can make hair shaders with plane in Three js, my hair got broken with a lot transparency :C

crowbr
Автор

I figured out why its not working for the other half of people seeing black screens. The Viewport is based on your screen size, not the window size, so if you have a large screen, the 800 X 600 window doesn't see the block, it just sees the black background to the left of it. Change your window size to be your native screen resolution and it'll work.

harveysaayman
Автор

Hello thanks for the tutorial but i wrote the entire code but there is à Problem with thé shader = glCreateProgram(); variable it says shader is not existing in the actual context

ChezRG-YT