mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display..(#1599)
Examples: Updated examples.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL2_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS).
|
||||
@ -43,10 +44,10 @@ static Uint64 g_Time = 0;
|
||||
static bool g_MousePressed[3] = { false, false, false };
|
||||
static GLuint g_FontTexture = 0;
|
||||
|
||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||
// OpenGL2 Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||
// If text or lines are blurry when integrating ImGui in your engine: in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||
void ImGui_ImplSdlGL2_RenderDrawLists(ImDrawData* draw_data)
|
||||
void ImGui_ImplSdlGL2_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -245,7 +246,6 @@ bool ImGui_ImplSdlGL2_Init(SDL_Window* window)
|
||||
io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z;
|
||||
|
||||
io.RenderDrawListsFn = ImGui_ImplSdlGL2_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||
io.SetClipboardTextFn = ImGui_ImplSdlGL2_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplSdlGL2_GetClipboardText;
|
||||
io.ClipboardUserData = NULL;
|
||||
|
@ -19,6 +19,7 @@ typedef union SDL_Event SDL_Event;
|
||||
IMGUI_API bool ImGui_ImplSdlGL2_Init(SDL_Window* window);
|
||||
IMGUI_API void ImGui_ImplSdlGL2_Shutdown();
|
||||
IMGUI_API void ImGui_ImplSdlGL2_NewFrame(SDL_Window* window);
|
||||
IMGUI_API void ImGui_ImplSdlGL2_RenderDrawData(ImDrawData* draw_data);
|
||||
IMGUI_API bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event);
|
||||
|
||||
// Use if you want to reset your rendering device without losing ImGui state.
|
||||
|
@ -122,6 +122,7 @@ 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());
|
||||
SDL_GL_SwapWindow(window);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user