Hello all
I'm just running through a few tutorials at the moment on SDL. I keep noticing that some of them make my laptop go into over-drive - lots of activity on the memory, even for simple things like displaying a picture, fan coming on after a short time etc etc. For example the prog below which simply displays a picture and polls for events.
I'm using a macbook and running it under XCode. The picture I'm using is 696kb. I do get a warning which doesn't stop the program from running, but says:
"Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz."
Can anyone shed any light on this? I guess this shouldn't be happening.
Here's the last bit of code I was running:
Code:#include <iostream> #include <string> #include "SDL_image/SDL_image.h" #include "SDL.h" const int cSCREEN_WIDTH = 640; const int cSCREEN_HEIGHT = 480; const int cSCREEN_BPP = 32; SDL_Surface * image = NULL; SDL_Surface * screen = NULL; SDL_Event event; //SDL data type which stores event data SDL_Surface * loadImage(std::string filename) { SDL_Surface * loadedImage = NULL; SDL_Surface * optimisedImage = NULL; loadedImage = IMG_Load(filename.c_str()); if (loadedImage != NULL) { optimisedImage = SDL_DisplayFormat(loadedImage); SDL_FreeSurface(loadedImage); } return optimisedImage; } void applySurface (int x, int y, SDL_Surface * src, SDL_Surface *dest) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface(src, NULL, dest, &offset); } //wrapper around init functions bool init() { if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { return false; } screen = SDL_SetVideoMode(cSCREEN_WIDTH, cSCREEN_HEIGHT, cSCREEN_BPP, SDL_SWSURFACE); if (screen == NULL) { return false; } return true; } //Wrapper around file loading bool loadFiles() { image = loadImage ("trees.jpg"); if (image == NULL) { return false; } return true; } void cleanUp() { SDL_FreeSurface(image); SDL_Quit(); } int main(int argc, char *argv[]) { bool quit = false; if (init() == false) { return 1; } if (loadFiles() == false) { return 1; } applySurface (0,0,image, screen); if (SDL_Flip(screen) == -1) { return 1; } while (quit == false) { while (SDL_PollEvent(&event) ) { if( event.type == SDL_QUIT || event.type == SDLK_a) { std::cout << "\nQuitting"; quit = true; } } } std::cout << "\nCleaning up"; cleanUp(); return(0); }



LinkBack URL
About LinkBacks


