[SDL] A couple questions on SDL
Lilith Calbridge
lilith at dcccd.edu
Fri Jul 14 09:18:39 PDT 2006
If I may pursue this a bit more.....
I took the advice and set up a surface for the background with the same
dimensions and depth (32bit) as the "screen" to which I will later blit
the background. No alpha involved. I fill the background surface with
some random green and yellow pixels. A debug session shows the pixels
are being generated properly (this same function was previously used to
generate the random pixels to "screen" with no problem.)
I then blit background to screen and place my movable image at its
starting location before entering a loop to detect cursor key input.
The problem is that the screen isn't filled with green and yellow
pixels. Instead, it's filled with grey pixels. The movable image,
however, is showing in color. When I move the image with the cursor
keys the grey lightens up a bit with each movement to a point before it
stabilizes.
Another (unsuccessful) object, an attempt at gradiating the color of a
rectangle, drawn directly to the background also appears in shades of
black and white.
Have I not done something to match up the screen properties?
Thanks,
Lilith
>>> On 7/13/2006 at 4:25 PM, in message <44B67402.C7C3.00AE.0>,
lilith at dcccd.edu
wrote:
> That would certainly simplify my programming efforts. I figured
that
> saving data under the image and restoring it would help to keep the
time
> consumption down. I don't expect to have a large number of items on
the
> screen with the project I have in progress so this is probably
viable.
>
> Thanks for your advice.
>
> Lilith
>
>>>> On 7/13/2006 at 4:05 PM, in message
> <20060713210548.5369.qmail at web56114.mail.re3.yahoo.com>,
> jgiors at yahoo.com
> wrote:
>>>>>>> Lilith wrote >>>>>
>>>
>>>I'm getting my feet wet with SDL and, in a great sense, video
> graphics
>>>in general...
>>>
>>>...My purpose is to restore the background under
>>>a blitted surface to it's original content before redrawing the
> object
>>>at a displaced position...
>>
>> Since you're new to gfx programming, I thought I should mention:
>>
>> It is not so common to move objects as you've described above. In
> most
>> applications/games (especially when scrolling and/or
> double-buffered), the
>> entire background is blitted each frame which "clears" the
background
> to
>> it's
>> original state, then the moving "sprites" are drawn over that
> background.
>>
>> This eliminates the need to store and re-draw small pieces of the
> background
>> (which was a common technique in the "good ol' days" before blitter
> chips).
>>
>> But the decision about which way to go is implementation-specific,
so
> it
>> depends upon what you're making. In any case, I hope this info's
> useful.
>>
>> -- JohnG
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam? Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>>
>> _______________________________________________
>> SDL mailing list
>> SDL at libsdl.org
>> http://www.libsdl.org/mailman/listinfo/sdl
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
More information about the SDL
mailing list