From 0f6735640a15743ce9c6f839ce46060f86de66b0 Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 24 Apr 2018 04:48:20 +0300 Subject: [PATCH] remove API-specific code from Core --- src/core.h | 225 +++------------------------------------- src/debug.h | 2 +- src/gapi_gl.h | 217 ++++++++++++++++++++++++++++++++++++-- src/gapi_gu.h | 18 ++++ src/inventory.h | 6 +- src/shaders/shader.glsl | 4 +- src/texture.h | 11 +- 7 files changed, 248 insertions(+), 235 deletions(-) diff --git a/src/core.h b/src/core.h index 13917ee..8a1f744 100644 --- a/src/core.h +++ b/src/core.h @@ -11,16 +11,11 @@ #define OS_PTHREAD_MT #ifdef WIN32 - #define _OS_WINDOWS + #define _OS_WIN #define _GAPI_GL //#define _GAPI_VULKAN #include - - #ifdef _GAPI_GL - #include - #include - #endif #undef OS_PTHREAD_MT #elif ANDROID @@ -29,89 +24,16 @@ #define _GAPI_GLES //#define _GAPI_VULKAN - #include - - #ifdef _GAPI_GL - #include - #include - #define GL_CLAMP_TO_BORDER 0x812D - #define GL_TEXTURE_BORDER_COLOR 0x1004 - - #define GL_TEXTURE_COMPARE_MODE 0x884C - #define GL_TEXTURE_COMPARE_FUNC 0x884D - #define GL_COMPARE_REF_TO_TEXTURE 0x884E - - #define GL_RGBA16F 0x881A - #define GL_RGBA32F 0x8814 - #define GL_HALF_FLOAT 0x140B - - #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES - #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES - - #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC - #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC - #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC - #define glGenVertexArrays glGenVertexArraysOES - #define glDeleteVertexArrays glDeleteVertexArraysOES - #define glBindVertexArray glBindVertexArrayOES - - #define PFNGLGETPROGRAMBINARYPROC PFNGLGETPROGRAMBINARYOESPROC - #define PFNGLPROGRAMBINARYPROC PFNGLPROGRAMBINARYOESPROC - #define glGetProgramBinary glGetProgramBinaryOES - #define glProgramBinary glProgramBinaryOES - - #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES - #endif - extern void osToggleVR(bool enable); #elif __RPI__ #define _OS_RPI #define _GAPI_GL #define _GAPI_GLES - #include - #include - #include - #include - - #define GL_CLAMP_TO_BORDER 0x812D - #define GL_TEXTURE_BORDER_COLOR 0x1004 - - #define GL_TEXTURE_COMPARE_MODE 0x884C - #define GL_TEXTURE_COMPARE_FUNC 0x884D - #define GL_COMPARE_REF_TO_TEXTURE 0x884E - - #undef GL_RGBA32F - #undef GL_RGBA16F - #undef GL_HALF_FLOAT - - #define GL_RGBA32F GL_RGBA - #define GL_RGBA16F GL_RGBA - #define GL_HALF_FLOAT GL_HALF_FLOAT_OES - - #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES - #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES - - #define glGenVertexArrays(...) - #define glDeleteVertexArrays(...) - #define glBindVertexArray(...) - - #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES - #define glGetProgramBinary(...) - #define glProgramBinary(...) - - extern EGLDisplay display; - #define DYNGEOM_NO_VBO #elif __linux__ #define _OS_LINUX #define _GAPI_GL - - #ifdef _GAPI_GL - #include - #include - #include - #endif #elif __APPLE__ #define _GAPI_GL #include "TargetConditionals.h" @@ -119,73 +41,18 @@ #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR #define _OS_IOS #define _GAPI_GLES - - #include - #include - #include - - #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC - #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC - #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC - #define glGenVertexArrays glGenVertexArraysOES - #define glDeleteVertexArrays glDeleteVertexArraysOES - #define glBindVertexArray glBindVertexArrayOES - - #define GL_CLAMP_TO_BORDER 0x812D - #define GL_TEXTURE_BORDER_COLOR 0x1004 - - #define GL_TEXTURE_COMPARE_MODE GL_TEXTURE_COMPARE_MODE_EXT - #define GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC_EXT - #define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_REF_TO_TEXTURE_EXT #else - #define _OS_MACOS - - #include - #include - #include - #include - #include - #include - - #define GL_RGBA16F 0x881A - #define GL_RGBA32F 0x8814 - #define GL_HALF_FLOAT 0x140B - - #define GL_RGB565 GL_RGBA - #define GL_TEXTURE_COMPARE_MODE 0x884C - #define GL_TEXTURE_COMPARE_FUNC 0x884D - #define GL_COMPARE_REF_TO_TEXTURE 0x884E - - #define glGenVertexArrays glGenVertexArraysAPPLE - #define glDeleteVertexArrays glDeleteVertexArraysAPPLE - #define glBindVertexArray glBindVertexArrayAPPLE - - #define GL_PROGRAM_BINARY_LENGTH 0 - #define glGetProgramBinary(...) 0 - #define glProgramBinary(...) 0 + #define _OS_MAC #endif #elif __EMSCRIPTEN__ #define _OS_WEB #define _GAPI_GL #define _GAPI_GLES - #include - #include - #include - #include - - #define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_EXT - #define GL_TEXTURE_BORDER_COLOR GL_TEXTURE_BORDER_COLOR_EXT - - #define glGetProgramBinary(...) - #define glProgramBinary(...) - #undef OS_FILEIO_CACHE #elif _PSP #define _OS_PSP #define _GAPI_SCEGU - #include - #include #define FFP #define TEX_SWIZZLE @@ -434,8 +301,6 @@ namespace Core { #include "input.h" #include "sound.h" - - #define MAX_LIGHTS 4 #define MAX_RENDER_BUFFERS 32 #define MAX_CONTACTS 15 @@ -518,20 +383,6 @@ namespace Core { enum Pass { passCompose, passShadow, passAmbient, passWater, passFilter, passGUI, passMAX } pass; - #ifdef _OS_PSP - void *curBackBuffer; - #else - GLuint FBO, defaultFBO; - struct RenderTargetCache { - int count; - struct Item { - GLuint ID; - int width; - int height; - } items[MAX_RENDER_BUFFERS]; - } rtCache[2]; - #endif - Texture *defaultTarget; int32 renderState; @@ -547,13 +398,14 @@ namespace Core { uint32 targetOp; vec4 viewport; vec4 material; - #ifdef _OS_PSP - Index *iBuffer; + + #ifdef _GAPI_GL + uint32 VAO; + uint32 iBuffer; + uint32 vBuffer; + #elif _GAPI_SCEGU + Index *iBuffer; GAPI::Vertex *vBuffer; - #else - GLuint VAO; - GLuint iBuffer; - GLuint vBuffer; #endif int32 basisCount; @@ -610,6 +462,7 @@ namespace Core { void init() { x = y = 0; + #ifdef USE_INFLATE tinf_init(); #endif @@ -639,7 +492,6 @@ namespace Core { LOG("\n"); defaultTarget = NULL; - memset(rtCache, 0, sizeof(rtCache)); for (int i = 0; i < MAX_LIGHTS; i++) { lightPos[i] = vec3(0.0); @@ -715,7 +567,7 @@ namespace Core { } // use S key for action on Mac because Ctrl + Left/Right used by system (default) - #ifdef _OS_MACOS + #ifdef _OS_MAC settings.controls[0].keys[ cAction ].key = ikS; #endif @@ -766,28 +618,6 @@ namespace Core { GAPI::waitVBlank(); } -#ifndef _OS_PSP - int cacheRenderTarget(bool depth, int width, int height) { - RenderTargetCache &cache = rtCache[depth]; - - for (int i = 0; i < cache.count; i++) - if (cache.items[i].width == width && cache.items[i].height == height) - return i; - - ASSERT(cache.count < MAX_RENDER_BUFFERS); - - RenderTargetCache::Item &item = cache.items[cache.count]; - item.width = width; - item.height = height; - - glGenRenderbuffers(1, &item.ID); - glBindRenderbuffer(GL_RENDERBUFFER, item.ID); - glRenderbufferStorage(GL_RENDERBUFFER, depth ? GL_RGB565 : GL_DEPTH_COMPONENT16, width, height); - glBindRenderbuffer(GL_RENDERBUFFER, 0); - return cache.count++; - } -#endif - bool update() { resetState = false; int time = getTime(); @@ -809,34 +639,11 @@ namespace Core { uint32 face = reqTarget.face; if (target != active.target || face != active.targetFace) { - #ifdef _OS_PSP -/* - if (!target) - sceGuDrawBufferList(GU_PSM_5650, curBackBuffer, 512); - else - sceGuDrawBufferList(GU_PSM_5650, target->offset, target->width); -*/ - #else - bool depth = false; - Core::stats.rt++; - if (!target) { // may be a null - glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - } else { - GLenum texTarget = GL_TEXTURE_2D; - if (target->opt & Texture::CUBEMAP) - texTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; - depth = target->format == FMT_DEPTH || target->format == FMT_SHADOW; - - int rtIndex = cacheRenderTarget(depth, target->width, target->height); - - glBindFramebuffer(GL_FRAMEBUFFER, FBO); - glFramebufferTexture2D (GL_FRAMEBUFFER, depth ? GL_DEPTH_ATTACHMENT : GL_COLOR_ATTACHMENT0, texTarget, target->ID, 0); - glFramebufferRenderbuffer (GL_FRAMEBUFFER, depth ? GL_COLOR_ATTACHMENT0 : GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rtCache[depth].items[rtIndex].ID); - } - #endif + GAPI::bindTarget(target, face); + bool depth = target && (target->format == FMT_DEPTH || target->format == FMT_SHADOW); if (support.discardFrame) { if (!(reqTarget.op & RT_LOAD_COLOR) && !depth) reqTarget.op |= RT_CLEAR_COLOR; if (!(reqTarget.op & RT_LOAD_DEPTH) && depth) reqTarget.op |= RT_CLEAR_DEPTH; @@ -976,11 +783,7 @@ namespace Core { void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { validateRenderState(); - // GAPI::copyTarget(dst, xOffset, yOffset, x, y, width, height); TODO - dst->bind(sDiffuse); - #ifdef _GAPI_GL - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, x, y, width, height); // TODO: too bad for iOS devices! - #endif + GAPI::copyTarget(dst, xOffset, yOffset, x, y, width, height); } vec4 copyPixel(int x, int y) { // GPU sync! diff --git a/src/debug.h b/src/debug.h index 70fc07f..859080d 100644 --- a/src/debug.h +++ b/src/debug.h @@ -11,7 +11,7 @@ namespace Debug { static GLuint font; void init() { - #ifdef _OS_WINDOWS + #ifdef _OS_WIN font = glGenLists(256); HDC hdc = GetDC(0); HFONT hfont = CreateFontA(-MulDiv(10, GetDeviceCaps(hdc, LOGPIXELSY), 72), 0, diff --git a/src/gapi_gl.h b/src/gapi_gl.h index 31a8e7f..3834eca 100644 --- a/src/gapi_gl.h +++ b/src/gapi_gl.h @@ -3,13 +3,142 @@ #include "core.h" -#if defined(_OS_WINDOWS) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID) +#ifdef _OS_WIN + #include + #include +#elif _OS_ANDROID + #include + + #include + #include + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE_BORDER_COLOR 0x1004 + + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + + #define GL_RGBA16F 0x881A + #define GL_RGBA32F 0x8814 + #define GL_HALF_FLOAT 0x140B + + #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES + #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES + + #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC + #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC + #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC + #define glGenVertexArrays glGenVertexArraysOES + #define glDeleteVertexArrays glDeleteVertexArraysOES + #define glBindVertexArray glBindVertexArrayOES + + #define PFNGLGETPROGRAMBINARYPROC PFNGLGETPROGRAMBINARYOESPROC + #define PFNGLPROGRAMBINARYPROC PFNGLPROGRAMBINARYOESPROC + #define glGetProgramBinary glGetProgramBinaryOES + #define glProgramBinary glProgramBinaryOES + + #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES +#elif _OS_RPI + #include + #include + #include + #include + + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE_BORDER_COLOR 0x1004 + + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + + #undef GL_RGBA32F + #undef GL_RGBA16F + #undef GL_HALF_FLOAT + + #define GL_RGBA32F GL_RGBA + #define GL_RGBA16F GL_RGBA + #define GL_HALF_FLOAT GL_HALF_FLOAT_OES + + #define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES + #define GL_UNSIGNED_INT_24_8 GL_UNSIGNED_INT_24_8_OES + + #define glGenVertexArrays(...) + #define glDeleteVertexArrays(...) + #define glBindVertexArray(...) + + #define GL_PROGRAM_BINARY_LENGTH GL_PROGRAM_BINARY_LENGTH_OES + #define glGetProgramBinary(...) + #define glProgramBinary(...) + + extern EGLDisplay display; +#elif _OS_LINUX + #include + #include + #include +#elif __APPLE__ + #ifdef _OS_IOS + #include + #include + #include + + #define PFNGLGENVERTEXARRAYSPROC PFNGLGENVERTEXARRAYSOESPROC + #define PFNGLDELETEVERTEXARRAYSPROC PFNGLDELETEVERTEXARRAYSOESPROC + #define PFNGLBINDVERTEXARRAYPROC PFNGLBINDVERTEXARRAYOESPROC + #define glGenVertexArrays glGenVertexArraysOES + #define glDeleteVertexArrays glDeleteVertexArraysOES + #define glBindVertexArray glBindVertexArrayOES + + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE_BORDER_COLOR 0x1004 + + #define GL_TEXTURE_COMPARE_MODE GL_TEXTURE_COMPARE_MODE_EXT + #define GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC_EXT + #define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_REF_TO_TEXTURE_EXT + #else + #include + #include + #include + #include + #include + #include + + #define GL_RGBA16F 0x881A + #define GL_RGBA32F 0x8814 + #define GL_HALF_FLOAT 0x140B + + #define GL_RGB565 GL_RGBA + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_REF_TO_TEXTURE 0x884E + + #define glGenVertexArrays glGenVertexArraysAPPLE + #define glDeleteVertexArrays glDeleteVertexArraysAPPLE + #define glBindVertexArray glBindVertexArrayAPPLE + + #define GL_PROGRAM_BINARY_LENGTH 0 + #define glGetProgramBinary(...) 0 + #define glProgramBinary(...) 0 + #endif +#elif _OS_WEB + #include + #include + #include + #include + + #define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_EXT + #define GL_TEXTURE_BORDER_COLOR GL_TEXTURE_BORDER_COLOR_EXT + + #define glGetProgramBinary(...) + #define glProgramBinary(...) +#endif + +#if defined(_OS_WIN) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID) #ifdef _OS_ANDROID #define GetProc(x) dlsym(libGL, x); #else void* GetProc(const char *name) { - #ifdef _OS_WINDOWS + #ifdef _OS_WIN return (void*)wglGetProcAddress(name); #elif _OS_LINUX return (void*)glXGetProcAddress((GLubyte*)name); @@ -22,12 +151,12 @@ #define GetProcOGL(x) x=(decltype(x))GetProc(#x); // Texture - #ifdef _OS_WINDOWS + #ifdef _OS_WIN PFNGLACTIVETEXTUREPROC glActiveTexture; #endif // VSync - #ifdef _OS_WINDOWS + #ifdef _OS_WIN typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT; #elif _OS_LINUX @@ -35,7 +164,7 @@ PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; #endif - #if defined(_OS_WINDOWS) || defined(_OS_LINUX) + #if defined(_OS_WIN) || defined(_OS_LINUX) PFNGLGENERATEMIPMAPPROC glGenerateMipmap; // Profiling #ifdef PROFILE @@ -200,27 +329,49 @@ namespace GAPI { int cullMode, blendMode; + struct Texture { + enum Option { CUBEMAP = 1, MIPMAPS = 2, NEAREST = 4 }; + + uint32 ID; + int width, height, origWidth, origHeight; + Format format; + uint32 opt; + }; + + + GLuint FBO, defaultFBO; + struct RenderTargetCache { + int count; + struct Item { + GLuint ID; + int width; + int height; + } items[MAX_RENDER_BUFFERS]; + } rtCache[2]; + bool extSupport(const char *str, const char *ext) { return strstr(str, ext) != NULL; } void init() { + memset(rtCache, 0, sizeof(rtCache)); + #ifdef _OS_ANDROID void *libGL = dlopen("libGLESv2.so", RTLD_LAZY); #endif - #if defined(_OS_WINDOWS) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID) - #ifdef _OS_WINDOWS + #if defined(_OS_WIN) || (defined(_OS_LINUX) && !defined(_OS_RPI)) || defined(_OS_ANDROID) + #ifdef _OS_WIN GetProcOGL(glActiveTexture); #endif - #ifdef _OS_WINDOWS + #ifdef _OS_WIN GetProcOGL(wglSwapIntervalEXT); #elif _OS_LINUX GetProcOGL(glXSwapIntervalSGI); #endif - #if defined(_OS_WINDOWS) || defined(_OS_LINUX) + #if defined(_OS_WIN) || defined(_OS_LINUX) GetProcOGL(glGenerateMipmap); #ifdef PROFILE @@ -399,6 +550,44 @@ namespace GAPI { glUseProgram(0); } + int cacheRenderTarget(bool depth, int width, int height) { + RenderTargetCache &cache = rtCache[depth]; + + for (int i = 0; i < cache.count; i++) + if (cache.items[i].width == width && cache.items[i].height == height) + return i; + + ASSERT(cache.count < MAX_RENDER_BUFFERS); + + RenderTargetCache::Item &item = cache.items[cache.count]; + item.width = width; + item.height = height; + + glGenRenderbuffers(1, &item.ID); + glBindRenderbuffer(GL_RENDERBUFFER, item.ID); + glRenderbufferStorage(GL_RENDERBUFFER, depth ? GL_RGB565 : GL_DEPTH_COMPONENT16, width, height); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + return cache.count++; + } + + void bindTarget(Texture *target, int face) { + if (!target) { // may be a null + glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); + } else { + GLenum texTarget = GL_TEXTURE_2D; + if (target->opt & Texture::CUBEMAP) + texTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; + + bool depth = target->format == FMT_DEPTH || target->format == FMT_SHADOW; + + int rtIndex = cacheRenderTarget(depth, target->width, target->height); + + glBindFramebuffer(GL_FRAMEBUFFER, FBO); + glFramebufferTexture2D (GL_FRAMEBUFFER, depth ? GL_DEPTH_ATTACHMENT : GL_COLOR_ATTACHMENT0, texTarget, target->ID, 0); + glFramebufferRenderbuffer (GL_FRAMEBUFFER, depth ? GL_COLOR_ATTACHMENT0 : GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rtCache[depth].items[rtIndex].ID); + } + } + void discardTarget(bool color, bool depth) { #ifdef _GAPI_GLES if (Core::support.discardFrame) { @@ -412,8 +601,16 @@ namespace GAPI { #endif } + void copyTarget(Texture *dst, int xOffset, int yOffset, int x, int y, int width, int height) { + Core::active.textures[0] = NULL; + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, dst->ID); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, x, y, width, height); + glBindTexture(GL_TEXTURE_2D, 0); + } + void setVSync(bool enable) { - #ifdef _OS_WINDOWS + #ifdef _OS_WIN if (wglSwapIntervalEXT) wglSwapIntervalEXT(enable ? 1 : 0); #elif _OS_LINUX if (glXSwapIntervalSGI) glXSwapIntervalSGI(enable ? 1 : 0); diff --git a/src/gapi_gu.h b/src/gapi_gu.h index 8652ffd..3682a2d 100644 --- a/src/gapi_gu.h +++ b/src/gapi_gu.h @@ -3,6 +3,14 @@ #include "core.h" +#include +#include + +#define FFP +#define TEX_SWIZZLE +//#define EDRAM_MESH +#define EDRAM_TEX + namespace GAPI { using namespace Core; @@ -17,6 +25,7 @@ namespace GAPI { int cullMode, blendMode; uint32 *cmdBuf = NULL; + void *curBackBuffer; static int EDRAM_OFFSET; static int EDRAM_SIZE; @@ -121,6 +130,15 @@ namespace GAPI { void resetState() {} + void bindTarget(Texture *texture, int face) { +/* + if (!target) + sceGuDrawBufferList(GU_PSM_5650, GAPI::curBackBuffer, 512); + else + sceGuDrawBufferList(GU_PSM_5650, target->offset, target->width); +*/ + } + void discardTarget(bool color, bool depth) {} void setVSync(bool enable) {} diff --git a/src/inventory.h b/src/inventory.h index ed4fda5..7e6a085 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -125,12 +125,12 @@ static const OptionItem optDetail[] = { OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ), OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ), OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ), -#if defined(_OS_WINDOWS) || defined(_OS_LINUX) || defined(_OS_PSP) || defined(_OS_RPI) +#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_PSP) || defined(_OS_RPI) OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ), #endif #ifndef _OS_PSP OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_STEREO, SETTINGS( detail.stereo ), STR_OFF, 0, -#if /*defined(_OS_WINDOWS) ||*/ defined(_OS_ANDROID) +#if /*defined(_OS_WIN) ||*/ defined(_OS_ANDROID) 3 /* with VR option */ #else 2 /* without VR support */ @@ -154,7 +154,7 @@ static const OptionItem optControls[] = { OptionItem( ), OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED , SETTINGS( playerIndex ), STR_PLAYER_1, 0, 1 ), OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_GAMEPAD , SETTINGS( controls[0].joyIndex ), STR_GAMEPAD_1, 0, 3 ), -#ifdef _OS_WINDOWS +#ifdef _OS_WIN OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_VIBRATION , SETTINGS( controls[0].vibration ), STR_OFF, 0, 1 ), #endif OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_RETARGET , SETTINGS( controls[0].retarget ), STR_OFF, 0, 1 ), diff --git a/src/shaders/shader.glsl b/src/shaders/shader.glsl index a0cb79b..eb15259 100644 --- a/src/shaders/shader.glsl +++ b/src/shaders/shader.glsl @@ -20,12 +20,12 @@ varying vec4 vTexCoord; // xy - atlas coords, zw - trapezoidal correction uniform mat4 uViewProj; uniform vec3 uViewPos; + uniform vec4 uParam; // x - time, y - water height, z - clip plane sign, w - clip plane height uniform vec4 uLightPos[MAX_LIGHTS]; uniform vec4 uLightColor[MAX_LIGHTS]; // xyz - color, w - radius * intensity -uniform vec4 uFogParams; - uniform vec4 uMaterial; // x - diffuse, y - ambient, z - specular, w - alpha +uniform vec4 uFogParams; #ifndef PASS_SHADOW varying vec4 vViewVec; // xyz - dir * dist, w - coord.y * clipPlaneSign diff --git a/src/texture.h b/src/texture.h index 8b98dbb..ec54c9e 100644 --- a/src/texture.h +++ b/src/texture.h @@ -4,12 +4,7 @@ #include "core.h" #include "format.h" -struct Texture { - enum Option { CUBEMAP = 1, MIPMAPS = 2, NEAREST = 4 }; - - int width, height, origWidth, origHeight; - Format format; - uint32 opt; +struct Texture : GAPI::Texture { #ifdef _OS_PSP TR::Tile4 *tiles; @@ -34,7 +29,6 @@ struct Texture { } #else - uint32 ID; Texture *tiles[32]; #endif @@ -82,7 +76,8 @@ struct Texture { } #endif - Texture(int width, int height, Format format, uint32 opt = 0, void *data = NULL) : opt(opt) { + Texture(int width, int height, Format format, uint32 opt = 0, void *data = NULL) { + this->opt = opt; // LOG("create texture %d x %d (%d)\n", width, height, format); #ifndef _OS_PSP