naev 0.10.4
Data Structures | Macros | Enumerations | Functions
opengl_vbo.c File Reference

Handles OpenGL vbos. More...

#include "log.h"
#include "opengl.h"

Go to the source code of this file.

Data Structures

struct  gl_vbo
 Contains the VBO. More...
 

Macros

#define BUFFER_OFFSET(i)   ((char *)(sizeof(char) * (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. More...
 
int gl_initVBO (void)
 Initializes the OpenGL VBO subsystem. More...
 
void gl_exitVBO (void)
 Exits the OpenGL VBO subsystem. More...
 
void gl_vboData (gl_vbo *vbo, GLsizei size, const void *data)
 Reloads new data or grows the size of the vbo. More...
 
void gl_vboSubData (gl_vbo *vbo, GLint offset, GLsizei size, const void *data)
 Loads some data into the VBO. More...
 
gl_vbo * gl_vboCreateStream (GLsizei size, const void *data)
 Creates a stream vbo. More...
 
gl_vbo * gl_vboCreateDynamic (GLsizei size, const void *data)
 Creates a dynamic vbo. More...
 
gl_vbo * gl_vboCreateStatic (GLsizei size, const void *data)
 Creates a stream vbo. More...
 
void * gl_vboMap (gl_vbo *vbo)
 Maps a buffer. More...
 
void gl_vboUnmap (gl_vbo *vbo)
 Unmaps a buffer. More...
 
void gl_vboActivateAttribOffset (gl_vbo *vbo, GLuint index, GLuint offset, GLint size, GLenum type, GLsizei stride)
 Activates a VBO's offset. More...
 
void gl_vboDestroy (gl_vbo *vbo)
 Destroys a VBO. More...
 

Detailed Description

Handles OpenGL vbos.

Definition in file opengl_vbo.c.

Macro Definition Documentation

◆ BUFFER_OFFSET

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

Taken from OpengL spec.

Definition at line 16 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 21 of file opengl_vbo.c.

Function Documentation

◆ gl_exitVBO()

void gl_exitVBO ( void  )

Exits the OpenGL VBO subsystem.

Definition at line 56 of file opengl_vbo.c.

◆ gl_initVBO()

int gl_initVBO ( void  )

Initializes the OpenGL VBO subsystem.

Returns
0 on success.

Definition at line 48 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 228 of file opengl_vbo.c.

◆ gl_vboCreate()

static 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 datat to use.
usageUsage to use.
Returns
ID of the vbo.

Definition at line 69 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 164 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 181 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 147 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 100 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 248 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 198 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 132 of file opengl_vbo.c.

◆ gl_vboUnmap()

void gl_vboUnmap ( gl_vbo *  vbo)

Unmaps a buffer.

Parameters
vboVBO to unmap.

Definition at line 209 of file opengl_vbo.c.