remove gl_lightmap_shift, fix shader to match gl_overbright, es2/egl fixes

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3804 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2011-05-30 21:48:32 +00:00
parent fc421a05bc
commit 8464020053
9 changed files with 147 additions and 138 deletions

View file

@ -58,10 +58,10 @@ extern cvar_t r_stainfadeammount;
static int lightmap_shift; static int lightmap_shift;
int Surf_LightmapShift (model_t *model) int Surf_LightmapShift (model_t *model)
{ {
extern cvar_t gl_overbright_all, gl_overbright, gl_lightmap_shift; extern cvar_t gl_overbright_all, gl_overbright;
if (gl_overbright_all.ival || (model->engineflags & MDLF_NEEDOVERBRIGHT)) if (gl_overbright_all.ival || (model->engineflags & MDLF_NEEDOVERBRIGHT))
lightmap_shift = bound(0, gl_lightmap_shift.ival + gl_overbright.ival, 2); lightmap_shift = bound(0, gl_overbright.ival, 2);
else else
lightmap_shift = 0; lightmap_shift = 0;
return lightmap_shift; return lightmap_shift;

View file

@ -236,9 +236,6 @@ cvar_t gl_font = CVARF ("gl_font", "",
CVAR_RENDERERCALLBACK); CVAR_RENDERERCALLBACK);
cvar_t gl_lateswap = CVAR ("gl_lateswap", "0"); cvar_t gl_lateswap = CVAR ("gl_lateswap", "0");
cvar_t gl_lerpimages = CVAR ("gl_lerpimages", "1"); cvar_t gl_lerpimages = CVAR ("gl_lerpimages", "1");
cvar_t gl_lightmap_shift = CVARFC ("gl_lightmap_shift", "1",
CVAR_ARCHIVE,
Surf_RebuildLightmap_Callback);
//cvar_t gl_lightmapmode = SCVARF("gl_lightmapmode", "", //cvar_t gl_lightmapmode = SCVARF("gl_lightmapmode", "",
// CVAR_ARCHIVE); // CVAR_ARCHIVE);
cvar_t gl_load24bit = SCVARF ("gl_load24bit", "1", cvar_t gl_load24bit = SCVARF ("gl_load24bit", "1",
@ -433,8 +430,6 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_blendsprites, GLRENDEREROPTIONS); Cvar_Register (&gl_blendsprites, GLRENDEREROPTIONS);
Cvar_Register (&gl_lightmap_shift, GLRENDEREROPTIONS);
Cvar_Register (&gl_menutint_shader, GLRENDEREROPTIONS); Cvar_Register (&gl_menutint_shader, GLRENDEREROPTIONS);
R_BloomRegister(); R_BloomRegister();

View file

@ -533,21 +533,31 @@ dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
if (!lib) if (!lib)
return NULL; return NULL;
for (i = 0; funcs[i].name; i++) if (funcs)
{ {
*funcs[i].funcptr = dlsym(lib, funcs[i].name); for (i = 0; funcs[i].name; i++)
if (!*funcs[i].funcptr) {
break; *funcs[i].funcptr = dlsym(lib, funcs[i].name);
} if (!*funcs[i].funcptr)
if (funcs[i].name) break;
{ }
Sys_CloseLibrary((dllhandle_t*)lib); if (funcs[i].name)
lib = NULL; {
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
} }
return (dllhandle_t*)lib; return (dllhandle_t*)lib;
} }
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
{
if (!module)
return NULL;
return dlsym(module, exportname);
}
// ======================================================================= // =======================================================================
// Sleeps for microseconds // Sleeps for microseconds
// ======================================================================= // =======================================================================

View file

@ -366,21 +366,31 @@ dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
if (!lib) if (!lib)
return NULL; return NULL;
for (i = 0; funcs[i].name; i++) if (funcs)
{ {
*funcs[i].funcptr = dlsym(lib, funcs[i].name); for (i = 0; funcs[i].name; i++)
if (!*funcs[i].funcptr) {
break; *funcs[i].funcptr = dlsym(lib, funcs[i].name);
} if (!*funcs[i].funcptr)
if (funcs[i].name) break;
{ }
Sys_CloseLibrary((dllhandle_t*)lib); if (funcs[i].name)
lib = NULL; {
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
} }
return (dllhandle_t*)lib; return (dllhandle_t*)lib;
} }
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
{
if (!module)
return NULL;
return dlsym(module, exportname);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
double oldtime, newtime; double oldtime, newtime;

View file

@ -299,20 +299,29 @@ dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
if (!lib) if (!lib)
return NULL; return NULL;
for (i = 0; funcs[i].name; i++) if (funcs)
{ {
*funcs[i].funcptr = SDL_LoadFunction(lib, funcs[i].name); for (i = 0; funcs[i].name; i++)
if (!*funcs[i].funcptr) {
break; *funcs[i].funcptr = SDL_LoadFunction(lib, funcs[i].name);
} if (!*funcs[i].funcptr)
if (funcs[i].name) break;
{ }
Sys_CloseLibrary((dllhandle_t*)lib); if (funcs[i].name)
lib = NULL; {
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
} }
return (dllhandle_t*)lib; return (dllhandle_t*)lib;
} }
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
{
if (!module)
return NULL;
return SDL_LoadFunction((void *)module, exportname);
}
//Without these two we cannot run Q2 gamecode. //Without these two we cannot run Q2 gamecode.
dllhandle_t *q2gamedll; dllhandle_t *q2gamedll;

