naev 0.12.6
opengl_vbo.c File Reference

Handles OpenGL vbos. More...

#include "opengl.h"
Include dependency graph for opengl_vbo.c:

Go to the source code of this file.

Data Structures

struct  gl_vbo
 Contains the VBO. More...

Macros

#define BUFFER_OFFSET(i)

Enumerations

enum  gl_vboType { NGL_VBO_NULL , NGL_VBO_STREAM , NGL_VBO_DYNAMIC , NGL_VBO_STATIC }
 VBO types. More...

Functions

static gl_vbo * gl_vboCreate (GLenum target, GLsizei size, const void *data, GLenum usage)
 Creates a VBO.
int gl_initVBO (void)
 Initializes the OpenGL VBO subsystem.
void gl_exitVBO (void)
 Exits the OpenGL VBO subsystem.
void gl_vboData (gl_vbo *vbo, GLsizei size, const void *data)
 Reloads new data or grows the size of the vbo.
void gl_vboSubData (gl_vbo *vbo, GLint offset, GLsizei size, const void *data)
 Loads some data into the VBO.
gl_vbo * gl_vboCreateStream (GLsizei size, const void *data)
 Creates a stream vbo.
gl_vbo * gl_vboCreateDynamic (GLsizei size, const void *data)
 Creates a dynamic vbo.
gl_vbo * gl_vboCreateStatic (GLsizei size, const void *data)
 Creates a stream vbo.
void * gl_vboMap (gl_vbo *vbo)
 Maps a buffer.
void gl_vboUnmap (gl_vbo *vbo)
 Unmaps a buffer.
void gl_vboActivateAttribOffset (gl_vbo *vbo, GLuint index, GLuint offset, GLint size, GLenum type, GLsizei stride)
 Activates a VBO's offset.
void gl_vboDestroy (gl_vbo *vbo)
 Destroys a VBO.

Detailed Description

Handles OpenGL vbos.

Definition in file opengl_vbo.c.

Macro Definition Documentation

◆ BUFFER_OFFSET

#define BUFFER_OFFSET ( i)
Value:
( (char *)( sizeof( char ) * ( i ) ) )

Taken from OpengL spec.

Definition at line 11 of file opengl_vbo.c.

Enumeration Type Documentation

◆ gl_vboType

enum gl_vboType

VBO types.

Enumerator
NGL_VBO_NULL 

No VBO type.

NGL_VBO_STREAM 

VBO streaming type.

NGL_VBO_DYNAMIC 

VBO dynamic type.

NGL_VBO_STATIC 

VBO static type.

Definition at line 17 of file opengl_vbo.c.

Function Documentation

◆ gl_exitVBO()

void gl_exitVBO ( void )

Exits the OpenGL VBO subsystem.

Definition at line 53 of file opengl_vbo.c.

◆ gl_initVBO()

int gl_initVBO ( void )

Initializes the OpenGL VBO subsystem.

Returns
0 on success.

Definition at line 45 of file opengl_vbo.c.

◆ gl_vboActivateAttribOffset()

void gl_vboActivateAttribOffset ( gl_vbo * vbo,
GLuint index,
GLuint offset,
GLint size,
GLenum type,
GLsizei stride )

Activates a VBO's offset.

Parameters
vboVBO to activate.
indexIndex of generic vertex attribute.
offsetOffset (in bytes).
sizeSpecifies components per point.
typeType of data (usually GL_FLOAT).
strideOffset between consecutive points.

Definition at line 224 of file opengl_vbo.c.

◆ gl_vboCreate()

gl_vbo * gl_vboCreate ( GLenum target,
GLsizei size,
const void * data,
GLenum usage )
static

Creates a VBO.

Prototypes.

Parameters
targetTarget to create to (usually GL_ARRAY_BUFFER).
sizeSize of the buffer (in bytes).
dataThe actual data to use.
usageUsage to use.
Returns
ID of the vbo.

Definition at line 66 of file opengl_vbo.c.

◆ gl_vboCreateDynamic()

gl_vbo * gl_vboCreateDynamic ( GLsizei size,
const void * data )

Creates a dynamic vbo.

Parameters
sizeSize of the dynamic vbo (multiply by sizeof(type)).
dataData for the VBO.

Definition at line 160 of file opengl_vbo.c.

◆ gl_vboCreateStatic()

gl_vbo * gl_vboCreateStatic ( GLsizei size,
const void * data )

Creates a stream vbo.

Parameters
sizeSize of the stream vbo (multiply by sizeof(type)).
dataData for the VBO.

Definition at line 177 of file opengl_vbo.c.

◆ gl_vboCreateStream()

gl_vbo * gl_vboCreateStream ( GLsizei size,
const void * data )

Creates a stream vbo.

Parameters
sizeSize of the stream vbo (multiply by sizeof(type)).
dataData for the VBO.

Definition at line 143 of file opengl_vbo.c.

◆ gl_vboData()

void gl_vboData ( gl_vbo * vbo,
GLsizei size,
const void * data )

Reloads new data or grows the size of the vbo.

Parameters
vboVBO to set new data of.
sizeSize of new data.
dataNew data.

Definition at line 96 of file opengl_vbo.c.

◆ gl_vboDestroy()

void gl_vboDestroy ( gl_vbo * vbo)

Destroys a VBO.

Parameters
vboVBO to destroy. (If NULL, function does nothing.)

Definition at line 244 of file opengl_vbo.c.

◆ gl_vboMap()

void * gl_vboMap ( gl_vbo * vbo)

Maps a buffer.

Parameters
vboVBO to map.
Returns
The data contained in the vbo.

Definition at line 194 of file opengl_vbo.c.

◆ gl_vboSubData()

void gl_vboSubData ( gl_vbo * vbo,
GLint offset,
GLsizei size,
const void * data )

Loads some data into the VBO.

Parameters
vboVBO to load data into.
offsetOffset location of the data (in bytes).
sizeSize of the data (in bytes).
dataPointer to the data.

Definition at line 128 of file opengl_vbo.c.

◆ gl_vboUnmap()

void gl_vboUnmap ( gl_vbo * vbo)

Unmaps a buffer.

Parameters
vboVBO to unmap.

Definition at line 205 of file opengl_vbo.c.