Sin, cos, tan

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?

Thanks.

You can use:

#include <math.h>

Please use a C newsgroup like comp.lang.c or another mailing list to
discuss generic C questions. You can also use most C books’ index section
to find C functions and the required header files. If you have access to
UNIX, BSD, or Linux, you can use the man program as well. Thank you.

-MarkOn Fri, 30 Jan 2004, Mario de Sousa wrote:

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?

Thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage

that would be math.h :P> ----- Original Message -----

From: mcd@jhb.ucs.co.za (Mario de Sousa)
To: “SDL”
Sent: Thursday, January 29, 2004 11:16 PM
Subject: [SDL] sin, cos, tan.

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?

Thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Sorry about that. I sent to wrong group.

Thanks.On Thu, 29 Jan 2004 23:43:22 -0800 (PST) “Mark K. Kim” wrote:

You can use:

#include <math.h>

Please use a C newsgroup like comp.lang.c or another mailing list to
discuss generic C questions. You can also use most C books’ index
section
to find C functions and the required header files. If you have access
to
UNIX, BSD, or Linux, you can use the man program as well. Thank you.

-Mark

On Fri, 30 Jan 2004, Mario de Sousa wrote:

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?

Thanks.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Mark K. Kim
AIM: markus kimius
Homepage: http://www.cbreak.org/
Xanga: http://www.xanga.com/vindaci
Friendster: http://www.friendster.com/user.jsp?id=13046
PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE
PGP key available on the homepage


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

#include <math.h>On Fri, 2004-01-30 at 01:16, Mario de Sousa wrote:

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?


Mando

#include <math.h>

Link with “-lm” (gcc)

Not really an SDL question, tho :slight_smile:

-bill!On Fri, Jan 30, 2004 at 09:16:42AM +0200, Mario de Sousa wrote:

Hey, guys.

Which header do you include to get sin, cos and tan functions in C?

Hi,

I’m developing a game and i’m wondering how to do some effects that i’ve
seen in some games. I’m asking if it possible to do in SDL or i have to do
it in openGL.

The first effect is a fade to black. I have an scene with animations (some
stars
tiling, some leaves moving, etc) and i want to dark this scene leaving a
circle
in the middle of the screen with normal ligth to show an animation.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or some
kind of light generation. When the light is painted i want to get some part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

And finally, Is it possible to dump a smpeg video to a sdl surface ? I want
to
load a smpeg in memory instead of converting it to a list of sdl surfaces,
to save
memory, and when the video is needed i want to dump it directly to the sdl
screen
surface.

Any comment is welcome !
Thanks
Jorge

I’m developing a game and i’m wondering how to do some effects that i’ve
seen in some games. I’m asking if it possible to do in SDL or i have to do
it in openGL.

It depends, 2D games can be done in both “plain” SDL and in Open GL. For 3D
games I recommend OpenGL, if you use SDL only here you will have to build
(or have) a software rasterizer.

The first effect is a fade to black. I have an scene with animations (some
stars
tiling, some leaves moving, etc) and i want to dark this scene leaving a
circle
in the middle of the screen with normal ligth to show an animation.

Well, put a big black surface over the entire screen and use alpha to fade
it up from totaly transparent to totaly non-transparent. Similar approach
works from OpenGL

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

This depend on how good you want it to look and the viewing-angle of the
game. The most simple thing is to have a yellow circle/elipse that you
alphablend to get it ransparent and blit onto the surface that should recive
the light.

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl surfaces,
to save
memory, and when the video is needed i want to dump it directly to the sdl
screen
surface.

Not sure about this one. Well, let me say. Ofcourse it is possible. I just
mean that I don’t know if such a lib already exist or if you would have to
write your own. Most likley something like that exist though since ALOT of
people make ALOT of stuff all the time ;)… Start by checking the SDL/libs
page on libsdl.org. I think there are some kind of “movie” player there and
a lib that can, at least, play mpg or something. If you find something like
that you could alwaysconvert your source movie to that format.

Good luck…

Best regards
Daniel Liljeberg> ----- Original Message -----

