diff --git a/examples/common/entry_android.cpp b/examples/common/entry_android.cpp index 3fd258b7..480534d4 100644 --- a/examples/common/entry_android.cpp +++ b/examples/common/entry_android.cpp @@ -17,6 +17,7 @@ #include #include #include + extern "C" { #include @@ -37,6 +38,7 @@ namespace entry struct Context { Context() + : m_window(NULL) { } @@ -47,16 +49,10 @@ namespace entry m_app->onAppCmd = onAppCmdCB; m_app->onInputEvent = onInputEventCB; - bgfx::androidSetWindow(m_app->window); - const char* argv[1] = { "android.so" }; - MainThreadEntry mte; - mte.m_argc = 1; - mte.m_argv = const_cast(argv); - - bx::Thread thread; - thread.init(mte.threadFunc, &mte); - + m_mte.m_argc = 1; + m_mte.m_argv = const_cast(argv); + while (0 == m_app->destroyRequested) { int32_t num; @@ -69,7 +65,7 @@ namespace entry } } - thread.shutdown(); + m_thread.shutdown(); } void onAppCmd(int32_t _cmd) @@ -86,6 +82,12 @@ namespace entry // Command from main thread: a new ANativeWindow is ready for use. Upon // receiving this command, android_app->window will contain the new window // surface. + if (m_window == NULL) + { + m_window = m_app->window; + bgfx::androidSetWindow(m_app->window); + m_thread.init(MainThreadEntry::threadFunc, &m_mte); + } break; case APP_CMD_TERM_WINDOW: @@ -180,7 +182,12 @@ namespace entry return self->onInputEvent(_event); } + MainThreadEntry m_mte; + bx::Thread m_thread; + EventQueue m_eventQueue; + + ANativeWindow* m_window; android_app* m_app; }; @@ -222,9 +229,7 @@ extern int _main_(int _argc, char** _argv); extern "C" void android_main(android_app* _app) { - DBG("entry_android"); using namespace entry; - app_dummy(); s_ctx.run(_app); } diff --git a/premake/premake4.lua b/premake/premake4.lua index 74c19eb5..f75839c7 100644 --- a/premake/premake4.lua +++ b/premake/premake4.lua @@ -78,12 +78,6 @@ function exampleProject(_name, _uuid) "pthread", } - configuration { "nacl", "Release" } - postbuildcommands { - "@echo Stripping symbols.", - "@$(NACL)/bin/x86_64-nacl-strip -s \"$(TARGET)\"" - } - configuration { "linux" } links { "GL", @@ -105,6 +99,10 @@ function exampleProject(_name, _uuid) "EGL", "GLESv2", } + + configuration {} + + strip() end dofile "bgfx.lua" diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 3196c9c5..225a1362 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1471,8 +1471,10 @@ namespace bgfx static int32_t renderThread(void* _userData) { + BX_TRACE("render thread start"); Context* ctx = (Context*)_userData; while (!ctx->renderFrame() ); + BX_TRACE("render thread exit"); return EXIT_SUCCESS; } diff --git a/src/config.h b/src/config.h index 8539900a..7767cce0 100644 --- a/src/config.h +++ b/src/config.h @@ -103,7 +103,15 @@ #endif // BGFX_CONFIG_DEBUG_OBJECT_NAME #ifndef BGFX_CONFIG_MULTITHREADED -# define BGFX_CONFIG_MULTITHREADED ( (BX_PLATFORM_WINDOWS|BX_PLATFORM_XBOX360|BX_PLATFORM_NACL)&(!BGFX_CONFIG_RENDERER_NULL) ) +# define BGFX_CONFIG_MULTITHREADED ( (!BGFX_CONFIG_RENDERER_NULL)&(0 \ + | BX_PLATFORM_ANDROID \ + | BX_PLATFORM_IOS \ + | BX_PLATFORM_NACL \ + | BX_PLATFORM_OSX \ + | BX_PLATFORM_QNX \ + | BX_PLATFORM_WINDOWS \ + | BX_PLATFORM_XBOX360 \ + ) ) #endif // BGFX_CONFIG_MULTITHREADED #ifndef BGFX_CONFIG_MAX_DRAW_CALLS diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index b1513187..a4a2e8f2 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -162,8 +162,32 @@ namespace bgfx } } + static const char* getGLString(GLenum _name) + { + const char* str = (const char*)glGetString(_name); + glGetError(); // ignore error if glGetString returns NULL. + if (NULL != str) + { + return str; + } + + return ""; + } + + static uint32_t getGLStringHash(GLenum _name) + { + const char* str = (const char*)glGetString(_name); + glGetError(); // ignore error if glGetString returns NULL. + if (NULL != str) + { + return bx::hashMurmur2A(str, strlen(str) ); + } + + return 0; + } + #if BGFX_CONFIG_RENDERER_OPENGL - static const char* toString(GLenum _enum) + const char* toString(GLenum _enum) { switch (_enum) { @@ -454,6 +478,11 @@ namespace bgfx { m_glctx.create(BGFX_DEFAULT_WIDTH, BGFX_DEFAULT_HEIGHT); + m_vendor = getGLString(GL_VENDOR); + m_renderer = getGLString(GL_RENDERER); + m_version = getGLString(GL_VERSION); + m_glslVersion = getGLString(GL_SHADING_LANGUAGE_VERSION); + #if BGFX_CONFIG_RENDERER_OPENGL m_queries.create(); #endif // BGFX_CONFIG_RENDERER_OPENGL @@ -511,6 +540,11 @@ namespace bgfx GLuint m_backBufferFbo; GLuint m_backBufferRbos[2]; GlContext m_glctx; + + const char* m_vendor; + const char* m_renderer; + const char* m_version; + const char* m_glslVersion; }; RendererContext s_renderCtx; @@ -2128,18 +2162,6 @@ namespace bgfx return result; } - uint32_t glGetStringHash(GLenum _name) - { - const char* str = (const char*)glGetString(_name); - glGetError(); // ignore error if glGetString returns NULL. - if (NULL != str) - { - return bx::hashMurmur2A(str, strlen(str) ); - } - - return 0; - } - void Context::rendererInit() { s_renderCtx.init(); @@ -2179,17 +2201,18 @@ namespace bgfx GL_GET(GL_MAX_TEXTURE_SIZE, 64); GL_GET(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0); GL_GET(GL_MAX_RENDERBUFFER_SIZE, 1); - - const char* version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); - GL_CHECK(;); // check if error is generated by glGetString. - BX_TRACE("GLSL version: %s", version); + + BX_TRACE(" Vendor: %s", s_renderCtx.m_vendor); + BX_TRACE(" Renderer: %s", s_renderCtx.m_renderer); + BX_TRACE(" Version: %s", s_renderCtx.m_version); + BX_TRACE("GLSL version: %s", s_renderCtx.m_glslVersion); #endif // BGFX_CONFIG_DEBUG // Initial binary shader hash depends on driver version. s_renderCtx.m_hash = ( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT) - ^ (uint64_t(glGetStringHash(GL_VENDOR ) )<<32) - ^ (uint64_t(glGetStringHash(GL_RENDERER) )<<0 ) - ^ (uint64_t(glGetStringHash(GL_VERSION ) )<<16) + ^ (uint64_t(getGLStringHash(GL_VENDOR ) )<<32) + ^ (uint64_t(getGLStringHash(GL_RENDERER) )<<0 ) + ^ (uint64_t(getGLStringHash(GL_VERSION ) )<<16) ; const char* extensions = (const char*)glGetString(GL_EXTENSIONS); @@ -2314,19 +2337,23 @@ namespace bgfx } #if !BGFX_CONFIG_RENDERER_OPENGLES3 - if (NULL != glVertexAttribDivisor - && NULL != glDrawArraysInstanced - && NULL != glDrawElementsInstanced) + if (s_extension[Extension::ARB_instanced_arrays].m_supported + && s_extension[Extension::ANGLE_instanced_arrays].m_supported) { - s_vertexAttribDivisor = glVertexAttribDivisor; - s_drawArraysInstanced = glDrawArraysInstanced; - s_drawElementsInstanced = glDrawElementsInstanced; - } - else - { - s_vertexAttribDivisor = stubVertexAttribDivisor; - s_drawArraysInstanced = stubDrawArraysInstanced; - s_drawElementsInstanced = stubDrawElementsInstanced; + if (NULL != glVertexAttribDivisor + && NULL != glDrawArraysInstanced + && NULL != glDrawElementsInstanced) + { + s_vertexAttribDivisor = glVertexAttribDivisor; + s_drawArraysInstanced = glDrawArraysInstanced; + s_drawElementsInstanced = glDrawElementsInstanced; + } + else + { + s_vertexAttribDivisor = stubVertexAttribDivisor; + s_drawArraysInstanced = stubDrawArraysInstanced; + s_drawElementsInstanced = stubDrawElementsInstanced; + } } #endif // !BGFX_CONFIG_RENDERER_OPENGLES3 @@ -3250,8 +3277,14 @@ namespace bgfx double toMs = 1000.0/freq; tvm.clear(); - uint16_t pos = 10; - tvm.printf(0, 0, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); + uint16_t pos = 0; + tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); + tvm.printf(0, pos++, 0x0f, " Vendor: %s", s_renderCtx.m_vendor); + tvm.printf(0, pos++, 0x0f, " Renderer: %s", s_renderCtx.m_renderer); + tvm.printf(0, pos++, 0x0f, " Version: %s", s_renderCtx.m_version); + tvm.printf(0, pos++, 0x0f, "GLSL version: %s", s_renderCtx.m_glslVersion); + + pos = 10; tvm.printf(10, pos++, 0x8e, " Frame CPU: %7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS" , double(frameTime)*toMs , double(min)*toMs