From 5651e77c30630bc9b744640884311d3738635801 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 16 Jan 2012 06:22:06 +0000 Subject: [PATCH] Android fixes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3956 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/Makefile | 6 ++-- engine/droid/AndroidManifest.xml | 2 +- engine/gl/gl_backend.c | 14 +++++---- engine/gl/gl_shader.c | 49 ++++++++++++++++++++++++++------ engine/gl/gl_vidcommon.c | 1 + engine/gl/gl_warp.c | 2 +- 6 files changed, 54 insertions(+), 20 deletions(-) diff --git a/engine/Makefile b/engine/Makefile index 86add360a..30c3b34aa 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -1191,9 +1191,9 @@ droid-rel: droid/build.xml droid/ftekeystore @echo @echo Signing package... I hope you remember your password. @echo - jarsigner -verbose -keystore droid/ftekeystore droid/bin/FTEDroid-unsigned.apk autogen + jarsigner -digestalg SHA1 -sigalg MD5withRSA -keystore droid/ftekeystore droid/bin/FTEDroid-unsigned.apk autogen -rm -f $(RELEASE_DIR)/FTEDroid.apk - $(DROID_SDK_PATH)/tools/zipalign -v 4 droid/bin/FTEDroid-unsigned.apk $(RELEASE_DIR)/FTEDroid.apk + $(DROID_SDK_PATH)/tools/zipalign 4 droid/bin/FTEDroid-unsigned.apk $(RELEASE_DIR)/FTEDroid.apk droid-opt: droid/build.xml droid/ftekeystore $(MAKE) FTE_TARGET=droid gl-rel @@ -1207,6 +1207,6 @@ droid-dbg: droid/build.xml $(MAKE) FTE_TARGET=droid gl-dbg @mkdir -p droid/libs/armeabi @cp $(DEBUG_DIR)/libftedroid.so droid/libs/armeabi/ - @cd droid && ant debug && ant install + @cd droid && ant debug install cp droid/bin/FTEDroid-debug.apk $(DEBUG_DIR)/FTEDroid.apk diff --git a/engine/droid/AndroidManifest.xml b/engine/droid/AndroidManifest.xml index 510f52877..660c6a393 100644 --- a/engine/droid/AndroidManifest.xml +++ b/engine/droid/AndroidManifest.xml @@ -3,7 +3,7 @@ package="com.fteqw" android:versionCode="1" android:versionName="1.0"> - + diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index dad0abeb1..6d995156b 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -1,11 +1,6 @@ #include "quakedef.h" -#ifdef ANDROID -//FIXME: this shouldn't be defined -#define FORCESTATE -#else //#define FORCESTATE -#endif //#define WIREFRAME #ifdef GLQUAKE @@ -249,6 +244,7 @@ void GL_TexEnv(GLenum mode) static void BE_SetPassBlendMode(int tmu, int pbm) { + #ifndef FORCESTATE if (shaderstate.blendmode[tmu] != pbm) #endif @@ -616,7 +612,8 @@ static void RevertToKnownState(void) BE_SetPassBlendMode(0, PBM_REPLACE); - qglColor3f(1,1,1); + if (qglColor3f) + qglColor3f(1,1,1); shaderstate.shaderbits &= ~(SBITS_MISC_DEPTHEQUALONLY|SBITS_MISC_DEPTHCLOSERONLY|SBITS_MASK_BITS); shaderstate.shaderbits |= SBITS_MISC_DEPTHWRITE; @@ -962,6 +959,11 @@ void GLBE_Init(void) shaderstate.shader_cube = R_RegisterCustom("rtlight_sube", Shader_LightPass_Cube, NULL); } + gl_overbright.modified = true; /*in case the d3d renderer does the same*/ + /*lock the cvar down if the backend can't actually do it*/ + if (!gl_config.tex_env_combine && !gl_config.nofixedfunc && gl_overbright.ival) + Cvar_ApplyLatchFlag(&gl_overbright, "0", CVAR_RENDERERLATCH); + shaderstate.shaderbits = ~0; BE_SendPassBlendDepthMask(0); diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 115d8e98f..1f309245c 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -790,7 +790,7 @@ static void Shader_EntityMergable ( shader_t *shader, shaderpass_t *pass, char * static void Shader_ProgAutoFields(program_t *prog, char **cvarnames, int *cvartypes); /*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(char *name, program_t *prog, char *script, int qrtype, int ver) +static qboolean Shader_LoadPermutations(char *name, program_t *prog, char *script, int qrtype, int ver) { static char *permutationname[] = { @@ -921,6 +921,8 @@ static void Shader_LoadPermutations(char *name, program_t *prog, char *script, i } permutationdefines[pn++] = NULL; prog->handle[p].glsl = GLSlang_CreateProgram(name, (((p & PERMUTATION_SKELETAL) && ver < 120)?120:ver), permutationdefines, script, script); + if (!p && !prog->handle[p].glsl) + break; } #endif #ifdef D3DQUAKE @@ -937,7 +939,8 @@ static void Shader_LoadPermutations(char *name, program_t *prog, char *script, i permutationdefines[pn++] = permutationname[n]; } permutationdefines[pn++] = NULL; - D3DShader_CreateProgram(prog, p, permutationdefines, script, script); + if (!D3DShader_CreateProgram(prog, p, permutationdefines, script, script)) + break; } #endif } @@ -945,6 +948,10 @@ static void Shader_LoadPermutations(char *name, program_t *prog, char *script, i free(permutationdefines[--nummodifiers]); Shader_ProgAutoFields(prog, cvarnames, cvartypes); + + if (p == PERMUTATIONS) + return true; + return false; } typedef struct sgeneric_s { @@ -2321,6 +2328,7 @@ static program_t *Shader_LoadGeneric(char *name, int qrtype) void *file; sgeneric_t *g; + for (g = sgenerics; g; g = g->next) { if (!strcmp(name, g->name)) @@ -2359,7 +2367,7 @@ static program_t *Shader_LoadGeneric(char *name, int qrtype) if (file) { Con_DPrintf("Loaded %s from disk\n", name); - Shader_LoadPermutations(name, &g->prog, file, qrtype, 0); + g->failed = !Shader_LoadPermutations(name, &g->prog, file, qrtype, 0); FS_FreeFile(file); g->prog.refs++; @@ -2392,7 +2400,7 @@ static program_t *Shader_LoadGeneric(char *name, int qrtype) } } #endif - Shader_LoadPermutations(name, &g->prog, sbuiltins[i].body, sbuiltins[i].qrtype, sbuiltins[i].apiver); + g->failed = !Shader_LoadPermutations(name, &g->prog, sbuiltins[i].body, sbuiltins[i].qrtype, sbuiltins[i].apiver); g->prog.refs++; return &g->prog; @@ -2727,7 +2735,11 @@ static void Shader_SLProgramName (shader_t *shader, shaderpass_t *pass, char **p shader->prog = malloc(sizeof(*shader->prog)); memset(shader->prog, 0, sizeof(*shader->prog)); shader->prog->refs = 1; - Shader_LoadPermutations(shader->name, shader->prog, programbody, qrtype, 0); + if (!Shader_LoadPermutations(shader->name, shader->prog, programbody, qrtype, 0)) + { + free(shader->prog); + shader->prog = NULL; + } BZ_Free(programbody); } @@ -4187,9 +4199,24 @@ static qboolean Shader_Parsetok (shader_t *shader, shaderpass_t *pass, shaderkey void Shader_SetPassFlush (shaderpass_t *pass, shaderpass_t *pass2) { - qboolean config_tex_env_combine = 1;//0; - qboolean config_nv_tex_env_combine4 = 1;//0; - qboolean config_env_add = 1;//0; + qboolean config_tex_env_combine; + qboolean config_nv_tex_env_combine4; + qboolean config_env_add; + +#ifdef GLQUAKE + if (qrenderer == QR_OPENGL) + { + config_tex_env_combine = gl_config.tex_env_combine; + config_nv_tex_env_combine4 = gl_config.nv_tex_env_combine4; + config_env_add = gl_config.env_add; + } + else +#endif + { + config_tex_env_combine = 1; + config_nv_tex_env_combine4 = 1; + config_env_add = 1; + } if (((pass->flags & SHADER_PASS_DETAIL) && !r_detailtextures.value) || ((pass2->flags & SHADER_PASS_DETAIL) && !r_detailtextures.value) || @@ -4220,6 +4247,10 @@ void Shader_SetPassFlush (shaderpass_t *pass, shaderpass_t *pass2) if ((pass->shaderbits & SBITS_MASK_BITS) != (pass2->shaderbits & SBITS_MASK_BITS)) return; + /*don't merge passes if the hardware cannot support it*/ + if (pass->numMergedPasses >= be_maxpasses) + return; + // check if we can use multiple passes if (pass2->blendmode == PBM_DOTPRODUCT) { @@ -4250,7 +4281,7 @@ void Shader_SetPassFlush (shaderpass_t *pass, shaderpass_t *pass2) } else return; - if (pass2->texgen == T_GEN_LIGHTMAP && pass2->blendmode == PBM_MODULATE) + if (pass2->texgen == T_GEN_LIGHTMAP && pass2->blendmode == PBM_MODULATE && config_tex_env_combine) pass2->blendmode = PBM_OVERBRIGHT; } diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index 9d811fca4..df1b5122f 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -456,6 +456,7 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name), float ver) qglClientActiveTextureARB = (void *) getglext("glClientActiveTexture"); qglSelectTextureSGIS = qglActiveTextureARB; mtexid0 = GL_TEXTURE0_ARB; + qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_mtexarbable); } else if (GL_CheckExtension("GL_ARB_multitexture") && !COM_CheckParm("-noamtex")) { //ARB multitexture is the popular choice. diff --git a/engine/gl/gl_warp.c b/engine/gl/gl_warp.c index b3de75de3..9ce54720a 100644 --- a/engine/gl/gl_warp.c +++ b/engine/gl/gl_warp.c @@ -88,7 +88,7 @@ void R_DrawSkyChain (batch_t *batch) GL_SkyForceDepth(batch); return; } -#ifdef GLQUAKE +#if defined(GLQUAKE) && !defined(ANDROID) if (*r_fastsky.string && qrenderer == QR_OPENGL && TEXVALID(batch->shader->defaulttextures.base)) { R_CalcSkyChainBounds(batch);