Advertisement
Guest User

Untitled

a guest
May 26th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <SFML/Window.hpp>
  2. #include <SFML/OpenGL.hpp>
  3. #include <iostream>
  4.  
  5. #include "chunk.h"
  6.  
  7. void InitializeGL(){
  8.     glClearDepth(1.0);
  9.     glClearColor(0.6, 0.7, 0.8, 0.0); //COLOR OF SKY
  10.  
  11.     glEnable(GL_DEPTH_TEST);
  12.     glDepthMask(GL_TRUE);
  13.  
  14.     glMatrixMode(GL_PROJECTION);
  15.     glLoadIdentity();
  16.     gluPerspective(90.0, 1.0, 1.0, 300.0);
  17.     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  18. }
  19.  
  20. int main()
  21. {
  22.     sf::Window window(sf::VideoMode(800, 800), "OpenGL", sf::Style::Default, sf::ContextSettings(32,8,4,3,0));
  23.     window.setVerticalSyncEnabled(true);
  24.  
  25.     window.setActive(true);
  26.  
  27.     InitializeGL();
  28.  
  29.     bool running = true;
  30.     while (running)
  31.     {
  32.         sf::Event event;
  33.         while (window.pollEvent(event))
  34.         {
  35.             if (event.type == sf::Event::Closed)
  36.             {
  37.                 // end the program
  38.                 running = false;
  39.             }
  40.             else if (event.type == sf::Event::Resized)
  41.             {
  42.                 glViewport(0, 0, event.size.width, event.size.height);
  43.             }
  44.         }
  45.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  46.  
  47.         glMatrixMode(GL_MODELVIEW);
  48.         glLoadIdentity();
  49.  
  50.         gluLookAt(5, 3, 6,    0, 0, 0,    0, 1, 0);
  51.         // draw...
  52.         Chunk chunk1(0,0,0);
  53.         chunk1.CreateMesh();
  54.  
  55.         // end the current frame (internally swaps the front and back buffers)
  56.         window.display();
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement