Advertisement
Ramaraunt1

Untitled

Jan 17th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <iostream>
  2. #define GLEW_STATIC
  3. #include<GL/glew.h>
  4. #include<GLFW/glfw3.h>
  5.  
  6. const GLint WIDTH = 900, HEIGHT = 600;
  7.  
  8. int main()
  9. {
  10. glfwInit();
  11.  
  12. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  13. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  14. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  15. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  16. glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
  17.  
  18. GLFWwindow *window = glfwCreateWindow(WIDTH, HEIGHT, "Learn OpenGL", nullptr, nullptr);
  19.  
  20. int screenWidth, screenHeight;
  21. glfwGetFramebufferSize(window, &screenWidth, &screenHeight);
  22.  
  23. if (nullptr == window)
  24. {
  25. std::cout << "Failed to create GLFW window" << std::endl;
  26. glfwTerminate();
  27.  
  28. return EXIT_FAILURE;
  29. }
  30.  
  31. glfwMakeContextCurrent(window);
  32.  
  33. glewExperimental = GL_TRUE;
  34.  
  35. if (GLEW_OK != glewInit())
  36. {
  37. std::cout << "Failed to initialize GLEW" << std::endl;
  38.  
  39. return EXIT_FAILURE;
  40. }
  41.  
  42. glViewport(0,0,screenWidth, screenHeight);
  43.  
  44. while (!glfwWindowShouldClose(window))
  45. {
  46. glfwPollEvents();
  47.  
  48. glClearColor(0.2f,0.3f,0.3f,1.0f);
  49. glClear(GL_COLOR_BUFFER_BIT);
  50.  
  51. //draw stuff here!!!
  52.  
  53. glfwSwapBuffers(window);
  54. }
  55.  
  56. glfwTerminate();
  57.  
  58. return EXIT_SUCCESS;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement