RtB/src/main.cpp

47 lines
1.3 KiB
C++

#include "SDL.h"
#include "GL.hpp"
int main(int argc, char *argv[]) {
// TEMP location of video vars
SDL_Window *v_window = NULL;
SDL_GLContext v_context = 0;
SDL_Event event;
int v_width = 640;
int v_height = 480;
int v_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE;
int g_running = 0;
// initialize SDL
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init: %s\n", SDL_GetError());
return 1;
}
// create our window
v_window = SDL_CreateWindow("Roll them Bones", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, v_width, v_height, v_flags);
if (v_window == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "SDL_CreateWindow: %s\n", SDL_GetError());
return 1;
}
// get our OpenGL context
v_context = SDL_GL_CreateContext(v_window);
if (v_context == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "SDL_GL_CreateContext: %s\n", SDL_GetError());
return 1;
}
glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
g_running = 1;
// begin our main loop
while (g_running) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
g_running = 0;
}
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapWindow(v_window);
SDL_Delay(1);
}
SDL_Quit();
return 0;
}