mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Working on emscripten support ( compiles but doesn't render anything ).
Fixed a bug with a shader in OpenGL ES 2 ( i haven't seen this before, it seems that it new ).
This commit is contained in:
@@ -4,14 +4,15 @@
|
||||
#include <eepp/helper/sophist/sophist.h>
|
||||
#include <cmath>
|
||||
|
||||
#define EE_PLATFORM_WIN 1
|
||||
#define EE_PLATFORM_LINUX 2
|
||||
#define EE_PLATFORM_MACOSX 3
|
||||
#define EE_PLATFORM_BSD 4
|
||||
#define EE_PLATFORM_SOLARIS 5
|
||||
#define EE_PLATFORM_HAIKU 6
|
||||
#define EE_PLATFORM_ANDROID 7
|
||||
#define EE_PLATFORM_IOS 8
|
||||
#define EE_PLATFORM_WIN 1
|
||||
#define EE_PLATFORM_LINUX 2
|
||||
#define EE_PLATFORM_MACOSX 3
|
||||
#define EE_PLATFORM_BSD 4
|
||||
#define EE_PLATFORM_SOLARIS 5
|
||||
#define EE_PLATFORM_HAIKU 6
|
||||
#define EE_PLATFORM_ANDROID 7
|
||||
#define EE_PLATFORM_IOS 8
|
||||
#define EE_PLATFORM_EMSCRIPTEN 9
|
||||
|
||||
#if defined( __WIN32__ ) || defined( _WIN32 ) || defined( _WIN64 )
|
||||
#define EE_PLATFORM EE_PLATFORM_WIN
|
||||
@@ -43,7 +44,8 @@
|
||||
#else
|
||||
#define EE_PLATFORM EE_PLATFORM_MACOSX
|
||||
#endif
|
||||
|
||||
#elif defined( __emscripten__ ) || defined( EMSCRIPTEN )
|
||||
#define EE_PLATFORM EE_PLATFORM_EMSCRIPTEN
|
||||
#elif defined( __ANDROID__ ) || defined( ANDROID )
|
||||
#define EE_PLATFORM EE_PLATFORM_ANDROID
|
||||
#elif defined ( linux ) || defined( __linux__ )
|
||||
@@ -56,12 +58,12 @@
|
||||
#define EE_PLATFORM EE_PLATFORM_HAIKU
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS
|
||||
#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS || EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
#if !defined( EE_GLES1 ) && !defined( EE_GLES2 )
|
||||
#define EE_GLES2
|
||||
#endif
|
||||
|
||||
#ifndef EE_PLATFORM_TOUCH
|
||||
#if !defined( EE_PLATFORM_TOUCH ) && EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
#define EE_PLATFORM_TOUCH
|
||||
#endif
|
||||
#endif
|
||||
@@ -77,7 +79,7 @@
|
||||
#endif
|
||||
|
||||
//! Since EE just use basic POSIX stuff, declare as POSIX some OS that are mostly POSIX-compliant
|
||||
#if defined ( linux ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) || defined( __SVR4 ) || defined( __sun ) || defined( __APPLE_CC__ ) || defined ( __APPLE__ ) || defined( __HAIKU__ ) || defined( __BEOS__ )
|
||||
#if defined ( linux ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) || defined( __SVR4 ) || defined( __sun ) || defined( __APPLE_CC__ ) || defined ( __APPLE__ ) || defined( __HAIKU__ ) || defined( __BEOS__ ) || defined( __emscripten__ ) || defined( EMSCRIPTEN )
|
||||
#define EE_PLATFORM_POSIX
|
||||
#endif
|
||||
|
||||
|
||||
44
premake4.lua
44
premake4.lua
@@ -40,6 +40,17 @@ newplatform {
|
||||
}
|
||||
}
|
||||
|
||||
newplatform {
|
||||
name = "emscripten",
|
||||
description = "Emscripten",
|
||||
gcc = {
|
||||
cc = "emcc",
|
||||
cxx = "em++",
|
||||
ar = "emar",
|
||||
cppflags = "-MMD -D__emscripten__"
|
||||
}
|
||||
}
|
||||
|
||||
newgcctoolchain {
|
||||
name = "mingw32",
|
||||
description = "Mingw32 to cross-compile windows binaries from *nix",
|
||||
@@ -121,6 +132,10 @@ function os.get_real()
|
||||
if _OPTIONS.platform == "mingw32" then
|
||||
return _OPTIONS.platform
|
||||
end
|
||||
|
||||
if _OPTIONS.platform == "emscripten" then
|
||||
return _OPTIONS.platform
|
||||
end
|
||||
|
||||
return os.get()
|
||||
end
|
||||
@@ -244,6 +259,8 @@ end
|
||||
function build_link_configuration( package_name, use_ee_icon )
|
||||
includedirs { "include", "src" }
|
||||
|
||||
local extension = "";
|
||||
|
||||
if package_name == "eepp" then
|
||||
defines { "EE_EXPORTS" }
|
||||
elseif package_name == "eepp-static" then
|
||||
@@ -265,8 +282,12 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
linkoptions { "../../assets/icon/ee.res" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if os.is_real("emscripten") then
|
||||
extension = ".html"
|
||||
end
|
||||
end
|
||||
|
||||
configuration "debug"
|
||||
defines { "DEBUG", "EE_DEBUG", "EE_MEMORY_MANAGER" }
|
||||
flags { "Symbols" }
|
||||
@@ -275,7 +296,7 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
end
|
||||
|
||||
targetname ( package_name .. "-debug" )
|
||||
targetname ( package_name .. "-debug" .. extension )
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
@@ -285,11 +306,20 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
buildoptions { "-fno-strict-aliasing -O3 -s -ffast-math" }
|
||||
end
|
||||
|
||||
targetname ( package_name )
|
||||
targetname ( package_name .. extension )
|
||||
|
||||
configuration "windows"
|
||||
add_cross_config_links()
|
||||
|
||||
configuration "emscripten"
|
||||
if _OPTIONS["with-gles1"] then
|
||||
linkoptions{ "-s LEGACY_GL_EMULATION=1" }
|
||||
end
|
||||
|
||||
if _OPTIONS["with-gles2"] then
|
||||
linkoptions{ "-s FULL_ES2=1" }
|
||||
end
|
||||
|
||||
set_ios_config()
|
||||
end
|
||||
|
||||
@@ -351,7 +381,7 @@ function add_static_links()
|
||||
"imageresampler-static"
|
||||
}
|
||||
|
||||
if not os.is_real("haiku") and not os.is_real("ios") and not os.is_real("android") then
|
||||
if not os.is_real("haiku") and not os.is_real("ios") and not os.is_real("android") and not os.is_real("emscripten") then
|
||||
links{ "glew-static" }
|
||||
end
|
||||
end
|
||||
@@ -453,7 +483,7 @@ function backend_is( name )
|
||||
|
||||
local ret_val = os_findlib( name ) and backend_sel
|
||||
|
||||
if os.is_real("mingw32") then
|
||||
if os.is_real("mingw32") or os.is_real("emscripten") then
|
||||
ret_val = backend_sel
|
||||
end
|
||||
|
||||
@@ -585,7 +615,7 @@ solution "eepp"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir("libs/" .. os.get_real() .. "/helpers/")
|
||||
if not os.is_real("haiku") and not os.is_real("ios") and not os.is_real("android") then
|
||||
if not os.is_real("haiku") and not os.is_real("ios") and not os.is_real("android") and not os.is_real("emscripten") then
|
||||
files { "src/eepp/helper/glew/*.c" }
|
||||
end
|
||||
includedirs { "include/eepp/helper/glew" }
|
||||
|
||||
@@ -14,11 +14,11 @@ APP_LDLIBS := -llog $(EE_GLES_LINK) -lm -lz -lOpenSLES
|
||||
|
||||
#Debug Build
|
||||
# arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources
|
||||
#APP_CFLAGS := -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER
|
||||
#APP_OPTIM :=debug
|
||||
APP_CFLAGS := -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER
|
||||
APP_OPTIM :=debug
|
||||
|
||||
#Release Build
|
||||
APP_CFLAGS := -fno-strict-aliasing -O3 -s -DNDEBUG -ffast-math
|
||||
#APP_CFLAGS := -fno-strict-aliasing -O3 -s -DNDEBUG -ffast-math
|
||||
|
||||
APP_PLATFORM := android-9
|
||||
APP_MODULES := main
|
||||
|
||||
6
projects/emscripten/make.sh
Executable file
6
projects/emscripten/make.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd $(dirname "$0")
|
||||
premake4 --file=../../premake4.lua --with-gles2 --with-static-eepp --with-static-freetype --platform=emscripten --with-backend=SDL gmake
|
||||
cd ../../make/emscripten/
|
||||
sed -i 's/-rcs/rcs/g' *.make
|
||||
emmake make $@
|
||||
@@ -587,7 +587,7 @@ const int& cGL::QuadVertexs() const {
|
||||
}
|
||||
|
||||
void cGL::BindVertexArray ( GLuint array ) {
|
||||
#ifndef EE_GLES
|
||||
#if !defined( EE_GLES ) || EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
if ( mCurVAO != array ) {
|
||||
glBindVertexArray( array );
|
||||
|
||||
@@ -597,13 +597,13 @@ void cGL::BindVertexArray ( GLuint array ) {
|
||||
}
|
||||
|
||||
void cGL::DeleteVertexArrays ( GLsizei n, const GLuint *arrays ) {
|
||||
#ifndef EE_GLES
|
||||
#if !defined( EE_GLES ) || EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
glDeleteVertexArrays( n, arrays );
|
||||
#endif
|
||||
}
|
||||
|
||||
void cGL::GenVertexArrays ( GLsizei n, GLuint *arrays ) {
|
||||
#ifndef EE_GLES
|
||||
#if !defined( EE_GLES ) || EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
glGenVertexArrays( n, arrays );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,8 +7,13 @@
|
||||
"#define MAX_CLIP_PLANES 6\n\
|
||||
uniform sampler2D textureUnit0;\n\
|
||||
uniform int dgl_TexActive;\n\
|
||||
#ifndef GL_ES\n\
|
||||
uniform int dgl_ClippingEnabled;\n\
|
||||
uniform int dgl_ClipEnabled[ MAX_CLIP_PLANES ];\n\
|
||||
#else\n\
|
||||
uniform lowp int dgl_ClippingEnabled;\n\
|
||||
uniform lowp int dgl_ClipEnabled[ MAX_CLIP_PLANES ];\n\
|
||||
#endif\n\
|
||||
uniform vec4 dgl_ClipPlane[ MAX_CLIP_PLANES ];\n\
|
||||
varying vec4 dgl_Color;\n\
|
||||
#ifndef GL_ES\n\
|
||||
|
||||
@@ -7,8 +7,13 @@
|
||||
"#define MAX_CLIP_PLANES 6\n\
|
||||
uniform mat4 dgl_ProjectionMatrix;\n\
|
||||
uniform mat4 dgl_ModelViewMatrix;\n\
|
||||
uniform int dgl_ClippingEnabled;\n\
|
||||
uniform int dgl_ClipEnabled[ MAX_CLIP_PLANES ];\n\
|
||||
#ifndef GL_ES\n\
|
||||
uniform int dgl_ClippingEnabled;\n\
|
||||
uniform int dgl_ClipEnabled[ MAX_CLIP_PLANES ];\n\
|
||||
#else\n\
|
||||
uniform lowp int dgl_ClippingEnabled;\n\
|
||||
uniform lowp int dgl_ClipEnabled[ MAX_CLIP_PLANES ];\n\
|
||||
#endif\n\
|
||||
uniform vec4 dgl_ClipPlane[ MAX_CLIP_PLANES ];\n\
|
||||
attribute vec4 dgl_Vertex;\n\
|
||||
attribute vec4 dgl_FrontColor;\n\
|
||||
|
||||
@@ -35,7 +35,7 @@ typedef SOPHIST_uint32 u32;
|
||||
#define HK_PLATFORM HK_PLATFORM_HAIKU
|
||||
#endif
|
||||
|
||||
#if defined ( linux ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) || defined( __SVR4 ) || defined( __APPLE_CC__ ) || defined ( __APPLE__ ) || defined( __HAIKU__ ) || defined( __BEOS__ )
|
||||
#if defined ( linux ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined( __DragonFly__ ) || defined( __SVR4 ) || defined( __APPLE_CC__ ) || defined ( __APPLE__ ) || defined( __HAIKU__ ) || defined( __BEOS__ ) || defined( __emscripten__ ) || defined( EMSCRIPTEN )
|
||||
#define HK_PLATFORM_POSIX
|
||||
#endif
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
|
||||
#ifndef SDL_NUMEVENTS
|
||||
#define SDL_NUMEVENTS SDL_LASTEVENT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <eepp/window/backend/SDL/cinputsdl.hpp>
|
||||
#include <eepp/window/backend/SDL/cjoystickmanagersdl.hpp>
|
||||
#include <eepp/window/backend/SDL/ccursormanagersdl.hpp>
|
||||
@@ -60,7 +66,9 @@ void cInputSDL::Update() {
|
||||
|
||||
EEEvent.Type = InputEvent::KeyDown;
|
||||
EEEvent.key.state = SDLEvent.key.state;
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
EEEvent.key.which = SDLEvent.key.which;
|
||||
#endif
|
||||
EEEvent.key.keysym.sym = SDLEvent.key.keysym.sym;
|
||||
EEEvent.key.keysym.mod = SDLEvent.key.keysym.mod;
|
||||
EEEvent.key.keysym.unicode = SDLEvent.key.keysym.unicode;
|
||||
@@ -70,7 +78,9 @@ void cInputSDL::Update() {
|
||||
{
|
||||
EEEvent.Type = InputEvent::KeyUp;
|
||||
EEEvent.key.state = SDLEvent.key.state;
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
EEEvent.key.which = SDLEvent.key.which;
|
||||
#endif
|
||||
EEEvent.key.keysym.sym = SDLEvent.key.keysym.sym;
|
||||
EEEvent.key.keysym.mod = SDLEvent.key.keysym.mod;
|
||||
EEEvent.key.keysym.unicode = SDLEvent.key.keysym.unicode;
|
||||
@@ -79,7 +89,9 @@ void cInputSDL::Update() {
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
EEEvent.Type = InputEvent::MouseMotion;
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
EEEvent.motion.which = SDLEvent.motion.which;
|
||||
#endif
|
||||
EEEvent.motion.state = SDLEvent.motion.state;
|
||||
EEEvent.motion.x = SDLEvent.motion.x;
|
||||
EEEvent.motion.y = SDLEvent.motion.y;
|
||||
@@ -91,7 +103,9 @@ void cInputSDL::Update() {
|
||||
{
|
||||
EEEvent.Type = InputEvent::MouseButtonDown;
|
||||
EEEvent.button.button = SDLEvent.button.button;
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
EEEvent.button.which = SDLEvent.button.which;
|
||||
#endif
|
||||
EEEvent.button.state = SDLEvent.button.state;
|
||||
EEEvent.button.x = SDLEvent.button.x;
|
||||
EEEvent.button.y = SDLEvent.button.y;
|
||||
@@ -101,7 +115,9 @@ void cInputSDL::Update() {
|
||||
{
|
||||
EEEvent.Type = InputEvent::MouseButtonUp;
|
||||
EEEvent.button.button = SDLEvent.button.button;
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
EEEvent.button.which = SDLEvent.button.which;
|
||||
#endif
|
||||
EEEvent.button.state = SDLEvent.button.state;
|
||||
EEEvent.button.x = SDLEvent.button.x;
|
||||
EEEvent.button.y = SDLEvent.button.y;
|
||||
|
||||
@@ -192,7 +192,10 @@ void cWindowSDL::SetGLConfig() {
|
||||
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE , mWindow.ContextConfig.DepthBufferSize ); // Depth
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, ( mWindow.ContextConfig.DoubleBuffering ? 1 : 0 ) ); // Double Buffering
|
||||
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, mWindow.ContextConfig.StencilBufferSize );
|
||||
|
||||
#if EE_PLATFORM != EE_PLATFORM_EMSCRIPTEN
|
||||
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, ( mWindow.ContextConfig.VSync ? 1 : 0 ) ); // VSync
|
||||
#endif
|
||||
}
|
||||
|
||||
void cWindowSDL::ToggleFullscreen() {
|
||||
|
||||
Reference in New Issue
Block a user