Compare commits
No commits in common. "155ced8410ec399721c21b9ef01c2088893cc9d2" and "b989eba66de743692532c5f0aace97be9f3a8041" have entirely different histories.
155ced8410
...
b989eba66d
18 changed files with 118 additions and 146 deletions
|
|
@ -8,36 +8,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|||
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" PSEMEK_BUILD_TYPE)
|
||||
|
||||
set(_PSEMEK_ALL_PLATFORMS linux windows mac android web)
|
||||
|
||||
if(WIN32)
|
||||
set(_PSEMEK_PLATFORM windows)
|
||||
elseif(APPLE)
|
||||
set(_PSEMEK_PLATFORM mac)
|
||||
elseif(ANDROID)
|
||||
set(_PSEMEK_PLATFORM android)
|
||||
elseif(UNIX)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
set(_PSEMEK_PLATFORM web)
|
||||
else()
|
||||
set(_PSEMEK_PLATFORM linux)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Failed to detect platform")
|
||||
set(_PSEMEK_PLATFORM unknown)
|
||||
endif()
|
||||
|
||||
set(PSEMEK_PLATFORM "${_PSEMEK_PLATFORM}" CACHE INTERNAL "Build platform (auto-detected)")
|
||||
|
||||
foreach(_PLATFORM IN LISTS _PSEMEK_ALL_PLATFORMS)
|
||||
string(TOUPPER "${_PLATFORM}" _PLATFORM_UPPER)
|
||||
set(_PLATFORM_ON OFF)
|
||||
if("${_PLATFORM}" STREQUAL "${_PSEMEK_PLATFORM}")
|
||||
set(_PLATFORM_ON ON)
|
||||
endif()
|
||||
set(PSEMEK_PLATFORM_${_PLATFORM_UPPER} "${_PLATFORM_ON}" CACHE INTERNAL "Build platform is ${_PLATFORM}")
|
||||
endforeach()
|
||||
|
||||
set(PSEMEK_DEFINITIONS)
|
||||
if(PSEMEK_BUILD_TYPE STREQUAL "DEBUG")
|
||||
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_DEBUG=1")
|
||||
|
|
|
|||
|
|
@ -147,10 +147,6 @@ typedef unsigned short GLhalfNV;
|
|||
typedef GLintptr GLvdpauSurfaceNV;
|
||||
typedef void (GLVULKANPROCNV)(void);
|
||||
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
|
|
@ -1869,13 +1865,14 @@ namespace gl
|
|||
const char * api();
|
||||
int major_version();
|
||||
int minor_version();
|
||||
std::unordered_set<std::string> const & extensions();
|
||||
std::string_view shader_prelude();
|
||||
|
||||
bool has_extension(const char * name);
|
||||
bool ext_ARB_compute_shader();
|
||||
bool ext_ARB_shader_image_load_store();
|
||||
bool ext_ARB_texture_filter_anisotropic();
|
||||
|
||||
const char * shader_prefix();
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
#include <stdio.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
#include <EGL/egl.h>
|
||||
#else
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
|
|
@ -79,13 +77,6 @@ namespace gl
|
|||
|
||||
return reinterpret_cast<void*>(GetProcAddress(image, reinterpret_cast<LPCSTR>(name)));
|
||||
}
|
||||
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
|
||||
static void * get_proc_address(const char *func)
|
||||
{
|
||||
return reinterpret_cast<void *>(eglGetProcAddress(func));
|
||||
}
|
||||
|
||||
#else // GLX
|
||||
|
||||
|
|
@ -1253,7 +1244,7 @@ namespace gl
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::unordered_set<std::string> extensions_set;
|
||||
static std::unordered_set<std::string> extensions;
|
||||
bool initialize()
|
||||
{
|
||||
if (!load_core()) return false;
|
||||
|
|
@ -1261,13 +1252,13 @@ namespace gl
|
|||
GLint num_extensions;
|
||||
internal::glGetIntegerv(0x821D, &num_extensions);
|
||||
for (GLint i = 0; i < num_extensions; ++i)
|
||||
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
|
||||
if (extensions_set.count("GL_ARB_compute_shader") > 0)
|
||||
if (extensions.count("GL_ARB_compute_shader") > 0)
|
||||
ext_GL_ARB_compute_shader_loaded = load_ext_GL_ARB_compute_shader();
|
||||
if (extensions_set.count("GL_ARB_shader_image_load_store") > 0)
|
||||
if (extensions.count("GL_ARB_shader_image_load_store") > 0)
|
||||
ext_GL_ARB_shader_image_load_store_loaded = load_ext_GL_ARB_shader_image_load_store();
|
||||
if (extensions_set.count("GL_ARB_texture_filter_anisotropic") > 0)
|
||||
if (extensions.count("GL_ARB_texture_filter_anisotropic") > 0)
|
||||
ext_GL_ARB_texture_filter_anisotropic_loaded = load_ext_GL_ARB_texture_filter_anisotropic();
|
||||
|
||||
return true;
|
||||
|
|
@ -1279,16 +1270,19 @@ namespace gl
|
|||
|
||||
int minor_version(){ return 3; }
|
||||
|
||||
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
|
||||
|
||||
std::string_view shader_prelude(){ return R"(#version 330 core
|
||||
)";
|
||||
}
|
||||
bool has_extension(const char * name){ return extensions.contains(name); }
|
||||
|
||||
bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; }
|
||||
bool ext_ARB_shader_image_load_store(){ return ext_GL_ARB_shader_image_load_store_loaded; }
|
||||
bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; }
|
||||
|
||||
const char * shader_prefix()
|
||||
{
|
||||
return R"(#version 330 core
|
||||
|
||||
)";
|
||||
}
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
|||
|
|
@ -147,10 +147,6 @@ typedef unsigned short GLhalfNV;
|
|||
typedef GLintptr GLvdpauSurfaceNV;
|
||||
typedef void (GLVULKANPROCNV)(void);
|
||||
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
|
|
@ -1292,13 +1288,9 @@ namespace gl
|
|||
|
||||
// GL_EXT_texture_filter_anisotropic
|
||||
|
||||
constexpr GLenum TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
|
||||
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
|
||||
constexpr GLenum TEXTURE_MAX_ANISOTROPY = 0x84FE;
|
||||
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY = 0x84FF;
|
||||
|
||||
// Manually added compatibility constants
|
||||
|
||||
constexpr GLenum TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT;
|
||||
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY = MAX_TEXTURE_MAX_ANISOTROPY_EXT;
|
||||
|
||||
namespace sys
|
||||
{
|
||||
|
|
@ -1307,11 +1299,12 @@ namespace gl
|
|||
const char * api();
|
||||
int major_version();
|
||||
int minor_version();
|
||||
std::unordered_set<std::string> const & extensions();
|
||||
std::string_view shader_prelude();
|
||||
|
||||
bool has_extension(const char * name);
|
||||
bool ext_EXT_texture_filter_anisotropic();
|
||||
|
||||
const char * shader_prefix();
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@
|
|||
#include <stdio.h>
|
||||
#elif defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
|
|
@ -79,14 +80,14 @@ namespace gl
|
|||
|
||||
return reinterpret_cast<void*>(GetProcAddress(image, reinterpret_cast<LPCSTR>(name)));
|
||||
}
|
||||
|
||||
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
|
||||
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
|
||||
static void * get_proc_address(const char *func)
|
||||
{
|
||||
return reinterpret_cast<void *>(eglGetProcAddress(func));
|
||||
}
|
||||
|
||||
|
||||
#else // GLX
|
||||
|
||||
static void * get_proc_address(const char *func)
|
||||
|
|
@ -867,7 +868,7 @@ namespace gl
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::unordered_set<std::string> extensions_set;
|
||||
static std::unordered_set<std::string> extensions;
|
||||
bool initialize()
|
||||
{
|
||||
if (!load_core()) return false;
|
||||
|
|
@ -875,9 +876,9 @@ namespace gl
|
|||
GLint num_extensions;
|
||||
internal::glGetIntegerv(0x821D, &num_extensions);
|
||||
for (GLint i = 0; i < num_extensions; ++i)
|
||||
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
|
||||
if (extensions_set.count("GL_EXT_texture_filter_anisotropic") > 0)
|
||||
if (extensions.count("GL_EXT_texture_filter_anisotropic") > 0)
|
||||
ext_GL_EXT_texture_filter_anisotropic_loaded = load_ext_GL_EXT_texture_filter_anisotropic();
|
||||
|
||||
return true;
|
||||
|
|
@ -889,19 +890,22 @@ namespace gl
|
|||
|
||||
int minor_version(){ return 0; }
|
||||
|
||||
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
|
||||
bool has_extension(const char * name){ return extensions.contains(name); }
|
||||
|
||||
std::string_view shader_prelude(){ return R"(#version 300 es
|
||||
bool ext_EXT_texture_filter_anisotropic(){ return ext_GL_EXT_texture_filter_anisotropic_loaded; }
|
||||
|
||||
const char * shader_prefix()
|
||||
{
|
||||
return R"(#version 300 es
|
||||
|
||||
precision highp int;
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision highp usampler2D;
|
||||
|
||||
)";
|
||||
}
|
||||
|
||||
bool ext_EXT_texture_filter_anisotropic(){ return ext_GL_EXT_texture_filter_anisotropic_loaded; }
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
|||
|
|
@ -147,10 +147,6 @@ typedef unsigned short GLhalfNV;
|
|||
typedef GLintptr GLvdpauSurfaceNV;
|
||||
typedef void (GLVULKANPROCNV)(void);
|
||||
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
||||
|
|
@ -1953,14 +1949,17 @@ namespace gl
|
|||
const char * api();
|
||||
int major_version();
|
||||
int minor_version();
|
||||
std::unordered_set<std::string> const & extensions();
|
||||
std::string_view shader_prelude();
|
||||
|
||||
bool has_extension(const char * name);
|
||||
bool ext_ARB_compute_shader();
|
||||
bool ext_ARB_shader_image_load_store();
|
||||
bool ext_ARB_texture_filter_anisotropic();
|
||||
|
||||
const char * shader_prefix();
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
||||
#define PSEMEK_GLES 1
|
||||
|
||||
|
|
|
|||
|
|
@ -1235,7 +1235,7 @@ namespace gl
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::unordered_set<std::string> extensions_set;
|
||||
static std::unordered_set<std::string> extensions;
|
||||
bool initialize()
|
||||
{
|
||||
if (!load_core()) return false;
|
||||
|
|
@ -1243,13 +1243,13 @@ namespace gl
|
|||
GLint num_extensions;
|
||||
internal::glGetIntegerv(0x821D, &num_extensions);
|
||||
for (GLint i = 0; i < num_extensions; ++i)
|
||||
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
|
||||
|
||||
if (extensions_set.count("GL_ARB_compute_shader") > 0)
|
||||
if (extensions.count("GL_ARB_compute_shader") > 0)
|
||||
ext_GL_ARB_compute_shader_loaded = load_ext_GL_ARB_compute_shader();
|
||||
if (extensions_set.count("GL_ARB_shader_image_load_store") > 0)
|
||||
if (extensions.count("GL_ARB_shader_image_load_store") > 0)
|
||||
ext_GL_ARB_shader_image_load_store_loaded = load_ext_GL_ARB_shader_image_load_store();
|
||||
if (extensions_set.count("GL_ARB_texture_filter_anisotropic") > 0)
|
||||
if (extensions.count("GL_ARB_texture_filter_anisotropic") > 0)
|
||||
ext_GL_ARB_texture_filter_anisotropic_loaded = load_ext_GL_ARB_texture_filter_anisotropic();
|
||||
|
||||
return true;
|
||||
|
|
@ -1261,21 +1261,24 @@ namespace gl
|
|||
|
||||
int minor_version(){ return 2; }
|
||||
|
||||
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
|
||||
|
||||
std::string_view shader_prelude(){ return R"(#version 320 es
|
||||
|
||||
precision highp int;
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision highp usampler2D;
|
||||
)";
|
||||
}
|
||||
bool has_extension(const char * name){ return extensions.contains(name); }
|
||||
|
||||
bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; }
|
||||
bool ext_ARB_shader_image_load_store(){ return ext_GL_ARB_shader_image_load_store_loaded; }
|
||||
bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; }
|
||||
|
||||
const char * shader_prefix()
|
||||
{
|
||||
return R"(#version 320 es
|
||||
|
||||
precision highp int;
|
||||
precision highp float;
|
||||
precision highp sampler2D;
|
||||
precision highp usampler2D;
|
||||
|
||||
)";
|
||||
}
|
||||
|
||||
} // namespace sys
|
||||
|
||||
} // namespace gl
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@
|
|||
"loader_namespace": "sys",
|
||||
"internal_namespace": "internal",
|
||||
"internal_prefix": "",
|
||||
"shader_prelude": true,
|
||||
"undef": 4,
|
||||
"strip": true,
|
||||
"out_header": "api/gl33/include/psemek/gfx/gl.hpp",
|
||||
"out_source": "api/gl33/source/gl.cpp",
|
||||
"out_header": "gl.hpp",
|
||||
"out_source": "gl.cpp",
|
||||
"include": "<psemek/gfx/gl.hpp>"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"spec_file": "gl.xml",
|
||||
"api": "gles3",
|
||||
"api": "gles2",
|
||||
"version": "3.0",
|
||||
"profile": "core",
|
||||
"extensions": [
|
||||
|
|
@ -11,10 +11,9 @@
|
|||
"loader_namespace": "sys",
|
||||
"internal_namespace": "internal",
|
||||
"internal_prefix": "",
|
||||
"shader_prelude": true,
|
||||
"undef": 4,
|
||||
"strip": true,
|
||||
"out_header": "api/gles30-emscripten/include/psemek/gfx/gl.hpp",
|
||||
"out_source": "api/gles30-emscripten/source/gl.cpp",
|
||||
"out_header": "gl.hpp",
|
||||
"out_source": "gl.cpp",
|
||||
"include": "<psemek/gfx/gl.hpp>"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"spec_file": "gl.xml",
|
||||
"api": "gles3",
|
||||
"api": "gles2",
|
||||
"version": "3.2",
|
||||
"profile": "core",
|
||||
"extensions": [
|
||||
|
|
@ -13,10 +13,9 @@
|
|||
"loader_namespace": "sys",
|
||||
"internal_namespace": "internal",
|
||||
"internal_prefix": "",
|
||||
"shader_prelude": true,
|
||||
"undef": 4,
|
||||
"strip": true,
|
||||
"out_header": "api/gles32/include/psemek/gfx/gl.hpp",
|
||||
"out_source": "api/gles32/source/gl.cpp",
|
||||
"out_header": "gl.hpp",
|
||||
"out_source": "gl.cpp",
|
||||
"include": "<psemek/gfx/gl.hpp>"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,11 +60,8 @@ namespace psemek::gfx
|
|||
, part(part)
|
||||
{}
|
||||
|
||||
#ifndef PSEMEK_GLES
|
||||
using texture_view_1d = basic_texture_view<1, gl::TEXTURE_1D>;
|
||||
using texture_view_1d_array = basic_texture_view<2, gl::TEXTURE_1D_ARRAY>;
|
||||
#endif
|
||||
|
||||
using texture_view_2d = basic_texture_view<2, gl::TEXTURE_2D>;
|
||||
using texture_view_2d_array = basic_texture_view<3, gl::TEXTURE_2D_ARRAY>;
|
||||
using texture_view_3d = basic_texture_view<3, gl::TEXTURE_3D>;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include <psemek/gfx/effect/blur.hpp>
|
||||
#include <psemek/gfx/program.hpp>
|
||||
#include <psemek/gfx/array.hpp>
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
|
||||
#include <psemek/util/to_string.hpp>
|
||||
|
||||
|
|
@ -13,7 +12,8 @@ namespace psemek::gfx
|
|||
{
|
||||
|
||||
static char const blur_vs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
const vec4 vertices[6] = vec4[6](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4( 1.0, -1.0, 0.0, 1.0),
|
||||
|
|
@ -34,7 +34,8 @@ void main()
|
|||
)";
|
||||
|
||||
static char const blur_fs_template[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
#define BLUR_SIZE @BLUR_SIZE@
|
||||
#define BLUR_COEFFS_COUNT 2 * BLUR_SIZE + 1
|
||||
|
||||
|
|
@ -117,7 +118,7 @@ void main()
|
|||
gfx::array array;
|
||||
|
||||
blur_impl(int size, float sigma, float gamma, bool horizontal)
|
||||
: program(std::string(gl::sys::shader_prelude()) + blur_vs, std::string(gl::sys::shader_prelude()) + generate_blur_fs_source(size, sigma, horizontal))
|
||||
: program(blur_vs, generate_blur_fs_source(size, sigma, horizontal))
|
||||
{
|
||||
program.bind();
|
||||
program["u_texture"] = 0;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
#include <psemek/gfx/program.hpp>
|
||||
#include <psemek/gfx/array.hpp>
|
||||
#include <psemek/gfx/error.hpp>
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
static char const fxaa_vs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
const vec4 vertices[6] = vec4[6](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4( 1.0, -1.0, 0.0, 1.0),
|
||||
|
|
@ -34,7 +34,8 @@ void main()
|
|||
// TODO: refactor
|
||||
|
||||
static char const fxaa_fs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
uniform sampler2D u_input;
|
||||
uniform vec2 u_d;
|
||||
|
||||
|
|
@ -206,7 +207,7 @@ void main()
|
|||
|
||||
struct fxaa::impl
|
||||
{
|
||||
gfx::program program{std::string(gl::sys::shader_prelude()) + fxaa_vs, std::string(gl::sys::shader_prelude()) + fxaa_fs};
|
||||
gfx::program program{fxaa_vs, fxaa_fs};
|
||||
gfx::array array;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
#include <psemek/gfx/program.hpp>
|
||||
#include <psemek/gfx/array.hpp>
|
||||
#include <psemek/gfx/error.hpp>
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
static char const gamma_vs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
const vec4 vertices[6] = vec4[6](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4( 1.0, -1.0, 0.0, 1.0),
|
||||
|
|
@ -30,7 +30,8 @@ void main()
|
|||
)";
|
||||
|
||||
static char const gamma_fs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
uniform float u_gamma;
|
||||
uniform sampler2D u_input;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ void main()
|
|||
|
||||
struct gamma_correction::impl
|
||||
{
|
||||
gfx::program program{std::string(gl::sys::shader_prelude()) + gamma_vs, std::string(gl::sys::shader_prelude()) + gamma_fs};
|
||||
gfx::program program{gamma_vs, gamma_fs};
|
||||
gfx::array array;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include <psemek/gfx/effect/overlay.hpp>
|
||||
#include <psemek/gfx/program.hpp>
|
||||
#include <psemek/gfx/array.hpp>
|
||||
#include <psemek/gfx/gl.hpp>
|
||||
|
||||
#include <psemek/util/pimpl.hpp>
|
||||
|
||||
|
|
@ -9,7 +8,8 @@ namespace psemek::gfx
|
|||
{
|
||||
|
||||
static char const overlay_vs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
const vec4 vertices[6] = vec4[6](
|
||||
vec4(-1.0, -1.0, 0.0, 1.0),
|
||||
vec4( 1.0, -1.0, 0.0, 1.0),
|
||||
|
|
@ -30,7 +30,8 @@ void main()
|
|||
)";
|
||||
|
||||
static char const overlay_fs[] =
|
||||
R"(
|
||||
R"(#version 330
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
in vec2 texcoord;
|
||||
|
|
@ -45,7 +46,7 @@ void main()
|
|||
|
||||
struct overlay::impl
|
||||
{
|
||||
gfx::program program{std::string(gl::sys::shader_prelude()) + overlay_vs, std::string(gl::sys::shader_prelude()) + overlay_fs};
|
||||
gfx::program program{overlay_vs, overlay_fs};
|
||||
gfx::array array;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ namespace psemek::gfx
|
|||
|
||||
std::optional<std::size_t> available_memory()
|
||||
{
|
||||
static bool const nvx = gl::sys::extensions().contains("GL_NVX_gpu_memory_info");
|
||||
static bool const ati = gl::sys::extensions().contains("GL_ATI_meminfo");
|
||||
static bool const nvx = gl::sys::has_extension("GL_NVX_gpu_memory_info");
|
||||
static bool const ati = gl::sys::has_extension("GL_ATI_meminfo");
|
||||
|
||||
if (nvx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ void main()
|
|||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
static std::string shader_prefix = std::string{gl::sys::shader_prelude()};
|
||||
static std::string shader_prefix = gl::sys::shader_prefix();
|
||||
|
||||
struct painter::impl
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,11 +3,26 @@ set(PSEMEK_PACKAGE_OUTPUT_PATH "" CACHE STRING "Packaging output path")
|
|||
set(PSEMEK_PACKAGE_VERSION_SUFFIX "" CACHE STRING "Packaging version suffix")
|
||||
|
||||
if(PSEMEK_PACKAGE_MODE)
|
||||
set(PSEMEK_PACKAGE_SUFFIX ${PSEMEK_PLATFORM} CACHE INTERNAL "Packaging suffix" FORCE)
|
||||
if(WIN32)
|
||||
set(PSEMEK_PACKAGE_SUFFIX_RAW windows)
|
||||
elseif(APPLE)
|
||||
set(PSEMEK_PACKAGE_SUFFIX_RAW mac)
|
||||
elseif(ANDROID)
|
||||
set(PSEMEK_PACKAGE_SUFFIX_RAW android)
|
||||
elseif(UNIX)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
set(PSEMEK_PACKAGE_SUFFIX_RAW web)
|
||||
else()
|
||||
set(PSEMEK_PACKAGE_SUFFIX_RAW linux)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL "Uknown system for packaging")
|
||||
endif()
|
||||
set(PSEMEK_PACKAGE_SUFFIX ${PSEMEK_PACKAGE_SUFFIX_RAW} CACHE INTERNAL "Packaging suffix" FORCE)
|
||||
|
||||
set(PSEMEK_PACKAGE_LINK_FLAGS_RAW)
|
||||
|
||||
if(PSEMEK_PLATFORM_WEB)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-sMIN_WEBGL_VERSION=2" "-sNO_DISABLE_EXCEPTION_CATCHING" "-sFULL_ES3")
|
||||
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$autoResumeAudioContext','$dynCall'")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
|
@ -26,7 +41,7 @@ function(psemek_package_output_path target outvar)
|
|||
message(FATAL "psemek_package_output_path must only be called during packaging")
|
||||
endif()
|
||||
|
||||
if(PSEMEK_PLATFORM_ANDROID)
|
||||
if(ANDROID)
|
||||
set(_PACKAGE_EXTENSION apk)
|
||||
else()
|
||||
set(_PACKAGE_EXTENSION zip)
|
||||
|
|
@ -45,7 +60,7 @@ function(psemek_add_executable_impl target is_application)
|
|||
|
||||
target_link_libraries(${target} PUBLIC psemek)
|
||||
if(${is_application})
|
||||
if(PSEMEK_PLATFORM_ANDROID)
|
||||
if(ANDROID)
|
||||
target_link_libraries(${target} PUBLIC
|
||||
"-Wl,--whole-archive $<TARGET_FILE:${PSEMEK_BACKEND_LIBRARY}> -Wl,--no-whole-archive"
|
||||
${PSEMEK_BACKEND_LIBRARY})
|
||||
|
|
@ -53,7 +68,7 @@ function(psemek_add_executable_impl target is_application)
|
|||
target_link_libraries(${target} PUBLIC ${PSEMEK_BACKEND_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(PSEMEK_PLATFORM_WEB)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
target_link_options(${target} PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/web/template.html"
|
||||
)
|
||||
|
|
@ -68,13 +83,13 @@ function(psemek_add_executable_impl target is_application)
|
|||
|
||||
target_compile_definitions(${target} PUBLIC "-DPSEMEK_PACKAGE_MODE")
|
||||
|
||||
if(PSEMEK_PLATFORM_LINUX)
|
||||
if(UNIX AND (NOT APPLE))
|
||||
set_target_properties(${target} PROPERTIES
|
||||
BUILD_RPATH "."
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PSEMEK_PLATFORM_LINUX)
|
||||
if(UNIX AND (NOT APPLE) AND (NOT ANDROID) AND (NOT (CMAKE_SYSTEM_NAME STREQUAL Emscripten)))
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND chrpath -r . $<TARGET_FILE:${target}>
|
||||
)
|
||||
|
|
@ -82,13 +97,13 @@ function(psemek_add_executable_impl target is_application)
|
|||
|
||||
psemek_package_output_path(${target} _OUTPUT_PATH)
|
||||
|
||||
if(NOT PSEMEK_PLATFORM_ANDROID)
|
||||
if(NOT ANDROID)
|
||||
get_filename_component(_OUTPUT_DIRECTORY "${_OUTPUT_PATH}" DIRECTORY)
|
||||
|
||||
set(_TARGET_FILE $<TARGET_FILE:${target}>)
|
||||
|
||||
set(_TARGET_RUNTIME)
|
||||
if(PSEMEK_PLATFORM_WEB)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
set(_TARGET_PARENT $<PATH:GET_PARENT_PATH,${_TARGET_FILE}>)
|
||||
set(_TARGET_STEM $<PATH:GET_STEM,${_TARGET_FILE}>)
|
||||
set(_TARGET_NOEXT "${_TARGET_PARENT}/${_TARGET_STEM}")
|
||||
|
|
@ -111,7 +126,6 @@ function(psemek_add_executable_impl target is_application)
|
|||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND echo Packaging target ${target} into ${_OUTPUT_PATH}
|
||||
COMMAND mkdir -pv "${_OUTPUT_DIRECTORY}"
|
||||
COMMAND rm -f "${_OUTPUT_PATH}"
|
||||
COMMAND zip -v "${_OUTPUT_PATH}" -j ${_COPY_FILES}
|
||||
COMMAND echo Packaged target ${target} into ${_OUTPUT_PATH}
|
||||
)
|
||||
|
|
@ -190,7 +204,7 @@ function(psemek_add_library target)
|
|||
endfunction()
|
||||
|
||||
function(psemek_add_winrc target path)
|
||||
if(PSEMEK_PLATFORM_WINDOWS AND (TARGET ${target}))
|
||||
if(WIN32 AND (TARGET ${target}))
|
||||
get_target_property(OUT_DIR ${target} BINARY_DIR)
|
||||
|
||||
set(_IN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${path}")
|
||||
|
|
@ -210,12 +224,12 @@ endfunction()
|
|||
function(psemek_package_files target)
|
||||
if(PSEMEK_PACKAGE_MODE)
|
||||
if(PSEMEK_PACKAGE_TARGET)
|
||||
if(PSEMEK_PLATFORM_ANDROID)
|
||||
if(ANDROID)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
COMMAND ${PSEMEK_COPY_FILES} ${ARGN}
|
||||
)
|
||||
elseif(PSEMEK_PLATFORM_WEB)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
|
||||
foreach(_FILE IN LISTS ARGN)
|
||||
target_link_options(${target} PRIVATE
|
||||
"--preload-file=${CMAKE_CURRENT_LIST_DIR}/${_FILE}@/${_FILE}"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue