Skip to content

Commit

Permalink
gpu.rst: gpu-driver-role and vao-vbo binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan2251 committed Aug 5, 2023
1 parent 0870b06 commit 5a45498
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Binary file modified Fig/gpu/gpu-driver-role.key
Binary file not shown.
Binary file modified Fig/gpu/gpu-driver-role.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion References/01-triangles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,31 @@ void
init( void )
{
glGenVertexArrays( NumVAOs, VAOs );
// Make the new VAO:VAOs[Triangles] active, creating it if necessary.
glBindVertexArray( VAOs[Triangles] );

// opengl->current_array_buffer = VAOs[Triangles]

GLfloat vertices[NumVertices][2] = {
{ -0.90f, -0.90f }, { 0.85f, -0.90f }, { -0.90f, 0.85f }, // Triangle 1
{ 0.90f, -0.85f }, { 0.90f, 0.90f }, { -0.85f, 0.90f } // Triangle 2
};

glCreateBuffers( NumBuffers, Buffers );

// Make the buffer the active array buffer.
glBindBuffer( GL_ARRAY_BUFFER, Buffers[ArrayBuffer] );
// Attach the active VBO:Buffers[ArrayBuffer] to VAOs[Triangles]
// as an array of vectors with 4 floats each.
// Kind of like:
// opengl->current_vertex_array->attributes[attr] = {
// type = GL_FLOAT,
// size = 4,
// data = opengl->current_array_buffer
// }
// Can be replaced with glVertexArrayVertexBuffer(VAOs[Triangles], Triangles,
// buffer[ArrayBuffer], ArrayBuffer, sizeof(vmath::vec2));, glVertexArrayAttribFormat(), ...
// in OpenGL 4.5.

glBufferStorage( GL_ARRAY_BUFFER, sizeof(vertices), vertices, 0);

ShaderInfo shaders[] =
Expand Down
Binary file added References/short-math-guide.pdf
Binary file not shown.

0 comments on commit 5a45498

Please sign in to comment.