View file

@ -944,6 +944,40 @@ struct sbuiltin_s
"}\n" "}\n"
"#endif\n" "#endif\n"
}, },
{QR_OPENGL/*ES*/, 100, "defaultwall",
"!!cvarf gl_overbright\n"
"#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n"
"attribute vec3 v_position;\n"
"attribute vec2 v_texcoord;\n"
"attribute vec2 v_lmcoord;\n"
"varying vec2 tc, lm;\n"
"void main (void)\n"
"{\n"
" tc = v_texcoord;\n"
" lm = v_lmcoord;\n"
" gl_Position = m_projection * m_modelview * vec4(v_position, 1.0);\n"
"}\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"uniform sampler2D s_t0;\n" /*tex_diffuse*/
"uniform sampler2D s_t1;\n" /*tex_lightmap*/
//"uniform sampler2D s_t2;\n" /*tex_normalmap*/
//"uniform sampler2D s_t3;\n" /*tex_deluxmap*/
//"uniform sampler2D s_t4;\n" /*tex_fullbright*/
"varying mediump vec2 tc, lm;\n"
"uniform mediump float cvar_gl_overbright;\n"
"void main (void)\n"
"{\n"
" mediump float scale = exp2(floor(clamp(cvar_gl_overbright, 0.0, 2.0)));\n"
" gl_FragColor = texture2D(s_t0, tc) * texture2D(s_t1, lm) * vec4(scale, scale, scale, 1);\n"
"}\n"
"#endif\n"
},
{QR_OPENGL, 110, "defaultwall", {QR_OPENGL, 110, "defaultwall",
"!!cvarf gl_overbright\n" "!!cvarf gl_overbright\n"
"#ifdef VERTEX_SHADER\n" "#ifdef VERTEX_SHADER\n"
@ -972,45 +1006,8 @@ struct sbuiltin_s
"void main (void)\n" "void main (void)\n"
"{\n" "{\n"
" gl_FragColor = texture2D(s_t0, tc) * texture2D(s_t1, lm) * vec4(cvar_gl_overbright, cvar_gl_overbright, cvar_gl_overbright, 1);\n" " float scale = exp2(floor(clamp(cvar_gl_overbright, 0.0, 2.0)));\n"
"}\n" " gl_FragColor = texture2D(s_t0, tc) * texture2D(s_t1, lm) * vec4(scale, scale, scale, 1);\n"
"#endif\n"
},
/*FIXME: this doesn't match the gl3 version*/
{QR_OPENGL/*ES*/, 100, "defaultwall",
"!!permu FULLBRIGHT\n"
"#ifdef VERTEX_SHADER\n"
"uniform mat4 m_modelview;\n"
"uniform mat4 m_projection;\n"
"attribute vec3 v_position;\n"
"attribute vec2 v_texcoord;\n"
"attribute vec2 v_lmcoord;\n"
"varying vec2 tc, lm;\n"
"void main (void)\n"
"{\n"
" tc = v_texcoord;\n"
" lm = v_lmcoord;\n"
" gl_Position = m_projection * m_modelview * vec4(v_position, 1.0);\n"
"}\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"uniform sampler2D s_t0;\n" /*tex_diffuse*/
"uniform sampler2D s_t1;\n" /*tex_lightmap*/
//"uniform sampler2D s_t2;\n" /*tex_normalmap*/
//"uniform sampler2D s_t3;\n" /*tex_deluxmap*/
"#ifdef FULLBRIGHT\n"
"uniform sampler2D s_t4;\n" /*tex_fullbright*/
"#endif\n"
"varying mediump vec2 tc, lm;\n"
"void main (void)\n"
"{\n"
" gl_FragColor = texture2D(s_t0, tc) * texture2D(s_t1, lm);\n"
"#ifdef FULLBRIGHT\n"
" gl_FragColor += texture2D(s_t4, tc);\n"
"#endif\n"
"}\n" "}\n"
"#endif\n" "#endif\n"
}, },
@ -1199,23 +1196,23 @@ struct sbuiltin_s
"#endif\n" "#endif\n"
"varying mediump vec2 tc;\n" "varying mediump vec2 tc;\n"
"varying lowp vec3 light;\n" "varying lowp vec3 light;\n"
"uniform vec4 e_colourident;\n" "uniform lowp vec4 e_colourident;\n"
"void main (void)\n" "void main (void)\n"
"{\n" "{\n"
" vec4 col, sp;\n" " lowp vec4 col;\n"
" col = texture2D(s_t0, tc);\n" " col = texture2D(s_t0, tc);\n"
"#ifdef UPPER\n" "#ifdef UPPER\n"
" vec4 uc = texture2D(s_t2, tc);\n" " lowp vec4 uc = texture2D(s_t2, tc);\n"
" col.rgb = mix(col.rgb, uc.rgb*e_uppercolour, uc.a);\n" " col.rgb = mix(col.rgb, uc.rgb*e_uppercolour, uc.a);\n"
"#endif\n" "#endif\n"
"#ifdef LOWER\n" "#ifdef LOWER\n"
" vec4 lc = texture2D(s_t1, tc);\n" " lowp vec4 lc = texture2D(s_t1, tc);\n"
" col.rgb = mix(col.rgb, lc.rgb*e_lowercolour, lc.a);\n" " col.rgb = mix(col.rgb, lc.rgb*e_lowercolour, lc.a);\n"
"#endif\n" "#endif\n"
" col.rgb *= light;\n" " col.rgb *= light;\n"
"#ifdef FULLBRIGHT\n" "#ifdef FULLBRIGHT\n"
" vec4 fb = texture2D(s_t3, tc);\n" " lowp vec4 fb = texture2D(s_t3, tc);\n"
" col.rgb = mix(col.rgb, fb.rgb, fb.a);\n" " col.rgb = mix(col.rgb, fb.rgb, fb.a);\n"
"#endif\n" "#endif\n"
" gl_FragColor = col * e_colourident;\n" " gl_FragColor = col * e_colourident;\n"

