Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <GL/glew.h>
- #include <SDL.h>
- #define GLM_FORCE_RADIANS //force glm to use radians //must do **before** including GLM headers
- //NOTE: GLSL uses radians, so will do the same, for consistency
- #include <glm/glm.hpp> //include the main glm header
- #include <glm/gtc/matrix_transform.hpp> //include functions to ease the calculation of the view and projection matrices
- #include <glm/gtc/type_ptr.hpp> //include functionality for converting a matrix object into a float array for usage in OpenGL
- using namespace std;
- int main( int argc, char* args[] )
- {
- SDL_Init(SDL_INIT_EVERYTHING);
- cout << "SDL Initialised\n";
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
- cout << "Happy hats!" << endl;
- SDL_Window* window = SDL_CreateWindow("OpenGL Tutorial Fun!", 100, 100, 800, 600, SDL_WINDOW_OPENGL);
- cout << "SDL Window Created" << endl;
- SDL_GLContext context = SDL_GL_CreateContext(window);
- cout << "Context Created." << endl;
- glewExperimental = GL_TRUE;
- glewInit();
- GLuint vertexBuffer;
- glGenBuffers(1, &vertexBuffer);
- printf("Vertex Buffer Created", vertexBuffer);
- SDL_Event windowEvent;
- while(true){
- if (SDL_PollEvent(&windowEvent)){
- if(windowEvent.type == SDL_QUIT) break;
- if(windowEvent.type == SDL_KEYUP && windowEvent.key.keysym.sym == SDLK_ESCAPE) break;
- }
- SDL_GL_SwapWindow(window);
- }
- SDL_GL_DeleteContext(context);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement