GLBox() { // Create the main window App = new sf::Window(sf::VideoMode(RESOLUTION, RESOLUTION, 32), "program1"); sf::Clock clock; clock.Reset(); graphicsInit(); board = new Board(shaderProg); // Start render loop while (App->IsOpened()) { // Set the active window before using OpenGL commands // It's not needed here because the active window is always the same, // but don't forget it if you use multiple windows or controls App->SetActive(); // Handle any events that are in the queue handleEvents(); // Render the scene //display(); board->display(); //printf("Frame time is %.2fs\n", clock.GetElapsedTime()); // Finally, display rendered frame on screen App->Display(); } }
void registerClasses() { RGA = rb_define_module("RGA"); graphicsInit(); spriteInit(); bitmapInit(); rectInit(); colorInit(); }
GLBox() { // Create the main window sf::Window window(sf::VideoMode(RESOLUTION, RESOLUTION, 32), "program1"); graphicsInit(); unsigned int frameCount = 0; // Start render loop while (window.isOpen()) { // Set the active window before using OpenGL commands // It's not needed here because the active window is always the same, // but don't forget it if you use multiple windows or controls window.setActive(); // Handle any events that are in the queue sf::Event event; while (window.pollEvent(event)) { // Close window : exit //if (event.type == sf::Event::Closed) // window.close(); // Escape key : exit if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)) window.close(); // This is for grading your code. DO NOT REMOVE if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Equal) { saveBuffer(window); } } // Render the scene display(); frameCount++; if(frameCount == 100) saveBuffer(window); // Finally, display rendered frame on screen window.display(); } }
GLBox() { //sf::err().rdbuf(NULL); //hide errors #ifdef __APPLE__ //int nullFD = open("/dev/null", O_WRONLY); //int oldFD = dup(2); // Duplicate the old file descriptor, so it can be restored //dup2(nullFD, 2); // Redirect #endif sf::VideoMode mode(RESOLUTION, RESOLUTION, 32); #ifdef __linux__ sf::ContextSettings settings(32, 0, 0, 3, 3); #else sf::ContextSettings settings(0, 0, 0, 3, 3); #endif sf::Window window(mode, "glver", sf::Style::Default, settings); float ver = getVer(); #ifdef __APPLE__ //dup2(oldFD, 2); // Redirect back //close(oldFD); // Not needed anymore #endif if( ver < 1.0f ) { printf("OpenGL is not supported.\n"); exit(1); } printf("OpenGL version %.1f is supported.\n", ver); sf::Clock time; WorldState state; graphicsInit(); while (state.isRunning()) { this->handleEvents(window, state); state.timeStep( time.getElapsedTime().asSeconds() ); display(state); window.display(); } window.close(); }
int main(int argc, char* argv[]) { /* Initialize the graphics system */ graphicsInit(&argc, argv); if(!netClient) { if (testWorld == 1) build_test_world(); else { build_world(); place_mobs(); } } trimout(); /* starts the graphics processing loop */ glutMainLoop(); return 0; }
void SDLFunction (Graphics *graphics) { SDL_Init (SDL_INIT_EVERYTHING); graphicsInit(graphics); }