ref: e2b64df84a2abe8a838499918b5c5d44002883b7
parent: 0f5af36951ce1ca7a9acd107fe30864e3f7ed2a0
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Sep 15 12:18:48 EDT 2020
Oops, also offload colour-fill vertices as well
--- a/src/Backends/Rendering/OpenGL3.cpp
+++ b/src/Backends/Rendering/OpenGL3.cpp
@@ -85,6 +85,7 @@
GLuint id;
struct
{
+ GLint vertex_transform;
GLint colour;
} uniforms;
} program_colour_fill;
@@ -125,10 +126,11 @@
#ifdef USE_OPENGLES2
static const GLchar *vertex_shader_plain = " \
#version 100\n \
+uniform mat4 vertex_transform; \
attribute vec2 input_vertex_coordinates; \
void main() \
{ \
- gl_Position = vec4(input_vertex_coordinates.xy, 0.0, 1.0); \
+ gl_Position = vec4(input_vertex_coordinates.xy, 0.0, 1.0) * vertex_transform; \
} \
";
@@ -197,10 +199,11 @@
#else
static const GLchar *vertex_shader_plain = " \
#version 150 core\n \
+uniform mat4 vertex_transform; \
in vec2 input_vertex_coordinates; \
void main() \
{ \
- gl_Position = vec4(input_vertex_coordinates.xy, 0.0, 1.0); \
+ gl_Position = vec4(input_vertex_coordinates.xy, 0.0, 1.0) * vertex_transform; \
} \
";
@@ -514,6 +517,7 @@
program_texture_colour_key.uniforms.texture_coordinate_transform = glGetUniformLocation(program_texture_colour_key.id, "texture_coordinate_transform");
program_texture_colour_key.uniforms.vertex_transform = glGetUniformLocation(program_texture_colour_key.id, "vertex_transform");
+ program_colour_fill.uniforms.vertex_transform = glGetUniformLocation(program_colour_fill.id, "vertex_transform");
program_colour_fill.uniforms.colour = glGetUniformLocation(program_colour_fill.id, "colour");
program_glyph.uniforms.texture_coordinate_transform = glGetUniformLocation(program_glyph.id, "texture_coordinate_transform");
@@ -874,7 +878,15 @@
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, surface->texture_id, 0);
glViewport(0, 0, surface->width, surface->height);
+ const GLfloat vertex_transform[4 * 4] = {
+ 2.0f / surface->width, 0.0f, 0.0f, -1.0f,
+ 0.0f, 2.0f / surface->height, 0.0f, -1.0f,
+ 0.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ };
+
glUseProgram(program_colour_fill.id);
+ glUniformMatrix4fv(program_colour_fill.uniforms.vertex_transform, 1, GL_FALSE, vertex_transform);
glDisable(GL_BLEND);
@@ -889,10 +901,10 @@
if (vertex_buffer_slot != NULL)
{
- const GLfloat vertex_left = rect->left * 2.0f / surface->width - 1.0f;
- const GLfloat vertex_top = rect->top * 2.0f / surface->height - 1.0f;
- const GLfloat vertex_right = rect->right * 2.0f / surface->width - 1.0f;
- const GLfloat vertex_bottom = rect->bottom * 2.0f / surface->height - 1.0f;
+ const GLfloat vertex_left = rect->left;
+ const GLfloat vertex_top = rect->top;
+ const GLfloat vertex_right = rect->right;
+ const GLfloat vertex_bottom = rect->bottom;
vertex_buffer_slot->vertices[0][0].position.x = vertex_left;
vertex_buffer_slot->vertices[0][0].position.y = vertex_top;