View file

@ -4,8 +4,8 @@ EGLContext eglctx = EGL_NO_CONTEXT;
EGLDisplay egldpy = EGL_NO_DISPLAY; EGLDisplay egldpy = EGL_NO_DISPLAY;
EGLSurface eglsurf = EGL_NO_SURFACE; EGLSurface eglsurf = EGL_NO_SURFACE;
static void *egllibrary; static dllhandle_t egllibrary;
static void *eslibrary; static dllhandle_t eslibrary;
static EGLint (*qeglGetError)(void); static EGLint (*qeglGetError)(void);
@ -26,10 +26,11 @@ static EGLContext (*qeglCreateContext)(EGLDisplay dpy, EGLConfig config, EGLCont
static EGLBoolean (*qeglDestroyContext)(EGLDisplay dpy, EGLContext ctx); static EGLBoolean (*qeglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
static void *(*qeglGetProcAddress) (char *name); static void *(*qeglGetProcAddress) (char *name);
/*
static dllfunction_t qeglfuncs[] = static dllfunction_t qeglfuncs[] =
{ {
{(void*)&qeglGetError, "eglGetError"}, {(void*)&qeglGetError, "eglGetError"},
{(void*)&qeglGetDisplay, "eglGetDisplay"},
{(void*)&qeglInitialize, "eglInitialize"}, {(void*)&qeglInitialize, "eglInitialize"},
{(void*)&qeglTerminate, "eglTerminate"}, {(void*)&qeglTerminate, "eglTerminate"},
@ -49,7 +50,7 @@ static dllfunction_t qeglfuncs[] =
{NULL} {NULL}
}; };
*/
void *EGL_Proc(char *f) void *EGL_Proc(char *f)
{ {
@ -66,9 +67,9 @@ void *EGL_Proc(char *f)
if (qeglGetProcAddress) if (qeglGetProcAddress)
proc = qeglGetProcAddress(f); proc = qeglGetProcAddress(f);
if (!proc) if (!proc)
proc = dlsym(eslibrary, f); proc = Sys_GetAddressForName(eslibrary, f);
if (!proc) if (!proc)
proc = dlsym(egllibrary, f); proc = Sys_GetAddressForName(egllibrary, f);
return proc; return proc;
} }
@ -76,52 +77,28 @@ void *EGL_Proc(char *f)
void EGL_UnloadLibrary(void) void EGL_UnloadLibrary(void)
{ {
if (egllibrary) if (egllibrary)
dlclose(egllibrary); Sys_CloseLibrary(egllibrary);
if (egllibrary == eslibrary) if (egllibrary == eslibrary)
eslibrary = NULL; eslibrary = NULL;
if (eslibrary) if (eslibrary)
dlclose(eslibrary); Sys_CloseLibrary(eslibrary);
eslibrary = egllibrary = NULL; eslibrary = egllibrary = NULL;
} }
qboolean EGL_LoadLibrary(char *driver) qboolean EGL_LoadLibrary(char *driver)
{ {
/* ignore driver for now */ /* apps seem to load glesv2 first for dependency issues */
egllibrary = dlopen("libEGL.so", RTLD_LAZY); eslibrary = Sys_LoadLibrary("libGLESv2", NULL);
if (!egllibrary)
return false;
/*eslibrary = dlopen("GLESwrap.so", RTLD_LAZY);*/
eslibrary = dlopen("libGLESv2.so", RTLD_LAZY);
if (!eslibrary) if (!eslibrary)
return false; return false;
qeglGetError = dlsym(egllibrary, "eglGetError"); egllibrary = Sys_LoadLibrary("libEGL", qeglfuncs);
if (!egllibrary)
qeglGetDisplay = dlsym(egllibrary, "eglGetDisplay"); {
qeglInitialize = dlsym(egllibrary, "eglInitialize"); /* TODO: some implementations combine EGL/GLESv2 into single library... */
qeglTerminate = dlsym(egllibrary, "eglTerminate"); Sys_CloseLibrary(eslibrary);
qeglGetConfigs = dlsym(egllibrary, "eglGetConfigs");
qeglChooseConfig = dlsym(egllibrary, "eglChooseConfig");
qeglCreateWindowSurface = dlsym(egllibrary, "eglCreateWindowSurface");
qeglDestroySurface = dlsym(egllibrary, "eglDestroySurface");
qeglQuerySurface = dlsym(egllibrary, "eglQuerySurface");
qeglSwapBuffers = dlsym(egllibrary, "eglSwapBuffers");
qeglMakeCurrent = dlsym(egllibrary, "eglMakeCurrent");
qeglCreateContext = dlsym(egllibrary, "eglCreateContext");
qeglDestroyContext = dlsym(egllibrary, "eglDestroyContext");
qeglGetProcAddress = dlsym(egllibrary, "eglGetProcAddress");
// TODO: properly unload on error
if (!qeglGetError || !qeglGetDisplay || !qeglInitialize || !qeglTerminate || !qeglCreateWindowSurface ||
!qeglDestroySurface || !qeglGetConfigs || !qeglChooseConfig || !qeglQuerySurface ||
!qeglSwapBuffers || !qeglMakeCurrent || !qeglCreateContext || !qeglDestroyContext ||
!qeglGetProcAddress)
return false; return false;
}
return true; return true;
} }

View file

@ -794,21 +794,29 @@ dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
if (!lib) if (!lib)
return NULL; return NULL;
for (i = 0; funcs[i].name; i++) if (funcs)
{ {
*funcs[i].funcptr = dlsym(lib, funcs[i].name); for (i = 0; funcs[i].name; i++)
if (!*funcs[i].funcptr) {
break; *funcs[i].funcptr = dlsym(lib, funcs[i].name);
} if (!*funcs[i].funcptr)
if (funcs[i].name) break;
{ }
Sys_CloseLibrary((dllhandle_t*)lib); if (funcs[i].name)
lib = NULL; {
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
} }
return (dllhandle_t*)lib; return (dllhandle_t*)lib;
} }
void *Sys_GetAddressForName(dllhandle_t *module, const char *exportname)
{
if (!module)
return NULL;
return dlsym(module, exportname);
}
static void *game_library; static void *game_library;

View file

@ -141,16 +141,19 @@ dllhandle_t *Sys_LoadLibrary(const char *name, dllfunction_t *funcs)
if (!lib) if (!lib)
return NULL; return NULL;
for (i = 0; funcs[i].name; i++) if (funcs)
{ {
*funcs[i].funcptr = GetProcAddress(lib, funcs[i].name); for (i = 0; funcs[i].name; i++)
if (!*funcs[i].funcptr) {
break; *funcs[i].funcptr = GetProcAddress(lib, funcs[i].name);
} if (!*funcs[i].funcptr)
if (funcs[i].name) break;
{ }
Sys_CloseLibrary((dllhandle_t*)lib); if (funcs[i].name)
lib = NULL; {
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
} }
return (dllhandle_t*)lib; return (dllhandle_t*)lib;