From: jorgefm@cirsa.com (Jorge Fernandez Monteagudo)
To:
Sent: Friday, January 30, 2004 10:15 AM
Subject: [SDL] Graphic Effects

Hi,

I’m developing a game and i’m wondering how to do some effects that i’ve
seen in some games. I’m asking if it possible to do in SDL or i have to do
it in openGL.

The first effect is a fade to black. I have an scene with animations (some
stars
tiling, some leaves moving, etc) and i want to dark this scene leaving a
circle
in the middle of the screen with normal ligth to show an animation.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl surfaces,
to save
memory, and when the video is needed i want to dump it directly to the sdl
screen
surface.

Any comment is welcome !
Thanks
Jorge


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Once again I read you mail to fast. :slight_smile:
To get the circle in the middle where you wanted to play the anim you will
have to use alphamask on the black image you use to fade with. If you mean
that you should see through and see the game in that circle. Otherwise, if
you just mean that it should be a light circle then you can do as I said
first and blit a light circle on top…

Best regards
Daniel Liljeberg> ----- Original Message -----

From: @Daniel_Liljeberg (Daniel Liljeberg)
To:
Sent: Friday, January 30, 2004 10:49 AM
Subject: Re: [SDL] Graphic Effects

I’m developing a game and i’m wondering how to do some effects that i’ve
seen in some games. I’m asking if it possible to do in SDL or i have to
do

it in openGL.

It depends, 2D games can be done in both “plain” SDL and in Open GL. For
3D
games I recommend OpenGL, if you use SDL only here you will have to build
(or have) a software rasterizer.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving a
circle
in the middle of the screen with normal ligth to show an animation.

Well, put a big black surface over the entire screen and use alpha to fade
it up from totaly transparent to totaly non-transparent. Similar approach
works from OpenGL

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

This depend on how good you want it to look and the viewing-angle of the
game. The most simple thing is to have a yellow circle/elipse that you
alphablend to get it ransparent and blit onto the surface that should
recive
the light.

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Not sure about this one. Well, let me say. Ofcourse it is possible. I just
mean that I don’t know if such a lib already exist or if you would have to
write your own. Most likley something like that exist though since ALOT of
people make ALOT of stuff all the time ;)… Start by checking the
SDL/libs
page on libsdl.org. I think there are some kind of “movie” player there
and
a lib that can, at least, play mpg or something. If you find something
like
that you could alwaysconvert your source movie to that format.

Good luck…

Best regards
Daniel Liljeberg

----- Original Message -----
From:
To:
Sent: Friday, January 30, 2004 10:15 AM
Subject: [SDL] Graphic Effects

Hi,

I’m developing a game and i’m wondering how to do some effects that i’ve
seen in some games. I’m asking if it possible to do in SDL or i have to
do

it in openGL.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving a
circle
in the middle of the screen with normal ligth to show an animation.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Any comment is welcome !
Thanks
Jorge


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

Thanks Daniel for your tips !

Yes, i want to have a circle in the middle. You can image this scene like
a focus over the background and i have to put an animation in this focus
and the rest of the scene is faded. What it is an alphamask and how can
i get one in SDL ? Two overlapped surfaces ? I have only see the
SDL_SetAlpha method.

Thanks again,
Jorge

                  "DAMiEN"                                                                                                      
                  <damien_ at hotmail.co      Para:     <sdl at libsdl.org>                                                           
                  m>                       cc:                                                                                  
                  Enviado por:             Asunto:   Re: [SDL] Graphic Effects                                                  
                  sdl-admin at libsdl.or                                                                                           
                  g                                                                                                             
                                                                                                                                
                                                                                                                                
                  30/01/2004 10.59                                                                                              
                  Por favor, responda                                                                                           
                  a sdl                                                                                                         

Once again I read you mail to fast. :slight_smile:
To get the circle in the middle where you wanted to play the anim you will
have to use alphamask on the black image you use to fade with. If you mean
that you should see through and see the game in that circle. Otherwise, if
you just mean that it should be a light circle then you can do as I said
first and blit a light circle on top…

