Merge branch 'master' of github.com:bkaradzic/bgfx

This commit is contained in:
bkaradzic 2012-10-22 19:46:42 -07:00
commit 7bdcb903d9
5 changed files with 81 additions and 12 deletions

View File

@ -0,0 +1,45 @@
/*
* Copyright 2011-2012 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bx/bx.h>
#if BX_PLATFORM_EMSCRIPTEN
#include <emscripten/emscripten.h>
#include <pthread.h>
extern int _main_(int _argc, char** _argv);
#include <setjmp.h>
jmp_buf s_main;
jmp_buf s_loop;
void emscripten_yield()
{
if (!setjmp(s_main) )
{
longjmp(s_loop, 1);
}
}
void loop()
{
if (!setjmp(s_loop) )
{
longjmp(s_main, 1);
}
}
int main(int _argc, char** _argv)
{
if (!setjmp(s_loop) )
{
_main_(_argc, _argv);
}
emscripten_set_main_loop(loop, 10, true);
}
#endif // BX_PLATFORM_EMSCRIPTEN

View File

@ -59,9 +59,14 @@ if _ACTION == "gmake" then
}
if "emscripten" == _OPTIONS["gcc"] then
premake.gcc.cc = "emcc"
premake.gcc.cxx = "em++"
premake.gcc.ar = "emar"
if not os.getenv("EMSCRIPTEN") then
print("Set EMSCRIPTEN enviroment variables.")
end
premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
premake.gcc.ar = "$(EMSCRIPTEN)/emar"
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-emscripten")
end
@ -203,6 +208,10 @@ configuration { "emscripten" }
targetdir (BGFX_BUILD_DIR .. "emscripten" .. "/bin")
objdir (BGFX_BUILD_DIR .. "emscripten" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/emscripten" }
includedirs { "$(EMSCRIPTEN)/system/include" }
buildoptions {
"-pthread",
}
configuration { "nacl" }
defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" }

View File

@ -215,7 +215,14 @@ namespace bgfx
uint8_t* rgba = mem->data;
charsetFillTexture(vga8x8, rgba, 8, pitch, bpp);
charsetFillTexture(vga8x16, &rgba[8*pitch], 16, pitch, bpp);
m_texture = createTexture2D(2048, 24, 1, TextureFormat::L8, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT, mem);
m_texture = createTexture2D(2048, 24, 1, TextureFormat::L8
, BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MAG_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
, mem
);
#if BGFX_CONFIG_RENDERER_DIRECT3D9
mem = makeRef(vs_debugfont_dx9, sizeof(vs_debugfont_dx9) );

View File

@ -391,14 +391,18 @@ namespace bgfx
success = eglMakeCurrent(m_display, m_surface, m_surface, m_context);
BGFX_FATAL(success, Fatal::OPENGL_UnableToCreateContext, "Failed to set context.");
# define GL_IMPORT(_optional, _proto, _func) \
{ \
_func = (_proto)eglGetProcAddress(#_func); \
BX_TRACE(#_func " 0x%08x", _func); \
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
}
# include "glimports.h"
# undef GL_IMPORT
# if BX_PLATFORM_EMSCRIPTEN
emscripten_set_canvas_size(_width, _height);
# else
# define GL_IMPORT(_optional, _proto, _func) \
{ \
_func = (_proto)eglGetProcAddress(#_func); \
BX_TRACE(#_func " 0x%08x", _func); \
BGFX_FATAL(_optional || NULL != _func, Fatal::OPENGL_UnableToCreateContext, "Failed to create OpenGLES context. eglGetProcAddress(\"%s\")", #_func); \
}
# include "glimports.h"
# undef GL_IMPORT
# endif // !BX_PLATFORM_EMSCRIPTEN
}
#endif // BX_PLATFORM_
}

View File

@ -95,6 +95,10 @@
# define BGFX_USE_EGL 1
# endif // BX_PLATFORM_
# if BX_PLATFORM_EMSCRIPTEN
# include <emscripten/emscripten.h>
# endif // BX_PLATFORM_EMSCRIPTEN
# ifndef GL_BGRA_EXT
# define GL_BGRA_EXT 0x80E1
# endif // GL_BGRA_EXT