GitXplorerGitXplorer
b

opengl_demos

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
f13dfbc75f682a782f98a691419ecbc5372635d8

add clang-format

bbartekpacia committed 22 days ago
Verified
5cf84d50d3476e88fbad0ff74f743a26981550ea

initial commit; display empty black window

bbartekpacia committed 23 days ago

README

The README file for this repository.

Resources

Followed guides for GLFW:

Resources

I'm following the OpenGL Course from freecodecamp.

In the middle I got a bit confused about all the buffers (VAOs, VBOs, etc.) so to better understand what buffers are in OpenGL, I watched From CPU to GPU: Understanding Data Transfer with Buffers in OpenGL.

Then I went on a bit of watching spree.

[!NOTE]

There's quite a good official wiki on OpenGL: https://www.khronos.org/opengl/wiki/Main_Page.

Buffers

First, I have to ask OpenGL for a buffer:

int size = 1;
int bufferName; // this variable could be called VBO (Vertex Buffer Object)
glGenBuffers(size, &bufferName);

Then bufferName may be e.g., 124 (yes, this number is a name).

We now have a buffer name but it's empty.

Then the buffer has to be binded ("made bound") to specific target using glBindBuffer. The target specifies how you intend to use the buffer (e.g., for vertex attributes, indices, etc.).

glBindBuffer(GL_ARRAY_BUFFER, bufferName);

This tells OpenGL that the bufferName should now be used as the current buffer for the GL_ARRAY_BUFFER target. The GL_ARRAY_BUFFER target is typically used for vertex attribute data.

Finally, I can put data into the buffer (this is the "from CPU to GPU" move of data) with glBufferData.

// A simple triangle
GLfloat vertices[] = {
    0.5f, 0.5f, 0,
    1.5f, 0.5f, 0,
    1.0f, 1.5f, 0,
    };
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

Buffer types

GL_ARRAY_BUFFER stores vertices.

GL_ELEMENT_ARRAY_BUFFER stores indices.