diff --git a/polymer/eduke32/Android.mk b/polymer/eduke32/Android.mk index 3be837fa5..5c03d4e1e 100644 --- a/polymer/eduke32/Android.mk +++ b/polymer/eduke32/Android.mk @@ -16,7 +16,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := duke +LOCAL_MODULE := duke3d # -O2 -fvisibility=hidden @@ -29,7 +29,7 @@ else endif LOCAL_CFLAGS += -W -Werror-implicit-function-declaration -Wpointer-arith -Wextra -Wno-unused-result -Wno-char-subscripts -Wno-strict-overflow -Wno-attributes -Wno-write-strings -LOCAL_CPPFLAGS := -std=gnu++03 +LOCAL_CPPFLAGS := -std=gnu++11 LOCAL_CFLAGS += -DHAVE_SDL -DHAVE_VORBIS -DHAVE_JWZGLES -DHAVE_ANDROID -DRENDERTYPESDL=1 -DUSE_OPENGL -DNETCODE_DISABLE -DUSE_LIBVPX diff --git a/polymer/eduke32/build/include/common.h b/polymer/eduke32/build/include/common.h index be80ee62c..6b18c6e05 100644 --- a/polymer/eduke32/build/include/common.h +++ b/polymer/eduke32/build/include/common.h @@ -11,7 +11,6 @@ #include "scriptfile.h" #include "cache1d.h" #include "pragmas.h" // klabs -#include "build.h" #ifdef __cplusplus diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 9a4de14c6..16006576e 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -134,6 +134,14 @@ int32_t r_parallaxskypanning = 0; #define MIN_CACHETIME_PRINT 10 +#ifdef EDUKE32_GLES +int32_t texfmt_art = GL_RGB5_A1; +int32_t texfmt_alpha = GL_RGBA4; +#else +int32_t texfmt_art = GL_RGBA; +int32_t texfmt_alpha = GL_RGBA; +#endif + // this was faster in MSVC but slower with GCC... currently unknown on ARM where both // the FPU and possibly the optimization path in the compiler need improvement #if 0 @@ -671,10 +679,20 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t intexfmt, int32_t texfmt if (!miplevel) { +redo: if (doalloc&1) bglTexImage2D(GL_TEXTURE_2D,0,intexfmt,siz.x,siz.y,0,texfmt,GL_UNSIGNED_BYTE,pic); //loading 1st time else bglTexSubImage2D(GL_TEXTURE_2D,0,0,0,siz.x,siz.y,texfmt,GL_UNSIGNED_BYTE,pic); //overwrite old texture + + if (bglGetError() != GL_NO_ERROR) + { + if (intexfmt == GL_RGB5_A1) + texfmt_art = intexfmt = GL_RGB; + else if (intexfmt == GL_RGBA4) + texfmt_alpha = intexfmt = GL_RGBA; + goto redo; + } } vec2_t siz2 = siz; @@ -728,10 +746,20 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t intexfmt, int32_t texfmt if (j >= miplevel) { +redo_mip: if (doalloc & 1) // loading 1st time bglTexImage2D(GL_TEXTURE_2D, j - miplevel, intexfmt, siz3.x, siz3.y, 0, texfmt, GL_UNSIGNED_BYTE, pic); else // overwrite old texture bglTexSubImage2D(GL_TEXTURE_2D, j - miplevel, 0, 0, siz3.x, siz3.y, texfmt, GL_UNSIGNED_BYTE, pic); + + if (bglGetError() != GL_NO_ERROR) + { + if (intexfmt == GL_RGB5_A1) + texfmt_art = intexfmt = GL_RGB; + else if (intexfmt == GL_RGBA4) + texfmt_alpha = intexfmt = GL_RGBA; + goto redo_mip; + } } siz2 = siz3; @@ -943,7 +971,8 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das npoty = PTH_NPOTWALL; } - uploadtexture(doalloc, siz, hasalpha ? GL_RGBA : GL_RGB, GL_RGBA, pic, tsiz, dameth | DAMETH_NOFIX); + uploadtexture(doalloc, siz, hasalpha && texfmt_art == GL_RGBA ? GL_RGB : texfmt_art, + GL_RGBA, pic, tsiz, dameth | DAMETH_NOFIX); Bfree(pic); @@ -1221,14 +1250,18 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp if (glinfo.texcompr && glusetexcompr && !(hicr->flags & HICR_NOSAVE)) intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB; else -#endif if (hasalpha == 255) intexfmt = GL_RGB; +#else + if (hasalpha == 255) intexfmt = texfmt_art; + else intexfmt = texfmt_alpha; +#endif if ((doalloc&3)==1) bglGenTextures(1, &pth->glpic); //# of textures (make OpenGL allocate structure) bglBindTexture(GL_TEXTURE_2D,pth->glpic); fixtransparency(pic,tsiz,siz,dameth); + uploadtexture(doalloc,siz,intexfmt,texfmt,pic,tsiz, dameth | DAMETH_HI | DAMETH_NOFIX | (hicr->flags & HICR_NOCOMPRESS ? DAMETH_NOCOMPRESS : 0)); } diff --git a/polymer/eduke32/source/android/android-jni.cpp b/polymer/eduke32/source/android/android-jni.cpp index 980e27dcc..9b978d305 100644 --- a/polymer/eduke32/source/android/android-jni.cpp +++ b/polymer/eduke32/source/android/android-jni.cpp @@ -21,9 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- -#include -#include -#include #include #include @@ -43,7 +40,7 @@ extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char #include "in_android.h" #include "../function.h" -#include "../GL/gl.h" +// #include "../GL/gl.h" // Copied from build.h, which didnt include here enum rendmode_t @@ -86,6 +83,7 @@ static int curRenderer; static bool hideTouchControls = true; static bool hasTouch = false; static int weaponWheelVisible = false; +static bool hwScaling = false; static int controlsCreated = 0; @@ -142,49 +140,19 @@ void openGLStart() glDisable(GL_CULL_FACE); glMatrixMode(GL_MODELVIEW); - - // nanoPushState(); } -/* - else // software mode - { - glDisable(GL_ALPHA_TEST); - glDisableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_TEXTURE_2D); - glDisable(GL_CULL_FACE); - glMatrixMode(GL_MODELVIEW); - } -*/ } void openGLEnd() { if (curRenderer == REND_GL) - { - // glPopMatrix(); - // nanoPopState(); glPopMatrix(); - } -/* - else // Software mode - { - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glMatrixMode(GL_MODELVIEW); - } -*/ } void gameSettingsButton(int state) { if (state == 1) - { showTouchSettings(); - } } // This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon @@ -207,12 +175,16 @@ void showWeaponsInventory(bool show) tcGameWeapons->fade(touchcontrols::FADE_IN, 5); // fade in weaponWheelVisible = true; + + PortableTimer(0); } else // hide { tcGameWeapons->setAllButtonsEnable(false); weaponWheel->setTapMode(false); weaponWheelVisible = false; + + PortableTimer(120); } } @@ -256,12 +228,10 @@ void gameButton(int state, int code) { weaponWheel->setTapMode(true); showWeaponsInventory(true); - PortableTimer(30); } else { showWeaponsInventory(false); - PortableTimer(120); } } break; @@ -289,7 +259,6 @@ void inventoryButton(int state, int code) { // Inventory chosen, hide them and wheel showWeaponsInventory(false); - PortableTimer(120); } } @@ -320,7 +289,6 @@ void blankTapButton(int state, int code) void weaponWheelSelected(int enabled) { showWeaponsInventory(enabled ? true : false); - PortableTimer(enabled ? 0 : 120); } void weaponWheelChosen(int segment) @@ -396,6 +364,16 @@ void initControls(int width, int height, const char *graphics_path) touchcontrols::GLScaleWidth = (float)width; touchcontrols::GLScaleHeight = (float)-height; + touchcontrols::ScaleY = nearbyintf(((float) height/(float) width) * touchcontrols::ScaleX); + +/* + if (hwScaling) + { + touchcontrols::GLScaleWidth = (float) (width * 2); + touchcontrols::GLScaleHeight = (float) -(height * 2); + } +*/ + LOGI("initControls %d x %d,x path = %s", width, height, graphics_path); if (controlsCreated) @@ -412,10 +390,9 @@ void initControls(int width, int height, const char *graphics_path) tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false); tcYesNo = new touchcontrols::TouchControls("yes_no", false, false); tcMenuMain = new touchcontrols::TouchControls("menu", false, false); - tcGameMain = new touchcontrols::TouchControls("game", false, true, 1, true); - tcGameWeapons = new touchcontrols::TouchControls("weapons", false, true, 1, false); + tcGameMain = new touchcontrols::TouchControls("game", false, true, 1); + tcGameWeapons = new touchcontrols::TouchControls("weapons", false, false); tcAutomap = new touchcontrols::TouchControls("automap", false, false); - // tcInventory = new touchcontrols::TouchControls("inventory", false,true,1,false); ///////////////////////// BLANK TAP SCREEN ////////////////////// @@ -437,7 +414,7 @@ void initControls(int width, int height, const char *graphics_path) ///////////////////////// MAIN MENU SCREEN ///////////////////// tcMenuMain->addControl( - new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 2, 2, 4), "arrow_left", SDL_SCANCODE_ESCAPE)); + new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 0, 2, 2), "arrow_left", SDL_SCANCODE_ESCAPE)); tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton)); touchcontrols::MultitouchMouse *mouseMenu = @@ -634,13 +611,11 @@ void updateTouchScreenMode(touchscreemode_t mode) // This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not // be seen anyway - showWeaponsInventory(true); break; case TOUCH_SCREEN_GAME: tcGameMain->setEnabled(true); tcGameMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES); tcGameWeapons->setEnabled(true); - showWeaponsInventory(false); break; case TOUCH_SCREEN_AUTOMAP: tcAutomap->setEnabled(true); @@ -710,6 +685,7 @@ void setTouchSettings(int other) // TODO: defined names for these values hasTouch = other & 0x4000 ? true : false; hideTouchControls = other & 0x8000 ? true : false; + hwScaling = other & 0x10000 ? true : false; // keep in sync with Duke3d/res/values/strings.xml int doubletap_options[4] = { -1, gamefunc_Quick_Kick, gamefunc_MedKit, gamefunc_Jetpack }; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1b7149094..cc3851131 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -5207,7 +5207,6 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) break; case T_ANIMSOUNDS: { - char *otokptr = script->ltextptr; int32_t numpairs = 0, allocsz = 4, bad = 1, lastframenum = INT32_MIN; dukeanim_t *anim = NULL; @@ -5239,7 +5238,6 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) break; } - if (animname) anim = Anim_Find(animname); @@ -5250,7 +5248,6 @@ static int32_t parsedefinitions_game(scriptfile *script, int32_t preload) break; } - if (anim->sounds) { initprintf("Warning: overwriting already defined hi-anim %s's sounds on line %s:%d\n", animname, diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index c4d930c77..f6b14e243 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -4676,8 +4676,8 @@ static void M_RunMenu_MouseReturn(Menu_t *cm, const vec2_t origin) { #if !defined EDUKE32_TOUCH_DEVICES if (!MOUSEACTIVECONDITION) - return; #endif + return; if (cm->menuID == MENU_MAIN) return;