also UpdateRects is only neccessary for updating the screen
“Marco Mattiazzo” <marco.mattiazzo at halleyveneto.it> wrote in message
news:200011012141.NAA29332 at mail.lokigames.com…> Can anyone tell me how tocreate a SDL_Surface that is a sub image of =
This solution is stolen from libuta so i haven;t really tested it. Soon I
hope to implement my own version, so If this turns out not to work for you
just tell me and I’ll put that at the front of my work queue:
SDL_Surface* CreateSubSurface(SDL_Surface* source, int x, int y, int w, int
h)
{
//make a copy of the original struct
sdlSurface_ = new SDL_Surface;
*sdlSurface_ = *source;
//then set new metrics
sdlSurface_->w = w;
sdlSurface_->h = h;
Now keep in mind in your snip-it the source surface is copied. In the
function I included, editting the subsurface changes the source surface.
This is what I think of as a sub-surface but I am not sure if that is what
you wanted. I hope this can help…
sdlSurface_ = new SDL_Surface;
*sdlSurface_ = *source;
Stop propagating bad code. You can create an SDL_Surface by calling
SDL_CreateRGBSurface() or SDL_CreateRGBSurfaceFrom(), or indirectly
using SDL_ConvertSurface(), SDL_DisplayFormat(), SDL_DisplayFormatAlpha(),
IMG_Load(), etc. Don’t ever construct it yourself if you don’t know
what you are doing
sdlSurface_ = new SDL_Surface;
*sdlSurface_ = *source;
Stop propagating bad code. You can create an SDL_Surface by calling
SDL_CreateRGBSurface() or SDL_CreateRGBSurfaceFrom(), or indirectly
using SDL_ConvertSurface(), SDL_DisplayFormat(), SDL_DisplayFormatAlpha(),
IMG_Load(), etc. Don’t ever construct it yourself if you don’t know
what you are doing
As I understand it (creating a surface that represents a “window” inside
another surface, using the same physical pixel data),
SDL_CreateRGBSurfaceFrom() would be the one to use here.
(I’m using a similar trick in a simple linear framebuffer GUI toolkit in order
to avoid special cases for clip rects, windows and other stuff - there is only
one surface structure, and the only variable is that some surfaces may not own
the pixel data they represent.)
David Olofson
Programmer
Reologica Instruments AB
david.olofson at reologica.se
…- M u C o S --------------------------------. .- David Olofson ------.
| A Free/Open Multimedia | | Audio Hacker |
| Plugin and Integration Standard | | Linux Advocate | ------------> http://www.linuxdj.com/mucos -' | Open Source Advocate | ..- A u d i a l i t y ------------------------. | Singer | | Rock Solid Low Latency Signal Processing | | Songwriter |—> http://www.angelfire.com/or/audiality -’ `-> david at linuxdj.com -’
sdlSurface_ = new SDL_Surface;
*sdlSurface_ = *source;
Stop propagating bad code. You can create an SDL_Surface by calling
SDL_CreateRGBSurface() or SDL_CreateRGBSurfaceFrom(), or indirectly
using SDL_ConvertSurface(), SDL_DisplayFormat(), SDL_DisplayFormatAlpha(),
IMG_Load(), etc. Don’t ever construct it yourself if you don’t know
what you are doing
The idea is that the origanal surface “source” was created using one of these
methods you described then mearly copied and offset to the appropriate
value. Sorry, i was just trying to help…
The idea is that the origanal surface “source” was created using one of these
methods you described then mearly copied and offset to the appropriate
value. Sorry, i was just trying to help…
No, my bad, I got the wrong impression. Sorry for jumping on you like that.