Performance optimization
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m49s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m49s
This commit is contained in:
@@ -44,6 +44,7 @@ namespace JGL::ShapeCache {
|
||||
inline VRamList* cube_normal_data = nullptr;
|
||||
// Facing straight out.
|
||||
inline VRamList* j2d_default_normal_data = nullptr;
|
||||
inline VRamList* square_origin_topleft_vertex_data = nullptr;
|
||||
void Init();
|
||||
}
|
||||
|
||||
|
@@ -43,10 +43,13 @@ void JGL::ShapeCache::Init() {
|
||||
if (!cube_index_data)
|
||||
cube_index_data = new VRamList(indices.data(), indices.size());
|
||||
|
||||
if (!cube_normal_data) {
|
||||
if (!cube_normal_data)
|
||||
cube_normal_data = new VRamList(vertex_normals.data(), vertex_normals.size());
|
||||
}
|
||||
|
||||
if (!square_origin_topleft_vertex_data) {
|
||||
std::array<Vector2, 4> square_vertices = { Vector2(0, 0), {1, 0}, {1, -1}, {0, -1} };
|
||||
square_origin_topleft_vertex_data = new VRamList(square_vertices.data(), square_vertices.size());
|
||||
}
|
||||
if (!j2d_default_normal_data) {
|
||||
std::array<GLfloat, 3> normal {0, 0, 1};
|
||||
j2d_default_normal_data = new VRamList(normal.data(), normal.size());
|
||||
|
@@ -291,10 +291,16 @@ void JGL::J2D::FillRect(const Color4& color, const Vector2& pos, const Vector2&
|
||||
if (!inJ2D)
|
||||
Logger::Error("Drawing J2D element before J2D begin.");
|
||||
|
||||
Vector2 vertices[] = {{pos.x, pos.y}, {pos.x, pos.y + size.y}, {pos.x + size.x, pos.y + size.y}, {pos.x + size.x, pos.y}};
|
||||
glColor4ubv(color.ptr());
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), vertices);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, ShapeCache::square_origin_topleft_vertex_data->GetHandle());
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vector2), nullptr);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(pos.x, pos.y + size.y, 0);
|
||||
glScalef(size.x, size.y, 1);
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glPopMatrix();
|
||||
glColor4fv(OpenGLState::baseColor);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user