1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-02-04 04:00:07 +00:00

Examples: SDL: Extracted into imgui_impl_sdl.*, reused imgui_impl_opengl* files.

This commit is contained in:
omar 2018-02-16 22:22:47 +01:00
parent 42c32bf00c
commit ef521d1e0b
10 changed files with 82 additions and 676 deletions

View file

@ -7,7 +7,8 @@
// See imgui_impl_sdl.cpp for details.
#include "imgui.h"
#include "imgui_impl_sdl_gl2.h"
#include "../imgui_impl_sdl2.h"
#include "../imgui_impl_opengl2.h"
#include <stdio.h>
#include <SDL.h>
#include <SDL_opengl.h>
@ -36,7 +37,8 @@ int main(int, char**)
// Setup ImGui binding
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplSdlGL2_Init(window);
ImGui_ImplSDL2_Init(window);
ImGui_ImplOpenGL2_Init();
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
// Setup style
@ -73,11 +75,12 @@ int main(int, char**)
SDL_Event event;
while (SDL_PollEvent(&event))
{
ImGui_ImplSdlGL2_ProcessEvent(&event);
ImGui_ImplSDL2_ProcessEvent(&event);
if (event.type == SDL_QUIT)
done = true;
}
ImGui_ImplSdlGL2_NewFrame(window);
ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(window);
// 1. Show a simple window.
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
@ -122,12 +125,13 @@ int main(int, char**)
glClear(GL_COLOR_BUFFER_BIT);
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
ImGui::Render();
ImGui_ImplSdlGL2_RenderDrawData(ImGui::GetDrawData());
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
SDL_GL_SwapWindow(window);
}
// Cleanup
ImGui_ImplSdlGL2_Shutdown();
ImGui_ImplOpenGL2_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
SDL_GL_DeleteContext(glcontext);