![]() ![]() I cannot really compare GLFW with SDL thoroughly, because I don’t know much about their capabilities, but I was curious to compare the footprint of applications built with both. The full project source code is published here. Since it’s C++ and thanks to our universal CMakeLists.txt, the application builds and works fine not only on Mac OS but also on Windows: Fonts -> AddFontFromFileTTF ( "verdana.ttf", 18.0f * highDPIscaleFactor, NULL, NULL ) It’s cross-platform Running this on Mac OS gives this simple window: GlClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) GlClearColor(backgroundR, backgroundG, backgroundB, 1.0f) GlViewport( 0, 0, actualWindowWidth, actualWindowHeight) GlfwGetWindowSize(window, &actualWindowWidth, &actualWindowHeight) Int actualWindowWidth, actualWindowHeight Std ::cout << " OpenGL from glad " << GLVersion.major << "." << GLVersion.minor Std ::cerr << " Couldn't initialize GLAD" << std ::endl If ( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) GlfwSetFramebufferSizeCallback(window, framebuffer_size_callback) Std ::cerr << " Couldn't create a GLFW window \n " GlfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE) GlfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE) Static void framebuffer_size_callback(GLFWwindow *window, int width, int height) #include #include #include "functions.h" std ::string programName = "GLFW window" If you’re on Linux, then you can try to install it via your package manager, but for me that option failed, so I built it from sources ( which can be downloaded from the same page): If you’re on Mac OS or Windows, simply download the pre-build binaries. It looks like I switched to CMake for good, so I’ll be using it for all my C++ projects, including this one. So let’s create a cross-platform application using GLFW and add a Dear ImGui to it. It also seems to have most of the SDL features as well, such as events, user input with keyboard and mouse, and others. GLFW is almost the same thing as SDL - a way to create windows and OpenGL contexts. There will be also a silly SDL vs GLFW comparison. So today I would like to explore a GLFW and Dear ImGui combo. Last time I tried SDL and Dear ImGui and that was quite interesting. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |