FANDOM


What is a Vertex Buffer? Edit

A vertex buffer is an OpenGL feature that provides method's for uploading vertex data (position, normal vector, colour, etc) to the video device for non-immediate-mode rendering. They offer substantial performance gains over immediate-mode-rendering primarily because the data resides in the video device memory rather than the system memory, and so it can be rendered directly by the video device. These are equivalent to the vertex buffers in Direct3D.

What is a Shader?Edit

A Shader is a user-defined program designed to run on some stage of a graphics processor. It's purpose is to execute one of the programmable stages of the rendering pipeline.

Creating a Vertex BufferEdit

/* Define a Vertex Buffer */
glGenBuffers(x, y);

x = Specifies the number of buffers to generate.

y = Specifies an array in which the generated buffer is stored (pointer).

Example of creating a buffer :

unsigned int buffer;
/* Define Vertex Buffer */
glGenBuffers(1, &buffer);

/* Select/bind the buffer */
glBindBuffer(GL_ARRAY_BUFFER, buffer);

/* Specify the data */
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW);

Then to draw the buffer :

/* Render here */
glClear(GL_COLOR_BUFFER_BIT);

/* Initialize draw call for our buffer*/
glDrawArrays(GL_TRIANGLES, 0, 3);


ReferencesEdit

Vertex Buffers and Drawing a Triangle in OpenGL - TheChernoProject

Vertex buffer - Wikipedia

What are shaders in OpenGL and what do we need them for? - stackoverflow

Shader - OpenGL wiki

OpenGL API Documentation

Community content is available under CC-BY-SA unless otherwise noted.