Public Group

# SDL_Surface.w

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to get the width and height of a SDL_Surface, and am not able to. SDL_Surface looks like this:
Quote:
 libSDL.org:typedef struct SDL_Surface { Uint32 flags; /* Read-only */ SDL_PixelFormat *format; /* Read-only */ int w, h; /* Read-only */ Uint16 pitch; /* Read-only */ void *pixels; /* Read-write */ SDL_Rect clip_rect; /* Read-only */ int refcount; /* Read-mostly */ /* This structure also contains private fields not shown here */ } SDL_Surface;
And I'm trying to get it merely by having int myInt = mySurface.w which runs into problems. It's read-only, so unless I misunderstand that, I should be able to get it's value, as long as I don't change .w's value. I get a "request for member w' in locSpriteSheet', which is of non-aggregate type `SDL_Surface*'" error in Dev C++. What is the proper way to find the size of a SDL_Surface? I couldn't find it on libSDL.org. Thanks, [Edited by - Servant of the Lord on July 28, 2006 4:11:12 AM]

##### Share on other sites
locSpriteSheet->w, not locSpriteSheet.w

##### Share on other sites
Thanks, that did it. I don't get that '->' thing though, although I've seen it in the past. When and why is it used?

##### Share on other sites
Its used to access the members if you have pointer to a structure or class pretty much the same as you were trying to do. SDL_Surface is a pointer so to access the members you would have to do that, which is a shorcut to having to dereference the pointer and accessing the members which you could also do.

(*locSpriteSheet).w

You should probably read up a little about how to use pointers so you don't run into nasty bugs while using SDL later on as well.

• 10
• 17
• 9
• 14
• 41
• ### Forum Statistics

• Total Topics
631073
• Total Posts
2997753
×