-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fb2caf
commit a17cd52
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef GLISY_GEOMETRY_H | ||
#define GLISY_GEOMETRY_H | ||
|
||
#include <glisy/vao.h> | ||
#include <glisy/buffer.h> | ||
|
||
/** | ||
* Glisy Geometry struct type. | ||
*/ | ||
|
||
typedef struct glisy_geometry glisy_geometry; | ||
struct glisy_geometry { | ||
|
||
// vertext array object | ||
glisy_vao vao; | ||
|
||
// array of vao attributes | ||
glisy_vao_attribute *attributes[GLISY_MAX_VAO_ATTRIBS]; | ||
|
||
// length os vao attributes array | ||
GLuint attrlen; | ||
|
||
// index buffer | ||
glisy_buffer index; | ||
|
||
// does the geometry need an update | ||
GLboolean dirty; | ||
|
||
}; | ||
|
||
/** | ||
* Glisy Geometry initializer. | ||
* @param geometry - pointer to a Glisy Geometry struct | ||
*/ | ||
|
||
void | ||
glisy_geometry_init(glisy_geometry *geometry); | ||
|
||
/** | ||
* Glisy Geometry update. | ||
* @param geometry - pointer to a Glisy Geometry struct | ||
*/ | ||
|
||
void | ||
glisy_geometry_update(glisy_geometry *geometry); | ||
|
||
/** | ||
* Glisy Geometry attributes. | ||
* @param geometry - pointer to a Glisy Geometry struct | ||
*/ | ||
|
||
void | ||
glisy_geometry_attr(glisy_geometry *geometry, GLchar *name, glisy_vao_attribute *attr); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <strings.h> | ||
#include <glisy/geometry.h> | ||
|
||
// push a vao attribute onto the geometry attributes array | ||
static void | ||
push_attr(glisy_geometry *geometry, glisy_vao_attribute *attribute) { | ||
if (geometry == NULL) return; | ||
if (attribute == NULL) return; | ||
|
||
if (geometry->attrlen < GLISY_MAX_VAO_ATTRIBS) { | ||
geometry->attributes[geometry->attrlen++] = attribute; | ||
} | ||
} | ||
|
||
/** | ||
* Glisy Geometry initializer. | ||
*/ | ||
|
||
void | ||
glisy_geometry_init(glisy_geometry *geometry) { | ||
if (geometry == NULL) return; | ||
|
||
geometry->attrlen = 0; | ||
geometry->dirty = GL_FALSE; | ||
|
||
memset(&geometry->attributes, 0, sizeof(glisy_vao_attribute *) * GLISY_MAX_VAO_ATTRIBS); | ||
glisy_vao_init(&geometry->vao); | ||
} | ||
|
||
/** | ||
* Glisy Geometry update. | ||
*/ | ||
|
||
void | ||
glisy_geometry_update(glisy_geometry *geometry) { | ||
if (geometry == NULL) return; | ||
if (!geometry->dirty) return; | ||
|
||
glisy_vao_dispose(&geometry->vao); | ||
glisy_vao_init(&geometry->vao); | ||
//@TODO(jwerle): complete me | ||
} | ||
|
||
/** | ||
* Glisy Geometry attributes. | ||
*/ | ||
|
||
void | ||
glisy_geometry_attr(glisy_geometry *geometry, GLchar *name, glisy_vao_attribute *attr) { | ||
if (geometry == NULL) return; | ||
if (name == NULL) return; | ||
|
||
geometry->dirty = GL_TRUE; | ||
attr->name = name; | ||
push_attr(geometry, attr); | ||
} |