diff --git a/CMakeLists.txt b/CMakeLists.txt index 953a5df..ab6a893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -project(test_pybind11 VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX) +project(glpy VERSION 1.0 DESCRIPTION "a default project" LANGUAGES CXX) file(GLOB_RECURSE SRC src/*.cpp) find_package(Python 3.12.3 COMPONENTS Interpreter Development REQUIRED) find_package(pybind11 CONFIG REQUIRED) diff --git a/src/main.cpp b/src/main.cpp index 869ae38..b04402b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,8 +2,45 @@ #include #include +int pytest_glfw_window() +{ + GLFWwindow* window; -PYBIND11_MODULE(test_pybind11, m) { + /* Initialize the library */ + if (!glfwInit()) + return -1; + + /* Create a windowed mode window and its OpenGL context */ + window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); + if (!window) + { + glfwTerminate(); + return -1; + } + + /* Make the window's context current */ + glfwMakeContextCurrent(window); + + /* Loop until the user closes the window */ + while (!glfwWindowShouldClose(window)) + { + /* Render here */ + glClear(GL_COLOR_BUFFER_BIT); + + /* Swap front and back buffers */ + glfwSwapBuffers(window); + + /* Poll for and process events */ + glfwPollEvents(); + } + + glfwTerminate(); + return 0; +} + + + +PYBIND11_MODULE(glpy, m) { m.doc() = "glpy a python opengl project"; // optional module docstring - + m.def("pytest_glfw_window",pytest_glfw_window); } \ No newline at end of file