From 748e09a7c21de8e58681ec0dea71a5295f8659a1 Mon Sep 17 00:00:00 2001 From: ZtRXR Date: Sat, 29 Jun 2024 17:32:40 +0800 Subject: [PATCH] update --- include/glpy.h | 3 +- src/glfw_basic_triangle.cpp | 52 ++++++++++++++++++++++++ src/{test_window.cpp => glfw_shader.cpp} | 2 +- src/main.cpp | 11 +++-- 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 src/glfw_basic_triangle.cpp rename src/{test_window.cpp => glfw_shader.cpp} (96%) diff --git a/include/glpy.h b/include/glpy.h index ba0f99d..6ecec21 100644 --- a/include/glpy.h +++ b/include/glpy.h @@ -4,6 +4,7 @@ namespace py = pybind11; namespace tests{ - int glfw_window(unsigned width,unsigned height, std::string title); + int glfw_shader(unsigned width,unsigned height, std::string title); int glfw_black_window(unsigned width,unsigned height,std::string title); + int glfw_basic_triangle(unsigned width,unsigned height, std::string title); } \ No newline at end of file diff --git a/src/glfw_basic_triangle.cpp b/src/glfw_basic_triangle.cpp new file mode 100644 index 0000000..3a88207 --- /dev/null +++ b/src/glfw_basic_triangle.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +int tests::glfw_basic_triangle(unsigned width,unsigned height, std::string title) +{ + GLFWwindow* window; + + /* Initialize the library */ + if (!glfwInit()) + return -1; + + + + /* Create a windowed mode window and its OpenGL context */ + window = glfwCreateWindow(width, height, title.c_str(), NULL, NULL); + if (!window) + { + glfwTerminate(); + return -1; + } + + glfwMakeContextCurrent(window); + + std::cout<<"-- OPEN_GL_VERSION: "<