Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

SDL_Surface.w

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
locSpriteSheet->w, not locSpriteSheet.w

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!