Advertisement
marichan022

openGL.sublime-snippet

Mar 25th, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.46 KB | None | 0 0
  1. <snippet>
  2.     <content><![CDATA[
  3. #include <iostream>
  4. #include <GL/glew.h>
  5. #include <GLFW/glfw3.h>
  6. #include <glm/glm.hpp>
  7.  
  8. #include "shader.h"
  9.  
  10. int main()
  11. {
  12.     if( !glfwInit() )
  13.     {
  14.        std::cerr << "GLFW nije inicijaliziran\n";
  15.         getchar();
  16.         return -1;
  17.     }
  18.  
  19.     glfwWindowHint(GLFW_SAMPLES, 4);
  20.     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  21.     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  22.    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // samo za MacOS
  23.     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  24.  
  25.    GLFWwindow* window = glfwCreateWindow( 1024, 768, "prog", nullptr, nullptr);
  26.    if( window == nullptr )
  27.    {
  28.        std::cerr << "Nije proΕ‘ao init glfw prozora. Npr. neki Intel GPU nisu 3.3 kompatibilni.\n";
  29.         getchar();
  30.         glfwTerminate();
  31.         return -1;
  32.     }
  33.     glfwMakeContextCurrent(window);
  34.  
  35.    if (glewInit() != GLEW_OK)
  36.    {
  37.        std::cerr << "GLEW nije inicijaliziran\n";
  38.         getchar();
  39.         glfwTerminate();
  40.         return -1;
  41.     }
  42.  
  43.     glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
  44.  
  45.     glClearColor(0.9f, 0.9f, 0.9f, 0.0f);
  46.  
  47.     GLuint programID = loadShaders($1);
  48.  
  49.     do {
  50.         glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  51.  
  52.         glUseProgram(programID);
  53.        
  54.         glfwSwapBuffers(window);
  55.         glfwPollEvents();
  56.  
  57.    }
  58.     while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
  59.            glfwWindowShouldClose(window) == 0 );
  60.  
  61.     glfwTerminate();
  62.  
  63.     return 0;
  64. }]]></content>
  65.     <tabTrigger>gl</tabTrigger>
  66. </snippet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement