upate
This commit is contained in:
parent
b0351c9323
commit
82ed26c165
@ -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)
|
||||
|
41
src/main.cpp
41
src/main.cpp
@ -2,8 +2,45 @@
|
||||
#include <pybind11/stl.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
int pytest_glfw_window()
|
||||
{
|
||||
GLFWwindow* window;
|
||||
|
||||
PYBIND11_MODULE(test_pybind11, m) {
|
||||
m.doc() = "glpy a python opengl project"; // optional module docstring
|
||||
/* 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user