REFACTOR : demoModel -> GLModel

This commit is contained in:
Aaron Culliney 2015-04-09 22:49:53 -07:00
parent 9bbb180feb
commit 5712850e84
5 changed files with 28 additions and 26 deletions

View File

@ -32,7 +32,7 @@ static struct timespec cputiming_begin = { 0 };
static bool cputiming_enabled = true;
static bool texture_dirty = true;
static demoModel *cpuMessageObjModel = NULL;
static GLModel *cpuMessageObjModel = NULL;
static GLuint cpuMessageObjVAOName = UNINITIALIZED_GL;
static GLenum cpuMessageObjElementType = UNINITIALIZED_GL;
static GLuint cpuMessageObjNumElements = UNINITIALIZED_GL;
@ -63,7 +63,7 @@ static void _create_message_model(void) {
0, 1, 2, 2, 1, 3
};
demoModel *messageObj = calloc(1, sizeof(demoModel));
GLModel *messageObj = calloc(1, sizeof(GLModel));
messageObj->numVertices = 4;
messageObj->numElements = 6;
@ -93,7 +93,7 @@ static void _create_message_model(void) {
cpuMessageObjModel = messageObj;
}
static void _create_message_VAO_VBOs(const demoModel *messageModel, GLuint *messageVAOName, GLuint *posBufferName, GLuint *texcoordBufferName, GLuint *elementBufferName) {
static void _create_message_VAO_VBOs(const GLModel *messageModel, GLuint *messageVAOName, GLuint *posBufferName, GLuint *texcoordBufferName, GLuint *elementBufferName) {
// Create a vertex array object (VAO) to cache model parameters
#if USE_VAO

View File

@ -78,7 +78,7 @@ static int buttSideYMax = 0;
// touch axis variables
static demoModel *touchAxisObjModel = NULL;
static GLModel *touchAxisObjModel = NULL;
static GLuint touchAxisObjVAOName = UNINITIALIZED_GL;
static GLuint touchAxisObjTextureName = UNINITIALIZED_GL;
static GLuint touchAxisObjPosBufferName = UNINITIALIZED_GL;
@ -97,7 +97,7 @@ static struct timespec axisTimingBegin = { 0 };
// button object variables
static demoModel *buttonObjModel = NULL;
static GLModel *buttonObjModel = NULL;
static GLuint buttonObjVAOName = UNINITIALIZED_GL;
static GLuint buttonObjTextureName = UNINITIALIZED_GL;
static GLuint buttonObjPosBufferName = UNINITIALIZED_GL;
@ -132,7 +132,7 @@ static uint8_t downChar = MOUSETEXT_DOWN;
// ----------------------------------------------------------------------------
static demoModel *_create_model(GLfloat skew_x, GLfloat skew_y, GLfloat obj_w, GLfloat obj_h) {
static GLModel *_create_model(GLfloat skew_x, GLfloat skew_y, GLfloat obj_w, GLfloat obj_h) {
/* 2...3
* .
@ -157,7 +157,7 @@ static demoModel *_create_model(GLfloat skew_x, GLfloat skew_y, GLfloat obj_w, G
0, 1, 2, 2, 1, 3
};
demoModel *obj = calloc(1, sizeof(demoModel));
GLModel *obj = calloc(1, sizeof(GLModel));
obj->numVertices = 4;
obj->numElements = 6;
@ -186,7 +186,7 @@ static demoModel *_create_model(GLfloat skew_x, GLfloat skew_y, GLfloat obj_w, G
return obj;
}
static void _create_VAO_VBOs(const demoModel *model, GLuint *vaoName, GLuint *posBufferName, GLuint *texcoordBufferName, GLuint *elementBufferName) {
static void _create_VAO_VBOs(const GLModel *model, GLuint *vaoName, GLuint *posBufferName, GLuint *texcoordBufferName, GLuint *elementBufferName) {
// Create a vertex array object (VAO) to cache model parameters
#if USE_VAO
@ -366,7 +366,7 @@ static inline void _screen_to_model(float x, float y, float *screenX, float *scr
*screenY = ((viewportHeight-y)/(viewportHeight>>1))-1.f;
}
static void _model_to_screen(float screenCoords[4], demoModel *model) {
static void _model_to_screen(float screenCoords[4], GLModel *model) {
float x0 = 1.0;
float y0 = 1.0;
@ -489,7 +489,7 @@ static void gltouchjoy_destroy(void) {
buttonObjModel = NULL;
}
static void _render_object(demoModel *model, GLuint vaoName, GLuint posBufferName, GLuint texcoordBufferName, GLuint elementBufferName) {
static void _render_object(GLModel *model, GLuint vaoName, GLuint posBufferName, GLuint texcoordBufferName, GLuint elementBufferName) {
// Bind our vertex array object
#if USE_VAO
@ -640,7 +640,7 @@ static inline bool _is_point_on_button_side(float x, float y) {
return (x >= buttSideX && x <= buttSideXMax && y >= buttSideY && y <= buttSideYMax);
}
static inline void _reset_model_position(demoModel *model, float touchX, float touchY, float objHalfW, float objHalfH) {
static inline void _reset_model_position(GLModel *model, float touchX, float touchY, float objHalfW, float objHalfH) {
float centerX = 0.f;
float centerY = 0.f;

View File

@ -45,7 +45,7 @@ static GLuint crtVAOName = UNINITIALIZED_GL;
static GLuint posBufferName = UNINITIALIZED_GL;
static GLuint texcoordBufferName = UNINITIALIZED_GL;
static GLuint elementBufferName = UNINITIALIZED_GL;
static demoModel *crtModel = NULL;
static GLModel *crtModel = NULL;
static video_backend_s glvideo_backend = { 0 };
@ -86,7 +86,7 @@ static void _create_CRT_model(void) {
#endif
};
demoModel *crt = calloc(1, sizeof(demoModel));
GLModel *crt = calloc(1, sizeof(GLModel));
crt->numVertices = 4;
crt->numElements = 6;

View File

@ -16,13 +16,13 @@
#include <stdlib.h>
#include <string.h>
typedef struct modelHeaderRec {
typedef struct modelHeader {
char fileIdentifier[30];
unsigned int majorVersion;
unsigned int minorVersion;
} modelHeader;
typedef struct modelTOCRec {
typedef struct modelTOC {
unsigned int attribHeaderSize;
unsigned int byteElementOffset;
unsigned int bytePositionOffset;
@ -30,7 +30,7 @@ typedef struct modelTOCRec {
unsigned int byteNormalOffset;
} modelTOC;
typedef struct modelAttribRec {
typedef struct modelAttrib {
unsigned int byteSize;
GLenum datatype;
GLenum primType; //If index data
@ -38,11 +38,11 @@ typedef struct modelAttribRec {
unsigned int numElements;
} modelAttrib;
demoModel *mdlLoadModel(const char *filepathname) {
GLModel *mdlLoadModel(const char *filepathname) {
if (!filepathname) {
return NULL;
}
demoModel *model = (demoModel *)calloc(sizeof(demoModel), 1);
GLModel *model = (GLModel *)calloc(sizeof(GLModel), 1);
if (!model) {
return NULL;
}
@ -247,7 +247,7 @@ demoModel *mdlLoadModel(const char *filepathname) {
return model;
}
demoModel *mdlLoadQuadModel() {
GLModel *mdlLoadQuadModel() {
GLfloat posArray[] = {
-200.0f, 0.0f, -200.0f,
200.0f, 0.0f, -200.0f,
@ -274,7 +274,7 @@ demoModel *mdlLoadQuadModel() {
0, 3, 2
};
demoModel *model = (demoModel *)calloc(sizeof(demoModel), 1);
GLModel *model = (GLModel *)calloc(sizeof(GLModel), 1);
if (!model) {
return NULL;
@ -311,7 +311,7 @@ demoModel *mdlLoadQuadModel() {
return model;
}
void mdlDestroyModel(demoModel *model) {
void mdlDestroyModel(GLModel *model) {
if (!model) {
return;
}

View File

@ -16,7 +16,9 @@
#include "glUtil.h"
typedef struct demoModelRec {
#define UNINITIALIZED_GL 31337
typedef struct GLModel {
GLuint numVertices;
GLvoid *positions;
@ -41,12 +43,12 @@ typedef struct demoModelRec {
GLenum primType;
} demoModel;
} GLModel;
demoModel *mdlLoadModel(const char *filepathname);
GLModel *mdlLoadModel(const char *filepathname);
demoModel *mdlLoadQuadModel();
GLModel *mdlLoadQuadModel();
void mdlDestroyModel(demoModel *model);
void mdlDestroyModel(GLModel *model);
#endif //__MODEL_UTIL_H__