glpy/src/test_window.cpp

39 lines
884 B
C++
Raw Normal View History

2024-06-28 13:17:11 +00:00
#include <pybind11/stl.h>
#include <GLFW/glfw3.h>
#include <glpy.h>
int tests::glfw_window(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;
}
/* 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;
}