Browse Source

Ensure ImGui has OpenGL 4.6, pass through dock

I was trying to draw my own things in OpenGL, but the dock space was
completely hiding it. I couldn't debug it because I was actually
ending up with a 2.1 context. I'm not certain either of these changes
are good.
windows-imgui
Macoy Madson 6 months ago
parent
commit
bb4b1eb48b
  1. 22
      src/ImGui.cake
  2. 4
      src/ImGuiSDLOpenGL.cpp

22
src/ImGui.cake

@ -137,8 +137,9 @@
(defun (token-splice entry-point-name) (&return int)
(printf "Hello ImGui\n")
(var glsl-version (* (const char)) null)
(ImGuiSDLOpenGL_SetAttributes (addr glsl-version))
;; TODO Don't set these so high; I only did this for RenderDoc
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MAJOR_VERSION 4)
(SDL_GL_SetAttribute SDL_GL_CONTEXT_MINOR_VERSION 6)
(var window (* SDL_Window) null)
(set window
@ -149,6 +150,9 @@
(sdl-print-error)
(return 1))
(var glsl-version (* (const char)) null)
(ImGuiSDLOpenGL_SetAttributes (addr glsl-version))
(var gl-context SDL_GLContext (SDL_GL_CreateContext window))
(SDL_GL_MakeCurrent window gl-context)
(SDL_GL_SetSwapInterval 1) ;; Enable vsync
@ -212,18 +216,20 @@
(ImGui_ImplSDL2_NewFrame window)
(imgui-call NewFrame)
(imgui-call DockSpaceOverViewport (imgui-call GetMainViewport))
(token-splice once-per-frame)
(imgui-call Render)
(scope ;; Probably will be handled by your game instead
(var imgui-io (& ImGuiIO) (imgui-call GetIO))
(var clear-color ImVec4 (array 0.2f 0.2f 0.2f 1.f))
(ImGuiSDLOpenGL_ClearWindow (addr imgui-io) clear-color))
(imgui-call DockSpaceOverViewport (imgui-call GetMainViewport)
;; Allow inputs and graphics to go through the dock
ImGuiDockNodeFlags_PassthruCentralNode)
(token-splice once-per-frame)
(imgui-call Render)
(ImGui_ImplOpenGL3_RenderDrawData (imgui-call GetDrawData))
(SDL_GL_SwapWindow window))
(when exit-reason

4
src/ImGuiSDLOpenGL.cpp

@ -60,8 +60,8 @@ void ImGuiSDLOpenGL_SetAttributes(const char** glsl_version_out)
const char* glsl_version = "#version 130";
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
#endif
// Create window with graphics context

Loading…
Cancel
Save