#include "renderer.h" #include #include GfxObject obj, background; void close(); int main( int argc, char* args[] ) { // If you want the program to not launch the terminal, then // go to Project->Settings->General->This program is a GUI application // and uncheck that flag. //Start up SDL and create window of width=800, height = 600 initRenderer(800, 600); // Create an object obj = createGfxObject( "../ship.png" ); obj.outputWidth = 200; obj.outputHeight = 200; while(true) // The real-time loop { //Handle events on the inqueue (e.g., mouse events) SDL_Event e; //Event handler while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { close(); exit(0); } } //Clear screen with a grey background color, red=0x33, blue=0x33, green=0x33, alpha=0xff. 0xff is maximum. // alpha is transparency: 0 = fully transparent, 0xFF = fully opaque SDL_SetRenderDrawColor( gRenderer, 0x33, 0x33, 0x33, 0xFF ); SDL_RenderClear( gRenderer ); //Render our object(s) - background objects first, and then forward objects (like a painter) renderGfxObject(&obj, 400, 300, 0, 1.0f); renderText("Hello World!", 300, 150); // This function updates the screen and also sleeps 16 ms or so (based on the screens refresh rate), // because we used the flag SDL_RENDERER_PRESENTVSYNC in function initRenderer() SDL_RenderPresent( gRenderer ); } //Free resources close(); return 0; } void close() { //Preferably, you should first free all your GfxObjects by calls to freeGfxObject(GfxObject* gfx) - but you don't have to // ... closeRenderer(); //Free resources and close SDL }