SHARE
TWEET

Untitled

a guest Jun 16th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. #define GLEW_STATIC
  4. #include <GL/glew.h>
  5.  
  6. #include <GLFW/glfw3.h>
  7.  
  8. const GLint WIDTH = 800, HEIGHT = 600;
  9.  
  10. int main()
  11. {
  12.     glfwInit();
  13.  
  14.     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  15.     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  16.     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  17.     glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
  18.     glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
  19.  
  20.     GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Learn OpenGL", nullptr, nullptr);
  21.  
  22.     int screenWidth, screenHeight;
  23.     glfwGetFramebufferSize(window, &screenWidth, &screenHeight);
  24.  
  25.     if(nullptr == window)
  26.     {
  27.         std::cout << "Failed to create GLFW window" << 'n';
  28.         glfwTerminate();
  29.  
  30.         return -1;
  31.     }
  32.  
  33.     glewExperimental = GL_TRUE;
  34.     GLenum err=glewInit();
  35.  
  36.     if(err != glewInit())
  37.     {
  38.         std::cout << "Failed to initialize GLEW" << 'n';
  39.  
  40.         return -1;
  41.     }
  42.  
  43.     glViewport(0, 0, screenWidth, screenHeight);
  44.  
  45.     while(!glfwWindowShouldClose(window))
  46.     {
  47.         glfwPollEvents();
  48.  
  49.         glClearColor(0.2f, 0.2f, 0.9f, 0.5f);
  50.         glClear(GL_COLOR_BUFFER_BIT);
  51.  
  52.         glfwSwapBuffers(window);
  53.     }
  54.  
  55.     glfwTerminate();
  56.  
  57.     return 0;
  58. }
  59.      
  60. glfwMakeContextCurrent(window);
  61.      
  62. wlgMakeCurrent()
  63. glClearColor( R, G, B, 1.0 ); //: <--Make sure alpha isn't transparent.
  64. glClear( GL_COLOR_BUFFER_BIT )
  65. SwapBuffers( your_window_HDC ); //: from GDI32.dll
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top