Original Post
🔒 Locked
SDL pixels?
Advertisement
All the pixels? Just create a copy of the surface (something like SDL_ConvertSurface(surface, surface->format, 0) and then use SDL_BlitSurface() to draw them back later.
If you only need to do this for a subset of the pixels, you can create a surface of the correct size and use SDL_BlitSurface() back and forth.
If this is the screen surface and you are doing a dirty rectangle system, keep one surface the same size and just blit rectangles to/from it using the clipping rectangle parameters SDL_BlitSurface() provides. If you are redrawing more than 50% of the screen every frame it might be more efficient to just re-draw everything rather than worry about this kind of thing.
If you give us a higher level overview of your goal we can be more specific.
If you only need to do this for a subset of the pixels, you can create a surface of the correct size and use SDL_BlitSurface() back and forth.
If this is the screen surface and you are doing a dirty rectangle system, keep one surface the same size and just blit rectangles to/from it using the clipping rectangle parameters SDL_BlitSurface() provides. If you are redrawing more than 50% of the screen every frame it might be more efficient to just re-draw everything rather than worry about this kind of thing.
If you give us a higher level overview of your goal we can be more specific.
Use SDL_BlitSurface(). If you only want to draw a portion of a surface, you specify that portion in the source rectangle.
SDL_Rect srcRect = { x, y, w, h }; // The portion we want to copySDL_Rect pos = { posX, posY }; // Position on the target surface (w/h are not used)SDL_BlitSurface(mySurface, &srcRect, otherSurface, &pos);
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement