From 532feb55ff024b4f00155329fa4132e2f59b69a6 Mon Sep 17 00:00:00 2001 From: sonoro1234 Date: Thu, 21 Jun 2018 17:06:31 +0200 Subject: [PATCH] add opengl2 implementation --- cimgui/cimgui.h | 20 ++++++++++++++++++++ cimgui/generator/generator.bat | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cimgui/cimgui.h b/cimgui/cimgui.h index 0781a63..a8e63d3 100644 --- a/cimgui/cimgui.h +++ b/cimgui/cimgui.h @@ -1038,6 +1038,18 @@ struct GLFWwindow; // About GLSL version: // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! +// Called by Init/NewFrame/Shutdown +// ImGui Renderer for: OpenGL2 (legacy OpenGL, fixed pipeline) +// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) +// Implemented features: +// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp. +// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** +// **Prefer using the code in imgui_impl_opengl3.cpp** +// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. +// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more +// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might +// confuse your GPU driver. +// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. // Called by Init/NewFrame/Shutdown struct GlyphRangesBuilder { @@ -1726,6 +1738,14 @@ CIMGUI_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); CIMGUI_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); CIMGUI_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); CIMGUI_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); +CIMGUI_API bool ImGui_ImplOpenGL2_Init(); +CIMGUI_API void ImGui_ImplOpenGL2_Shutdown(); +CIMGUI_API void ImGui_ImplOpenGL2_NewFrame(); +CIMGUI_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data); +CIMGUI_API bool ImGui_ImplOpenGL2_CreateFontsTexture(); +CIMGUI_API void ImGui_ImplOpenGL2_DestroyFontsTexture(); +CIMGUI_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(); +CIMGUI_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(); /////////////////////////hand written functions diff --git a/cimgui/generator/generator.bat b/cimgui/generator/generator.bat index 05e04f2..c560993 100644 --- a/cimgui/generator/generator.bat +++ b/cimgui/generator/generator.bat @@ -12,10 +12,10 @@ set PATH=%PATH%;C:\mingw32\bin;C:\luaGL; :: gcc -E -P no #pragma location information ::generate preprocessed file -gcc -E -C -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../../imgui/imgui.h ../../imgui/examples/imgui_impl_glfw.h ../../imgui/examples/imgui_impl_opengl3.h > 1.txt +gcc -E -C -DIMGUI_DISABLE_OBSOLETE_FUNCTIONS -DIMGUI_API="" -DIMGUI_IMPL_API="" ../../imgui/imgui.h ../../imgui/examples/imgui_impl_glfw.h ../../imgui/examples/imgui_impl_opengl3.h ../../imgui/examples/imgui_impl_opengl2.h > 1.txt ::process preprocessed file -type 1.txt | luajit.exe ./generator.lua true imgui imgui_impl_glfw imgui_impl_opengl3 > out.txt +type 1.txt | luajit.exe ./generator.lua true imgui imgui_impl_glfw imgui_impl_opengl3 imgui_impl_opengl2 > out.txt ::copy cimgui.h and cimgui.cpp copy .\cimgui.h ..\cimgui.h