mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-02-04 19:24:22 +00:00
gl2shim: support more GLSL versions
This commit is contained in:
parent
40dd6e0234
commit
8c88e82709
@ -1,10 +1,20 @@
|
|||||||
R"(
|
R"(
|
||||||
|
|
||||||
|
|
||||||
|
#if VER <= 300
|
||||||
|
#define layout(x)
|
||||||
|
#endif
|
||||||
|
#if VER < 300
|
||||||
|
#define out attribute
|
||||||
|
#define in varying
|
||||||
|
#define texture texture2D
|
||||||
|
#endif
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#if ATTR_TEXCOORD0
|
#if ATTR_TEXCOORD0
|
||||||
uniform sampler2D uTex0;
|
layout(location = 5) uniform sampler2D uTex0;
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_TEXCOORD1
|
#if ATTR_TEXCOORD1
|
||||||
uniform sampler2D uTex1;
|
layout(location = 6) uniform sampler2D uTex1;
|
||||||
#endif
|
#endif
|
||||||
#if FEAT_ALPHA_TEST
|
#if FEAT_ALPHA_TEST
|
||||||
uniform float uAlphaTest;
|
uniform float uAlphaTest;
|
||||||
@ -12,7 +22,7 @@ uniform float uAlphaTest;
|
|||||||
#if FEAT_FOG
|
#if FEAT_FOG
|
||||||
uniform vec4 uFog;
|
uniform vec4 uFog;
|
||||||
#endif
|
#endif
|
||||||
uniform vec4 uColor;
|
layout(location = 2) uniform vec4 uColor;
|
||||||
#if ATTR_COLOR
|
#if ATTR_COLOR
|
||||||
in vec4 vColor;
|
in vec4 vColor;
|
||||||
#endif
|
#endif
|
||||||
@ -25,7 +35,11 @@ in vec2 vTexCoord1;
|
|||||||
#if ATTR_NORMAL
|
#if ATTR_NORMAL
|
||||||
in vec2 vNormal;
|
in vec2 vNormal;
|
||||||
#endif
|
#endif
|
||||||
|
#if VER >= 300
|
||||||
out vec4 oFragColor;
|
out vec4 oFragColor;
|
||||||
|
#else
|
||||||
|
#define oFragColor gl_FragColor
|
||||||
|
#endif
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#if ATTR_COLOR
|
#if ATTR_COLOR
|
||||||
|
@ -18,8 +18,9 @@ GNU General Public License for more details.
|
|||||||
this will only provide performance gains if vitaGL is built with DRAW_SPEEDHACK=1
|
this will only provide performance gains if vitaGL is built with DRAW_SPEEDHACK=1
|
||||||
since that makes it assume that all vertex data pointers are GPU-mapped
|
since that makes it assume that all vertex data pointers are GPU-mapped
|
||||||
*/
|
*/
|
||||||
#ifndef XASH_GL_STATIC
|
|
||||||
#include "gl_local.h"
|
#include "gl_local.h"
|
||||||
|
#ifndef XASH_GL_STATIC
|
||||||
#include "gl2_shim.h"
|
#include "gl2_shim.h"
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
//#include "xash3d_mathlib.h"
|
//#include "xash3d_mathlib.h"
|
||||||
@ -142,24 +143,44 @@ static char *GL_PrintInfoLog( GLhandleARB object )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GLuint GL2_GenerateShader( const gl2wrap_prog_t *prog, GLenum type )
|
static GLuint GL2_GenerateShader( gl2wrap_prog_t *prog, GLenum type )
|
||||||
{
|
{
|
||||||
char *shader, shader_buf[MAX_SHADERLEN + 1];
|
char *shader, shader_buf[MAX_SHADERLEN + 1];
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
int i;
|
int i;
|
||||||
GLint status, len;
|
GLint status, len;
|
||||||
GLuint id;
|
GLuint id, loc;
|
||||||
|
int version = 320;
|
||||||
|
|
||||||
shader = shader_buf;
|
shader = shader_buf;
|
||||||
//shader[0] = '\n';
|
//shader[0] = '\n';
|
||||||
shader[0] = 0;
|
shader[0] = 0;
|
||||||
Q_strncat(shader, "#version 300 es\n", MAX_SHADERLEN);
|
|
||||||
|
Q_snprintf(shader, MAX_SHADERLEN, "#version %d%s\n", version, version >= 300 && version < 330 ? " es":"");
|
||||||
|
|
||||||
|
Q_snprintf(tmp, sizeof( tmp ), "#define VER %d\n", version);
|
||||||
|
Q_strncat( shader, tmp, MAX_SHADERLEN );
|
||||||
|
|
||||||
for ( i = 0; i < GL2_FLAG_MAX; ++i )
|
for ( i = 0; i < GL2_FLAG_MAX; ++i )
|
||||||
{
|
{
|
||||||
Q_snprintf( tmp, sizeof( tmp ), "#define %s %d\n", gl2wrap_flag_name[i], prog->flags & ( 1 << i ) );
|
Q_snprintf( tmp, sizeof( tmp ), "#define %s %d\n", gl2wrap_flag_name[i], prog->flags & ( 1 << i ) );
|
||||||
Q_strncat( shader, tmp, MAX_SHADERLEN );
|
Q_strncat( shader, tmp, MAX_SHADERLEN );
|
||||||
}
|
}
|
||||||
|
loc = 0;
|
||||||
|
for ( i = 0; i < GL2_ATTR_MAX; ++i )
|
||||||
|
{
|
||||||
|
if ( prog->flags & ( 1 << i ) )
|
||||||
|
{
|
||||||
|
Q_snprintf( tmp, sizeof( tmp ), "#define LOC_%s %d\n", gl2wrap_flag_name[i], loc++ );
|
||||||
|
Q_strncat( shader, tmp, MAX_SHADERLEN );
|
||||||
|
prog->attridx[i] = loc;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prog->attridx[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( type == GL_FRAGMENT_SHADER_ARB )
|
if ( type == GL_FRAGMENT_SHADER_ARB )
|
||||||
Q_strncat( shader, gl2wrap_frag_src, MAX_SHADERLEN );
|
Q_strncat( shader, gl2wrap_frag_src, MAX_SHADERLEN );
|
||||||
|
@ -1,23 +1,27 @@
|
|||||||
R"(
|
R"(
|
||||||
|
|
||||||
|
#if VER <= 300
|
||||||
#define layout(x)
|
#define layout(x)
|
||||||
//#define in attribute
|
|
||||||
//#define out varying
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 inPosition;
|
|
||||||
#if ATTR_COLOR
|
|
||||||
layout(location = 1) in vec4 inColor;
|
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_NORMAL
|
#if VER < 300
|
||||||
layout(location = 2) in vec3 inNormal;
|
#define in attribute
|
||||||
|
#define out varying
|
||||||
|
#endif
|
||||||
|
|
||||||
|
layout(location = LOC_ATTR_POSITION) in vec3 inPosition;
|
||||||
|
#if ATTR_COLOR
|
||||||
|
layout(location = LOC_ATTR_COLOR) in vec4 inColor;
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_TEXCOORD0
|
#if ATTR_TEXCOORD0
|
||||||
layout(location = 3) in vec2 inTexCoord0;
|
layout(location = LOC_ATTR_TEXCOORD0) in vec2 inTexCoord0;
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_TEXCOORD1
|
#if ATTR_TEXCOORD1
|
||||||
layout(location = 4) in vec2 inTexCoord1;
|
layout(location = LOC_ATTR_TEXCOORD1) in vec2 inTexCoord1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ATTR_NORMAL
|
||||||
|
in vec3 inNormal;
|
||||||
|
#endif
|
||||||
#if ATTR_COLOR
|
#if ATTR_COLOR
|
||||||
out vec4 vColor;
|
out vec4 vColor;
|
||||||
#endif
|
#endif
|
||||||
@ -25,7 +29,7 @@ out vec4 vColor;
|
|||||||
out vec2 vTexCoord0;
|
out vec2 vTexCoord0;
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_TEXCOORD1
|
#if ATTR_TEXCOORD1
|
||||||
out vec2 vTexCoord0;
|
out vec2 vTexCoord1;
|
||||||
#endif
|
#endif
|
||||||
#if ATTR_NORMAL
|
#if ATTR_NORMAL
|
||||||
out vec3 vNormal;
|
out vec3 vNormal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user