int AGOL_InitVideo(const string& drivers, const int width, const int height, const short depth) { ostringstream spec; cout << "Initializing with resolution (" << width << "x" << height << ")..." << endl; /* Initialize Agar-GUI. */ if(drivers.size()) spec << drivers; else spec << "<OpenGL>"; spec << "(width=" << width << ":height=" << height << ":depth=" << depth << ")"; if (AG_InitGraphics(spec.str().c_str()) == -1) { cerr << AG_GetError() << endl; return -1; } #ifdef _XBOX // Software cursor only updates at the refresh rate so make it respectable if(agDriverSw) AG_SetRefreshRate(60); #endif return 0; }
int main(int argc, char *argv[]) { Uint flags = AG_VIDEO_RESIZABLE; int c, i, fps = -1; char *s; if (AG_InitCore("agar-bench", 0) == -1) { fprintf(stderr, "%s\n", AG_GetError()); return (1); } while ((c = getopt(argc, argv, "?vegt:r:T:")) != -1) { extern char *optarg; switch (c) { case 'v': exit(0); case 'g': flags |= AG_VIDEO_OPENGL; break; case 't': AG_TextParseFontSpec(optarg); break; case 'T': AG_SetString(agConfig, "font-path", optarg); break; case 'r': fps = atoi(optarg); break; case '?': default: printf("%s [-vfFgG] [-w width] [-h height] [-r fps]" " [-t font,size,flags] [-T font-path]\n", agProgName); exit(0); } } if (AG_InitVideo(640, 480, 32, flags) == -1) { fprintf(stderr, "%s\n", AG_GetError()); return (-1); } AG_BindGlobalKey(AG_KEY_ESCAPE, AG_KEYMOD_ANY, AG_Quit); AG_BindGlobalKey(AG_KEY_F8, AG_KEYMOD_ANY, AG_ViewCapture); AG_SetRefreshRate(fps); MainWindow(); AG_EventLoop(); AG_Destroy(); return (0); fail: AG_Destroy(); return (1); }