1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Main.cpp
#include <iostream>
#include <GL\glew.h>
#include <GLFW\glfw3.h>
//#define GLEW_STATIC //will put glew32.dll in game exe
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define WINDOW_TITLE "OpenGL Project"
int main(int argc, char *argv[]) {
//Init GLFW
if (!glfwInit()) {
return -1;
}
//Init GLEW
if (glewInit() != GLEW_OK) {
return -2;
}
//Create GLFW Window
GLFWwindow* game_window;
glfwWindowHint(GLFW_VERSION_MAJOR, 3); //Tell the game that OpenGL V3.3 is needed; Major then Minor
glfwWindowHint(GLFW_VERSION_MINOR, 3);
game_window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, NULL, NULL);
if (!game_window) {
glfwTerminate();
return -3;
}
//Setup Window
int window_width, window_height;
glfwGetFramebufferSize(game_window, &window_width, &window_height); //get window sites
glViewport(0, 0, window_width, window_height); //set coordinates to top left (0,0); and set width and height to actual window width and height
glfwMakeContextCurrent(game_window); //make game_window the current focused window
//Loop game
while (true) {
glClear(GL_COLOR_BUFFER_BIT);
//Poll and Process events
glfwPollEvents();
//Update
//Swap Buffers
glfwSwapBuffers(game_window);
//Check if game should quit;; X Button is pressed
if (glfwWindowShouldClose(game_window)) {
break;
}
}
//Quit Game
glfwTerminate();
return 0;
}
|