Best regards
Daniel Liljeberg> ----- Original Message -----

From: damien_@hotmail.com (Daniel Liljeberg)
To:
Sent: Friday, January 30, 2004 10:49 AM
Subject: Re: [SDL] Graphic Effects

I’m developing a game and i’m wondering how to do some effects that
i’ve

seen in some games. I’m asking if it possible to do in SDL or i have to
do

it in openGL.

It depends, 2D games can be done in both “plain” SDL and in Open GL. For
3D
games I recommend OpenGL, if you use SDL only here you will have to build
(or have) a software rasterizer.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving
a

circle
in the middle of the screen with normal ligth to show an animation.

Well, put a big black surface over the entire screen and use alpha to
fade
it up from totaly transparent to totaly non-transparent. Similar approach
works from OpenGL

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

This depend on how good you want it to look and the viewing-angle of the
game. The most simple thing is to have a yellow circle/elipse that you
alphablend to get it ransparent and blit onto the surface that should
recive
the light.

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Not sure about this one. Well, let me say. Ofcourse it is possible. I
just
mean that I don’t know if such a lib already exist or if you would have
to
write your own. Most likley something like that exist though since ALOT
of
people make ALOT of stuff all the time ;)… Start by checking the
SDL/libs
page on libsdl.org. I think there are some kind of “movie” player there
and
a lib that can, at least, play mpg or something. If you find something
like
that you could alwaysconvert your source movie to that format.

Good luck…

Best regards
Daniel Liljeberg

----- Original Message -----
From: <@Jorge_Fernandez_Mont>
To:
Sent: Friday, January 30, 2004 10:15 AM
Subject: [SDL] Graphic Effects

Hi,

I’m developing a game and i’m wondering how to do some effects that
i’ve

seen in some games. I’m asking if it possible to do in SDL or i have to
do

it in openGL.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving
a

circle
in the middle of the screen with normal ligth to show an animation.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Any comment is welcome !
Thanks
Jorge


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


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

[…]

The first effect is a fade to black. I have an scene with
animations (some stars
tiling, some leaves moving, etc) and i want to dark this scene
leaving a circle
in the middle of the screen with normal ligth to show an animation.

There are many ways you could do that in SDL without OpenGL, but
they’ll all rely on s/w rendering on nearly all targets. A few ideas:

1. Use only opaque and colorkeyed surfaces for your
   animations. That way, you can modulate their alpha,
   which means you can fade them in and out, provided
   you're rendering the scene on top of a black
   background. (SDL_FillRect() to clear an area before
   blitting to it.)

2. Do it the other way around; render the scene as
   usual, and then blit a black surface over it,
   modulating the full surface alpha for the fade
   effect. You'll have to render an area from
   scratch (first the graphics, then the fade) to
   change the fade level.

3. The iterative approach: Blend a black surface
   with a fixed alpha over the screen repeatedly,
   to fade out. Doesn't mix with animations, though!

Note that unless you actually get h/w accelerated alpha blits (only
glSDL and DirectFB provide that, AFAIK), DO NOT blit the alpha
blended surfaces directly to a h/w display surface. It’s insanely
slow on both PCI and AGP video cards, so never do that unless you
know for a fact that your game will only run on some exotic hardware
that doesn’t have this problem.

As to the circle in the middle, you can do that using colorkeying of
the black “fade surface” for methods 2 and 3, but then you’ll get
aliasing around the edges of the circles. (Full surface alpha and
alpha channels don’t mix.)

You could work around that by putting antialiasing pixels in separate
colorkeyed surfaces, and using for example 25, 50 and 75% of the
"fade alpha" for those.

Or you just hack your own software blitter, maybe generating the
circle on the fly instead of using a source surface, while you’re at
it. Keep in mind that for best performance, you’ll have to hack
multiple versions, unless you’re intending to support only one pixel
format.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp
or some kind of light generation. When the light is painted i want
to get some part of
the scene painted with the yellow component increised.

Custom blitter. SDL supports alpha blending and colorkeying, but not
additive blending, which would be the right tool for this.

