cuestion

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • I'm working with SDL but i think that this of what i'm going to talk is for any kind of 2D game.
      When i want to clear o delete a image, has SDL some kind of function that for? or only i have to redrawing the background.
      Be a pointer my friend

      The post was edited 1 time, last by budark ().

    • Whenever you allocate memory in C\C++ you have to also free that memory when you are finished with it, I am assuming you are talking about an SDL_Surface when you mean an image. When you are sure you know longer need the surface, you may use SDL_FreeSurface to free the memory.

      When you call SDL_Flip this is actually what redraws the background, all of the memory (surfaces) you used to draw to the screen will still be available when you are finished.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Yeah, so basically when you know for a fact that you will not need to use an SDL_Surface "image" to be rendered again in your game, if you are doing small tests, just free all of those at the very end of your program, if your project is bigger then a good resource caching system (Like in the book) would be good to have.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz