From f04ddf031de8849c070110d4b15b78c89e519e27 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 9 Jan 2021 19:44:46 +0100 Subject: [PATCH] extra surf prop for opengl --- src/gl/gl3device.cpp | 8 +++++--- src/gl/rwgl3.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gl/gl3device.cpp b/src/gl/gl3device.cpp index 4474d71..4ed7977 100644 --- a/src/gl/gl3device.cpp +++ b/src/gl/gl3device.cpp @@ -111,6 +111,7 @@ struct GLShaderState { RGBA matColor; SurfaceProperties surfProps; + float extraSurfProp; }; const char *shaderDecl120 = @@ -1103,7 +1104,7 @@ Shader *lastShaderUploaded; #define U(i) currentShader->uniformLocations[i] void -setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops) +setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp) { bool force = lastShaderUploaded != currentShader; if(force || !equal(shaderState.matColor, color)){ @@ -1116,12 +1117,13 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops) if(force || shaderState.surfProps.ambient != surfaceprops.ambient || shaderState.surfProps.specular != surfaceprops.specular || - shaderState.surfProps.diffuse != surfaceprops.diffuse){ + shaderState.surfProps.diffuse != surfaceprops.diffuse || + shaderState.extraSurfProp != extraSurfProp){ float surfProps[4]; surfProps[0] = surfaceprops.ambient; surfProps[1] = surfaceprops.specular; surfProps[2] = surfaceprops.diffuse; - surfProps[3] = 0.0f; + surfProps[3] = extraSurfProp; glUniform4fv(U(u_surfProps), 1, surfProps); shaderState.surfProps = surfaceprops; } diff --git a/src/gl/rwgl3.h b/src/gl/rwgl3.h index 633c792..b14b28c 100644 --- a/src/gl/rwgl3.h +++ b/src/gl/rwgl3.h @@ -180,7 +180,7 @@ int32 setLights(WorldLights *lightData); // per Mesh void setTexture(int32 n, Texture *tex); -void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops); +void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f); void setAlphaBlend(bool32 enable); bool32 getAlphaBlend(void);