Note that additive blending is a bit of a PITA to get fast, since even
if the operation is very simple in theory, the saturation
conditionals can totally kill performance. (Long pipelines and
inpredictabe branches don’t mix…) However, in a “controlled
environment” such as a single game, you could get away without
saturation. Just make sure the graphics and the light surfaces are
sufficiently dark that the blending won’t overflow.

BTW, if you’re thinking “look-up table!” - well, maybe if you use a
512 byte table for saturating the sum of two 8 bit values at 255, but
I’m not even sure about that. And if the table doesn’t fit in L1
cache, you’re probably better off just using conditionals.

Either way, if it really matters, benchmark! Always… Don’t optimize
unless you need to, and when you need to, make sure you know what
actually burns your cycles before you start hacking.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?

Alpha blending would just look like yellow fog, I think, though you
might get away with it if the background graphics has the right
colors, and you don’t bend too much yellow in… Dunno. Could be
worth a try.

Anybody can point some open source game or demo with some example
of this ?

Example of applying light? Can’t think of one, but it’s actually
pretty easy to implement. (Well, we are talking about messing with
pixels directly, but everything is relative. :wink:

I don’t have much time to spare (already hacking a small game that
demonstrates various stuff, including fixed logic frame rates with
interpolation), but I’ll see if I have some code lying around that I
could subvert into a simple blending example…

And finally, Is it possible to dump a smpeg video to a sdl surface
? I want to
load a smpeg in memory instead of converting it to a list of sdl
surfaces, to save
memory, and when the video is needed i want to dump it directly to
the sdl screen
surface.

Don’t know if there’s a lib that will do this directly, but it’s a
rather sensible thing to do, so I’d be surprised if you can’t at
least extract raw frames one by one, or maybe a few at a time.
Provided the pixel format is somewhat sensible, you should be able to
use SDL’s blitters to get the data to the screen. You should probably
look into SDL YUV overlays and stuff as well, but I can’t really help
much in that area.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 30 January 2004 10.15, jorgefm at cirsa.com wrote:

An alpha mask is a channel like R G B that hold information about what
pixels of the image that are transparent and wich are not. Don’t remeber
exactly in my head if anything special has to be enabled to use alpha masks
in SDL. But I think that you just create you image using an alphamask (not
all image formats support this) and then you can use the alpha functions in
SDL as normal. But to be sure, try to seek out an SDL alphablending tutorial
or semthing of the sort…

Best regards
Daniel Liljeberg> ----- Original Message -----

From: jorgefm@cirsa.com (Jorge Fernandez Monteagudo)
To:
Sent: Friday, January 30, 2004 11:25 AM
Subject: Re: [SDL] Graphic Effects

Thanks Daniel for your tips !

Yes, i want to have a circle in the middle. You can image this scene like
a focus over the background and i have to put an animation in this focus
and the rest of the scene is faded. What it is an alphamask and how can
i get one in SDL ? Two overlapped surfaces ? I have only see the
SDL_SetAlpha method.

Thanks again,
Jorge

                  "DAMiEN"
                  <damien_ at hotmail.co      Para:     <sdl at libsdl.org>
                  m>                       cc:
                  Enviado por:             Asunto:   Re: [SDL] Graphic

Effects

                  sdl-admin at libsdl.or
                  g


                  30/01/2004 10.59
                  Por favor, responda
                  a sdl

Once again I read you mail to fast. :slight_smile:
To get the circle in the middle where you wanted to play the anim you will
have to use alphamask on the black image you use to fade with. If you mean
that you should see through and see the game in that circle. Otherwise, if
you just mean that it should be a light circle then you can do as I said
first and blit a light circle on top…

Best regards
Daniel Liljeberg

----- Original Message -----
From: “DAMiEN” <@Daniel_Liljeberg>
To:
Sent: Friday, January 30, 2004 10:49 AM
Subject: Re: [SDL] Graphic Effects

I’m developing a game and i’m wondering how to do some effects that
i’ve

seen in some games. I’m asking if it possible to do in SDL or i have
to
do

it in openGL.

It depends, 2D games can be done in both “plain” SDL and in Open GL. For
3D
games I recommend OpenGL, if you use SDL only here you will have to
build

(or have) a software rasterizer.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving
a

circle
in the middle of the screen with normal ligth to show an animation.

Well, put a big black surface over the entire screen and use alpha to
fade
it up from totaly transparent to totaly non-transparent. Similar
approach

works from OpenGL

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

This depend on how good you want it to look and the viewing-angle of the
game. The most simple thing is to have a yellow circle/elipse that you
alphablend to get it ransparent and blit onto the surface that should
recive
the light.

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Not sure about this one. Well, let me say. Ofcourse it is possible. I
just
mean that I don’t know if such a lib already exist or if you would have
to
write your own. Most likley something like that exist though since ALOT
of
people make ALOT of stuff all the time ;)… Start by checking the
SDL/libs
page on libsdl.org. I think there are some kind of “movie” player there
and
a lib that can, at least, play mpg or something. If you find something
like
that you could alwaysconvert your source movie to that format.

