Advertisement
Guest User

Untitled

a guest
Oct 6th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include "include/glad/glad.h"
  2. #include "GLFW/glfw3.h"
  3. #include <iostream>
  4. #include <cstddef>
  5. #include <string_view>
  6.  
  7.  
  8. void error_callback(int error, const char *msg) {
  9. std::string_view error_msg(msg);
  10. std::cerr << "[" << error << "]" << error_msg << "\n";
  11. }
  12.  
  13.  
  14. int main() {
  15. glfwSetErrorCallback(error_callback);
  16. if (glfwInit() == GL_FALSE) {
  17. std::cout << "Failed to initialize GLFW, check your drivers!" << std::endl;
  18. return EXIT_FAILURE;
  19. } else {
  20. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  21. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
  22. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  23. }
  24.  
  25. GLFWwindow *window = glfwCreateWindow(800, 600, "Hello, World", NULL, NULL);
  26.  
  27. if (window == nullptr) {
  28. std::cout << "Failed to create window" << std::endl;
  29. glfwTerminate();
  30. return EXIT_FAILURE;
  31. }
  32.  
  33. glfwMakeContextCurrent(window);
  34.  
  35. return EXIT_SUCCESS;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement