Refactor : naming RB -> Azimuth

This commit is contained in:
Aaron Culliney 2016-01-30 10:35:55 -08:00
parent ac151ae9e9
commit c29daf006e

View File

@ -72,26 +72,26 @@ static struct {
// TODO FIXME : support 2-players! // TODO FIXME : support 2-players!
} touchport = { 0 }; } touchport = { 0 };
#define RB_CLASS(CLS, ...) \ #define AZIMUTH_CLASS(CLS, ...) \
MODEL_CLASS(CLS, \ MODEL_CLASS(CLS, \
GLuint vertShader; \ GLuint vertShader; \
GLuint fragShader; \ GLuint fragShader; \
GLuint program; \ GLuint program; \
GLint uniformMVPIdx;); GLint uniformMVPIdx;);
RB_CLASS(GLModelRBJoystick); AZIMUTH_CLASS(GLModelJoystickAzimuth);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// joystick azimuth model // joystick azimuth model
static void _rb_destroy_model(GLModel *parent) { static void _azimuth_destroy_model(GLModel *parent) {
GLModelRBJoystick *azimuthJoystick = (GLModelRBJoystick *)parent->custom; GLModelJoystickAzimuth *azimuthJoystick = (GLModelJoystickAzimuth *)parent->custom;
if (!azimuthJoystick) { if (!azimuthJoystick) {
return; return;
} }
// detach and delete the RB shaders // detach and delete the Azimuth shaders
// 2015/11/06 NOTE : Tegra 2 for mobile has a bug whereby you cannot detach/delete shaders immediately after // 2015/11/06 NOTE : Tegra 2 for mobile has a bug whereby you cannot detach/delete shaders immediately after
// creating the program. So we delete them during the shutdown sequence instead. // creating the program. So we delete them during the shutdown sequence instead.
// https://code.google.com/p/android/issues/detail?id=61832 // https://code.google.com/p/android/issues/detail?id=61832
@ -112,10 +112,10 @@ static void _rb_destroy_model(GLModel *parent) {
FREE(parent->custom); FREE(parent->custom);
} }
static void *_rb_create_model(GLModel *parent) { static void *_azimuth_create_model(GLModel *parent) {
parent->custom = CALLOC(sizeof(GLModelRBJoystick), 1); parent->custom = CALLOC(sizeof(GLModelJoystickAzimuth), 1);
GLModelRBJoystick *azimuthJoystick = (GLModelRBJoystick *)parent->custom; GLModelJoystickAzimuth *azimuthJoystick = (GLModelJoystickAzimuth *)parent->custom;
if (!azimuthJoystick) { if (!azimuthJoystick) {
return NULL; return NULL;
@ -161,14 +161,14 @@ static void *_rb_create_model(GLModel *parent) {
azimuthJoystick->uniformMVPIdx = glGetUniformLocation(azimuthJoystick->program, "modelViewProjectionMatrix"); azimuthJoystick->uniformMVPIdx = glGetUniformLocation(azimuthJoystick->program, "modelViewProjectionMatrix");
if (azimuthJoystick->uniformMVPIdx < 0) { if (azimuthJoystick->uniformMVPIdx < 0) {
LOG("OOPS, no modelViewProjectionMatrix in RB shader : %d", azimuthJoystick->uniformMVPIdx); LOG("OOPS, no modelViewProjectionMatrix in Azimuth shader : %d", azimuthJoystick->uniformMVPIdx);
break; break;
} }
err = false; err = false;
} while (0); } while (0);
GL_ERRLOG("build RB joystick"); GL_ERRLOG("build Aziumth joystick");
if (vtxSource) { if (vtxSource) {
glshader_destroySource(vtxSource); glshader_destroySource(vtxSource);
@ -178,19 +178,19 @@ static void *_rb_create_model(GLModel *parent) {
} }
if (err) { if (err) {
_rb_destroy_model(parent); _azimuth_destroy_model(parent);
azimuthJoystick = NULL; azimuthJoystick = NULL;
} }
return azimuthJoystick; return azimuthJoystick;
} }
static void _rb_render(void) { static void _azimuth_render(void) {
if (!axes.azimuthModel) { if (!axes.azimuthModel) {
return; return;
} }
GLModelRBJoystick *azimuthJoystick = (GLModelRBJoystick *)axes.azimuthModel->custom; GLModelJoystickAzimuth *azimuthJoystick = (GLModelJoystickAzimuth *)axes.azimuthModel->custom;
// use azimuth (SolidColor) program // use azimuth (SolidColor) program
glUseProgram(azimuthJoystick->program); glUseProgram(azimuthJoystick->program);
@ -228,7 +228,7 @@ static void _rb_render(void) {
// back to main framebuffer/quad program // back to main framebuffer/quad program
glUseProgram(mainShaderProgram); glUseProgram(mainShaderProgram);
GL_ERRLOG("RB render"); GL_ERRLOG("Azimuth render");
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -397,8 +397,8 @@ static void gltouchjoy_setup(void) {
.tex_h = 0, .tex_h = 0,
.texcoordUsageHint = UNINITIALIZED_GL, // no texture data .texcoordUsageHint = UNINITIALIZED_GL, // no texture data
}, (GLCustom){ }, (GLCustom){
.create = &_rb_create_model, .create = &_azimuth_create_model,
.destroy = &_rb_destroy_model, .destroy = &_azimuth_destroy_model,
}); });
if (!axes.azimuthModel) { if (!axes.azimuthModel) {
LOG("gltouchjoy azimuth model initialization problem"); LOG("gltouchjoy azimuth model initialization problem");
@ -512,7 +512,7 @@ static void gltouchjoy_render(void) {
} }
if (joyglobals.showAzimuth && axes.azimuthModelDirty) { if (joyglobals.showAzimuth && axes.azimuthModelDirty) {
_rb_render(); _azimuth_render();
} }
// draw button(s) // draw button(s)
@ -611,11 +611,11 @@ static inline void _reset_model_position(GLModel *model, float touchX, float tou
quad[12+1] = centerY+objHalfH; quad[12+1] = centerY+objHalfH;
if (azimuthModel) { if (azimuthModel) {
GLfloat *quadRB = (GLfloat *)(azimuthModel->positions); GLfloat *quadAzimuth = (GLfloat *)(azimuthModel->positions);
quadRB[0 +0] = centerX; quadAzimuth[0 +0] = centerX;
quadRB[0 +1] = centerY; quadAzimuth[0 +1] = centerY;
quadRB[4 +0] = centerX; quadAzimuth[4 +0] = centerX;
quadRB[4 +1] = centerY; quadAzimuth[4 +1] = centerY;
} }
} }
@ -647,9 +647,9 @@ static inline void _axis_move(int x, int y) {
float centerX = 0.f; float centerX = 0.f;
float centerY = 0.f; float centerY = 0.f;
glhud_screenToModel(x, y, touchport.width, touchport.height, &centerX, &centerY); glhud_screenToModel(x, y, touchport.width, touchport.height, &centerX, &centerY);
GLfloat *quadRB = (GLfloat *)axes.azimuthModel->positions; GLfloat *quadAzimuth = (GLfloat *)axes.azimuthModel->positions;
quadRB[4 +0] = centerX; quadAzimuth[4 +0] = centerX;
quadRB[4 +1] = centerY; quadAzimuth[4 +1] = centerY;
axes.azimuthModelDirty = true; axes.azimuthModelDirty = true;
}; };