

I’ve left the Visual Studio version off as the process is mostly the same whether it’s Visual Studio 2017, 2019 or future versions. SDL is the name of the library but we don’t want the older SDL1 instead we want SDL2 which seems more or less permanently at version 2.0.12. You’ll see I use the terms SDL and SDL2 mostly interchangeably. That page will grow as I add tutorials, as each is added to it. You’ll see I’ve added a tutorials link to the top menu. Add the following line to the top of imgui/imgui_impl_opengl3.This is the first of a number of longer-piece game related tutorials. You will also need to tell Dear ImGui that you’re using exactly glad. ImGui_ImplOpenG元_RenderDrawData(ImGui ::GetDrawData()) Std ::cout << "counter button clicked \n " buttons and most other widgets return true when clicked/edited/activated ImGui ::Text( "CPU cores: %d", SDL_GetCPUCount()) ImGui ::Begin( "Controls", NULL, ImGuiWindowFlags_NoResize) Std ::cerr (controls_width), static_cast (sdl_height - 20)), If ( !gladLoadGLLoader((GLADloadproc)SDL_GL_GetProcAddress)) SDL_GLContext gl_context = SDL_GL_CreateContext(window) SDL_SetWindowMinimumSize(window, 500, 300) limit to which minimum size user can resize the window SDL_WindowFlags window_flags = (SDL_WindowFlags)( SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1) SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4) SDL_GL_SetAttribute( // required on Mac OS SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24) SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) #include "imgui-style.h" #include "imgui/imgui_impl_sdl.h" #include "imgui/imgui_impl_opengl3.h" #include "functions.h" int windowWidth = 1280, OpenGLįrom lots of supported backends I decided to go with OpenGL.ĬMake knows about it very well because adding it to CMakeLists.txt is very simple: But that’s just me - still a total noob in CMake. List all the files in application directoryĪlmost the most difficult and time consuming part of the whole thing was to make it all work with CMake.Get a string with current date and time.I also continue learning CMake with Visual Studio Code, so that’s what I will be using for building the project. While, in my opinion, it barely can compete with Qt (especially Qt Quick) in terms of beauty and fancy, it is nevertheless a simple, lightweight and quite powerful “framework”. Qt is certainly great, but there are other ways for creating cross-platform GUI, one of such ways being a combination of SDL and Dear ImGui.
