So, I'm trying to get better at manually compiling and building a program in VS Code. Also I'm running Windows 11 22H2 if that helps. I'm using SFML and ImGui with the ImGui-SFML backend. After days of trying to get a program up and running, I managed to get an SFML window created with a green circle in it. I then integrated ImGui and ImGui-SFML compiled into an .exe but when I run the exe, I get a shit ton of errors saying about how the Pixel Format is Invalid. this is my main.cpp, its just the example code from the ImGui-SFML repo:
#include "src/imgui-include/imgui.h"
#include "src/imgui-include/imgui-SFML.h"
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(window, event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::ShowDemoWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
}
This is the Makefile I have setup:
CXX = g++
CXXFLAGS = -g -Wextra -Wall
INCLUDE = -Isrc/include -Isrc/imgui-include
LIB = -Lsrc/lib -lsfml-audio -lsfml-graphics -lsfml-network -lsfml-system -lsfml-window -lopengl32
IMGUI_FILES = src/imgui-include/imgui.cpp src/imgui-include/imgui_draw.cpp src/imgui-include/imgui_widgets.cpp src/imgui-include/imgui_demo.cpp src/imgui-include/imgui_tables.cpp
IMGUI_SFML_FILES = src/imgui-include/imgui-SFML.cpp
all: compile link
compile:
$(CXX) $(CXXFLAGS) -c $(IMGUI_FILES) $(IMGUI_SFML_FILES) main.cpp $(INCLUDE)
link:
$(CXX) $(CXXFLAGS) $(IMGUI_FILES) $(IMGUI_SFML_FILES) main.o -o main $(LIB)
clean:
del *.o *.exe
This is my settings.json:
{
"cmake.configureOnOpen": true,
"cmake.showOptionsMovedNotification": false,
"explorer.confirmDelete": false,
"git.enableSmartCommit": true,
"makefile.makefilePath": "C:/Users/Peyton/source/repos/FortEditor/Makefile",
"git.autofetch": true,
"C_Cpp.default.compilerPath": "C:\\MinGW\\bin\\g++.exe",
"C_Cpp.default.includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/**"
]
}
and this is my terminal output:
Failed to activate OpenGL context: The pixel format is invalid.
Failed to activate the window's context
Failed to activate OpenGL context: The pixel format is invalid.
Failed to activate OpenGL context: The handle is invalid.
Failed to activate OpenGL context: The handle is invalid.
I've alread tried to get everything linked and workinng, I have opengl32.dll in with the rest of the dll's.
What I was expecting was a window to be created with a green circle in it and for an ImGui Demo Window to be created. Like I said before, I had managed to get a working SFML window to appear with a green circle inside it using the example code from the Linux setup.


