6 static void process_event(SDL_Event *ev);
8 static SDL_Window *win;
9 static SDL_GLContext ctx;
10 static bool redraw_pending = true;
13 int main(int argc, char **argv)
15 if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
16 fprintf(stderr, "failed to initialize SDL\n");
20 int x = SDL_WINDOWPOS_UNDEFINED;
21 int y = SDL_WINDOWPOS_UNDEFINED;
22 unsigned int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
25 if(!(win = SDL_CreateWindow("vrfileman", x, y, win_width, win_height, flags))) {
26 fprintf(stderr, "failed to create window\n");
30 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
31 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
32 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
33 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
34 SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
36 if(!(ctx = SDL_GL_CreateContext(win))) {
37 fprintf(stderr, "failed to create OpenGL context\n");
40 SDL_GL_GetDrawableSize(win, &win_width, &win_height);
41 app_reshape(win_width, win_height);
47 if(!SDL_WaitEvent(0)) {
48 fprintf(stderr, "error while waiting for events\n");
53 time_msec = app_get_msec();
54 while(SDL_PollEvent(&ev)) {
56 if(quit) goto break_evloop;
60 redraw_pending = false;
73 redraw_pending = true;
76 void app_swap_buffers()
78 SDL_GL_SwapWindow(win);
83 return SDL_GetTicks();