You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! So after some futzing, i got the readme example to work wiht >= opengl3 flavor stuff. as below.
i did hit a strange crash i'm not sure how to understand when i tried a compatiblity profile (not that i expect to need it, but was just trying things)
carterschonwald@CarterHydra ~/W/p/a/genicad (main) [1]> cabal run exe:trash_demo
Build profile: -w ghc-9.4.7 -O1
In order, the following will be built (use -v for more details):
- genicad-0.1.0.0 (exe:trash_demo) (file app/Trash.hs changed)
Preprocessing executable 'trash_demo' for genicad-0.1.0.0..
Building executable 'trash_demo' for genicad-0.1.0.0..
trash_demo: SDLCallFailed {sdlExceptionCaller = "SDL.Video.glCreateContext", sdlFunction = "SDL_GL_CreateContext", sdlExceptionError = "Failed creating OpenGL context at version requested"}
the full code with working core profile is as below
{-# LANGUAGE OverloadedStrings,GHC2021 #-}
moduleMain ( main ) whereimportControl.ExceptionimportControl.Monad.IO.ClassimportControl.Monad.ManagedimportDearImGuiimportDearImGui.OpenGL3importDearImGui.SDLimportDearImGui.SDL.OpenGLimportGraphics.GLimportSDLimportSDL.Videomain::IO()
main =do-- Initialize SDL
initializeAll
runManaged $do-- Create a window using SDL. As we're using OpenGL, we need to enable OpenGL too.
window <-dolet title ="Hello, Dear ImGui!"let config = defaultWindow { windowGraphicsContext =OpenGLContext defaultOpenGL{glProfile=CoreNormal41} , windowResizable =True }
managed $ bracket (createWindow title config) destroyWindow
-- Create an OpenGL context
glContext <- managed $ bracket (glCreateContext window) glDeleteContext
-- Create an ImGui context
_ <- managed $ bracket createContext destroyContext
-- Initialize ImGui's SDL2 backend
_ <- managed_ $ bracket_ (sdl2InitForOpenGL window glContext) sdl2Shutdown
-- Initialize ImGui's OpenGL backend
_ <- managed_ $ bracket_ openGL3Init openGL3Shutdown
liftIO $ mainLoop window
mainLoop::Window->IO()
mainLoop window = unlessQuit $do-- Tell ImGui we're starting a new frame
openGL3NewFrame
sdl2NewFrame
newFrame
-- Build the GUI
withWindowOpen "Hello, ImGui!"$do-- Add a text widget
text "Hello, ImGui!"-- Add a button widget, and call 'putStrLn' when it's clicked
button "Clickety Click">>=\x ->case x ofFalse->return()True->putStrLn"Ow!"-- Show the ImGui demo window
showDemoWindow
-- Render
glClear GL_COLOR_BUFFER_BIT
render
openGL3RenderDrawData =<< getDrawData
glSwapWindow window
mainLoop window
where-- Process the event loop
unlessQuit action =do
shouldQuit <- checkEvents
if shouldQuit thenpure()else action
checkEvents =do
pollEventWithImGui >>=\x ->case x ofNothing->returnFalseJust event ->
(isQuit event ||) <$> checkEvents
isQuit event =SDL.eventPayload event ==SDL.QuitEvent
The text was updated successfully, but these errors were encountered:
Hey! So after some futzing, i got the readme example to work wiht >= opengl3 flavor stuff. as below.
i did hit a strange crash i'm not sure how to understand when i tried a compatiblity profile (not that i expect to need it, but was just trying things)
the full code with working core profile is as below
The text was updated successfully, but these errors were encountered: