/******************************************************************************\ Title: SDL_gfx Example Description: This is an example of how to use the SDL_gfx DevKit. After the dev kit is installed into Dev-C++, you should be able to goto New Project and see the SDL_gfx Example project available there. SDL_gfx is a great graphics library for SDL. More information is available about it at http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/ Author: Rob Loach (http://www.robloach.net) Date: February 8th, 2005 Note: REQUIRED - You must copy SDL.dll, SDL_gfx.dll and sample24.bmp from Dev-C++/DLL directory to the folder where you saved this project. When making a new project, you must link to -lSDL_gfx. \******************************************************************************/ #include #include #include // SDL_gfx #include // SDL_gfx Rotozoom #include // SDL_gfx Primitives #include // SDL_gfx Framerate Manager // For more information about SDL_gfx, please visit their website at // http://www.ferzkopp.net/~aschiffler/Software/SDL_gfx-2.0/ int main(int argc, char *argv[]){ // Initialize SDL if(SDL_Init(SDL_INIT_VIDEO) == -1){ fprintf(stderr, "Failed to initialize SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); // Initilize the screen SDL_Surface *screen = SDL_SetVideoMode(400, 300, 32, SDL_HWSURFACE|SDL_DOUBLEBUF); if(screen == NULL){ fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError()); exit(1); } // Load the image SDL_Surface* image = SDL_LoadBMP("sample24.bmp"); if(image == NULL) fprintf(stderr, "Unable to load image: %s\n", SDL_GetError()); // FRAME RATE MANAGER EXAMPLE // Initialize Frame Rate Manager FPSmanager fpsm; SDL_initFramerate(&fpsm); SDL_setFramerate(&fpsm, 60); // 60 Frames Per Second int toiminta = 1; while(toiminta = 1){ // Clear the screen SDL_FillRect(screen, NULL, 0); // ROTOZOOM EXAMPLE // Make the new rotated image static double rotationAngle = 0; rotationAngle += 0.3; SDL_Surface* imageRotated = rotozoomSurface(image, rotationAngle, 1, 0); // Draw the rotated image SDL_Rect rect; rect.x = (int)(screen->w / 2) - (int)(imageRotated->w / 2); rect.y = (int)(screen->h / 2) - (int)(imageRotated->h / 2); SDL_BlitSurface(imageRotated, NULL, screen, &rect); // Clear memory when finished with the rotated image SDL_FreeSurface(imageRotated); // GRAPHICS PRIMATIVES EXAMPLE filledCircleRGBA(screen, 200, 200, 50, 255, 0, 0, 150); // Output to the screen SDL_Flip(screen); // FRAME RATE MANAGER EXAMPLE // Delay using the frame rate manager SDL_framerateDelay(&fpsm); // Check if user quits SDL_Event event; while(SDL_PollEvent(&event)){ switch(event.type){ case SDL_QUIT: toiminta = 2; break; case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_ESCAPE) toiminta = 2; break; } } } // Clean up the loaded image SDL_FreeSurface(image); return 0; }