From 22e099366f0e4c0ec4351ceac3abbceb9252f806 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 8 Jul 2015 10:20:08 -0600 Subject: [PATCH] SDL example: further cleanup to match other examples (#233 #226) --- .../sdl_opengl_example/imgui_impl_sdl.cpp | 11 +-------- examples/sdl_opengl_example/imgui_impl_sdl.h | 1 - examples/sdl_opengl_example/main.cpp | 23 +++---------------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.cpp b/examples/sdl_opengl_example/imgui_impl_sdl.cpp index 8c9b2f16..b22250b8 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.cpp +++ b/examples/sdl_opengl_example/imgui_impl_sdl.cpp @@ -1,15 +1,6 @@ -#ifdef _MSC_VER -#include -#include -#include -#endif - -#ifdef MACOSX -#include -#endif - #include #include +#include #include #include "imgui_impl_sdl.h" diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.h b/examples/sdl_opengl_example/imgui_impl_sdl.h index 08d6df69..6d56b2e0 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.h +++ b/examples/sdl_opengl_example/imgui_impl_sdl.h @@ -8,4 +8,3 @@ bool ImGui_ImplSdl_EventCallback(const SDL_Event& event); void ImGui_ImplSdl_InvalidateDeviceObjects(); bool ImGui_ImplSdl_CreateDeviceObjects(); - diff --git a/examples/sdl_opengl_example/main.cpp b/examples/sdl_opengl_example/main.cpp index 33361212..87e5c794 100644 --- a/examples/sdl_opengl_example/main.cpp +++ b/examples/sdl_opengl_example/main.cpp @@ -1,41 +1,26 @@ -// ImGui - standalone example application for SDL2 +// ImGui - standalone example application for SDL2 + OpenGL #include #include "imgui_impl_sdl.h" #include - -#ifdef WIN32 -#include -#include -#include -#endif - -#ifdef MACOSX -#include -#endif - #include #include -int SDL_main(int /*argc*/, char* /*argv*/[]) +int SDL_main(int, char**) { // Setup SDL if (SDL_Init(SDL_INIT_EVERYTHING) != 0) return -1; - // Init OpenGL + // Setup window SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); - - // SDL window SDL_DisplayMode current; SDL_GetCurrentDisplayMode(0, ¤t); SDL_Window *window = SDL_CreateWindow("ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE); - - // Create an OpenGL context associated with the window. SDL_GLContext glcontext = SDL_GL_CreateContext(window); // Setup ImGui binding @@ -103,10 +88,8 @@ int SDL_main(int /*argc*/, char* /*argv*/[]) // Cleanup ImGui_ImplSdl_Shutdown(); - SDL_GL_DeleteContext(glcontext); SDL_DestroyWindow(window); - SDL_Quit(); return 0;