Good luck…

Best regards
Daniel Liljeberg

----- Original Message -----
From:
To:
Sent: Friday, January 30, 2004 10:15 AM
Subject: [SDL] Graphic Effects

Hi,

I’m developing a game and i’m wondering how to do some effects that
i’ve

seen in some games. I’m asking if it possible to do in SDL or i have
to
do

it in openGL.

The first effect is a fade to black. I have an scene with animations
(some

stars
tiling, some leaves moving, etc) and i want to dark this scene leaving
a

circle
in the middle of the screen with normal ligth to show an animation.

In the second effect i want to have an scene then i want to put an
animation
over the previous one. This animation is a man with a lantern, lamp or
some
kind of light generation. When the light is painted i want to get some
part
of
the scene painted with the yellow component increised.

I think that this kind of effect can be done playing with the alpha
channel, isn’t it?
Anybody can point some open source game or demo with some example of
this ?

And finally, Is it possible to dump a smpeg video to a sdl surface ? I
want
to
load a smpeg in memory instead of converting it to a list of sdl
surfaces,

to save
memory, and when the video is needed i want to dump it directly to the
sdl

screen
surface.

Any comment is welcome !
Thanks
Jorge


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


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

It’s usually called the alpha or A channel (which is why the pixel
format is called RGBA), and it’s enabled using SDL_SetAlpha(), which
is also used to set the full surface alpha value. The former is just
like the alpha channel in an RGBA OpenGL texture, and the latter
corresponds to vertex color/alpha modulation.

That’s where the problem is, though, if you want both the circle and
fading at once: You can’t use both the A channel and the full
surface alpha in SDL - so you can’t modulate the alpha of an RGBA
surface.

However, there is colorkeying as well. Sort of like having a 1 bit
alpha channel, where 1 means 100% opaque. That works together with
the full surface alpha, so at least, you have a non-faded circle
without antialiasing.

Getting AA + blending should be doable the way I described in my last
mail, but it’s a bit messy. Fortunately, the RLE acceleration
eliminates everything but the visible pixels, so slicing an RGBA
surface along the “alpha axis”, into a bunch of RGB + colorkey
surfaces, shouldn’t cost much more than blitting the RGBA surface -
and it allows you to modulate the alpha.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 30 January 2004 11.42, DAMiEN wrote:

An alpha mask is a channel like R G B that hold information about
what pixels of the image that are transparent and wich are not.
Don’t remeber exactly in my head if anything special has to be
enabled to use alpha masks in SDL. But I think that you just create
you image using an alphamask (not all image formats support this)
and then you can use the alpha functions in SDL as normal. But to
be sure, try to seek out an SDL alphablending tutorial or semthing
of the sort…

Hi to all, i beg your pardon for the OT,
i’m developing a basic interpreter in C++ with the aim to be compatible with old AMOS Professional for amiga with a SDL class for graphics stuff. Is in under development but you can download the first beta version only for linux at this link:

Regards,
Muzero