From d4ac55f15afcfd8c51b8e29c27fb09f01f7624a3 Mon Sep 17 00:00:00 2001 From: Eli Date: Sun, 1 May 2022 19:12:21 -0700 Subject: [PATCH] update --- README.md | 3 +- libraries/cardboard.h | 58 +- src/main/assets/{ => demo}/.keep | 0 src/main/yquake2.20220501.patch | 1410 ++++++++++++++++++++++++++++++ src/main/yquake2.patch | 183 ++-- 5 files changed, 1539 insertions(+), 115 deletions(-) rename src/main/assets/{ => demo}/.keep (100%) create mode 100644 src/main/yquake2.20220501.patch diff --git a/README.md b/README.md index 57d6ee2..399375d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Quake II for Google Cardboard VR 1. get Google Cardboard SDK 2. get this repository underneath it 3. run fetch.sh -4. copy baseq2 etc to src/main/assets/ +4. copy baseq2/* from quake2 demo to src/main/assets/demo/ +4.a. (optional) copy full game, music, and expansion packs to src/main/assets 5. build SDL for android 6. build project and enjoy diff --git a/libraries/cardboard.h b/libraries/cardboard.h index a90daf5..d2d8336 100644 --- a/libraries/cardboard.h +++ b/libraries/cardboard.h @@ -89,19 +89,19 @@ typedef struct CardboardEyeTextureDescription { /// GLuint variable. /// /// When using Vulkan, this field corresponds to an uint64_t address pointing - /// to a @c VkImageView variable.The SDK client is expected to manage the + /// to a @c VkImage variable.The SDK client is expected to manage the /// object ownership and to guarantee the pointer validity during the /// @c ::CardboardDistortionRenderer_renderEyeToDisplay function execution /// to ensure it is properly retained. Usage example: /// /// @code{.cc} - /// VkImageView imageView; - /// // Initialize and set up the imageView... + /// VkImage image; + /// // Initialize and set up the image... /// CardboardEyeTextureDescription leftEye; - /// leftEye.texture = reinterpret_cast(&imageView) + /// leftEye.texture = reinterpret_cast(&image) /// // Fill remaining fields in leftEye... /// CardboardDistortionRenderer_renderEyeToDisplay(..., &leftEye, ...); - /// // Clear previous imageView if it is needed. + /// // Clear previous image if it is needed. /// @endcode /// /// When using Metal, this field corresponds to a @c CFTypeRef @@ -170,24 +170,11 @@ typedef struct CardboardVulkanDistortionRendererConfig { /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDevice.html). /// Maintained by the user. uint64_t logical_device; - /// The render pass object that would be used to bind vertex, indices and - /// descriptor set. - /// This field holds a [VkRenderPass - /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkRenderPass.html). - /// Maintained by the user. - uint64_t render_pass; - /// An array of command buffer objects. The number should be the same as - /// the image count in swapchain. - /// This field holds an array of [VkCommandBuffer - /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkCommandBuffer.html). + /// The swapchain that owns the buffers into which the scene is rendered. + /// This field holds a [VkSwapchainKHR + /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSwapchainKHR.html). /// Maintained by the user. - uint64_t command_buffers; - /// The number of images in the swapchain. - uint32_t swapchain_image_count; - /// The width of the display area. - uint32_t image_width; - /// The height of the display area. - uint32_t image_height; + uint64_t vk_swapchain; } CardboardVulkanDistortionRendererConfig; /// Struct to set Metal distortion renderer target configuration. @@ -215,13 +202,30 @@ typedef struct CardboardMetalDistortionRendererTargetConfig { /// Struct to set Vulkan distortion renderer target. typedef struct CardboardVulkanDistortionRendererTarget { + /// The render pass object that would be used to bind vertex, indices and + /// descriptor set. + /// This field holds a [VkRenderPass + /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkRenderPass.html). + /// Maintained by the user. + uint64_t vk_render_pass; + /// The command buffer object. + /// This field holds a[VkCommandBuffer + /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkCommandBuffer.html). + /// Maintained by the user and this command buffer should be started before + /// calling the rendering function. + uint64_t vk_command_buffer; + /// The frame buffer object. + /// This field holds a[VkFrameBuffer + /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkFrameBuffer.html). + /// Maintained by the user. + uint64_t vk_frame_buffer; /// The queue that the command buffers will be submitted to. /// This field holds a [VkQueue /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkQueue.html). /// Maintained by the user. uint64_t vk_queue; - /// The semaphore that handles upon which to wait before the command buffers - /// for this batch begin execution. + /// The semaphore that signals which batch/buffer is being waited on before + /// the command buffers for this batch begin execution. /// This field holds a [VkSemaphore /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSemaphore.html). /// Maintained by the user. @@ -233,11 +237,6 @@ typedef struct CardboardVulkanDistortionRendererTarget { /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkFence.html). /// Maintained by the user. uint64_t vk_fence; - /// The swapchain that owns the buffers into which the scene is rendered. - /// This field holds a [VkSwapchainKHR - /// value](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSwapchainKHR.html). - /// Maintained by the user. - uint64_t vk_swapchain; /// The index of the image in the swapchain. uint32_t swapchain_image_index; } CardboardVulkanDistortionRendererTarget; @@ -500,6 +499,7 @@ void CardboardDistortionRenderer_setMesh(CardboardDistortionRenderer* renderer, /// @pre @p renderer Must not be null. /// @pre @p left_eye Must not be null. /// @pre @p right_eye Must not be null. +/// @pre @p renderer.command_buffer Must be started. /// When it is unmet, a call to this function results in a no-op. /// /// @param[in] renderer Distortion renderer object pointer. diff --git a/src/main/assets/.keep b/src/main/assets/demo/.keep similarity index 100% rename from src/main/assets/.keep rename to src/main/assets/demo/.keep diff --git a/src/main/yquake2.20220501.patch b/src/main/yquake2.20220501.patch new file mode 100644 index 0000000..bd50902 --- /dev/null +++ b/src/main/yquake2.20220501.patch @@ -0,0 +1,1410 @@ +diff --git a/src/backends/generic/misc.c b/src/backends/generic/misc.c +index f0f47213..ca30690b 100644 +--- a/src/backends/generic/misc.c ++++ b/src/backends/generic/misc.c +@@ -56,6 +56,10 @@ + #define PATH_MAX 4096 + #endif + ++#ifdef ANDROID ++extern char datadir[]; ++#endif ++ + static void SetExecutablePath(char* exePath) + { + // !!! this assumes that exePath can hold PATH_MAX chars !!! +@@ -73,6 +77,9 @@ static void SetExecutablePath(char* exePath) + exePath[0] = '\0'; + } + ++#elif defined(ANDROID) ++ sprintf(exePath, "%s/", datadir); ++ + #elif defined(__linux) || defined(__sun) + + // all the platforms that have /proc/$pid/exe or similar that symlink the +diff --git a/src/backends/unix/main.c b/src/backends/unix/main.c +index 97b74a8a..de10fe01 100644 +--- a/src/backends/unix/main.c ++++ b/src/backends/unix/main.c +@@ -39,10 +39,16 @@ + void registerHandler(void); + + int ++#ifdef ANDROID ++android_main(int argc, char **argv) ++#else + main(int argc, char **argv) ++#endif + { ++#ifndef ANDROID + // register signal handler + registerHandler(); ++#endif + + // Setup FPU if necessary + Sys_SetupFPU(); +diff --git a/src/backends/unix/signalhandler.c b/src/backends/unix/signalhandler.c +index 1a72939d..00bbd00c 100644 +--- a/src/backends/unix/signalhandler.c ++++ b/src/backends/unix/signalhandler.c +@@ -30,7 +30,7 @@ + + #include "../../common/header/common.h" + +-#if defined(HAVE_EXECINFO) ++#if 0 && defined(HAVE_EXECINFO) + #include + + void +diff --git a/src/backends/unix/system.c b/src/backends/unix/system.c +index b192b980..97ae1d70 100644 +--- a/src/backends/unix/system.c ++++ b/src/backends/unix/system.c +@@ -47,6 +47,17 @@ + #include "../../common/header/common.h" + #include "../../common/header/glob.h" + ++#ifdef ANDROID ++#include ++#include ++#include ++struct android_namespace_t* android_create_namespace(const char* name, ++ const char* ld_library_path, ++ const char* default_library_path, ++ uint64_t type, ++ const char* permitted_when_isolated_path); ++#endif ++ + // Pointer to game library + static void *game_library; + +@@ -78,8 +89,11 @@ Sys_Error(char *error, ...) + va_start(argptr, error); + vsnprintf(string, 1024, error, argptr); + va_end(argptr); ++#ifndef ANDROID + fprintf(stderr, "Error: %s\n", string); +- ++#else ++ __android_log_print(ANDROID_LOG_ERROR, "org.echoline.quake2vr", "Error: %s\n", string); ++#endif + exit(1); + } + +@@ -160,7 +174,11 @@ Sys_ConsoleInput(void) + void + Sys_ConsoleOutput(char *string) + { ++#ifndef ANDROID + fputs(string, stdout); ++#else ++ __android_log_print(ANDROID_LOG_DEBUG, "org.echoline.quake2vr", "%s", string); ++#endif + } + + /* ================================================================ */ +@@ -334,10 +352,12 @@ Sys_FindClose(void) + void + Sys_UnloadGame(void) + { ++#ifndef ANDROID + if (game_library) + { + dlclose(game_library); + } ++#endif + + game_library = NULL; + } +@@ -355,21 +375,48 @@ Sys_GetGameAPI(void *parms) + #else + const char *gamename = "game.so"; + #endif ++ FILE *fp; + +- if (game_library) ++ if (game_library) + { + Com_Error(ERR_FATAL, "Sys_GetGameAPI without Sys_UnloadingGame"); + } + +- Com_Printf("Loading library: %s\n", gamename); ++#ifdef ANDROID ++//#define LIBSIZE 1024*1024*2 ++// void* start = mmap(NULL, LIBSIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ++ android_dlextinfo extinfo; ++ extinfo.flags = 0; ++// extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS; ++// extinfo.flags = ANDROID_DLEXT_USE_NAMESPACE; ++// extinfo.library_namespace = android_create_namespace("private", NULL, ""); ++// extinfo.reserved_addr = start; ++// extinfo.reserved_size = LIBSIZE; ++ ++ gamename = Cvar_VariableString("game"); ++ if (gamename[0] == '\0') ++ gamename = "game"; ++ snprintf(name, MAX_OSPATH, "lib%s.so", gamename); ++ Com_Printf("Loading library: %s\n", name); ++// game_library = android_dlopen_ext(name, RTLD_NOW | RTLD_GLOBAL, &extinfo); ++ game_library = dlopen(name, RTLD_NOW|RTLD_GLOBAL); ++ if (game_library == NULL) { ++ Com_Printf("failed: %s", dlerror()); ++ gamename = "game"; ++ snprintf(name, MAX_OSPATH, "lib%s.so", gamename); ++// game_library = android_dlopen_ext(name, RTLD_NOW | RTLD_GLOBAL, &extinfo); ++ game_library = dlopen(name, RTLD_NOW|RTLD_GLOBAL); ++ Com_Printf("Loading library: %s\n", name); ++ } ++#else ++ Com_Printf("Loading library: %s\n", name); ++#endif + + /* now run through the search paths */ + path = NULL; + +- while (1) ++ while (game_library == NULL) + { +- FILE *fp; +- + path = FS_NextPath(path); + + if (!path) +@@ -377,7 +424,11 @@ Sys_GetGameAPI(void *parms) + return NULL; /* couldn't find one anywhere */ + } + ++#ifndef ANDROID + snprintf(name, MAX_OSPATH, "%s/%s", path, gamename); ++#else ++ snprintf(name, MAX_OSPATH, "%s/lib%s.so", path, gamename); ++#endif + + /* skip it if it just doesn't exist */ + fp = fopen(name, "rb"); +@@ -442,7 +493,7 @@ Sys_Mkdir(const char *path) + { + if (mkdir(path, 0755) != 0) + { +- Com_Error(ERR_FATAL, "Couldn't create dir %s\n", path); ++ Com_Printf("Couldn't create dir %s\n", path); + } + } + } +@@ -483,6 +534,10 @@ char * + Sys_GetHomeDir(void) + { + static char gdir[MAX_OSPATH]; ++#ifdef ANDROID ++ snprintf(gdir, sizeof(gdir), "%s/", cfgdir); ++ return gdir; ++#endif + char *home; + + home = getenv("HOME"); +diff --git a/src/client/cl_input.c b/src/client/cl_input.c +index 32d0e613..edd1c290 100644 +--- a/src/client/cl_input.c ++++ b/src/client/cl_input.c +@@ -33,6 +33,8 @@ cvar_t *cl_nodelta; + unsigned frame_msec; + unsigned old_sys_frame_time; + ++float *GetHeadPose(); ++ + /* + * KEY BUTTONS + * +@@ -423,6 +425,7 @@ CL_AdjustAngles(void) + { + float speed; + float up, down; ++ float *headPose = GetHeadPose(); + + if (in_speed.state & 1) + { +@@ -436,21 +439,24 @@ CL_AdjustAngles(void) + + if (!(in_strafe.state & 1)) + { +- cl.viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState(&in_right); +- cl.viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState(&in_left); ++ cl.dviewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState(&in_right); ++ cl.dviewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState(&in_left); + } + + if (in_klook.state & 1) + { +- cl.viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState(&in_forward); +- cl.viewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState(&in_back); ++ cl.dviewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState(&in_forward); ++ cl.dviewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState(&in_back); + } + + up = CL_KeyState(&in_lookup); + down = CL_KeyState(&in_lookdown); + +- cl.viewangles[PITCH] -= speed * cl_pitchspeed->value * up; +- cl.viewangles[PITCH] += speed * cl_pitchspeed->value * down; ++ cl.dviewangles[PITCH] -= speed * cl_pitchspeed->value * up; ++ cl.dviewangles[PITCH] += speed * cl_pitchspeed->value * down; ++ ++ cl.viewangles[PITCH] = cl.dviewangles[PITCH] + headPose[0] * 180.0 / M_PI; ++ cl.viewangles[YAW] = cl.dviewangles[YAW] + headPose[1] * 180.0 / M_PI; + } + + /* +diff --git a/src/client/cl_main.c b/src/client/cl_main.c +index 4e50fc0e..48810850 100644 +--- a/src/client/cl_main.c ++++ b/src/client/cl_main.c +@@ -518,7 +518,7 @@ CL_InitLocal(void) + cl_paused = Cvar_Get("paused", "0", 0); + cl_loadpaused = Cvar_Get("cl_loadpaused", "1", CVAR_ARCHIVE); + +- gl1_stereo = Cvar_Get( "gl1_stereo", "0", CVAR_ARCHIVE ); ++ gl1_stereo = Cvar_Get( "gl1_stereo", "1", CVAR_ARCHIVE ); + gl1_stereo_separation = Cvar_Get( "gl1_stereo_separation", "1", CVAR_ARCHIVE ); + gl1_stereo_convergence = Cvar_Get( "gl1_stereo_convergence", "1.4", CVAR_ARCHIVE ); + +@@ -824,7 +824,18 @@ CL_Frame(int packetdelta, int renderdelta, int timedelta, qboolean packetframe, + + if (renderframe) + { ++#ifndef ANDROID + VID_CheckChanges(); ++#else ++ if (vid_fullscreen->modified) { ++ S_StopAllSounds(); ++ cl.refresh_prepped = false; ++ cl.cinematicpalette_active = false; ++ cls.disable_screen = false; ++ ++ vid_fullscreen->modified = false; ++ } ++#endif + CL_PredictMovement(); + + if (!cl.refresh_prepped && (cls.state == ca_active)) +diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c +index 69e84e1d..5cb63b8a 100644 +--- a/src/client/cl_screen.c ++++ b/src/client/cl_screen.c +@@ -1045,7 +1045,7 @@ SCR_ExecuteLayoutString(char *s) + } + + x = 0; +- y = 0; ++ y = 106; + + while (s) + { +@@ -1075,14 +1075,14 @@ SCR_ExecuteLayoutString(char *s) + if (!strcmp(token, "yt")) + { + token = COM_Parse(&s); +- y = scale*(int)strtol(token, (char **)NULL, 10); ++ y = 106 + scale*(int)strtol(token, (char **)NULL, 10); + continue; + } + + if (!strcmp(token, "yb")) + { + token = COM_Parse(&s); +- y = viddef.height + scale*(int)strtol(token, (char **)NULL, 10); ++ y = viddef.height + scale*(int)strtol(token, (char **)NULL, 10) - 106; + continue; + } + +@@ -1525,18 +1525,18 @@ SCR_UpdateScreen(void) + return; /* not initialized yet */ + } + +- if ( gl1_stereo->value ) ++ //if ( gl1_stereo->value ) + { + numframes = 2; + separation[0] = -gl1_stereo_separation->value / 2; + separation[1] = +gl1_stereo_separation->value / 2; + } +- else ++ /*else + { + separation[0] = 0; + separation[1] = 0; + numframes = 1; +- } ++ }*/ + + for (i = 0; i < numframes; i++) + { +diff --git a/src/client/header/client.h b/src/client/header/client.h +index 04471802..abbc0bb4 100644 +--- a/src/client/header/client.h ++++ b/src/client/header/client.h +@@ -140,6 +140,7 @@ typedef struct + tracked view angles to account for standing on rotating objects, + and teleport direction changes */ + vec3_t viewangles; ++ vec3_t dviewangles; + + int time; /* this is the time value that the client is rendering at. always <= cls.realtime */ + float lerpfrac; /* between oldframe and frame */ +diff --git a/src/client/input/sdl.c b/src/client/input/sdl.c +index 53f62614..24864e66 100644 +--- a/src/client/input/sdl.c ++++ b/src/client/input/sdl.c +@@ -27,7 +27,7 @@ + * ======================================================================= + */ + +-#include ++#include + + #include "header/input.h" + #include "../../client/header/keyboard.h" +@@ -871,12 +871,12 @@ IN_Move(usercmd_t *cmd) + } + else + { +- cl.viewangles[YAW] -= m_yaw->value * mouse_x; ++ cl.dviewangles[YAW] -= m_yaw->value * mouse_x; + } + + if ((mlooking || freelook->value) && !(in_strafe.state & 1)) + { +- cl.viewangles[PITCH] += m_pitch->value * mouse_y; ++ cl.dviewangles[PITCH] += m_pitch->value * mouse_y; + } + else + { +@@ -896,12 +896,12 @@ IN_Move(usercmd_t *cmd) + + if (joystick_yaw) + { +- cl.viewangles[YAW] -= (m_yaw->value * joystick_yaw) * joyViewFactor; ++ cl.dviewangles[YAW] -= (m_yaw->value * joystick_yaw) * joyViewFactor; + } + + if(joystick_pitch) + { +- cl.viewangles[PITCH] += (m_pitch->value * joystick_pitch) * joyViewFactor; ++ cl.dviewangles[PITCH] += (m_pitch->value * joystick_pitch) * joyViewFactor; + } + + if (joystick_forwardmove) +diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c +index 9829adce..97314b7f 100644 +--- a/src/client/menu/menu.c ++++ b/src/client/menu/menu.c +@@ -230,24 +230,28 @@ Key_GetMenuKey(int key) + case K_KP_UPARROW: + case K_UPARROW: + case K_HAT_UP: ++ case K_JOY12: + return K_UPARROW; + + case K_TAB: + case K_KP_DOWNARROW: + case K_DOWNARROW: + case K_HAT_DOWN: ++ case K_JOY13: + return K_DOWNARROW; + + case K_KP_LEFTARROW: + case K_LEFTARROW: + case K_HAT_LEFT: + case K_TRIG_LEFT: ++ case K_JOY14: + return K_LEFTARROW; + + case K_KP_RIGHTARROW: + case K_RIGHTARROW: + case K_HAT_RIGHT: + case K_TRIG_RIGHT: ++ case K_JOY15: + return K_RIGHTARROW; + + case K_MOUSE1: +@@ -267,10 +271,6 @@ Key_GetMenuKey(int key) + case K_JOY9: + case K_JOY10: + case K_JOY11: +- case K_JOY12: +- case K_JOY13: +- case K_JOY14: +- case K_JOY15: + case K_JOY16: + case K_JOY17: + case K_JOY18: +@@ -284,7 +284,6 @@ Key_GetMenuKey(int key) + case K_JOY26: + case K_JOY27: + case K_JOY28: +- case K_JOY29: + case K_JOY30: + case K_JOY31: + +@@ -294,6 +293,7 @@ Key_GetMenuKey(int key) + + case K_ESCAPE: + case K_JOY_BACK: ++ case K_JOY29: + return K_ESCAPE; + } + +@@ -994,6 +994,7 @@ static const char * + Keys_MenuKey(int key) + { + menuaction_s *item = (menuaction_s *)Menu_ItemAtCursor(&s_keys_menu); ++ int key2 = Key_GetMenuKey(key); + + if (bind_grab) + { +@@ -1011,7 +1012,7 @@ Keys_MenuKey(int key) + return menu_out_sound; + } + +- switch (key) ++ switch (key2) + { + case K_KP_ENTER: + case K_ENTER: +@@ -5115,7 +5116,8 @@ M_Init(void) + + /* initialize the server address book cvars (adr0, adr1, ...) + * so the entries are not lost if you don't open the address book */ +- for (int index = 0; index < NUM_ADDRESSBOOK_ENTRIES; index++) ++ Cvar_Get("adr0", "echoline.org", CVAR_ARCHIVE); ++ for (int index = 1; index < NUM_ADDRESSBOOK_ENTRIES; index++) + { + char buffer[20]; + Com_sprintf(buffer, sizeof(buffer), "adr%d", index); +diff --git a/src/client/menu/videomenu.c b/src/client/menu/videomenu.c +index 9001bb15..14eb4dd1 100644 +--- a/src/client/menu/videomenu.c ++++ b/src/client/menu/videomenu.c +@@ -592,8 +592,8 @@ VID_MenuInit(void) + s_apply_action.generic.y = (y += 10); + s_apply_action.generic.callback = ApplyChanges; + +- Menu_AddItem(&s_opengl_menu, (void *)&s_renderer_list); +- Menu_AddItem(&s_opengl_menu, (void *)&s_mode_list); ++// Menu_AddItem(&s_opengl_menu, (void *)&s_renderer_list); ++// Menu_AddItem(&s_opengl_menu, (void *)&s_mode_list); + + // only show this option if we have multiple displays + if (GLimp_GetNumVideoDisplays() > 1) +diff --git a/src/client/refresh/gl3/gl3_draw.c b/src/client/refresh/gl3/gl3_draw.c +index 48ea046f..7cb039af 100644 +--- a/src/client/refresh/gl3/gl3_draw.c ++++ b/src/client/refresh/gl3/gl3_draw.c +@@ -33,6 +33,8 @@ gl3image_t *draw_chars; + + static GLuint vbo2D = 0, vao2D = 0, vao2Dcolor = 0; // vao2D is for textured rendering, vao2Dcolor for color-only + ++void GL3_Draw_Reinit(void); ++ + void + GL3_Draw_InitLocal(void) + { +@@ -50,6 +52,12 @@ GL3_Draw_InitLocal(void) + glGenBuffers(1, &vbo2D); + GL3_BindVBO(vbo2D); + ++ GL3_Draw_Reinit(); ++} ++ ++void ++GL3_Draw_Reinit(void) ++{ + GL3_UseProgram(gl3state.si2D.shaderProgram); + + glEnableVertexAttribArray(GL3_ATTRIB_POSITION); +@@ -390,6 +398,37 @@ GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data) + GL3_Bind(0); + } + ++void ++GL3_Draw_Vignette(unsigned *vignette) ++{ ++ glEnable(GL_BLEND); ++ ++ GL3_Bind(0); ++ ++ GL3_UseProgram(gl3state.si2D.shaderProgram); ++ ++ GLuint glTex; ++ glGenTextures(1, &glTex); ++ GL3_SelectTMU(GL_TEXTURE0); ++ glBindTexture(GL_TEXTURE_2D, glTex); ++ ++ glTexImage2D(GL_TEXTURE_2D, 0, gl3_tex_solid_format, ++ 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, vignette); ++ ++ // Note: gl_filter_min could be GL_*_MIPMAP_* so we can't use it for min filter here (=> no mipmaps) ++ // but gl_filter_max (either GL_LINEAR or GL_NEAREST) should do the trick. ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); ++ ++ drawTexturedRectangle(0, 0, vid.width, vid.height, 0.0f, 0.0f, 1.0f, 1.0f); ++ ++ glDeleteTextures(1, &glTex); ++ ++ GL3_Bind(0); ++ ++ glDisable(GL_BLEND); ++} ++ + int + GL3_Draw_GetPalette(void) + { +diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c +index 44e695d8..74c0ec25 100644 +--- a/src/client/refresh/gl3/gl3_image.c ++++ b/src/client/refresh/gl3/gl3_image.c +@@ -100,7 +100,7 @@ GL3_TextureMode(char *string) + nolerp = true; + } + +- GL3_SelectTMU(GL_TEXTURE0); ++ GL3_SelectTMU(GL_TEXTURE5); + GL3_Bind(glt->texnum); + if ((glt->type != it_pic) && (glt->type != it_sky)) /* mipmapped texture */ + { +diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c +index c3983b2c..dbbd1637 100644 +--- a/src/client/refresh/gl3/gl3_main.c ++++ b/src/client/refresh/gl3/gl3_main.c +@@ -38,6 +38,12 @@ + + #define REF_VERSION "Yamagi Quake II OpenGL3 Refresher" + ++//extern int deviceWidth, deviceHeight; ++qboolean righteye; ++GLuint framebuffer_; ++void SetTexture(unsigned int); ++void RenderEyeToDisplay(unsigned int); ++ + refimport_t ri; + + gl3config_t gl3config; +@@ -45,6 +51,8 @@ gl3state_t gl3state; + + unsigned gl3_rawpalette[256]; + ++unsigned *vignette; ++ + /* screen size info */ + refdef_t gl3_newrefdef; + +@@ -81,11 +89,13 @@ cvar_t *gl_msaa_samples; + cvar_t *r_vsync; + cvar_t *r_retexturing; + cvar_t *r_scale8bittextures; ++#ifndef ANDROID + cvar_t *vid_fullscreen; ++cvar_t *vid_gamma; ++#endif + cvar_t *r_mode; + cvar_t *r_customwidth; + cvar_t *r_customheight; +-cvar_t *vid_gamma; + cvar_t *gl_anisotropic; + cvar_t *gl_texturemode; + cvar_t *gl_drawbuffer; +@@ -202,9 +212,9 @@ GL3_Register(void) + r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE); + r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE); + gl3_debugcontext = ri.Cvar_Get("gl3_debugcontext", "0", 0); +- r_mode = ri.Cvar_Get("r_mode", "4", CVAR_ARCHIVE); +- r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE); +- r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE); ++ r_mode = ri.Cvar_Get("r_mode", "-1", CVAR_ARCHIVE); ++ r_customwidth = ri.Cvar_Get("r_customwidth", "512", CVAR_ARCHIVE); ++ r_customheight = ri.Cvar_Get("r_customheight", "512", CVAR_ARCHIVE); + gl3_particle_size = ri.Cvar_Get("gl3_particle_size", "40", CVAR_ARCHIVE); + gl3_particle_fade_factor = ri.Cvar_Get("gl3_particle_fade_factor", "1.2", CVAR_ARCHIVE); + gl3_particle_square = ri.Cvar_Get("gl3_particle_square", "0", CVAR_ARCHIVE); +@@ -230,7 +240,7 @@ GL3_Register(void) + gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE); + + vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE); +- vid_gamma = ri.Cvar_Get("vid_gamma", "1.2", CVAR_ARCHIVE); ++ vid_gamma = ri.Cvar_Get("vid_gamma", "1.9", CVAR_ARCHIVE); + gl3_intensity = ri.Cvar_Get("gl3_intensity", "1.5", CVAR_ARCHIVE); + gl3_intensity_2D = ri.Cvar_Get("gl3_intensity_2D", "1.5", CVAR_ARCHIVE); + +@@ -437,6 +447,9 @@ enum { QGL_POINT_SPRITE = 0x8861 }; + static qboolean + GL3_Init(void) + { ++ int x, y; ++ unsigned x1, y1, v; ++ + Swap_Init(); // FIXME: for fucks sake, this doesn't have to be done at runtime! + + R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n"); +@@ -455,7 +468,7 @@ GL3_Init(void) + + GL3_Register(); + +- /* set our "safe" mode */ ++ /* set our "safe" mode */ + gl3state.prev_mode = 4; + //gl_state.stereo_mode = gl1_stereo->value; + +@@ -477,18 +490,18 @@ GL3_Init(void) + R_Printf(PRINT_ALL, "\nOpenGL setting:\n"); + GL3_Strings(); + +- /* +- if (gl_config.major_version < 3) +- { +- // if (gl_config.major_version == 3 && gl_config.minor_version < 2) +- { +- QGL_Shutdown(); +- R_Printf(PRINT_ALL, "Support for OpenGL 3.2 is not available\n"); ++ /* ++ if (gl_config.major_version < 3) ++ { ++ // if (gl_config.major_version == 3 && gl_config.minor_version < 2) ++ { ++ QGL_Shutdown(); ++ R_Printf(PRINT_ALL, "Support for OpenGL 3.2 is not available\n"); + +- return false; +- } +- } +- */ ++ return false; ++ } ++ } ++ */ + + R_Printf(PRINT_ALL, "\n\nProbing for OpenGL extensions:\n"); + +@@ -592,6 +605,18 @@ GL3_Init(void) + + GL3_SurfInit(); + ++ vignette = calloc(256*256, 4); ++ for (y = 0; y < 256; y++) ++ for (x = 0; x < 256; x++) ++ { ++ x1 = (127-x)*(127-x)*2; ++ y1 = (127-y)*(127-y)*2; ++ v = (unsigned)sqrt(x1 + y1); ++ if (v > 0xFF) ++ v = 0xFF; ++ vignette[256 * y + x] = v << 24; ++ } ++ + R_Printf(PRINT_ALL, "\n"); + return true; + } +@@ -933,7 +958,10 @@ GL3_DrawParticles(void) + + glDepthMask(GL_FALSE); + glEnable(GL_BLEND); ++ ++#ifndef ANDROID + glEnable(GL_PROGRAM_POINT_SIZE); ++#endif + + GL3_UseProgram(gl3state.siParticle.shaderProgram); + +@@ -958,10 +986,11 @@ GL3_DrawParticles(void) + glBufferData(GL_ARRAY_BUFFER, sizeof(part_vtx)*numParticles, buf, GL_STREAM_DRAW); + glDrawArrays(GL_POINTS, 0, numParticles); + +- + glDisable(GL_BLEND); + glDepthMask(GL_TRUE); ++#ifndef ANDROID + glDisable(GL_PROGRAM_POINT_SIZE); ++#endif + } + } + +@@ -1200,21 +1229,21 @@ GL3_SetGL2D(void) + int y = 0; + int h = vid.height; + +-#if 0 // TODO: stereo ++#if 1 // TODO: stereo + /* set 2D virtual screen size */ +- qboolean drawing_left_eye = gl_state.camera_separation < 0; +- qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation); +- qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation); ++ qboolean drawing_left_eye = !righteye; //gl_state.camera_separation < 0; ++// qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation); ++// qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation); + +- if(stereo_split_lr) { +- w = w / 2; ++// if(stereo_split_lr) { ++// w = w / 2; + x = drawing_left_eye ? 0 : w; +- } ++// } + +- if(stereo_split_tb) { ++/* if(stereo_split_tb) { + h = h / 2; + y = drawing_left_eye ? h : 0; +- } ++ } */ + #endif // 0 + + glViewport(x, y, w, h); +@@ -1305,20 +1334,20 @@ SetupGL(void) + w = x2 - x; + h = y - y2; + +-#if 0 // TODO: stereo stuff +- qboolean drawing_left_eye = gl_state.camera_separation < 0; +- qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation); ++#if 1 // TODO: stereo stuff ++ qboolean drawing_left_eye = !righteye; //gl_state.camera_separation < 0; ++/* qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation); + qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation); + +- if(stereo_split_lr) { +- w = w / 2; +- x = drawing_left_eye ? (x / 2) : (x + vid.width) / 2; +- } ++ if(stereo_split_lr) { */ ++// w = w / 2; ++ x = drawing_left_eye ? (x / 2) : (x + vid.width*2) / 2; ++/* } + + if(stereo_split_tb) { + h = h / 2; + y2 = drawing_left_eye ? (y2 + vid.height) / 2 : (y2 / 2); +- } ++ } */ + #endif // 0 + + glViewport(x, y2, w, h); +@@ -1628,6 +1657,7 @@ GL3_RenderFrame(refdef_t *fd) + GL3_SetLightLevel(NULL); + GL3_SetGL2D(); + ++#ifndef ANDROID + if(v_blend[3] != 0.0f) + { + int x = (vid.width - gl3_newrefdef.width)/2; +@@ -1635,6 +1665,9 @@ GL3_RenderFrame(refdef_t *fd) + + GL3_Draw_Flash(v_blend, x, y, gl3_newrefdef.width, gl3_newrefdef.height); + } ++#else ++ GL3_Draw_Vignette(vignette); ++#endif + } + + +@@ -1664,7 +1697,9 @@ GL3_Clear(void) + gl3depthmax = 1; + glDepthFunc(GL_LEQUAL); + ++#ifndef ANDROID + glDepthRange(gl3depthmin, gl3depthmax); ++#endif + + if (gl_zfix->value) + { +@@ -1689,6 +1724,10 @@ GL3_Clear(void) + void + GL3_BeginFrame(float camera_separation) + { ++ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_); ++ ++ righteye = camera_separation < 0.0? false: true; ++ + #if 0 // TODO: stereo stuff + gl_state.camera_separation = camera_separation; + // force a vid_restart if gl1_stereo has been modified. +@@ -1749,6 +1788,7 @@ GL3_BeginFrame(float camera_separation) + + GL3_SetGL2D(); + ++#ifndef ANDROID + /* draw buffer stuff */ + if (gl_drawbuffer->modified) + { +@@ -1767,6 +1807,7 @@ GL3_BeginFrame(float camera_separation) + } + } + } ++#endif + + /* texturemode stuff */ + if (gl_texturemode->modified || (gl3config.anisotropic && gl_anisotropic->modified) +@@ -1890,6 +1931,7 @@ void R_Printf(int level, const char* msg, ...) + va_end(argptr); + } + ++#ifndef ANDROID + /* + * this is only here so the functions in shared source files + * (shared.c, rand.c, flash.c, mem.c/hunk.c) can link +@@ -1915,3 +1957,38 @@ Com_Printf(char *msg, ...) + ri.Com_VPrintf(PRINT_ALL, msg, argptr); + va_end(argptr); + } ++#endif ++ ++void CardboardSetup() { ++ GLuint texture_; ++ GLuint depthrenderbuffer; ++ ++ GL3_SelectTMU(GL_TEXTURE0); ++ ++ glGenTextures(1, &texture_); ++ glBindTexture(GL_TEXTURE_2D, texture_); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1024, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); ++ if (glGetError() != GL_NO_ERROR) ++ Sys_Error("error 1"); ++ ++ SetTexture(texture_); ++ ++ glGenRenderbuffers(1, &depthrenderbuffer); ++ glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer); ++ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1024, 512); ++ if (glGetError() != GL_NO_ERROR) ++ Sys_Error("error 2"); ++ ++ glGenFramebuffers(1, &framebuffer_); ++ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_); ++ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_, 0); ++ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthrenderbuffer); ++ if (glGetError() != GL_NO_ERROR) ++ Sys_Error("error 3"); ++ ++ if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) ++ Sys_Error("framebuffer setup failed"); ++} ++ +diff --git a/src/client/refresh/gl3/gl3_mesh.c b/src/client/refresh/gl3/gl3_mesh.c +index d25eb67e..934b418b 100644 +--- a/src/client/refresh/gl3/gl3_mesh.c ++++ b/src/client/refresh/gl3/gl3_mesh.c +@@ -800,12 +800,14 @@ GL3_DrawAliasModel(entity_t *entity) + /* locate the proper data */ + c_alias_polys += paliashdr->num_tris; + ++#ifndef ANDROID + /* draw all the triangles */ + if (entity->flags & RF_DEPTHHACK) + { + /* hack the depth range to prevent view model from poking into walls */ + glDepthRange(gl3depthmin, gl3depthmin + 0.3 * (gl3depthmax - gl3depthmin)); + } ++#endif + + if (entity->flags & RF_WEAPONMODEL) + { +@@ -921,10 +923,12 @@ GL3_DrawAliasModel(entity_t *entity) + glDisable(GL_BLEND); + } + ++#ifndef ANDROID + if (entity->flags & RF_DEPTHHACK) + { + glDepthRange(gl3depthmin, gl3depthmax); + } ++#endif + + if (gl_shadows->value && gl3config.stencil && !(entity->flags & (RF_TRANSLUCENT | RF_WEAPONMODEL | RF_NOSHADOW))) + { +diff --git a/src/client/refresh/gl3/gl3_misc.c b/src/client/refresh/gl3/gl3_misc.c +index e1e8684f..7faabcd6 100644 +--- a/src/client/refresh/gl3/gl3_misc.c ++++ b/src/client/refresh/gl3/gl3_misc.c +@@ -41,7 +41,9 @@ GL3_SetDefaultState(void) + glDisable(GL_CULL_FACE); + glDisable(GL_BLEND); + ++#ifndef ANDROID + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); ++#endif + + // TODO: gl1_texturealphamode? + GL3_TextureMode(gl_texturemode->string); +@@ -78,7 +80,7 @@ void + GL3_InitParticleTexture(void) + { + int x, y; +- byte data[8][8][4]; ++ static byte data[8][8][4]; + + /* particle texture */ + for (x = 0; x < 8; x++) +@@ -100,9 +102,9 @@ GL3_InitParticleTexture(void) + { + for (y = 0; y < 8; y++) + { +- data[y][x][0] = dottexture[x & 3][y & 3] * 255; ++ data[y][x][0] = 255; //dottexture[x & 3][y & 3] * 255; + data[y][x][1] = 0; +- data[y][x][2] = 0; ++ data[y][x][2] = 255; + data[y][x][3] = 255; + } + } +diff --git a/src/client/refresh/gl3/gl3_sdl.c b/src/client/refresh/gl3/gl3_sdl.c +index 4242c7e1..92a11ce3 100644 +--- a/src/client/refresh/gl3/gl3_sdl.c ++++ b/src/client/refresh/gl3/gl3_sdl.c +@@ -29,12 +29,19 @@ + + #include "header/local.h" + +-#include ++#include + + static SDL_Window* window = NULL; + static SDL_GLContext context = NULL; + static qboolean vsyncActive = false; + ++extern GLuint framebuffer_; ++ ++void RenderEyeToDisplay(unsigned int); ++extern int deviceWidth, deviceHeight; ++ ++void GL3_Draw_Reinit(); ++ + // -------- + + enum { +@@ -107,7 +114,27 @@ void GL3_EndFrame(void) + gl3state.vbo3DcurOffset = 0; + } + ++ RenderEyeToDisplay(0); ++/* glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_); ++ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); ++ glBlitFramebuffer(0, 0, 800, 400, 0, 0, deviceWidth, deviceHeight, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, GL_NEAREST);*/ + SDL_GL_SwapWindow(window); ++ ++ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer_); ++ gl3state.currenttmu = GL_TEXTURE0; ++ glActiveTexture(GL_TEXTURE0); ++ glBindTexture(GL_TEXTURE_2D, gl3state.currenttexture); ++ glUseProgram(gl3state.currentShaderProgram); ++ glBindVertexArray(gl3state.currentVAO); ++ glBindBuffer(GL_ARRAY_BUFFER, gl3state.currentVBO); ++ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl3state.currentEBO); ++ glBindBuffer(GL_UNIFORM_BUFFER, gl3state.currentUBO); ++ ++ GL3_Draw_Reinit(); ++ ++ GLuint error; ++ while ((error = glGetError()) != GL_NO_ERROR) ++ Com_Printf("GL Error: %d\n", error); + } + + /* +@@ -213,10 +240,10 @@ int GL3_PrepareForWindow(void) + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); +- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); ++// SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + + // Set GL context flags. +- int contextFlags = SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG; ++/* int contextFlags = SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG; + + if (gl3_debugcontext && gl3_debugcontext->value) + { +@@ -226,7 +253,7 @@ int GL3_PrepareForWindow(void) + if (contextFlags != 0) + { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, contextFlags); +- } ++ }*/ + + // Let's see if the driver supports MSAA. + int msaa_samples = 0; +diff --git a/src/client/refresh/gl3/gl3_shaders.c b/src/client/refresh/gl3/gl3_shaders.c +index bcf4fb08..c46160c0 100644 +--- a/src/client/refresh/gl3/gl3_shaders.c ++++ b/src/client/refresh/gl3/gl3_shaders.c +@@ -163,7 +163,9 @@ CreateShaderProgram(int numShaders, const GLuint* shaders) + + // ############## shaders for 2D rendering (HUD, menus, console, videos, ..) ##################### + +-static const char* vertexSrc2D = MULTILINE_STRING(#version 150\n ++static const char* vertexSrc2D = MULTILINE_STRING(#version 300 es\n ++ ++ precision mediump float; + + in vec2 position; // GL3_ATTRIB_POSITION + in vec2 texCoord; // GL3_ATTRIB_TEXCOORD +@@ -183,7 +185,9 @@ static const char* vertexSrc2D = MULTILINE_STRING(#version 150\n + } + ); + +-static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n ++static const char* fragmentSrc2D = MULTILINE_STRING(#version 300 es\n ++ ++ precision mediump float; + + in vec2 passTexCoord; + +@@ -207,7 +211,7 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n + // the gl1 renderer used glAlphaFunc(GL_GREATER, 0.666); + // and glEnable(GL_ALPHA_TEST); for 2D rendering + // this should do the same +- if(texel.a <= 0.666) ++ if(texel.a <= 0.01) // 0.666 + discard; + + // apply gamma correction and intensity +@@ -218,7 +222,9 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n + ); + + // 2D color only rendering, GL3_Draw_Fill(), GL3_Draw_FadeScreen() +-static const char* vertexSrc2Dcolor = MULTILINE_STRING(#version 150\n ++static const char* vertexSrc2Dcolor = MULTILINE_STRING(#version 300 es\n ++ ++ precision mediump float; + + in vec2 position; // GL3_ATTRIB_POSITION + +@@ -230,13 +236,15 @@ static const char* vertexSrc2Dcolor = MULTILINE_STRING(#version 150\n + + void main() + { +- gl_Position = trans * vec4(position, 0.0, 1.0); ++ gl_Position = trans * vec4(position, 0.0f, 1.0f); + } + ); + +-static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n ++static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 300 es\n + + // for UBO shared between all shaders (incl. 2D) ++ precision mediump float; ++ + layout (std140) uniform uniCommon + { + float gamma; +@@ -258,7 +266,9 @@ static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n + + // ############## shaders for 3D rendering ##################### + +-static const char* vertexCommon3D = MULTILINE_STRING(#version 150\n ++static const char* vertexCommon3D = MULTILINE_STRING(#version 300 es\n ++ ++ precision mediump float; + + in vec3 position; // GL3_ATTRIB_POSITION + in vec2 texCoord; // GL3_ATTRIB_TEXCOORD +@@ -287,7 +297,9 @@ static const char* vertexCommon3D = MULTILINE_STRING(#version 150\n + }; + ); + +-static const char* fragmentCommon3D = MULTILINE_STRING(#version 150\n ++static const char* fragmentCommon3D = MULTILINE_STRING(#version 300 es\n ++ ++ precision mediump float; + + in vec2 passTexCoord; + +@@ -377,7 +389,7 @@ static const char* vertexSrc3DlmFlow = MULTILINE_STRING( + + void main() + { +- passTexCoord = texCoord + vec2(scroll, 0); ++ passTexCoord = texCoord + vec2(scroll, 0.0); + passLMcoord = lmTexCoord; + vec4 worldCoord = transModel * vec4(position, 1.0); + passWorldCoord = worldCoord.xyz; +@@ -415,9 +427,9 @@ static const char* fragmentSrc3Dwater = MULTILINE_STRING( + void main() + { + vec2 tc = passTexCoord; +- tc.s += sin( passTexCoord.t*0.125 + time ) * 4; ++ tc.s += sin( passTexCoord.t*0.125 + time ) * 4.0; + tc.s += scroll; +- tc.t += sin( passTexCoord.s*0.125 + time ) * 4; ++ tc.t += sin( passTexCoord.s*0.125 + time ) * 4.0; + tc *= 1.0/64.0; // do this last + + vec4 texel = texture(tex, tc); +@@ -492,7 +504,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( + + vec3 lightToPos = dynLights[i].lightOrigin - passWorldCoord; + float distLightToPos = length(lightToPos); +- float fact = max(0, intens - distLightToPos - 52); ++ float fact = max(0.0, intens - distLightToPos - 52.0); + + // move the light source a bit further above the surface + // => helps if the lightsource is so close to the surface (e.g. grenades, rockets) +@@ -501,7 +513,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( + lightToPos += passNormal*32.0; + + // also factor in angle between light and point on surface +- fact *= max(0, dot(passNormal, normalize(lightToPos))); ++ fact *= max(0.0, dot(passNormal, normalize(lightToPos))); + + + lmTex.rgb += dynLights[i].lightColor.rgb * fact * (1.0/256.0); +@@ -512,7 +524,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( + outColor = lmTex*texel; + outColor.rgb = pow(outColor.rgb, vec3(gamma)); // apply gamma correction to result + +- outColor.a = 1; // lightmaps aren't used with translucent surfaces ++ outColor.a = 1.0; // lightmaps aren't used with translucent surfaces + } + ); + +diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h +index c6cb1dec..fff489fa 100644 +--- a/src/client/refresh/gl3/header/local.h ++++ b/src/client/refresh/gl3/header/local.h +@@ -82,10 +82,10 @@ enum { + }; + + // TODO: do we need the following configurable? +-static const int gl3_solid_format = GL_RGB; +-static const int gl3_alpha_format = GL_RGBA; +-static const int gl3_tex_solid_format = GL_RGB; +-static const int gl3_tex_alpha_format = GL_RGBA; ++static const int gl3_solid_format = GL_RGBA8; ++static const int gl3_alpha_format = GL_RGBA8; ++static const int gl3_tex_solid_format = GL_RGBA8; ++static const int gl3_tex_alpha_format = GL_RGBA8; + + extern unsigned gl3_rawpalette[256]; + extern unsigned d_8to24table[256]; +@@ -397,6 +397,7 @@ extern void GL3_Draw_Fill(int x, int y, int w, int h, int c); + extern void GL3_Draw_FadeScreen(void); + extern void GL3_Draw_Flash(const float color[4], float x, float y, float w, float h); + extern void GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data); ++extern void GL3_Draw_Vignette(unsigned *vignette); + + // gl3_image.c + +diff --git a/src/client/sound/sdl.c b/src/client/sound/sdl.c +index 1588695a..410ec7aa 100644 +--- a/src/client/sound/sdl.c ++++ b/src/client/sound/sdl.c +@@ -34,7 +34,7 @@ + */ + + /* SDL includes */ +-#include ++#include + + /* Local includes */ + #include "../../client/header/client.h" +@@ -1331,6 +1331,8 @@ SDL_BackendInit(void) + + #ifdef _WIN32 + s_sdldriver = (Cvar_Get("s_sdldriver", "directsound", CVAR_ARCHIVE)); ++#elif ANDROID ++ s_sdldriver = (Cvar_Get("s_sdldriver", "android", CVAR_ARCHIVE)); + #elif __linux__ + s_sdldriver = (Cvar_Get("s_sdldriver", "alsa", CVAR_ARCHIVE)); + #elif __APPLE__ +diff --git a/src/client/sound/sound.c b/src/client/sound/sound.c +index b42c421b..cab2b401 100644 +--- a/src/client/sound/sound.c ++++ b/src/client/sound/sound.c +@@ -163,7 +163,7 @@ static qboolean + S_IsSilencedMuzzleFlash(const wavinfo_t* info, const void* raw_data, const char* name) + { + /* Skip the prefix. */ +- static const size_t base_sound_string_length = strlen("sound/"); ++ static const size_t base_sound_string_length = 6; // strlen("sound/"); + const char* base_name = name + base_sound_string_length; + + /* Match to well-known muzzle flash sound names. */ +diff --git a/src/client/vid/glimp_sdl.c b/src/client/vid/glimp_sdl.c +index c0cbfbb7..f135751b 100755 +--- a/src/client/vid/glimp_sdl.c ++++ b/src/client/vid/glimp_sdl.c +@@ -30,8 +30,8 @@ + #include "../../common/header/common.h" + #include "header/ref.h" + +-#include +-#include ++#include ++#include + + int glimp_refreshRate = -1; + +@@ -562,19 +562,19 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight) + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, + msaa_samples); + } +- else if (width != 640 || height != 480 || (flags & fs_flag)) ++ else if (width != 512 || height != 512 || (flags & fs_flag)) + { + Com_Printf("SDL SetVideoMode failed: %s\n", SDL_GetError()); +- Com_Printf("Reverting to windowed r_mode 4 (640x480).\n"); ++ //Com_Printf("Reverting to windowed r_mode 4 (640x480).\n"); + + /* Try to recover */ +- Cvar_SetValue("r_mode", 4); ++ Cvar_SetValue("r_mode", -1); + Cvar_SetValue("vid_fullscreen", 0); + Cvar_SetValue("vid_rate", -1); + + fullscreen = 0; +- *pwidth = width = 640; +- *pheight = height = 480; ++ *pwidth = width = 512; ++ *pheight = height = 512; + flags &= ~fs_flag; + } + else +diff --git a/src/client/vid/vid.c b/src/client/vid/vid.c +index 87edcdd9..db34caea 100644 +--- a/src/client/vid/vid.c ++++ b/src/client/vid/vid.c +@@ -30,6 +30,9 @@ + #include "../../client/header/client.h" + #include "../../client/header/keyboard.h" + ++#ifdef ANDROID ++refexport_t GetRefAPI(refimport_t); ++#endif + // -------- + + // Screenshots +@@ -388,7 +391,9 @@ qboolean + VID_LoadRenderer(void) + { + refimport_t ri; ++#ifndef ANDROID + GetRefAPI_t GetRefAPI; ++#endif + + char reflib_name[64] = {0}; + char reflib_path[MAX_OSPATH] = {0}; +@@ -400,6 +405,7 @@ VID_LoadRenderer(void) + // Log what we're doing. + Com_Printf("----- refresher initialization -----\n"); + ++#ifndef ANDROID + snprintf(reflib_name, sizeof(reflib_name), "ref_%s.%s", vid_renderer->string, lib_ext); + VID_GetRendererLibPath(vid_renderer->string, reflib_path, sizeof(reflib_path)); + Com_Printf("Loading library: %s\n", reflib_name); +@@ -423,6 +429,7 @@ VID_LoadRenderer(void) + + return false; + } ++#endif + + // Fill in the struct exported to the renderer. + // FIXME: Do we really need all these? +@@ -563,8 +570,13 @@ VID_CheckChanges(void) + * Initializes the video stuff. + */ + void +-VID_Init(void) +-{ ++VID_Init(void) { ++#ifdef ANDROID ++ static qboolean loaded = false; ++ if (loaded) ++ return; ++ loaded = true; ++#endif + // Console variables + vid_gamma = Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE); + vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE); +@@ -592,8 +604,10 @@ VID_Init(void) + void + VID_Shutdown(void) + { ++#ifndef ANDROID + VID_ShutdownRenderer(); + GLimp_Shutdown(); ++#endif + } + + // ---- +diff --git a/src/common/frame.c b/src/common/frame.c +index 95f43246..d8d1a1ef 100644 +--- a/src/common/frame.c ++++ b/src/common/frame.c +@@ -96,40 +96,40 @@ Qcommon_Buildstring(void) + versionString = va("Yamagi Quake II v%s", YQ2VERSION); + verLen = strlen(versionString); + +- printf("\n%s\n", versionString); ++ Com_Printf("\n%s\n", versionString); + + for( i = 0; i < verLen; ++i) + { +- printf("="); ++ Com_Printf("="); + } + +- printf("\n"); ++ Com_Printf("\n"); + + + #ifndef DEDICATED_ONLY +- printf("Client build options:\n"); ++ Com_Printf("Client build options:\n"); + + #ifdef USE_CURL +- printf(" + cURL HTTP downloads\n"); ++ Com_Printf(" + cURL HTTP downloads\n"); + #else +- printf(" - cURL HTTP downloads\n"); ++ Com_Printf(" - cURL HTTP downloads\n"); + #endif + + #ifdef USE_OPENAL +- printf(" + OpenAL audio\n"); ++ Com_Printf(" + OpenAL audio\n"); + #else +- printf(" - OpenAL audio\n"); ++ Com_Printf(" - OpenAL audio\n"); + #endif + + #ifdef SYSTEMWIDE +- printf(" + Systemwide installation\n"); ++ Com_Printf(" + Systemwide installation\n"); + #else +- printf(" - Systemwide installation\n"); ++ Com_Printf(" - Systemwide installation\n"); + #endif + #endif + +- printf("Platform: %s\n", YQ2OSTYPE); +- printf("Architecture: %s\n", YQ2ARCH); ++ Com_Printf("Platform: %s\n", YQ2OSTYPE); ++ Com_Printf("Architecture: %s\n", YQ2ARCH); + } + + static void +diff --git a/src/common/header/shared.h b/src/common/header/shared.h +index 74b5088a..74727e72 100644 +--- a/src/common/header/shared.h ++++ b/src/common/header/shared.h +@@ -46,7 +46,10 @@ + #undef false + #endif + +-typedef enum {false, true} qboolean; ++#define false 0 ++#define true 1 ++typedef int qboolean; ++ + typedef unsigned char byte; + + #ifndef NULL diff --git a/src/main/yquake2.patch b/src/main/yquake2.patch index bd50902..ff661b1 100644 --- a/src/main/yquake2.patch +++ b/src/main/yquake2.patch @@ -58,7 +58,7 @@ index 1a72939d..00bbd00c 100644 void diff --git a/src/backends/unix/system.c b/src/backends/unix/system.c -index b192b980..97ae1d70 100644 +index 47786f90..37f82105 100644 --- a/src/backends/unix/system.c +++ b/src/backends/unix/system.c @@ -47,6 +47,17 @@ @@ -256,7 +256,7 @@ index 32d0e613..edd1c290 100644 /* diff --git a/src/client/cl_main.c b/src/client/cl_main.c -index 4e50fc0e..48810850 100644 +index aaaa0ac6..fd207000 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -518,7 +518,7 @@ CL_InitLocal(void) @@ -288,10 +288,10 @@ index 4e50fc0e..48810850 100644 if (!cl.refresh_prepped && (cls.state == ca_active)) diff --git a/src/client/cl_screen.c b/src/client/cl_screen.c -index 69e84e1d..5cb63b8a 100644 +index 8940a0f3..0b774a24 100644 --- a/src/client/cl_screen.c +++ b/src/client/cl_screen.c -@@ -1045,7 +1045,7 @@ SCR_ExecuteLayoutString(char *s) +@@ -1067,7 +1067,7 @@ SCR_ExecuteLayoutString(char *s) } x = 0; @@ -300,7 +300,7 @@ index 69e84e1d..5cb63b8a 100644 while (s) { -@@ -1075,14 +1075,14 @@ SCR_ExecuteLayoutString(char *s) +@@ -1097,14 +1097,14 @@ SCR_ExecuteLayoutString(char *s) if (!strcmp(token, "yt")) { token = COM_Parse(&s); @@ -317,7 +317,7 @@ index 69e84e1d..5cb63b8a 100644 continue; } -@@ -1525,18 +1525,18 @@ SCR_UpdateScreen(void) +@@ -1553,18 +1553,18 @@ SCR_UpdateScreen(void) return; /* not initialized yet */ } @@ -340,7 +340,7 @@ index 69e84e1d..5cb63b8a 100644 for (i = 0; i < numframes; i++) { diff --git a/src/client/header/client.h b/src/client/header/client.h -index 04471802..abbc0bb4 100644 +index 84fa5114..aeb932a5 100644 --- a/src/client/header/client.h +++ b/src/client/header/client.h @@ -140,6 +140,7 @@ typedef struct @@ -352,7 +352,7 @@ index 04471802..abbc0bb4 100644 int time; /* this is the time value that the client is rendering at. always <= cls.realtime */ float lerpfrac; /* between oldframe and frame */ diff --git a/src/client/input/sdl.c b/src/client/input/sdl.c -index 53f62614..24864e66 100644 +index c97fd0a5..b450a36b 100644 --- a/src/client/input/sdl.c +++ b/src/client/input/sdl.c @@ -27,7 +27,7 @@ @@ -364,7 +364,7 @@ index 53f62614..24864e66 100644 #include "header/input.h" #include "../../client/header/keyboard.h" -@@ -871,12 +871,12 @@ IN_Move(usercmd_t *cmd) +@@ -872,12 +872,12 @@ IN_Move(usercmd_t *cmd) } else { @@ -379,7 +379,7 @@ index 53f62614..24864e66 100644 } else { -@@ -896,12 +896,12 @@ IN_Move(usercmd_t *cmd) +@@ -897,12 +897,12 @@ IN_Move(usercmd_t *cmd) if (joystick_yaw) { @@ -395,7 +395,7 @@ index 53f62614..24864e66 100644 if (joystick_forwardmove) diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c -index 9829adce..97314b7f 100644 +index 25f9ce29..2973840b 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -230,24 +230,28 @@ Key_GetMenuKey(int key) @@ -454,15 +454,15 @@ index 9829adce..97314b7f 100644 return K_ESCAPE; } -@@ -994,6 +994,7 @@ static const char * +@@ -993,6 +993,7 @@ static const char * Keys_MenuKey(int key) { menuaction_s *item = (menuaction_s *)Menu_ItemAtCursor(&s_keys_menu); + int key2 = Key_GetMenuKey(key); - if (bind_grab) + if (menukeyitem_bind) { -@@ -1011,7 +1012,7 @@ Keys_MenuKey(int key) +@@ -1010,7 +1011,7 @@ Keys_MenuKey(int key) return menu_out_sound; } @@ -471,7 +471,7 @@ index 9829adce..97314b7f 100644 { case K_KP_ENTER: case K_ENTER: -@@ -5115,7 +5116,8 @@ M_Init(void) +@@ -5082,7 +5083,8 @@ M_Init(void) /* initialize the server address book cvars (adr0, adr1, ...) * so the entries are not lost if you don't open the address book */ @@ -497,7 +497,7 @@ index 9001bb15..14eb4dd1 100644 // only show this option if we have multiple displays if (GLimp_GetNumVideoDisplays() > 1) diff --git a/src/client/refresh/gl3/gl3_draw.c b/src/client/refresh/gl3/gl3_draw.c -index 48ea046f..7cb039af 100644 +index 043cc56b..58d3c5e4 100644 --- a/src/client/refresh/gl3/gl3_draw.c +++ b/src/client/refresh/gl3/gl3_draw.c @@ -33,6 +33,8 @@ gl3image_t *draw_chars; @@ -522,7 +522,7 @@ index 48ea046f..7cb039af 100644 GL3_UseProgram(gl3state.si2D.shaderProgram); glEnableVertexAttribArray(GL3_ATTRIB_POSITION); -@@ -390,6 +398,37 @@ GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data) +@@ -412,6 +420,37 @@ GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data) GL3_Bind(0); } @@ -561,10 +561,10 @@ index 48ea046f..7cb039af 100644 GL3_Draw_GetPalette(void) { diff --git a/src/client/refresh/gl3/gl3_image.c b/src/client/refresh/gl3/gl3_image.c -index 44e695d8..74c0ec25 100644 +index 00b9a505..039a4469 100644 --- a/src/client/refresh/gl3/gl3_image.c +++ b/src/client/refresh/gl3/gl3_image.c -@@ -100,7 +100,7 @@ GL3_TextureMode(char *string) +@@ -106,7 +106,7 @@ GL3_TextureMode(char *string) nolerp = true; } @@ -574,7 +574,7 @@ index 44e695d8..74c0ec25 100644 if ((glt->type != it_pic) && (glt->type != it_sky)) /* mipmapped texture */ { diff --git a/src/client/refresh/gl3/gl3_main.c b/src/client/refresh/gl3/gl3_main.c -index c3983b2c..dbbd1637 100644 +index f155fd24..1a9fb036 100644 --- a/src/client/refresh/gl3/gl3_main.c +++ b/src/client/refresh/gl3/gl3_main.c @@ -38,6 +38,12 @@ @@ -614,7 +614,7 @@ index c3983b2c..dbbd1637 100644 cvar_t *gl_anisotropic; cvar_t *gl_texturemode; cvar_t *gl_drawbuffer; -@@ -202,9 +212,9 @@ GL3_Register(void) +@@ -206,9 +216,9 @@ GL3_Register(void) r_retexturing = ri.Cvar_Get("r_retexturing", "1", CVAR_ARCHIVE); r_scale8bittextures = ri.Cvar_Get("r_scale8bittextures", "0", CVAR_ARCHIVE); gl3_debugcontext = ri.Cvar_Get("gl3_debugcontext", "0", 0); @@ -622,12 +622,12 @@ index c3983b2c..dbbd1637 100644 - r_customwidth = ri.Cvar_Get("r_customwidth", "1024", CVAR_ARCHIVE); - r_customheight = ri.Cvar_Get("r_customheight", "768", CVAR_ARCHIVE); + r_mode = ri.Cvar_Get("r_mode", "-1", CVAR_ARCHIVE); -+ r_customwidth = ri.Cvar_Get("r_customwidth", "512", CVAR_ARCHIVE); -+ r_customheight = ri.Cvar_Get("r_customheight", "512", CVAR_ARCHIVE); ++ r_customwidth = ri.Cvar_Get("r_customwidth", "500", CVAR_ARCHIVE); ++ r_customheight = ri.Cvar_Get("r_customheight", "500", CVAR_ARCHIVE); gl3_particle_size = ri.Cvar_Get("gl3_particle_size", "40", CVAR_ARCHIVE); gl3_particle_fade_factor = ri.Cvar_Get("gl3_particle_fade_factor", "1.2", CVAR_ARCHIVE); gl3_particle_square = ri.Cvar_Get("gl3_particle_square", "0", CVAR_ARCHIVE); -@@ -230,7 +240,7 @@ GL3_Register(void) +@@ -240,7 +250,7 @@ GL3_Register(void) gl_anisotropic = ri.Cvar_Get("r_anisotropic", "0", CVAR_ARCHIVE); vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE); @@ -636,7 +636,7 @@ index c3983b2c..dbbd1637 100644 gl3_intensity = ri.Cvar_Get("gl3_intensity", "1.5", CVAR_ARCHIVE); gl3_intensity_2D = ri.Cvar_Get("gl3_intensity_2D", "1.5", CVAR_ARCHIVE); -@@ -437,6 +447,9 @@ enum { QGL_POINT_SPRITE = 0x8861 }; +@@ -449,6 +459,9 @@ enum { QGL_POINT_SPRITE = 0x8861 }; static qboolean GL3_Init(void) { @@ -646,7 +646,7 @@ index c3983b2c..dbbd1637 100644 Swap_Init(); // FIXME: for fucks sake, this doesn't have to be done at runtime! R_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n"); -@@ -455,7 +468,7 @@ GL3_Init(void) +@@ -467,7 +480,7 @@ GL3_Init(void) GL3_Register(); @@ -655,7 +655,7 @@ index c3983b2c..dbbd1637 100644 gl3state.prev_mode = 4; //gl_state.stereo_mode = gl1_stereo->value; -@@ -477,18 +490,18 @@ GL3_Init(void) +@@ -489,18 +502,18 @@ GL3_Init(void) R_Printf(PRINT_ALL, "\nOpenGL setting:\n"); GL3_Strings(); @@ -685,9 +685,9 @@ index c3983b2c..dbbd1637 100644 R_Printf(PRINT_ALL, "\n\nProbing for OpenGL extensions:\n"); -@@ -592,6 +605,18 @@ GL3_Init(void) - - GL3_SurfInit(); +@@ -609,6 +622,18 @@ GL3_Init(void) + // take the viewsize into account (enforce that by setting invalid size) + gl3state.ppFBtexWidth = gl3state.ppFBtexHeight = -1; + vignette = calloc(256*256, 4); + for (y = 0; y < 256; y++) @@ -704,7 +704,7 @@ index c3983b2c..dbbd1637 100644 R_Printf(PRINT_ALL, "\n"); return true; } -@@ -933,7 +958,10 @@ GL3_DrawParticles(void) +@@ -961,7 +986,10 @@ GL3_DrawParticles(void) glDepthMask(GL_FALSE); glEnable(GL_BLEND); @@ -715,20 +715,17 @@ index c3983b2c..dbbd1637 100644 GL3_UseProgram(gl3state.siParticle.shaderProgram); -@@ -958,10 +986,11 @@ GL3_DrawParticles(void) - glBufferData(GL_ARRAY_BUFFER, sizeof(part_vtx)*numParticles, buf, GL_STREAM_DRAW); - glDrawArrays(GL_POINTS, 0, numParticles); +@@ -989,7 +1017,9 @@ GL3_DrawParticles(void) -- glDisable(GL_BLEND); glDepthMask(GL_TRUE); +#ifndef ANDROID glDisable(GL_PROGRAM_POINT_SIZE); +#endif - } - } -@@ -1200,21 +1229,21 @@ GL3_SetGL2D(void) + YQ2_VLAFREE(buf); + } +@@ -1230,21 +1260,21 @@ GL3_SetGL2D(void) int y = 0; int h = vid.height; @@ -759,7 +756,7 @@ index c3983b2c..dbbd1637 100644 #endif // 0 glViewport(x, y, w, h); -@@ -1305,20 +1334,20 @@ SetupGL(void) +@@ -1337,20 +1367,20 @@ SetupGL(void) w = x2 - x; h = y - y2; @@ -787,17 +784,17 @@ index c3983b2c..dbbd1637 100644 + } */ #endif // 0 - glViewport(x, y2, w, h); -@@ -1628,6 +1657,7 @@ GL3_RenderFrame(refdef_t *fd) - GL3_SetLightLevel(NULL); + +@@ -1728,6 +1758,7 @@ GL3_RenderFrame(refdef_t *fd) + } GL3_SetGL2D(); +#ifndef ANDROID - if(v_blend[3] != 0.0f) + int x = (vid.width - gl3_newrefdef.width)/2; + int y = (vid.height - gl3_newrefdef.height)/2; + if (usedFBO) +@@ -1739,6 +1770,9 @@ GL3_RenderFrame(refdef_t *fd) { - int x = (vid.width - gl3_newrefdef.width)/2; -@@ -1635,6 +1665,9 @@ GL3_RenderFrame(refdef_t *fd) - GL3_Draw_Flash(v_blend, x, y, gl3_newrefdef.width, gl3_newrefdef.height); } +#else @@ -806,7 +803,7 @@ index c3983b2c..dbbd1637 100644 } -@@ -1664,7 +1697,9 @@ GL3_Clear(void) +@@ -1768,7 +1802,9 @@ GL3_Clear(void) gl3depthmax = 1; glDepthFunc(GL_LEQUAL); @@ -816,7 +813,7 @@ index c3983b2c..dbbd1637 100644 if (gl_zfix->value) { -@@ -1689,6 +1724,10 @@ GL3_Clear(void) +@@ -1793,6 +1829,10 @@ GL3_Clear(void) void GL3_BeginFrame(float camera_separation) { @@ -827,7 +824,7 @@ index c3983b2c..dbbd1637 100644 #if 0 // TODO: stereo stuff gl_state.camera_separation = camera_separation; // force a vid_restart if gl1_stereo has been modified. -@@ -1749,6 +1788,7 @@ GL3_BeginFrame(float camera_separation) +@@ -1854,6 +1894,7 @@ GL3_BeginFrame(float camera_separation) GL3_SetGL2D(); @@ -835,7 +832,7 @@ index c3983b2c..dbbd1637 100644 /* draw buffer stuff */ if (gl_drawbuffer->modified) { -@@ -1767,6 +1807,7 @@ GL3_BeginFrame(float camera_separation) +@@ -1872,6 +1913,7 @@ GL3_BeginFrame(float camera_separation) } } } @@ -843,7 +840,7 @@ index c3983b2c..dbbd1637 100644 /* texturemode stuff */ if (gl_texturemode->modified || (gl3config.anisotropic && gl_anisotropic->modified) -@@ -1890,6 +1931,7 @@ void R_Printf(int level, const char* msg, ...) +@@ -1998,6 +2040,7 @@ void R_Printf(int level, const char* msg, ...) va_end(argptr); } @@ -851,7 +848,7 @@ index c3983b2c..dbbd1637 100644 /* * this is only here so the functions in shared source files * (shared.c, rand.c, flash.c, mem.c/hunk.c) can link -@@ -1915,3 +1957,38 @@ Com_Printf(char *msg, ...) +@@ -2023,3 +2066,38 @@ Com_Printf(char *msg, ...) ri.Com_VPrintf(PRINT_ALL, msg, argptr); va_end(argptr); } @@ -867,7 +864,7 @@ index c3983b2c..dbbd1637 100644 + glBindTexture(GL_TEXTURE_2D, texture_); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1024, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1000, 500, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); + if (glGetError() != GL_NO_ERROR) + Sys_Error("error 1"); + @@ -875,7 +872,7 @@ index c3983b2c..dbbd1637 100644 + + glGenRenderbuffers(1, &depthrenderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, depthrenderbuffer); -+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1024, 512); ++ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1000, 500); + if (glGetError() != GL_NO_ERROR) + Sys_Error("error 2"); + @@ -891,10 +888,10 @@ index c3983b2c..dbbd1637 100644 +} + diff --git a/src/client/refresh/gl3/gl3_mesh.c b/src/client/refresh/gl3/gl3_mesh.c -index d25eb67e..934b418b 100644 +index d2ce080c..8b871410 100644 --- a/src/client/refresh/gl3/gl3_mesh.c +++ b/src/client/refresh/gl3/gl3_mesh.c -@@ -800,12 +800,14 @@ GL3_DrawAliasModel(entity_t *entity) +@@ -806,12 +806,14 @@ GL3_DrawAliasModel(entity_t *entity) /* locate the proper data */ c_alias_polys += paliashdr->num_tris; @@ -909,7 +906,7 @@ index d25eb67e..934b418b 100644 if (entity->flags & RF_WEAPONMODEL) { -@@ -921,10 +923,12 @@ GL3_DrawAliasModel(entity_t *entity) +@@ -927,10 +929,12 @@ GL3_DrawAliasModel(entity_t *entity) glDisable(GL_BLEND); } @@ -923,7 +920,7 @@ index d25eb67e..934b418b 100644 if (gl_shadows->value && gl3config.stencil && !(entity->flags & (RF_TRANSLUCENT | RF_WEAPONMODEL | RF_NOSHADOW))) { diff --git a/src/client/refresh/gl3/gl3_misc.c b/src/client/refresh/gl3/gl3_misc.c -index e1e8684f..7faabcd6 100644 +index 532790de..e99a0578 100644 --- a/src/client/refresh/gl3/gl3_misc.c +++ b/src/client/refresh/gl3/gl3_misc.c @@ -41,7 +41,9 @@ GL3_SetDefaultState(void) @@ -1033,7 +1030,7 @@ index 4242c7e1..92a11ce3 100644 // Let's see if the driver supports MSAA. int msaa_samples = 0; diff --git a/src/client/refresh/gl3/gl3_shaders.c b/src/client/refresh/gl3/gl3_shaders.c -index bcf4fb08..c46160c0 100644 +index 7f52b8d2..aa5db804 100644 --- a/src/client/refresh/gl3/gl3_shaders.c +++ b/src/client/refresh/gl3/gl3_shaders.c @@ -163,7 +163,9 @@ CreateShaderProgram(int numShaders, const GLuint* shaders) @@ -1067,7 +1064,36 @@ index bcf4fb08..c46160c0 100644 discard; // apply gamma correction and intensity -@@ -218,7 +222,9 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n +@@ -217,7 +221,7 @@ static const char* fragmentSrc2D = MULTILINE_STRING(#version 150\n + } + ); + +-static const char* fragmentSrc2Dpostprocess = MULTILINE_STRING(#version 150\n ++static const char* fragmentSrc2Dpostprocess = MULTILINE_STRING(#version 300 es\n + in vec2 passTexCoord; + + // for UBO shared between all shaders (incl. 2D) +@@ -248,7 +252,7 @@ static const char* fragmentSrc2Dpostprocess = MULTILINE_STRING(#version 150\n + } + ); + +-static const char* fragmentSrc2DpostprocessWater = MULTILINE_STRING(#version 150\n ++static const char* fragmentSrc2DpostprocessWater = MULTILINE_STRING(#version 300 es\n + in vec2 passTexCoord; + + // for UBO shared between all shaders (incl. 2D) +@@ -281,8 +285,8 @@ static const char* fragmentSrc2DpostprocessWater = MULTILINE_STRING(#version 150 + //float sy = pc.scale - abs(pc.scrHeight / 2.0 - gl_FragCoord.y) * 2.0 / pc.scrHeight; + float sx = 1.0 - abs(0.5-uv.x)*2.0; + float sy = 1.0 - abs(0.5-uv.y)*2.0; +- float xShift = 2.0 * time + uv.y * PI * 10; +- float yShift = 2.0 * time + uv.x * PI * 10; ++ float xShift = 2.0 * time + uv.y * PI * 10.0; ++ float yShift = 2.0 * time + uv.x * PI * 10.0; + vec2 distortion = vec2(sin(xShift) * sx, sin(yShift) * sy) * 0.00666; + + uv += distortion; +@@ -299,7 +303,9 @@ static const char* fragmentSrc2DpostprocessWater = MULTILINE_STRING(#version 150 ); // 2D color only rendering, GL3_Draw_Fill(), GL3_Draw_FadeScreen() @@ -1078,7 +1104,7 @@ index bcf4fb08..c46160c0 100644 in vec2 position; // GL3_ATTRIB_POSITION -@@ -230,13 +236,15 @@ static const char* vertexSrc2Dcolor = MULTILINE_STRING(#version 150\n +@@ -311,13 +317,15 @@ static const char* vertexSrc2Dcolor = MULTILINE_STRING(#version 150\n void main() { @@ -1096,7 +1122,7 @@ index bcf4fb08..c46160c0 100644 layout (std140) uniform uniCommon { float gamma; -@@ -258,7 +266,9 @@ static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n +@@ -339,7 +347,9 @@ static const char* fragmentSrc2Dcolor = MULTILINE_STRING(#version 150\n // ############## shaders for 3D rendering ##################### @@ -1107,7 +1133,7 @@ index bcf4fb08..c46160c0 100644 in vec3 position; // GL3_ATTRIB_POSITION in vec2 texCoord; // GL3_ATTRIB_TEXCOORD -@@ -287,7 +297,9 @@ static const char* vertexCommon3D = MULTILINE_STRING(#version 150\n +@@ -368,7 +378,9 @@ static const char* vertexCommon3D = MULTILINE_STRING(#version 150\n }; ); @@ -1118,7 +1144,7 @@ index bcf4fb08..c46160c0 100644 in vec2 passTexCoord; -@@ -377,7 +389,7 @@ static const char* vertexSrc3DlmFlow = MULTILINE_STRING( +@@ -458,7 +470,7 @@ static const char* vertexSrc3DlmFlow = MULTILINE_STRING( void main() { @@ -1127,7 +1153,7 @@ index bcf4fb08..c46160c0 100644 passLMcoord = lmTexCoord; vec4 worldCoord = transModel * vec4(position, 1.0); passWorldCoord = worldCoord.xyz; -@@ -415,9 +427,9 @@ static const char* fragmentSrc3Dwater = MULTILINE_STRING( +@@ -496,9 +508,9 @@ static const char* fragmentSrc3Dwater = MULTILINE_STRING( void main() { vec2 tc = passTexCoord; @@ -1139,7 +1165,7 @@ index bcf4fb08..c46160c0 100644 tc *= 1.0/64.0; // do this last vec4 texel = texture(tex, tc); -@@ -492,7 +504,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( +@@ -573,7 +585,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( vec3 lightToPos = dynLights[i].lightOrigin - passWorldCoord; float distLightToPos = length(lightToPos); @@ -1148,7 +1174,7 @@ index bcf4fb08..c46160c0 100644 // move the light source a bit further above the surface // => helps if the lightsource is so close to the surface (e.g. grenades, rockets) -@@ -501,7 +513,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( +@@ -582,7 +594,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( lightToPos += passNormal*32.0; // also factor in angle between light and point on surface @@ -1157,7 +1183,7 @@ index bcf4fb08..c46160c0 100644 lmTex.rgb += dynLights[i].lightColor.rgb * fact * (1.0/256.0); -@@ -512,7 +524,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( +@@ -593,7 +605,7 @@ static const char* fragmentSrc3Dlm = MULTILINE_STRING( outColor = lmTex*texel; outColor.rgb = pow(outColor.rgb, vec3(gamma)); // apply gamma correction to result @@ -1167,7 +1193,7 @@ index bcf4fb08..c46160c0 100644 ); diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h -index c6cb1dec..fff489fa 100644 +index 39976312..b03bc42a 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -82,10 +82,10 @@ enum { @@ -1185,7 +1211,7 @@ index c6cb1dec..fff489fa 100644 extern unsigned gl3_rawpalette[256]; extern unsigned d_8to24table[256]; -@@ -397,6 +397,7 @@ extern void GL3_Draw_Fill(int x, int y, int w, int h, int c); +@@ -409,6 +409,7 @@ extern void GL3_Draw_Fill(int x, int y, int w, int h, int c); extern void GL3_Draw_FadeScreen(void); extern void GL3_Draw_Flash(const float color[4], float x, float y, float w, float h); extern void GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data); @@ -1215,21 +1241,8 @@ index 1588695a..410ec7aa 100644 #elif __linux__ s_sdldriver = (Cvar_Get("s_sdldriver", "alsa", CVAR_ARCHIVE)); #elif __APPLE__ -diff --git a/src/client/sound/sound.c b/src/client/sound/sound.c -index b42c421b..cab2b401 100644 ---- a/src/client/sound/sound.c -+++ b/src/client/sound/sound.c -@@ -163,7 +163,7 @@ static qboolean - S_IsSilencedMuzzleFlash(const wavinfo_t* info, const void* raw_data, const char* name) - { - /* Skip the prefix. */ -- static const size_t base_sound_string_length = strlen("sound/"); -+ static const size_t base_sound_string_length = 6; // strlen("sound/"); - const char* base_name = name + base_sound_string_length; - - /* Match to well-known muzzle flash sound names. */ diff --git a/src/client/vid/glimp_sdl.c b/src/client/vid/glimp_sdl.c -index c0cbfbb7..f135751b 100755 +index bc70d551..9485a08d 100755 --- a/src/client/vid/glimp_sdl.c +++ b/src/client/vid/glimp_sdl.c @@ -30,8 +30,8 @@ @@ -1393,7 +1406,7 @@ index 95f43246..d8d1a1ef 100644 static void diff --git a/src/common/header/shared.h b/src/common/header/shared.h -index 74b5088a..74727e72 100644 +index 8d3b12b1..943868f1 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -46,7 +46,10 @@