Jump to content
  • Advertisement
Sign in to follow this  
Mhondoz

SDL_MUSTLOCK needed for software surfaces?

This topic is 4714 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 am using software surfaces in SDL:
_screen = SDL_SetVideoMode( width, height, 8, SDL_SWSURFACE );
_backscreen = SDL_CreateRGBSurface( SDL_SWSURFACE, width, height, 8, 0, 0, 0, 0 );
Inspecting the SDL_MUSTLOCK macro it looks like you should lock your surface if you are using SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL, or surface->offset != 0. My question is, what is the surface->offset used for? The reason for questioning this is that I am not using any of the flags that will require locking, and if I could know for certain that the offset will not change from 0, I could use the surface without checking if it need to be locked. Btw. I am on Windows XP, and using the _screen in both windowed and fullscreen mode. [Edited by - Mhondoz on June 29, 2005 8:12:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
The offset is there because some drivers will pad surfaces that do not align on certain word boundaries as an optimization. So the surface block may begin at address x in memory, but the actual image data may begin at address x+offset. You should just use the macro. Just because you request a hardware surface or system memory surface or a surface with some other flags does not mean you will always get exactly what you requested. Many times the driver will decide where and how the surface actually gets allocated. The lock macro will resolve this for you and make sure you are getting a pointer to actual image data. There is very little overhead for using the macro, the overhead is in the actual lock itself if it becomes neccessary. I would recommend just using the macro and save yourself potential head aches.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!