GLES support

This commit is contained in:
milek7
2018-10-16 20:32:45 +02:00
parent f8857158ce
commit d16d96f2b2
77 changed files with 5601 additions and 26893 deletions

View File

@@ -59,11 +59,15 @@ void gl::framebuffer::blit_to(framebuffer &other, int w, int h, GLbitfield mask,
{
glBindFramebuffer(GL_READ_FRAMEBUFFER, *this);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, other);
if (mask & GL_COLOR_BUFFER_BIT)
{
glReadBuffer(attachment);
glDrawBuffer(attachment);
}
int attachment_n = attachment - GL_COLOR_ATTACHMENT0;
GLenum outputs[8] = { GL_NONE };
outputs[attachment_n] = attachment;
glReadBuffer(attachment);
glDrawBuffers(attachment_n + 1, outputs);
glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, mask, GL_NEAREST);
unbind();
}

View File

@@ -9,6 +9,7 @@ void gl::glsl_common_setup()
"#define ENVMAP_ENABLED " + std::to_string((int)Global.gfx_envmap_enabled) + "\n" +
"#define MOTIONBLUR_ENABLED " + std::to_string((int)Global.gfx_postfx_motionblur_enabled) + "\n" +
"#define POSTFX_ENABLED " + std::to_string((int)!Global.gfx_skippipeline) + "\n" +
"#define USE_GLES " + std::to_string((int)Global.use_gles) + "\n" +
"const uint MAX_LIGHTS = " + std::to_string(MAX_LIGHTS) + "U;\n" +
"const uint MAX_PARAMS = " + std::to_string(MAX_PARAMS) + "U;\n" +
R"STRING(

View File

@@ -1,6 +1,6 @@
#pragma once
#include <GL/glew.h>
#include <glad/glad.h>
namespace gl
{

View File

@@ -202,7 +202,18 @@ void gl::shader::log_error(const std::string &str)
gl::shader::shader(const std::string &filename)
{
name = filename;
std::string str = read_file(filename);
std::string str;
if (!Global.use_gles)
{
str += "#version 330 core\n";
}
else
{
str += "#version 300 es\n";
str += "precision highp float;\n";
str += "precision highp sampler2DShadow;\n";
}
str += read_file(filename);
process_source(str);
const GLchar *cstr = str.c_str();
@@ -228,9 +239,10 @@ gl::shader::shader(const std::string &filename)
{
GLchar info[512];
glGetShaderInfoLog(*this, 512, 0, info);
ErrorLog(std::string(info));
std::cerr << std::string(info) << std::endl;
throw shader_exception("failed to compile " + filename + ": " + std::string(info));
}
}
gl::shader::~shader()