Index: ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js =================================================================== --- ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js +++ ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -219,6 +219,11 @@ if (GL_VERSION.match(/^[3-9]/)) enable_glsl = true; + // Enable GLSL on OpenGL ES 2.0+, which doesn’t support the fixed + // function fallbacks + if (GL_VERSION.match(/^OpenGL ES /)) + enable_glsl = true; + // Enable most graphics options on OpenGL 4+, which should be // able to properly manage them if (GL_VERSION.match(/^[4-9]/)) Index: ps/trunk/binaries/data/mods/public/shaders/glsl/model_common.fs =================================================================== --- ps/trunk/binaries/data/mods/public/shaders/glsl/model_common.fs +++ ps/trunk/binaries/data/mods/public/shaders/glsl/model_common.fs @@ -129,13 +129,13 @@ float height = 1.0; float scale = effectSettings.z; - int iter = int(min(20, 25.0 - dist/10.0)); + int iter = int(min(20.0, 25.0 - dist/10.0)); - if (iter > 0.01) + if (iter > 0) { - float s = 1.0/iter; + float s = 1.0/float(iter); float t = s; - move = vec2(-eyeDir.x, eyeDir.y) * scale / (eyeDir.z * iter); + move = vec2(-eyeDir.x, eyeDir.y) * scale / (eyeDir.z * float(iter)); vec2 nil = vec2(0.0); for (int i = 0; i < iter; ++i) { Index: ps/trunk/source/gui/ObjectTypes/CChart.cpp =================================================================== --- ps/trunk/source/gui/ObjectTypes/CChart.cpp +++ ps/trunk/source/gui/ObjectTypes/CChart.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -86,12 +86,16 @@ shader->VertexPointer(3, GL_FLOAT, 0, &vertices[0]); shader->AssertPointersBound(); +#if !CONFIG2_GLES glEnable(GL_LINE_SMOOTH); +#endif glLineWidth(1.1f); if (!g_Renderer.m_SkipSubmit) glDrawArrays(GL_LINE_STRIP, 0, vertices.size() / 3); glLineWidth(1.0f); +#if !CONFIG2_GLES glDisable(GL_LINE_SMOOTH); +#endif } void CChart::DrawTriangleStrip(const CShaderProgramPtr& shader, const CGUIColor& color, const std::vector& vertices) const Index: ps/trunk/source/lib/external_libraries/glext_funcs.h =================================================================== --- ps/trunk/source/lib/external_libraries/glext_funcs.h +++ ps/trunk/source/lib/external_libraries/glext_funcs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -65,8 +65,6 @@ #if CONFIG2_GLES -// no GLES extensions used yet - // some functions that are extensions in GL are core functions in GLES, // so we should use them without the function pointer indirection #define pglActiveTextureARB glActiveTexture @@ -106,22 +104,41 @@ #define pglBufferSubDataARB glBufferSubData #define pglDeleteBuffersARB glDeleteBuffers #define pglGenBuffersARB glGenBuffers -#define pglMapBufferARB glMapBuffer -#define pglUnmapBufferARB glUnmapBuffer +// Those EXT symbols don’t exist in GLES 2.0, since it imported the ARB version instead. #define pglBindFramebufferEXT glBindFramebuffer #define pglCheckFramebufferStatusEXT glCheckFramebufferStatus #define pglDeleteFramebuffersEXT glDeleteFramebuffers #define pglFramebufferTexture2DEXT glFramebufferTexture2D #define pglGenFramebuffersEXT glGenFramebuffers - -#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT -#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0 #define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE #define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER -#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_EDGE // TODO: should fix code that relies on GL_CLAMP_TO_BORDER +// Those should come from GLES 2.0 core, not from GL_EXT_draw_buffers. +#ifndef GL_COLOR_ATTACHMENT0_EXT +#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0 +#define GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT1 +#endif +#ifndef GL_DEPTH_ATTACHMENT_EXT +#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT +#endif + +// GL_OES_mapbuffer +FUNC(GLvoid*, glMapBufferOES, (GLenum target, GLenum access)) +FUNC(GLboolean, glUnmapBufferOES, (GLenum target)) +#define pglMapBufferARB pglMapBufferOES +#define pglUnmapBufferARB pglUnmapBufferOES +#define GL_WRITE_ONLY GL_WRITE_ONLY_OES + +// GL_OES_texture_border_clamp +#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_EDGE + +// GL_OES_rgb8_rgba8 +#define GL_RGBA8 GL_RGBA8_OES + +// GL_OES_depth32 +#define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES typedef GLuint GLhandleARB; Index: ps/trunk/source/ps/GameSetup/HWDetect.cpp =================================================================== --- ps/trunk/source/ps/GameSetup/HWDetect.cpp +++ ps/trunk/source/ps/GameSetup/HWDetect.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -44,7 +44,8 @@ #include "ps/UserReport.h" #include "ps/VideoMode.h" -#ifdef SDL_VIDEO_DRIVER_X11 +// TODO: Support OpenGL platforms which don’t use GLX as well. +#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES #include #include "SDL_syswm.h" @@ -712,7 +713,8 @@ #endif // CONFIG2_GLES -#ifdef SDL_VIDEO_DRIVER_X11 +// TODO: Support OpenGL platforms which don’t use GLX as well. +#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES #define GLXQCR_INTEGER(id) do { \ unsigned int i = UINT_MAX; \ Index: ps/trunk/source/renderer/Renderer.cpp =================================================================== --- ps/trunk/source/renderer/Renderer.cpp +++ ps/trunk/source/renderer/Renderer.cpp @@ -433,11 +433,6 @@ if (skycolor.ParseString(skystring, 255.f)) SetClearColor(skycolor.AsSColor4ub()); -#if CONFIG2_GLES - // Override config option since GLES only supports GLSL - g_RenderingOptions.GetPreferGLSL() = true; -#endif - m_ShadowZBias = 0.02f; m_ShadowMapSize = 0; Index: ps/trunk/source/renderer/SkyManager.cpp =================================================================== --- ps/trunk/source/renderer/SkyManager.cpp +++ ps/trunk/source/renderer/SkyManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -126,11 +126,11 @@ } } - glTexImage2D(types[i], 0, GL_RGB, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &rotated[0]); + glTexImage2D(types[i], 0, GL_RGBA, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &rotated[0]); } else { - glTexImage2D(types[i], 0, GL_RGB, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + glTexImage2D(types[i], 0, GL_RGBA, tex.m_Width, tex.m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); } }