initial commit
This commit is contained in:
54
src/main.cpp
Normal file
54
src/main.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
|
||||
#endif
|
||||
|
||||
|
||||
#include "../lib/glfw/glfw3.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define SCREEN_WIDTH 800
|
||||
#define SCREEN_HEIGHT 600
|
||||
|
||||
int main() {
|
||||
// init glfw
|
||||
if ( !glfwInit() ) {
|
||||
std::cout << "could not initialize glfw" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// create window
|
||||
//glfwWindowHint(GLFW_RESIZABLE, false);
|
||||
glfwWindowHint(GLFW_SAMPLES, 8);
|
||||
GLFWwindow* win = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "", nullptr, nullptr);
|
||||
if (!win) {
|
||||
std::cout << "could not create opengl window" << std::endl;
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
glfwMakeContextCurrent(win);
|
||||
|
||||
|
||||
|
||||
// main loop
|
||||
float angle = 0;
|
||||
double lastTime = glfwGetTime();
|
||||
while ( !glfwWindowShouldClose(win) && !glfwGetKey(win, GLFW_KEY_ESCAPE) ) {
|
||||
// get delta time
|
||||
float deltaTime = static_cast<float>(glfwGetTime() - lastTime);
|
||||
lastTime = glfwGetTime();
|
||||
|
||||
// get window size
|
||||
int screenWidth, screenHeight;
|
||||
glfwGetWindowSize(win, &screenWidth, &screenHeight);
|
||||
|
||||
|
||||
|
||||
// refresh screen
|
||||
glfwSwapBuffers(win);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
// shutdown
|
||||
glfwTerminate();
|
||||
}
|
||||
Reference in New Issue
Block a user