fix crosshair rendering in GL2 mode
authorsheepluva
Sun, 07 Jan 2018 19:01:06 +0100
changeset 12891 a089326f0e16
parent 12890 dab60d247b75
child 12894 8f99199b33ea
fix crosshair rendering in GL2 mode
hedgewars/uRender.pas
share/hedgewars/Data/Shaders/default.fs
--- a/hedgewars/uRender.pas	Sun Jan 07 18:19:00 2018 +0100
+++ b/hedgewars/uRender.pas	Sun Jan 07 19:01:06 2018 +0100
@@ -68,7 +68,7 @@
 procedure Tint                  (r, g, b, a: Byte); inline;
 procedure Tint                  (c: Longword); inline;
 procedure untint(); inline;
-procedure setTintAdd            (f: boolean); inline;
+procedure setTintAdd            (enable: boolean); inline;
 
 // call this to finish the rendering of current frame
 procedure FinishRender();
@@ -1969,12 +1969,19 @@
     LastTint:= cWhiteColor;
 end;
 
-procedure setTintAdd(f: boolean); inline;
+procedure setTintAdd(enable: boolean); inline;
 begin
-    if f then
+    {$IFDEF GL2}
+        if enable then
+            glUniform1i(glGetUniformLocation(shaderMain, pchar('tintAdd')), 1)
+        else
+            glUniform1i(glGetUniformLocation(shaderMain, pchar('tintAdd')), 0);
+    {$ELSE}
+    if enable then
         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
     else
         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+    {$ENDIF}
 end;
 
 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
--- a/share/hedgewars/Data/Shaders/default.fs	Sun Jan 07 18:19:00 2018 +0100
+++ b/share/hedgewars/Data/Shaders/default.fs	Sun Jan 07 19:01:06 2018 +0100
@@ -4,6 +4,7 @@
 
 uniform sampler2D tex0;
 uniform vec4 tint;
+uniform bool tintAdd;
 uniform bool enableTexture;
 
 varying vec2 tex;
@@ -12,7 +13,12 @@
 void main()
 {
     if(enableTexture){
-        gl_FragColor = texture2D(tex0, tex) * tint;
+        if (tintAdd){
+            tint.a = 0.0;
+            gl_FragColor = clamp(texture2D(tex0, tex) + tint, 0.0, 1.1);
+        }else{
+            gl_FragColor = texture2D(tex0, tex) * tint;
+        }
     }else{
         gl_FragColor = tint;
     }