When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
12 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
woops
cmake_minimum_required(VERSION 3.10)
project(opengl C)
# Set C standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
# Find GLFW and glm
find_package(glfw3 REQUIRED)
find_package(cglm REQUIRED)
# Make custom and external headers available
add_library(shader headers/shaders/shader.c)
add_library(texture headers/textures/texture.c)
add_subdirectory("external/cimgui")
target_include_directories(shader
PUBLIC ${CMAKE_SOURCE_DIR}
PUBLIC external/glad/include)
# Link libraries
target_link_libraries(shader
PUBLIC glfw
PUBLIC glad)
# Add glad subdirectory
add_subdirectory(external/glad)
# Add stb subdirecotry
add_subdirectory(external/stb)
# Add the source files
add_executable(main src/main.c)
# Include all of the headers
target_include_directories(main
PUBLIC ${CMAKE_SOURCE_DIR}
PUBLIC external/glad/include
PUBLIC external/stb/include
PUBLIC headers/
PUBLIC external/cimgui
PUBLIC external/cimgui/imgui)
# Link libraries
target_link_libraries(main
PUBLIC glfw
PUBLIC glad
PUBLIC shader
PUBLIC texture
PUBLIC stb
PUBLIC cglm
PUBLIC cimgui)
thats my cmake
@bitter prism
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
and the important bit is:
#include <GLFW/glfw3.h>
#include <imgui.h>
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}
int main() {
// Initialize GLFW
if (!glfwInit()) return -1;
// Create a windowed mode window and its OpenGL context
GLFWwindow* window = glfwCreateWindow(800, 600, "CImGui Example", NULL, NULL);
if (!window) {
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// Initialize ImGui
igCreateContext(NULL);
ImGuiIO* io = igGetIO();
// Setup ImGui style, fonts, etc. here
while (!glfwWindowShouldClose(window)) {
// Start a new frame
igNewFrame();
// Render your UI here
igBegin("Hello, CImGui!", NULL, 0);
igText("This is a simple CImGui window.");
igEnd();
// Render ImGui
igRender();
// Clear the screen
glClear(GL_COLOR_BUFFER_BIT);
// Render ImGui draw data
ImGui_ImplOpenGL3_RenderDrawData(igGetDrawData());
// Swap buffers
glfwSwapBuffers(window);
glfwPollEvents();
}
// Cleanup
igDestroyContext(NULL);
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
it returns the error:
bool ImGui::Begin(const char*, bool*, ImGuiWindowFlags): Assertion `g.WithinFrameScope' failed.
I can't seem to get cimgui set up
and no matter what I do, it keeps giving me errors like this one
I'm on the edge of switching to something different
!solved