emilib
Public Member Functions | List of all members
emilib::ImGui_SDL Class Reference

#include <imgui_sdl.hpp>

Public Member Functions

 ImGui_SDL (float width_points, float height_points, float pixels_per_point)
 
 ~ImGui_SDL ()
 Will call ImGui::Shutdown.
 
bool visible () const
 When invisible, you can still call ImGui functions, but you cannot see or interact any widgets.
 
void set_visible (bool v)
 
bool interactive () const
 When not interactive, any ImGui widgets are passive (you can't click them).
 
void set_interactive (bool v)
 
void new_frame ()
 
void paint ()
 
void on_event (const SDL_Event &e)
 You must call this yourself!
 
bool mod_command () const
 Key modifiers:
 
bool mod_shift () const
 
float width_points () const
 
float height_points () const
 
float width_pixels () const
 
float height_pixels () const
 
float pixels_per_point () const
 

Detailed Description

Provides bindings between Dear ImGui and SDL. Handles input, copy-past etc. Does NOT handle painting! Please use imgui_gl_lib.hpp for that. You should have your own even loop and feed the events to ImGui_SDL.

emilib::sdl::Params sdl_params; sdl_params.window_name = "My window"; auto sdl = emilib::sdl::init(sdl_params);

emilib::ImGui_SDL imgui_sdl(sdl.width_points, sdl.height_points, sdl.pixels_per_point);

gl::bind_imgui_painting();

bool quit = false; while (!quit) { SDL_Event event; while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { quit = true; } imgui_sdl.on_event(event); }

// Handle window resize: gl::TempViewPort::set_back_buffer_size( (int)std::round(imgui_sdl.width_pixels()), (int)std::round(imgui_sdl.height_pixels()));

imgui_sdl.new_frame();

if (ImGui::Button("Quit!")) { quit = true; }

glClearColor(0.1f, 0.1f, 0.1f, 0); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

imgui_sdl.paint();

SDL_GL_SwapWindow(sdl.window); }


The documentation for this class was generated from the following file: