Window.c 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "Window.h"
  2. #include <GLFW/glfw3.h>
  3. #include <stdio.h>
  4. bool windowTest() {
  5. GLFWwindow* window;
  6. /* Initialize the library */
  7. if(!glfwInit()) {
  8. printf("init failed\n");
  9. return true;
  10. }
  11. /* Create a windowed mode window and its OpenGL context */
  12. window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
  13. if(!window) {
  14. glfwTerminate();
  15. printf("create window failed\n");
  16. return true;
  17. }
  18. /* Make the window's context current */
  19. glfwMakeContextCurrent(window);
  20. /* Loop until the user closes the window */
  21. while(!glfwWindowShouldClose(window)) {
  22. /* Render here */
  23. glClear(GL_COLOR_BUFFER_BIT);
  24. /* Swap front and back buffers */
  25. glfwSwapBuffers(window);
  26. /* Poll for and process events */
  27. glfwPollEvents();
  28. }
  29. printf("YES\n");
  30. glfwTerminate();
  31. return true;
  32. }