1
0
Fork 0
forked from fte/fteqw

Trying to fix stuff.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3796 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-05-26 16:46:43 +00:00
parent 39cec13461
commit 646fd03f44
12 changed files with 119 additions and 1041 deletions

View file

@ -251,6 +251,10 @@ void R2D_Init(void)
Cvar_ForceCallback(&crosshair); Cvar_ForceCallback(&crosshair);
Cvar_ForceCallback(&crosshaircolor); Cvar_ForceCallback(&crosshaircolor);
#ifdef PLUGINS
Plug_DrawReloadImages();
#endif
} }
mpic_t *R2D_SafeCachePic (char *path) mpic_t *R2D_SafeCachePic (char *path)

View file

@ -70,7 +70,7 @@ static void SSDL_SetUnderWater(soundcardinfo_t *sc, qboolean uw)
} }
static void SSDL_Submit(soundcardinfo_t *sc) static void SSDL_Submit(soundcardinfo_t *sc, int start, int end)
{ {
//SDL will call SSDL_Paint to paint when it's time, and the sound buffer is always there... //SDL will call SSDL_Paint to paint when it's time, and the sound buffer is always there...
} }

View file

@ -2274,7 +2274,8 @@ void COM_InitFilesystem (void)
//use the game based on an exe name over the filesystem one (could easily have multiple fs path matches). //use the game based on an exe name over the filesystem one (could easily have multiple fs path matches).
for (i = 0; gamemode_info[i].argname; i++) for (i = 0; gamemode_info[i].argname; i++)
{ {
if (strstr(com_argv[0], gamemode_info[i].exename)) ev = strstr(com_argv[0], gamemode_info[i].exename);
if (ev && (!strchr(ev, '\\') && !strchr(ev, '/')))
gamenum = i; gamenum = i;
} }
//use the game based on an parameter over all else. //use the game based on an parameter over all else.

View file

@ -2,6 +2,11 @@
#ifdef D3DQUAKE #ifdef D3DQUAKE
#include "shader.h" #include "shader.h"
#include "shader.h"
#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500)
#define HMONITOR_DECLARED
DECLARE_HANDLE(HMONITOR);
#endif
#include <d3d9.h> #include <d3d9.h>
extern LPDIRECT3DDEVICE9 pD3DDev9; extern LPDIRECT3DDEVICE9 pD3DDev9;

View file

@ -1087,9 +1087,6 @@ static void (D3D9_Draw_Init) (void)
} }
static void (D3D9_Draw_ReInit) (void) static void (D3D9_Draw_ReInit) (void)
{ {
#ifdef PLUGINS
Plug_DrawReloadImages();
#endif
} }
static void (D3D9_R_Init) (void) static void (D3D9_R_Init) (void)

File diff suppressed because it is too large Load diff

View file

