# Graphical glitches

**URL:** <https://discourse.libsdl.org/t/graphical-glitches/8803>\
**Category:** SDL Development\
**Created:** [May 25, 2003, 3:21am UTC](https://discourse.libsdl.org/t/graphical-glitches/8803 "2003-05-25T03:21:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_Schnayer](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/c57346/32.png) [@Jeffrey\_Schnayer](https://discourse.libsdl.org/u/Jeffrey_Schnayer)\
**Post date:** [May 25, 2003, 3:21am UTC](https://discourse.libsdl.org/t/graphical-glitches/8803/1 "2003-05-25T03:21:04Z")

</div>

I am using the mac os x port of SDL. I ported my game over to SDL from allegro and I have  
some issues with the screen updates that worked perfectly in my old version. I am using a  
dirty rectangle system. I simply blit to a buffer, then add the rectange to a list, then blit  
buffer rectangles to the screen every screen update.

Every once in awhile a rectangle is blit in the wrong place or not at all or i get a "garbled"  
image

My update function goes like this:  
SDL\_UpdateRects(buffscreen, num\_rects, rect\_array);  
to make sure the buffer is up to date

then run through the rectangle list with a for loop and blit from buffer to screen  
each pass I do  
SDL\_UnlockSurface(screen);  
SDL\_BlitSurface(buffscreen, &blit\_rect1, screen, &blit\_rect2);  
SDL\_LockSurface(screen);

after the loop is done I call  
SDL\_UpdateRects(screen, num\_rects, rect\_array);

can someone help understand what is happening.  
I thought SDL\_UnlockSurface(screen); should be switched with the lock, but no updates  
occur on the screen if I switch them.  
-thanks
