added asset loading class, zoom factor, vbo switch, shader version

This commit is contained in:
2017-03-13 01:16:20 +00:00
parent a2a221b17a
commit ee6d352fc6
25 changed files with 345 additions and 108 deletions

View File

@@ -14,10 +14,10 @@ bool Shape::create_buffers(GLvoid* idx, GLvoid* vertices, int isize, int vsize)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if USE_VBO
glGenVertexArrays(2, arrays);
if (!(arrays[0] && arrays[1]))
return false;
for (int i = 0; i < 2; i++)
{
glBindVertexArray(arrays[i]);
@@ -28,21 +28,43 @@ bool Shape::create_buffers(GLvoid* idx, GLvoid* vertices, int isize, int vsize)
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
}
glBindVertexArray(0);
#endif
return true;
}
void Shape::draw_fill() const
{
#if USE_VBO
glBindVertexArray(arrays[0]);
glDrawElements(GL_TRIANGLES, count[0], GL_UNSIGNED_SHORT, ioff[0]);
glBindVertexArray(0);
#else
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
glDrawElements(GL_TRIANGLES, count[0], GL_UNSIGNED_SHORT, ioff[0]);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif // USE_VBO
}
void Shape::draw_stroke() const
{
#if USE_VBO
glBindVertexArray(arrays[1]);
glDrawElements(GL_LINES, count[1], GL_UNSIGNED_SHORT, ioff[1]);
glBindVertexArray(0);
#else
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_t), (GLvoid*)offsetof(vertex_t, uvs));
glDrawElements(GL_LINES, count[1], GL_UNSIGNED_SHORT, ioff[1]);
#endif // USE_VBO
}
bool RectShape::create(float w, float h)