Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <GL/glew.h>
  3. #include <GL/freeglut.h>
  4.  
  5. using namespace std;
  6.  
  7. #define WINDOW_TITLE "Modern OpenGL"
  8.  
  9. int WindowWidth = 800, WindowHeight = 600;
  10.  
  11. void UInitialize(int, char*[]);
  12. void UInitWindow(int, char*[]);
  13. void UResizeWindow(int, int);
  14. void URenderGraphics(void);
  15.  
  16. int main(int argc, char* argv[]){
  17.     UInitialize(argc, argv);
  18.     glutMainLoop();
  19.     exit(EXIT_SUCCESS);
  20. }
  21.  
  22. void UInitialize(int argc, char* argv[]){
  23.  
  24.     GLenum GlewInitResult;
  25.  
  26.     UInitWindow(argc, argv);
  27.  
  28.     GlewInitResult = glewInit();
  29.  
  30.     if (GLEW_OK != GlewInitResult){
  31.         fprintf(stderr, "ERROR: %s\n", glewGetErrorString(GlewInitResult));
  32.         exit(EXIT_FAILURE);
  33.     }
  34.     fprintf(stdout, "INFO: OpenGL Version: %s\n", glGetString(GL_VERSION));
  35.     glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  36. }
  37.  
  38. void UinitWindow(int argc, char* argv[]){
  39.     glutInit(&argc, argv);
  40.     glutInitWindowSize(WindowWidth, WindowHeight);
  41.     glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
  42.     glutCreateWindow(WINDOW_TITLE);
  43.     glutReshapeFunc(UResizeWindow);
  44.     glutDisplayFunc(URenderGraphics);
  45. }
  46.  
  47. void UResizeWindow(int Width, int Height){
  48.     glViewport(0, 0, Width, Height);
  49. }
  50.  
  51. void URenderGraphics(void){
  52.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  53.     glutSwapBuffers();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement