void dump(const VertexDecl& _decl) { if (BX_ENABLED(BGFX_CONFIG_DEBUG) ) { dbgPrintf("vertexdecl %08x (%08x), stride %d\n" , _decl.m_hash , bx::hashMurmur2A(_decl.m_attributes) , _decl.m_stride ); for (uint32_t attr = 0; attr < Attrib::Count; ++attr) { if (UINT16_MAX != _decl.m_attributes[attr]) { uint8_t num; AttribType::Enum type; bool normalized; bool asInt; _decl.decode(Attrib::Enum(attr), num, type, normalized, asInt); dbgPrintf("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d\n" , attr , getAttribName(Attrib::Enum(attr) ) , num , type , normalized , asInt , _decl.m_offset[attr] ); } } } }
bool GlContext::isSwapChainSupported() { return BX_ENABLED(0 | BX_PLATFORM_LINUX | BX_PLATFORM_WINDOWS ); }
static void update(float dt) { int mx, my; uint32_t mouseMask = SDL_GetMouseState(&mx, &my); // Camera look/movement const float moveSpeed = BX_ENABLED(BX_PLATFORM_ANDROID) ? 1.0f : 5.0f; const float lookSpeed = BX_ENABLED(BX_PLATFORM_ANDROID) ? 0.1f : 3.0f; int numKeys; const uint8_t* keys = SDL_GetKeyboardState(&numKeys); if (keys[SDL_SCANCODE_A] || keys[SDL_SCANCODE_LEFT]) termite::camStrafe(&g_cam, -1.0f*moveSpeed*dt); if (keys[SDL_SCANCODE_D] || keys[SDL_SCANCODE_RIGHT]) termite::camStrafe(&g_cam, moveSpeed*dt); if (keys[SDL_SCANCODE_W] || keys[SDL_SCANCODE_UP]) termite::camForward(&g_cam, moveSpeed*dt); if (keys[SDL_SCANCODE_S] || keys[SDL_SCANCODE_DOWN]) termite::camForward(&g_cam, -1.0f*moveSpeed*dt); SDL_GetRelativeMouseState(&mx, &my); if (mouseMask & SDL_BUTTON(SDL_BUTTON_LEFT)) { termite::camPitchYaw(&g_cam, -float(my)*lookSpeed*dt, -float(mx)*lookSpeed*dt); } // Clear Scene termite::getGfxDriver()->touch(0); termite::getGfxDriver()->setViewClear(0, termite::GfxClearFlag::Color | termite::GfxClearFlag::Depth, 0x303030ff, 1.0f, 0); termite::getGfxDriver()->setViewRectRatio(0, 0, 0, termite::BackbufferRatio::Equal); float aspect = float(g_displaySize.x) / float(g_displaySize.y); termite::mtx4x4_t viewMtx = g_cam.getViewMtx(); termite::mtx4x4_t projMtx = g_cam.getProjMtx(aspect); termite::vgBegin(g_vg, float(g_displaySize.x), float(g_displaySize.y)); termite::vgTextf(g_vg, 10.0f, 10.0f, "Ft = %f", termite::getSmoothFrameTime()*1000.0); termite::vgEnd(g_vg); termite::ddBegin(g_debug, float(g_displaySize.x), float(g_displaySize.y), viewMtx, projMtx, g_vg); termite::ddColor(g_debug, termite::vec4_t(0, 0.5f, 0, 1.0f)); termite::ddSnapGridXZ(g_debug, g_cam, 1.0f, 5.0f, 50.0f); termite::ddColor(g_debug, termite::vec4_t(1.0f, 0, 0, 1.0f)); termite::ddBoundingBox(g_debug, termite::aabb_t(-1.0f, -0.5f, -0.5f, 0.5f, 1.5f, 2.5f), true); termite::ddBoundingSphere(g_debug, termite::sphere_t(0, 0, 5.0f, 1.5f), true); termite::ddEnd(g_debug); }
uint64_t GlContext::getCaps() const { return BX_ENABLED(0 | BX_PLATFORM_LINUX | BX_PLATFORM_WINDOWS ) ? BGFX_CAPS_SWAP_CHAIN : 0 ; }
void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc) { float aa; float bb; if (BX_ENABLED(NearFar::Reverse == NearFarT) ) { aa = _oglNdc ? -1.0f : 0.0f; bb = _oglNdc ? -2.0f*_near : -_near; } else { aa = 1.0f; bb = _oglNdc ? 2.0f*_near : _near; } memSet(_result, 0, sizeof(float)*16); _result[ 0] = _width; _result[ 5] = _height; _result[ 8] = (Handness::Right == HandnessT) ? _x : -_x; _result[ 9] = (Handness::Right == HandnessT) ? _y : -_y; _result[10] = (Handness::Right == HandnessT) ? -aa : aa; _result[11] = (Handness::Right == HandnessT) ? -1.0f : 1.0f; _result[14] = -bb; }
int main(int _argc, char** _argv) { //DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME); if (BX_ENABLED(ENTRY_CONFIG_PROFILER) ) { rmtSettings* settings = rmt_Settings(); BX_WARN(NULL != settings, "Remotery is not enabled."); if (NULL != settings) { settings->malloc = rmtMalloc; settings->realloc = rmtRealloc; settings->free = rmtFree; rmtError err = rmt_CreateGlobalInstance(&s_rmt); BX_WARN(RMT_ERROR_NONE != err, "Remotery failed to create global instance."); if (RMT_ERROR_NONE == err) { rmt_SetCurrentThreadName("Main"); } else { s_rmt = NULL; } } } #if BX_CONFIG_CRT_FILE_READER_WRITER s_fileReader = new bx::CrtFileReader; s_fileWriter = new bx::CrtFileWriter; #endif // BX_CONFIG_CRT_FILE_READER_WRITER cmdInit(); cmdAdd("mouselock", cmdMouseLock); cmdAdd("graphics", cmdGraphics ); cmdAdd("exit", cmdExit ); inputInit(); inputAddBindings("bindings", s_bindings); entry::WindowHandle defaultWindow = { 0 }; entry::setWindowTitle(defaultWindow, bx::baseName(_argv[0]) ); setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); int32_t result = ::_main_(_argc, _argv); inputRemoveBindings("bindings"); inputShutdown(); cmdShutdown(); #if BX_CONFIG_CRT_FILE_READER_WRITER delete s_fileReader; s_fileReader = NULL; delete s_fileWriter; s_fileWriter = NULL; #endif // BX_CONFIG_CRT_FILE_READER_WRITER if (BX_ENABLED(ENTRY_CONFIG_PROFILER) && NULL != s_rmt) { rmt_DestroyGlobalInstance(s_rmt); } return result; }