@ -435,10 +435,14 @@ void GL_TexEnv(GLenum mode)
static void BE_SetPassBlendMode(int tmu, int pbm) static void BE_SetPassBlendMode(int tmu, int pbm)
{ {
#ifndef FORCESTATE
if (shaderstate.blendmode[tmu] != pbm) if (shaderstate.blendmode[tmu] != pbm)
#endif
{ {
shaderstate.blendmode[tmu] = pbm; shaderstate.blendmode[tmu] = pbm;
#ifndef FORCESTATE
if (shaderstate.currenttmu != tmu) if (shaderstate.currenttmu != tmu)
#endif
GL_SelectTexture(tmu); GL_SelectTexture(tmu);
switch (pbm) switch (pbm)
@ -487,7 +491,9 @@ static void BE_SetPassBlendMode(int tmu, int pbm)
/*OpenGL requires glDepthMask(GL_TRUE) or glClear(GL_DEPTH_BUFFER_BIT) will fail*/ /*OpenGL requires glDepthMask(GL_TRUE) or glClear(GL_DEPTH_BUFFER_BIT) will fail*/
void GL_ForceDepthWritable(void) void GL_ForceDepthWritable(void)
{ {
#ifndef FORCESTATE
if (!(shaderstate.shaderbits & SBITS_MISC_DEPTHWRITE)) if (!(shaderstate.shaderbits & SBITS_MISC_DEPTHWRITE))
#endif
{ {
shaderstate.shaderbits |= SBITS_MISC_DEPTHWRITE; shaderstate.shaderbits |= SBITS_MISC_DEPTHWRITE;
qglDepthMask(GL_TRUE); qglDepthMask(GL_TRUE);
@ -632,16 +638,27 @@ void GL_LazyBind(int tmu, int target, texid_t texnum, qboolean arrays)
static void BE_EnableShaderAttributes(unsigned int newm) static void BE_EnableShaderAttributes(unsigned int newm)
{ {
unsigned int i; unsigned int i;
i = 0;
if (newm & (1u<<i))
qglEnableVertexAttribArray(i);
else
qglDisableVertexAttribArray(i);
if (newm == shaderstate.sha_attr) if (newm == shaderstate.sha_attr)
return; return;
for (i = 0; i < 8; i++) for (i = 1; i < 8; i++)
{
#ifndef FORCESTATE
if ((newm^shaderstate.sha_attr) & (1u<<i)) if ((newm^shaderstate.sha_attr) & (1u<<i))
#endif
{ {
if (newm & (1u<<i)) if (newm & (1u<<i))
qglEnableVertexAttribArray(i); qglEnableVertexAttribArray(i);
else else
qglDisableVertexAttribArray(i); qglDisableVertexAttribArray(i);
} }
}
shaderstate.sha_attr = newm; shaderstate.sha_attr = newm;
} }
void GL_SelectProgram(int program) void GL_SelectProgram(int program)
@ -662,6 +679,9 @@ static void GL_DeSelectProgram(void)
/*if disabling a program, we need to kill off custom attributes*/ /*if disabling a program, we need to kill off custom attributes*/
BE_EnableShaderAttributes(0); BE_EnableShaderAttributes(0);
/*ATI tends to use a true 100% alias here, so make sure this state is reenabled*/
qglEnableClientState(GL_VERTEX_ARRAY);
} }
} }
@ -2545,6 +2565,7 @@ static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pas
{ {
qglDisableClientState(GL_COLOR_ARRAY); qglDisableClientState(GL_COLOR_ARRAY);
qglDisableClientState(GL_VERTEX_ARRAY); qglDisableClientState(GL_VERTEX_ARRAY);
BE_EnableShaderAttributes(attr);
for (i = 0; i < pass->numMergedPasses; i++) for (i = 0; i < pass->numMergedPasses; i++)
{ {
Shader_BindTextureForPass(i, pass+i, false); Shader_BindTextureForPass(i, pass+i, false);
@ -2558,6 +2579,8 @@ static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pas
} }
else else
{ {
BE_EnableShaderAttributes(attr);
qglEnableClientState(GL_VERTEX_ARRAY);
GenerateColourMods(pass); GenerateColourMods(pass);
for (i = 0; i < pass->numMergedPasses; i++) for (i = 0; i < pass->numMergedPasses; i++)
{ {
@ -2571,11 +2594,7 @@ static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pas
shaderstate.lastpasstmus = pass->numMergedPasses; shaderstate.lastpasstmus = pass->numMergedPasses;
GL_ApplyVertexPointer(); GL_ApplyVertexPointer();
} }
BE_EnableShaderAttributes(attr);
BE_SubmitMeshChain(); BE_SubmitMeshChain();
qglEnableClientState(GL_VERTEX_ARRAY);
} }
qboolean GLBE_LightCullModel(vec3_t org, model_t *model) qboolean GLBE_LightCullModel(vec3_t org, model_t *model)
@ -3329,18 +3348,18 @@ void GLBE_DrawWorld (qbyte *vis)
BE_SelectMode(BEM_DEPTHDARK); BE_SelectMode(BEM_DEPTHDARK);
else else
BE_SelectMode(BEM_STANDARD); BE_SelectMode(BEM_STANDARD);
checkglerror();
RSpeedRemark(); RSpeedRemark();
GLBE_SubmitMeshes(true, batches); GLBE_SubmitMeshes(true, batches);
RSpeedEnd(RSPEED_WORLD); RSpeedEnd(RSPEED_WORLD);
checkglerror();
#ifdef RTLIGHTS #ifdef RTLIGHTS
RSpeedRemark(); RSpeedRemark();
BE_SelectEntity(&r_worldentity); BE_SelectEntity(&r_worldentity);
Sh_DrawLights(vis); Sh_DrawLights(vis);
RSpeedEnd(RSPEED_STENCILSHADOWS); RSpeedEnd(RSPEED_STENCILSHADOWS);
#endif #endif
checkglerror();
if (r_refdef.gfog_alpha) if (r_refdef.gfog_alpha)
{ {
BE_SelectMode(BEM_FOG); BE_SelectMode(BEM_FOG);

View file

@ -383,10 +383,6 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
TRACE(("dbg: GLDraw_ReInit: PPL_LoadSpecularFragmentProgram\n")); TRACE(("dbg: GLDraw_ReInit: PPL_LoadSpecularFragmentProgram\n"));
GL_InitSceneProcessingShaders(); GL_InitSceneProcessingShaders();
#ifdef PLUGINS
Plug_DrawReloadImages();
#endif
} }
void GLDraw_Init (void) void GLDraw_Init (void)

View file

@ -247,7 +247,7 @@ void GL_InitFisheyeFov(void)
gl_FragColor = textureCube(source, tc);\ gl_FragColor = textureCube(source, tc);\
}"; }";
scenepp_fisheye_program = GLSlang_CreateProgram(NULL, vshader, fisheyefshader); scenepp_fisheye_program = GLSlang_CreateProgram("#version 110\n", NULL, vshader, fisheyefshader);
if (scenepp_fisheye_program) if (scenepp_fisheye_program)
{ {
GLSlang_UseProgram(scenepp_fisheye_program); GLSlang_UseProgram(scenepp_fisheye_program);
@ -256,7 +256,7 @@ void GL_InitFisheyeFov(void)
GLSlang_UseProgram(0); GLSlang_UseProgram(0);
} }
scenepp_panorama_program = GLSlang_CreateProgram(NULL, vshader, panoramafshader); scenepp_panorama_program = GLSlang_CreateProgram("#version 110\n", NULL, vshader, panoramafshader);
if (scenepp_panorama_program) if (scenepp_panorama_program)
{ {
GLSlang_UseProgram(scenepp_panorama_program); GLSlang_UseProgram(scenepp_panorama_program);

View file

@ -744,7 +744,7 @@ static void Shader_EntityMergable ( shader_t *shader, shaderpass_t *pass, char *
static void Shader_ProgAutoFields(program_t *prog, char **cvarfnames); static void Shader_ProgAutoFields(program_t *prog, char **cvarfnames);
/*program text is already loaded, this function parses the 'header' of it to see which permutations it provides, and how many times we need to recompile it*/ /*program text is already loaded, this function parses the 'header' of it to see which permutations it provides, and how many times we need to recompile it*/
static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype) static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype, int ver)
{ {
static char *permutationname[] = static char *permutationname[] =
{ {
@ -760,6 +760,7 @@ static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype)
unsigned int nopermutation = ~0u; unsigned int nopermutation = ~0u;
int p, n, pn; int p, n, pn;
char *end; char *end;
char *vers;
char *cvarfnames[64]; char *cvarfnames[64];
int cvarfcount = 0; int cvarfcount = 0;
@ -798,10 +799,25 @@ static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype)
} }
script = end; script = end;
} }
else if (!strncmp(script, "!!ver", 5))
{
script += 5;
while (*script == ' ' || *script == '\t')
script++;
end = script;
while ((*end >= 'A' && *end <= 'Z') || (*end >= 'a' && *end <= 'z') || (*end >= '0' && *end <= '9') || *end == '_')
end++;
ver = strtol(script, NULL, 0);
script = end;
}
else else
break; break;
}; };
if (ver)
vers = va("#version %u\n", ver);
else
vers = NULL;
memset(prog->handle, 0, sizeof(*prog->handle)*PERMUTATIONS); memset(prog->handle, 0, sizeof(*prog->handle)*PERMUTATIONS);
for (p = 0; p < PERMUTATIONS; p++) for (p = 0; p < PERMUTATIONS; p++)
{ {
@ -822,7 +838,7 @@ static void Shader_LoadPermutations(program_t *prog, char *script, int qrtype)
permutationdefines[pn++] = permutationname[n]; permutationdefines[pn++] = permutationname[n];
} }
permutationdefines[pn++] = NULL; permutationdefines[pn++] = NULL;
prog->handle[p].glsl = GLSlang_CreateProgram(permutationdefines, script, script); prog->handle[p].glsl = GLSlang_CreateProgram(vers, permutationdefines, script, script);
} }
#endif #endif
#ifdef D3DQUAKE #ifdef D3DQUAKE
@ -871,8 +887,6 @@ struct sbuiltin_s
/*glsl es shaders require precisions to be defined for fragment shader variables /*glsl es shaders require precisions to be defined for fragment shader variables
more precision for shaders would be a good candidate for a cvar */ more precision for shaders would be a good candidate for a cvar */
{QR_OPENGL/*ES*/, 100, "default2d", {QR_OPENGL/*ES*/, 100, "default2d",
//SGX requires #version to come before defines
//"#version 100\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_view;\n" "uniform mat4 m_view;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -902,7 +916,6 @@ struct sbuiltin_s
"#endif\n" "#endif\n"
}, },
{QR_OPENGL, 110, "default2d", {QR_OPENGL, 110, "default2d",
"#version 110\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_view;\n" "uniform mat4 m_view;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -933,7 +946,6 @@ struct sbuiltin_s
}, },
{QR_OPENGL, 110, "defaultwall", {QR_OPENGL, 110, "defaultwall",
"!!cvarf gl_overbright\n" "!!cvarf gl_overbright\n"
"#version 110\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview, m_projection;\n" "uniform mat4 m_modelview, m_projection;\n"
"attribute vec3 v_position;\n" "attribute vec3 v_position;\n"
@ -967,7 +979,6 @@ struct sbuiltin_s
/*FIXME: this doesn't match the gl3 version*/ /*FIXME: this doesn't match the gl3 version*/
{QR_OPENGL/*ES*/, 100, "defaultwall", {QR_OPENGL/*ES*/, 100, "defaultwall",
"!!permu FULLBRIGHT\n" "!!permu FULLBRIGHT\n"
//"#version 100\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -1005,7 +1016,6 @@ struct sbuiltin_s
}, },
{QR_OPENGL/*ES*/, 100, "defaultwarp", {QR_OPENGL/*ES*/, 100, "defaultwarp",
"!!cvarf r_wateralpha\n" "!!cvarf r_wateralpha\n"
//"#version 100\n"
"varying mediump vec2 tc;\n" "varying mediump vec2 tc;\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
@ -1037,7 +1047,6 @@ struct sbuiltin_s
}, },
{QR_OPENGL, 110, "defaultwarp", {QR_OPENGL, 110, "defaultwarp",
"!!cvarf r_wateralpha\n" "!!cvarf r_wateralpha\n"
"#version 110\n"
"varying vec2 tc;\n" "varying vec2 tc;\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
@ -1068,7 +1077,6 @@ struct sbuiltin_s
"#endif\n" "#endif\n"
}, },
{QR_OPENGL/*ES*/, 100, "defaultsky", {QR_OPENGL/*ES*/, 100, "defaultsky",
//"#version 100\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -1111,7 +1119,6 @@ struct sbuiltin_s
"#endif\n" "#endif\n"
}, },
{QR_OPENGL, 110, "defaultsky", {QR_OPENGL, 110, "defaultsky",
"#version 110\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -1156,7 +1163,6 @@ struct sbuiltin_s
"!!permu FULLBRIGHT\n" "!!permu FULLBRIGHT\n"
"!!permu LOWER\n" "!!permu LOWER\n"
"!!permu UPPER\n" "!!permu UPPER\n"
//"#version 100\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -1220,7 +1226,6 @@ struct sbuiltin_s
"!!permu FULLBRIGHT\n" "!!permu FULLBRIGHT\n"
"!!permu LOWER\n" "!!permu LOWER\n"
"!!permu UPPER\n" "!!permu UPPER\n"
//"#version 110\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n" "uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n" "uniform mat4 m_projection;\n"
@ -1374,7 +1379,7 @@ static program_t *Shader_LoadGeneric(char *name, int qrtype)
FS_LoadFile(name, &file); FS_LoadFile(name, &file);
if (file) if (file)
{ {
Shader_LoadPermutations(&g->prog, file, qrtype); Shader_LoadPermutations(&g->prog, file, qrtype, 0);
FS_FreeFile(file); FS_FreeFile(file);
g->prog.refs++; g->prog.refs++;
@ -1398,7 +1403,7 @@ static program_t *Shader_LoadGeneric(char *name, int qrtype)
continue; continue;
} }
#endif #endif
Shader_LoadPermutations(&g->prog, sbuiltins[i].body, sbuiltins[i].qrtype); Shader_LoadPermutations(&g->prog, sbuiltins[i].body, sbuiltins[i].qrtype, sbuiltins[i].apiver);
g->prog.refs++; g->prog.refs++;
return &g->prog; return &g->prog;
@ -1571,7 +1576,7 @@ static void Shader_SLProgramName (shader_t *shader, shaderpass_t *pass, char **p
shader->prog = malloc(sizeof(*shader->prog)); shader->prog = malloc(sizeof(*shader->prog));
memset(shader->prog, 0, sizeof(*shader->prog)); memset(shader->prog, 0, sizeof(*shader->prog));
shader->prog->refs = 1; shader->prog->refs = 1;
Shader_LoadPermutations(shader->prog, programbody, qrtype); Shader_LoadPermutations(shader->prog, programbody, qrtype, 0);
BZ_Free(programbody); BZ_Free(programbody);
} }

View file

@ -151,6 +151,7 @@ FTEPFNGLLINKPROGRAMARBPROC qglLinkProgramARB;
FTEPFNGLBINDATTRIBLOCATIONARBPROC qglBindAttribLocationARB; FTEPFNGLBINDATTRIBLOCATIONARBPROC qglBindAttribLocationARB;
FTEPFNGLGETATTRIBLOCATIONARBPROC qglGetAttribLocationARB; FTEPFNGLGETATTRIBLOCATIONARBPROC qglGetAttribLocationARB;
FTEPFNGLVERTEXATTRIBPOINTER qglVertexAttribPointer; FTEPFNGLVERTEXATTRIBPOINTER qglVertexAttribPointer;
FTEPFNGLGETVERTEXATTRIBIV qglGetVertexAttribiv;
FTEPFNGLENABLEVERTEXATTRIBARRAY qglEnableVertexAttribArray; FTEPFNGLENABLEVERTEXATTRIBARRAY qglEnableVertexAttribArray;
FTEPFNGLDISABLEVERTEXATTRIBARRAY qglDisableVertexAttribArray; FTEPFNGLDISABLEVERTEXATTRIBARRAY qglDisableVertexAttribArray;
FTEPFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB; FTEPFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB;
@ -572,6 +573,7 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name), float ver)
qglBindAttribLocationARB = (void *)getglext("glBindAttribLocationARB"); qglBindAttribLocationARB = (void *)getglext("glBindAttribLocationARB");
qglGetAttribLocationARB = (void *)getglext("glGetAttribLocationARB"); qglGetAttribLocationARB = (void *)getglext("glGetAttribLocationARB");
qglVertexAttribPointer = (void *)getglext("glVertexAttribPointerARB"); qglVertexAttribPointer = (void *)getglext("glVertexAttribPointerARB");
qglGetVertexAttribiv = (void *)getglext("glGetVertexAttribivARB");
qglEnableVertexAttribArray = (void *)getglext("glEnableVertexAttribArrayARB"); qglEnableVertexAttribArray = (void *)getglext("glEnableVertexAttribArrayARB");
qglDisableVertexAttribArray = (void *)getglext("glDisableVertexAttribArrayARB"); qglDisableVertexAttribArray = (void *)getglext("glDisableVertexAttribArrayARB");
qglGetUniformLocationARB = (void *)getglext("glGetUniformLocationARB"); qglGetUniformLocationARB = (void *)getglext("glGetUniformLocationARB");
@ -605,6 +607,7 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name), float ver)
qglBindAttribLocationARB = (void *)getglext("glBindAttribLocation"); qglBindAttribLocationARB = (void *)getglext("glBindAttribLocation");
qglGetAttribLocationARB = (void *)getglext("glGetAttribLocation"); qglGetAttribLocationARB = (void *)getglext("glGetAttribLocation");
qglVertexAttribPointer = (void *)getglext("glVertexAttribPointer"); qglVertexAttribPointer = (void *)getglext("glVertexAttribPointer");
qglGetVertexAttribiv = (void *)getglext("glGetVertexAttribiv");
qglEnableVertexAttribArray = (void *)getglext("glEnableVertexAttribArray"); qglEnableVertexAttribArray = (void *)getglext("glEnableVertexAttribArray");
qglDisableVertexAttribArray = (void *)getglext("glDisableVertexAttribArray"); qglDisableVertexAttribArray = (void *)getglext("glDisableVertexAttribArray");
qglGetUniformLocationARB = (void *)getglext("glGetUniformLocation"); qglGetUniformLocationARB = (void *)getglext("glGetUniformLocation");
@ -651,15 +654,18 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name), float ver)
// glslang helper api function definitions // glslang helper api function definitions
// type should be GL_FRAGMENT_SHADER_ARB or GL_VERTEX_SHADER_ARB // type should be GL_FRAGMENT_SHADER_ARB or GL_VERTEX_SHADER_ARB
GLhandleARB GLSlang_CreateShader (char **precompilerconstants, char *shadersource, GLenum shadertype) GLhandleARB GLSlang_CreateShader (char *versionline, char **precompilerconstants, char *shadersource, GLenum shadertype)
{ {
GLhandleARB shader; GLhandleARB shader;
GLint compiled; GLint compiled;
char str[1024]; char str[1024];
int loglen, i; int loglen, i;
char *prstrings[3+16]; char *prstrings[4+16];
int strings = 0; int strings = 0;
if (versionline)
prstrings[strings++] = versionline;
prstrings[strings++] = "#define ENGINE_"DISTRIBUTION"\n"; prstrings[strings++] = "#define ENGINE_"DISTRIBUTION"\n";
switch (shadertype) switch (shadertype)
{ {
@ -768,7 +774,7 @@ bucket_t *compiledshadersbuckets[64];
static hashtable_t compiledshaderstable; static hashtable_t compiledshaderstable;
#endif #endif
GLhandleARB GLSlang_CreateProgram(char **precompilerconstants, char *vert, char *frag) GLhandleARB GLSlang_CreateProgram(char *versionline, char **precompilerconstants, char *vert, char *frag)
{ {
GLhandleARB handle; GLhandleARB handle;
GLhandleARB vs; GLhandleARB vs;
@ -802,8 +808,8 @@ GLhandleARB GLSlang_CreateProgram(char **precompilerconstants, char *vert, char
} }
#endif #endif
vs = GLSlang_CreateShader(precompilerconstants, vert, GL_VERTEX_SHADER_ARB); vs = GLSlang_CreateShader(versionline, precompilerconstants, vert, GL_VERTEX_SHADER_ARB);
fs = GLSlang_CreateShader(precompilerconstants, frag, GL_FRAGMENT_SHADER_ARB); fs = GLSlang_CreateShader(versionline, precompilerconstants, frag, GL_FRAGMENT_SHADER_ARB);
if (!vs || !fs) if (!vs || !fs)
handle = 0; handle = 0;

View file

@ -94,6 +94,7 @@ typedef void (APIENTRYP FTEPFNGLVERTEXATTRIBPOINTER) (GLuint index, GLint siz
typedef void (APIENTRYP FTEPFNGLENABLEVERTEXATTRIBARRAY) (GLuint index); typedef void (APIENTRYP FTEPFNGLENABLEVERTEXATTRIBARRAY) (GLuint index);
typedef void (APIENTRYP FTEPFNGLDISABLEVERTEXATTRIBARRAY) (GLuint index); typedef void (APIENTRYP FTEPFNGLDISABLEVERTEXATTRIBARRAY) (GLuint index);
typedef GLint (APIENTRYP FTEPFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); typedef GLint (APIENTRYP FTEPFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
typedef void (APIENTRYP FTEPFNGLGETVERTEXATTRIBIV) (GLuint index, GLenum pname, GLint *params);
typedef void (APIENTRYP FTEPFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRYP FTEPFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
typedef void (APIENTRYP FTEPFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, GLfloat *value); typedef void (APIENTRYP FTEPFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, GLfloat *value);
typedef void (APIENTRYP FTEPFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, GLfloat *value); typedef void (APIENTRYP FTEPFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, GLfloat *value);
@ -774,6 +775,7 @@ extern FTEPFNGLLINKPROGRAMARBPROC qglLinkProgramARB;
extern FTEPFNGLBINDATTRIBLOCATIONARBPROC qglBindAttribLocationARB; extern FTEPFNGLBINDATTRIBLOCATIONARBPROC qglBindAttribLocationARB;
extern FTEPFNGLGETATTRIBLOCATIONARBPROC qglGetAttribLocationARB; extern FTEPFNGLGETATTRIBLOCATIONARBPROC qglGetAttribLocationARB;
extern FTEPFNGLVERTEXATTRIBPOINTER qglVertexAttribPointer; extern FTEPFNGLVERTEXATTRIBPOINTER qglVertexAttribPointer;
extern FTEPFNGLGETVERTEXATTRIBIV qglGetVertexAttribiv;
extern FTEPFNGLENABLEVERTEXATTRIBARRAY qglEnableVertexAttribArray; extern FTEPFNGLENABLEVERTEXATTRIBARRAY qglEnableVertexAttribArray;
extern FTEPFNGLDISABLEVERTEXATTRIBARRAY qglDisableVertexAttribArray; extern FTEPFNGLDISABLEVERTEXATTRIBARRAY qglDisableVertexAttribArray;
extern FTEPFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB; extern FTEPFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB;
@ -786,7 +788,7 @@ extern FTEPFNGLUNIFORM1IARBPROC qglUniform1iARB;
extern FTEPFNGLUNIFORM1FARBPROC qglUniform1fARB; extern FTEPFNGLUNIFORM1FARBPROC qglUniform1fARB;
//glslang helper api //glslang helper api
GLhandleARB GLSlang_CreateProgram (char **precompilerconstants, char *vert, char *frag); GLhandleARB GLSlang_CreateProgram(char *versionline, char **precompilerconstants, char *vert, char *frag);
GLint GLSlang_GetUniformLocation (int prog, char *name); GLint GLSlang_GetUniformLocation (int prog, char *name);
void GL_SelectProgram(int program); void GL_SelectProgram(int program);
#define GLSlang_UseProgram(prog) GL_SelectProgram(prog) #define GLSlang_UseProgram(prog) GL_SelectProgram(prog)