GitXplorerGitXplorer
b

opengl_demos

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Verified
fb07a3c08904623441e674dac730f938a88977fc

add more findings

bbartekpacia committed 15 days ago
Verified
f79c8ac7bb237a51c693b24248dc2fbd148e8bff

glfw

bbartekpacia committed 16 days ago
Verified
138936de515ef150fea22ee675aee6fd576ac7c7

learning

bbartekpacia committed 17 days ago
Verified
44ca8afb5a1b1c798d40970577f3ca5bcac4af92

[03] indices (many triangles)

bbartekpacia committed 22 days ago
Verified
d3ef2d27edff932bbf8ecd2cbb641ea904a6c0f7

[02] display orange triangle

bbartekpacia committed 22 days ago
Verified
7713f52d51b15967cc69b5a8a9cf830fceb52cec

add glad

bbartekpacia committed 22 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.