Skip to content

Commit

Permalink
#5909: Use in position attribute instead of gl_Vertex
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 13, 2022
1 parent b196eb7 commit d14ece8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 34 deletions.
4 changes: 2 additions & 2 deletions install/gl/zfill_alpha_fp.glsl
Expand Up @@ -4,7 +4,7 @@ uniform sampler2D u_diffuse;
uniform float u_alphaTest;
uniform mat4 u_objectTransform;

varying vec2 var_tex_diffuse;
varying vec2 var_TexDiffuse;

void main()
{
Expand All @@ -15,7 +15,7 @@ void main()
}
else
{
vec4 tex = texture2D(u_diffuse, var_tex_diffuse);
vec4 tex = texture2D(u_diffuse, var_TexDiffuse);

if (tex.a <= u_alphaTest)
{
Expand Down
43 changes: 12 additions & 31 deletions install/gl/zfill_vp.glsl
@@ -1,40 +1,21 @@
/// ============================================================================
/*
Copyright (C) 2004 Robert Beckebans <trebor_7@users.sourceforge.net>
Please see the file "CONTRIBUTORS" for a list of contributors
#version 120

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
in vec4 attr_Position; // bound to attribute 0 in source, in object space
in vec4 attr_TexCoord; // bound to attribute 8 in source

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
uniform mat4 u_objectTransform; // object transform (object2world)

See the GNU Lesser General Public License for more details.
varying vec2 var_TexDiffuse;

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/// ============================================================================

attribute vec4 attr_TexCoord0;

uniform mat4 u_objectTransform;

varying vec2 var_tex_diffuse;

void main()
void main()
{
// Apply the supplied object transform to the incoming vertex
// transform vertex position into homogenous clip-space
gl_Position = gl_ModelViewProjectionMatrix * u_objectTransform * gl_Vertex;
// transform vertex position into homogenous clip-space
gl_Position = gl_ModelViewProjectionMatrix * u_objectTransform * attr_Position;

// transform texcoords
var_tex_diffuse = (gl_TextureMatrix[0] * attr_TexCoord0).st;
// transform texcoords
var_TexDiffuse = (gl_TextureMatrix[0] * attr_TexCoord).st;

// assign color
gl_FrontColor = gl_Color;
// assign color
gl_FrontColor = gl_Color;
}
Expand Up @@ -24,7 +24,8 @@ void GLSLDepthFillAlphaProgram::create()
DEPTHFILL_ALPHA_VP_FILENAME, DEPTHFILL_ALPHA_FP_FILENAME
);

glBindAttribLocation(_programObj, GLProgramAttribute::TexCoord, "attr_TexCoord0");
glBindAttribLocation(_programObj, GLProgramAttribute::Position, "attr_Position");
glBindAttribLocation(_programObj, GLProgramAttribute::TexCoord, "attr_TexCoord");

glLinkProgram(_programObj);

Expand Down

0 comments on commit d14ece8

Please sign in to comment.