[client] egl: add and use default quad helper for models

This commit is contained in:
Geoffrey McRae
2018-12-12 20:08:52 +11:00
parent 608b67af77
commit b9f8f1a0ad
5 changed files with 28 additions and 56 deletions

View File

@@ -181,24 +181,7 @@ bool egl_cursor_init(EGL_Cursor ** cursor)
return false;
}
static const GLfloat square[] =
{
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f
};
static const GLfloat uvs[] =
{
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f
};
egl_model_set_verticies((*cursor)->model, square, sizeof(square) / sizeof(GLfloat));
egl_model_set_uvs ((*cursor)->model, uvs , sizeof(uvs ) / sizeof(GLfloat));
egl_model_set_default((*cursor)->model);
return true;
}

View File

@@ -138,25 +138,8 @@ bool egl_fps_init(EGL_FPS ** fps, const LG_Font * font, LG_FontObj fontObj)
return false;
}
static const GLfloat square[] =
{
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f
};
static const GLfloat uvs[] =
{
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f
};
egl_model_set_verticies((*fps)->model, square, sizeof(square) / sizeof(GLfloat));
egl_model_set_uvs ((*fps)->model, uvs , sizeof(uvs ) / sizeof(GLfloat));
egl_model_set_texture ((*fps)->model, (*fps)->texture);
egl_model_set_default((*fps)->model);
egl_model_set_texture((*fps)->model, (*fps)->texture);
return true;
}

View File

@@ -73,6 +73,28 @@ void egl_model_free(EGL_Model ** model)
*model = NULL;
}
void egl_model_set_default(EGL_Model * model)
{
static const GLfloat square[] =
{
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f
};
static const GLfloat uvs[] =
{
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f
};
egl_model_set_verticies(model, square, sizeof(square) / sizeof(GLfloat));
egl_model_set_uvs (model, uvs , sizeof(uvs ) / sizeof(GLfloat));
}
void egl_model_set_verticies(EGL_Model * model, const GLfloat * verticies, const size_t count)
{
if (model->hasVertexBuffer)

View File

@@ -30,6 +30,7 @@ typedef struct EGL_Model EGL_Model;
bool egl_model_init(EGL_Model ** model);
void egl_model_free(EGL_Model ** model);
void egl_model_set_default (EGL_Model * model);
void egl_model_set_verticies (EGL_Model * model, const GLfloat * verticies, const size_t count);
void egl_model_set_uvs (EGL_Model * model, const GLfloat * uvs , const size_t count);
void egl_model_set_shader (EGL_Model * model, EGL_Shader * shader);