mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
Updating project to run with latest Emscripten
This commit is contained in:
parent
f68e4cd8ed
commit
e581065bbb
|
@ -65,8 +65,9 @@ if (BLAH_PLATFORM_SDL2)
|
|||
|
||||
# Emscripten can import SDL2 directly
|
||||
if (EMSCRIPTEN)
|
||||
|
||||
|
||||
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
||||
target_link_libraries(blah "-s USE_SDL=2 -s USE_WEBGL2=1")
|
||||
|
||||
# Pull SDL2 from its Github repo
|
||||
else()
|
||||
|
@ -106,3 +107,4 @@ endif()
|
|||
if (BLAH_NO_SHARED_PTR)
|
||||
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -141,7 +141,11 @@ bool SDL2_Platform::init(const Config& config)
|
|||
|
||||
// TODO:
|
||||
// control this via some kind of config flag
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// Note: Emscripten gets a Stack Overflow if this is assigned to Verbose, even when
|
||||
// increasing the node stack size to +8mb. Some kind of SDL2 problem?
|
||||
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
|
||||
#endif
|
||||
SDL_LogSetOutputFunction(blah_sdl_log, nullptr);
|
||||
|
||||
// Get SDL version
|
||||
|
@ -164,6 +168,7 @@ bool SDL2_Platform::init(const Config& config)
|
|||
flags |= SDL_WINDOW_OPENGL;
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#else
|
||||
|
@ -731,3 +736,4 @@ Platform* Platform::try_make_platform(const Config& config)
|
|||
}
|
||||
|
||||
#endif // BLAH_PLATFORM_SDL2
|
||||
|
||||
|
|
|
@ -793,21 +793,32 @@ namespace Blah
|
|||
|
||||
virtual void clear(Color color, float depth, u8 stencil, ClearMask mask) override
|
||||
{
|
||||
renderer->gl.BindFramebuffer(GL_FRAMEBUFFER, m_id);
|
||||
renderer->gl.Disable(GL_SCISSOR_TEST);
|
||||
|
||||
int clear = 0;
|
||||
|
||||
if (((int)mask & (int)ClearMask::Color) == (int)ClearMask::Color)
|
||||
{
|
||||
clear |= GL_COLOR_BUFFER_BIT;
|
||||
renderer->gl.ColorMask(true, true, true, true);
|
||||
renderer->gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
|
||||
}
|
||||
|
||||
if (((int)mask & (int)ClearMask::Depth) == (int)ClearMask::Depth)
|
||||
{
|
||||
clear |= GL_DEPTH_BUFFER_BIT;
|
||||
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
|
||||
clear |= GL_STENCIL_BUFFER_BIT;
|
||||
if (renderer->gl.ClearDepth)
|
||||
renderer->gl.ClearDepth(depth);
|
||||
}
|
||||
|
||||
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
|
||||
{
|
||||
clear |= GL_STENCIL_BUFFER_BIT;
|
||||
if (renderer->gl.ClearStencil)
|
||||
renderer->gl.ClearStencil(stencil);
|
||||
}
|
||||
|
||||
renderer->gl.BindFramebuffer(GL_FRAMEBUFFER, m_id);
|
||||
renderer->gl.Disable(GL_SCISSOR_TEST);
|
||||
renderer->gl.ColorMask(true, true, true, true);
|
||||
renderer->gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
|
||||
renderer->gl.ClearDepth(depth);
|
||||
renderer->gl.ClearStencil(stencil);
|
||||
renderer->gl.Clear(clear);
|
||||
}
|
||||
};
|
||||
|
@ -1535,22 +1546,33 @@ namespace Blah
|
|||
|
||||
void Renderer_OpenGL::clear_backbuffer(Color color, float depth, u8 stencil, ClearMask mask)
|
||||
{
|
||||
int clear = 0;
|
||||
renderer->gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderer->gl.Disable(GL_SCISSOR_TEST);
|
||||
|
||||
if (((int)mask & (int)ClearMask::Color) == (int)ClearMask::Color)
|
||||
clear |= GL_COLOR_BUFFER_BIT;
|
||||
if (((int)mask & (int)ClearMask::Depth) == (int)ClearMask::Depth)
|
||||
clear |= GL_DEPTH_BUFFER_BIT;
|
||||
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
|
||||
clear |= GL_STENCIL_BUFFER_BIT;
|
||||
int clear = 0;
|
||||
|
||||
renderer->gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
renderer->gl.Disable(GL_SCISSOR_TEST);
|
||||
renderer->gl.ColorMask(true, true, true, true);
|
||||
renderer->gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
|
||||
renderer->gl.ClearDepth(depth);
|
||||
renderer->gl.ClearStencil(stencil);
|
||||
renderer->gl.Clear(clear);
|
||||
if (((int)mask & (int)ClearMask::Color) == (int)ClearMask::Color)
|
||||
{
|
||||
clear |= GL_COLOR_BUFFER_BIT;
|
||||
renderer->gl.ColorMask(true, true, true, true);
|
||||
renderer->gl.ClearColor(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
|
||||
}
|
||||
|
||||
if (((int)mask & (int)ClearMask::Depth) == (int)ClearMask::Depth)
|
||||
{
|
||||
clear |= GL_DEPTH_BUFFER_BIT;
|
||||
if (renderer->gl.ClearDepth)
|
||||
renderer->gl.ClearDepth(depth);
|
||||
}
|
||||
|
||||
if (((int)mask & (int)ClearMask::Stencil) == (int)ClearMask::Stencil)
|
||||
{
|
||||
clear |= GL_STENCIL_BUFFER_BIT;
|
||||
if (renderer->gl.ClearStencil)
|
||||
renderer->gl.ClearStencil(stencil);
|
||||
}
|
||||
|
||||
renderer->gl.Clear(clear);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1569,3 +1591,4 @@ Blah::Renderer* Blah::Renderer::try_make_opengl()
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user