fix: make the selection box thickness scale invariant
This commit is contained in:
@@ -5,6 +5,7 @@ in vec2 vPos;
|
|||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
uniform float uTime;
|
uniform float uTime;
|
||||||
|
uniform float uScale;
|
||||||
uniform vec4 uColor1;
|
uniform vec4 uColor1;
|
||||||
uniform vec4 uColor2;
|
uniform vec4 uColor2;
|
||||||
uniform vec2 uMin;
|
uniform vec2 uMin;
|
||||||
@@ -12,7 +13,7 @@ uniform vec2 uMax;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float borderWidth = 0.008;
|
float borderWidth = 0.008 / uScale;
|
||||||
|
|
||||||
|
|
||||||
float distX = min(vPos.x - uMin.x, uMax.x - vPos.x);
|
float distX = min(vPos.x - uMin.x, uMax.x - vPos.x);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ static GLuint shader_standard_uProjMatrixLoc;
|
|||||||
|
|
||||||
static GLuint shader_selection_uProjMatrixLoc;
|
static GLuint shader_selection_uProjMatrixLoc;
|
||||||
static GLuint shader_selection_uTimeLoc;
|
static GLuint shader_selection_uTimeLoc;
|
||||||
|
static GLuint shader_selection_uScaleLoc;
|
||||||
static GLuint shader_selection_uC1Loc;
|
static GLuint shader_selection_uC1Loc;
|
||||||
static GLuint shader_selection_uC2Loc;
|
static GLuint shader_selection_uC2Loc;
|
||||||
static GLuint shader_selection_uMinLoc;
|
static GLuint shader_selection_uMinLoc;
|
||||||
@@ -103,6 +104,8 @@ static void init_shader(void) {
|
|||||||
glGetUniformLocation(selection_shader_program, "uProjection");
|
glGetUniformLocation(selection_shader_program, "uProjection");
|
||||||
shader_selection_uTimeLoc =
|
shader_selection_uTimeLoc =
|
||||||
glGetUniformLocation(selection_shader_program, "uTime");
|
glGetUniformLocation(selection_shader_program, "uTime");
|
||||||
|
shader_selection_uScaleLoc =
|
||||||
|
glGetUniformLocation(selection_shader_program, "uScale");
|
||||||
shader_selection_uC1Loc =
|
shader_selection_uC1Loc =
|
||||||
glGetUniformLocation(selection_shader_program, "uColor1");
|
glGetUniformLocation(selection_shader_program, "uColor1");
|
||||||
shader_selection_uC2Loc =
|
shader_selection_uC2Loc =
|
||||||
@@ -205,6 +208,7 @@ static gboolean render(GtkGLArea* a, GdkGLContext* ctx,
|
|||||||
glUniformMatrix4fv(shader_selection_uProjMatrixLoc, 1, GL_FALSE,
|
glUniformMatrix4fv(shader_selection_uProjMatrixLoc, 1, GL_FALSE,
|
||||||
renderInfo->canvasTransform);
|
renderInfo->canvasTransform);
|
||||||
glUniform1f(shader_selection_uTimeLoc, time);
|
glUniform1f(shader_selection_uTimeLoc, time);
|
||||||
|
glUniform1f(shader_selection_uScaleLoc, renderInfo->zoom);
|
||||||
glUniform2f(shader_selection_uMinLoc, bbox.min.x, bbox.min.y);
|
glUniform2f(shader_selection_uMinLoc, bbox.min.x, bbox.min.y);
|
||||||
glUniform2f(shader_selection_uMaxLoc, bbox.max.x, bbox.max.y);
|
glUniform2f(shader_selection_uMaxLoc, bbox.max.x, bbox.max.y);
|
||||||
glUniform4f(shader_selection_uC1Loc, 0, 0, 0, 0);
|
glUniform4f(shader_selection_uC1Loc, 0, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user