#define SDL_MAIN_HANDLED #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; rez::ball b("globalops.rez"); std::unique_ptr f, abcf; SDL_Window *window = nullptr; SDL_GLContext glcontext = nullptr; static const char extension[] = "GL_EXT_texture_compression_s3tc"; abc abc; dtx dtx; if (SDL_Init(SDL_INIT_VIDEO) < 0) { std::cerr << "SDL_Init failed: " << SDL_GetError() << '\n'; goto end; } SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); if (!(window = SDL_CreateWindow("GlobalOps", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE))) { std::cerr << "SDL_CreateWindow failed: " << SDL_GetError() << '\n'; goto end; } else if (!(glcontext = SDL_GL_CreateContext(window))) { std::cerr << "SDL_GL_CreateContext failed: " << SDL_GetError() << '\n'; goto end; } else if (!SDL_GL_ExtensionSupported(extension)) { std::cerr << "OpenGL extension " << extension << " not supported\n"; goto end; } else if (SDL_GL_MakeCurrent(window, glcontext)) { std::cerr << "SDL_GL_MakeCurrent failed: " << SDL_GetError() << std::endl; goto end; } else if (b.parse() || !(f = b.open("interface/blueprints/antarctica_tacmap.dtx")) || dtx.parse(*f) || !(f = b.open("models/grenades/v_frag.abc")) || abc.parse(*f)) goto end; for (;;) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: ret = EXIT_SUCCESS; goto end; } } glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); if (dtx.draw()) goto end; SDL_GL_SwapWindow(window); SDL_Delay(1.0f / 60.f * 1000.0f); } end: if (glcontext) SDL_GL_DeleteContext(glcontext); if (window) SDL_DestroyWindow(window); if (SDL_WasInit(SDL_INIT_VIDEO)) SDL_QuitSubSystem(SDL_INIT_VIDEO); return ret; }