X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fscreen.cpp;h=e7d5d4b022ce4cde9c01d6b2fadc024cbca0e1e7;hb=03cc1b0a0d0705e0b1d92e13fdb18608c7a00272;hp=f075684dbb9284ce0ec0a5c51bc022d7070c8671;hpb=2a1715c907ba3ccfb952e9630c3fe305655637e0;p=ipdf%2Fcode.git diff --git a/src/screen.cpp b/src/screen.cpp index f075684..e7d5d4b 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -24,12 +24,16 @@ static void opengl_debug_callback(GLenum source, GLenum type, GLuint id, GLenum } -Screen::Screen() +Screen::Screen(bool visible) { SDL_Init(SDL_INIT_VIDEO); + uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; + if (!visible) + flags |= SDL_WINDOW_HIDDEN; + m_window = SDL_CreateWindow("IPDF", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); + 800, 600, flags); if (!m_window) { @@ -48,17 +52,17 @@ Screen::Screen() // Why is this so horribly broken? if (ogl_IsVersionGEQ(3,0)) { - Fatal("We require OpenGL 3.1, but you have version %d.%d!",ogl_GetMajorVersion(), ogl_GetMinorVersion()); + Error("We require OpenGL 3.1, but you have version %d.%d!",ogl_GetMajorVersion(), ogl_GetMinorVersion()); } if (!SDL_GL_ExtensionSupported("GL_ARB_shading_language_420pack")) { - Fatal("Your system does not support the ARB_shading_language_420pack extension, which is required."); + Error("Your system does not support the ARB_shading_language_420pack extension, which is required."); } if (!SDL_GL_ExtensionSupported("GL_ARB_explicit_attrib_location")) { - Fatal("Your system does not support the ARB_explicit_attrib_location extension, which is required."); + Error("Your system does not support the ARB_explicit_attrib_location extension, which is required."); } m_frame_begin_time = SDL_GetPerformanceCounter(); @@ -92,10 +96,13 @@ Screen::Screen() m_viewport_ubo.SetType(GraphicsBuffer::BufferTypeUniform); m_debug_font_atlas = 0; - + m_no_quit_requested = true; + m_show_debug_font = true; m_view = NULL; ResizeViewport(800, 600); - + + + Clear(); Present(); @@ -128,13 +135,13 @@ void Screen::ResizeViewport(int width, int height) bool Screen::PumpEvents() { SDL_Event evt; - bool no_quit_requested = true; + while (SDL_PollEvent(&evt)) { switch (evt.type) { case SDL_QUIT: - no_quit_requested = false; + m_no_quit_requested = false; break; case SDL_WINDOWEVENT: switch (evt.window.event) @@ -183,7 +190,7 @@ bool Screen::PumpEvents() break; } } - return no_quit_requested; + return m_no_quit_requested; } void Screen::SetMouseCursor(Screen::MouseCursors cursor) @@ -454,7 +461,7 @@ struct fontvertex void Screen::DebugFontPrint(const char* str) { - if (!m_debug_font_atlas) return; + if (!m_debug_font_atlas || !m_show_debug_font) return; glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 41, -1, "Screen::DebugFontPrint()");