1
0
forked from 0ad/0ad

Fixes GLES mode builds on Mesa and running on Intel Iris drivers.

Patch By: linkmauve
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D2448
This was SVN commit r23410.
This commit is contained in:
Vladislav Belov 2020-01-17 21:13:51 +00:00
parent 220f1be652
commit 1750b0b34c
7 changed files with 49 additions and 26 deletions

View File

@ -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 @@ function RunDetection(settings)
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]/))

View File

@ -129,13 +129,13 @@ void main()
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) {

View File

@ -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 @@ void CChart::DrawLine(const CShaderProgramPtr& shader, const CGUIColor& color, c
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<float>& vertices) const

View File

@ -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 @@ actually supported).
#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 @@ actually supported).
#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;

View File

@ -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 <GL/glx.h>
#include "SDL_syswm.h"
@ -712,7 +713,8 @@ static void ReportGLLimits(const ScriptInterface& scriptInterface, JS::HandleVal
#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; \

View File

@ -433,11 +433,6 @@ CRenderer::CRenderer()
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;

View File

@ -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 @@ void SkyManager::LoadSkyTextures()
}
}
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);
}
}