void init(const char* argv0) { rmt_CreateGlobalInstance(&rmt); PHYSFS_init(argv0); PHYSFS_mount("AppData", 0, 1); PHYSFS_mount("../AppData", 0, 1); PHYSFS_mount("../../AppData", 0, 1); if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0) { fprintf(stderr, "Unable to open SDL: %s\n", SDL_GetError()); ::exit(1); } SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, TRUE ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); SDL_GL_SetAttribute( SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 4 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 4 ); SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE ); #ifdef _DEBUG SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG ); #endif window = SDL_CreateWindow( "", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE ); if(!window) { fprintf(stderr, "Unable to create window: %s\n", SDL_GetError()); ::exit(1); } context = SDL_GL_CreateContext(window); importOpenGL(); core::init(); gfx::init(1280, 720); ui::init(1280, 720); app::init(); notifyResize(1280, 720); prevTime = timerAbsoluteTime(); runLoop = true; recompileGLPrograms = false; }
void ShaderEditOverlay::renderFullscreen() { //update logic if (timerAbsoluteTime()>mNextTick) { mShaderEditor.Tick(); mDebugOutputView.Tick(); mNextTick = timerAbsoluteTime()+TICK_INTERVAL; } BraceMatch(mShaderEditor); glEnable(GL_SCISSOR_TEST); float w1=mWidth-80.0f, h1=mHeight-80.0f; v128 mv[4]; ml::make_identity_mat4(mv); { PROFILER_CPU_TIMESLICE("mSelectionList.Paint"); mv[3] = vi_set(30.0f, 30.0f, 0.0f, 1.0f); gfx::setModelViewMatrix(mv); mSelectionList.Paint(); } { PROFILER_CPU_TIMESLICE("mShaderEditor.Paint"); mv[3] = vi_set(w1*0.3f+50.0f, 30.0f, 0.0f, 1.0f); gfx::setModelViewMatrix(mv); mShaderEditor.Paint(); } { PROFILER_CPU_TIMESLICE("mDebugOutputView.Paint"); mv[3] = vi_set(w1*0.3f+50.0f, h1*0.7f+50.0f, 0.0f, 1.0f); gfx::setModelViewMatrix(mv); mDebugOutputView.Paint(); } glDisable(GL_SCISSOR_TEST); }
void run() { while (runLoop) { profilerStartSyncPoint(); { PROFILER_CPU_TIMESLICE("Frame"); processWindowEvents(); { PROFILER_CPU_TIMESLICE("Frame sync and gfx init"); gfx::beginFrame(); } uint64_t time = timerAbsoluteTime(); float dt = (time-prevTime)*0.000001f; prevTime = time; ui::update(dt); app::update(dt); if (recompileGLPrograms) { recompileGLPrograms = false; app::recompilePrograms(); } { PROFILER_CPU_TIMESLICE("onPaint"); app::render(); } ui::render(); gfx::endFrame(); { PROFILER_CPU_TIMESLICE("SDL_GL_SwapBuffers"); SDL_GL_SwapWindow(window); } } profilerStopSyncPoint(); } }