[SDL] aalineRGBA problem
Armin Steinhoff
A-Steinhoff at web.de
Tue Jun 13 03:44:09 PDT 2006
Tommi Kyntola <tommi.kyntola at ray.fi> schrieb am 13.06.2006 11:44:53:
>
>
> When the lines are not straight the antialiasing reduces the pixel
> colors just a tad away from white. And then your use of nonzero
> Amask in the SDL_CreateRGBSurface causes the SDL_gfx to go for
> alpha blending. And without alpha channel set in your image you
> get didley on the image.
Yes ... it is now working with the Amask set to zero :)
>
> I suggest you skip the alpha stuff unless you need it and use
> SDL_DisplayFormat to get an image suitable for blitting.
> You're using ABGR, which on little endian machines happens to be what
> the opengl wants (big endiand RGBA), but using that to blit
> on screen in 2D is probably not what you're looking for, because I'm
> betting you're display surface has something other than ABGR
> (could it be ARGB?).
Sorry ... I don't understand fully the concept behind these RGBA masks.
> It's been a while since I last played with SDL_gfx, so take all that
> with some salt, but your example would seem to work ok if you set the
> Amask to zero in the SDL_CreateRGBSurface call _or_ use SDL_setAlpha(image,0,255);
> to get something non-transparent on the surface.
Thank you for your help.
Best Regards
Armin
>
> However, I distinctly recall that there was fishy with SDL_gfx
> and the way it handled the alpha channeling. Or to be more precice,
> I never got it to work the way I was looking for, but it's quite
> likely I overlooked something as I was never really that
> keen on getting it to work.
>
> Maybe I'll check back with an example ...
>
> cheers,
> Tommi Kyntola
>
> Armin Steinhoff wrote:
> > Hello,
> >
> > I have a little bit trouble with the call 'aalineRGBA' from the SDL_Gfx library.
> > When I create a surface with a bpp of 32bit, 'aalineRGBA' draws only vertical and horizontal lines (ticks of a meter).
> > Only the start and end point of all other lines are drawn.
> >
> > On a surface with 8 bpp all lines are drawn, but the color is wrong.
> >
> > I have attached a short example. What's wrong in my code? ( I'm working under SuSE LINUX 9.0. )
> >
> > Thank you
> >
> > Armin
> >
> > ______________________________________________________________________
> > XXL-Speicher, PC-Virenschutz, Spartarife & mehr: Nur im WEB.DE Club!
> > Jetzt gratis testen! http://freemail.web.de/home/landingpad/?mc=021130
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > #include <stdlib.h>
> > #include <math.h>
> > #include "SDL.h"
> > #include "SDL_image.h"
> > #include "SDL_gfxPrimitives.h"
> >
> > void cpoint(float rad, short cx, short cy, short radius, short * px, short * py)
> > {
> > // cx, cy are the center point of the circle
> > // px, py are points of the circle
> > *px = cx + (short)((float)radius * cosf(rad));
> > *py = cy + (short)((float)radius * sinf(rad));
> > }
> >
> > int draw_tick(SDL_Surface * surf, float rad, short cx, short cy, short radius, short tick_len,
> > Uint8 r, Uint8 g, Uint8 b, Uint8 a )
> > {
> > short spx, spy, epx, epy;
> >
> > cpoint(rad, cx, cy, radius, &spx, &spy);
> > cpoint(rad, cx, cy, radius - tick_len, &epx, &epy);
> >
> > fprintf(stdout, "spx/spy %d,%d epx/epy: %d/%d\n", spx, spy, epx, epy);
> > return(aalineRGBA(surf, spx, spy, epx, epy, r, g, b, a));
> > }
> >
> > int main()
> > {
> >
> > SDL_Surface *display;
> > SDL_Surface *image;
> > int i, done, resp;
> > float rad;
> >
> > SDL_Rect drect;
> > SDL_Rect srect;
> > SDL_Event event;
> >
> > // init video stuff
> > if ( SDL_Init( SDL_INIT_VIDEO) < 0 )
> > {
> > fprintf(stderr, "SDL konnte nicht initialisiert werden: %s\n",
> > SDL_GetError());
> > exit(1);
> > }
> >
> > atexit(SDL_Quit);
> >
> > // init screen
> > display = SDL_SetVideoMode( 1024,768, 0, SDL_SWSURFACE);
> > if ( display == NULL )
> > {
> > fprintf(stderr, "SDL_SetVideoMode %s\n", SDL_GetError());
> > exit(1);
> > }
> >
> > image = SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 768, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
> > if ( image == NULL ) {
> > fprintf(stderr, "SDL_CreateRGBSurface: %s\n",SDL_GetError());
> > return(NULL);
> > }
> > //source rect
> > srect.x = 0;
> > srect.y = 0;
> > srect.w = (image->w);
> > srect.h = image->h;
> >
> > // destination rect
> > drect.x = 0;
> > drect.y = 0;
> > drect.w = (image->w);
> > drect.h = image->h;
> >
> > for (i=0; i < 360; i+=10)
> > {
> > rad = 6.28 * (float)i/360.0;
> >
> > resp = draw_tick(image, rad, 150, 150, 50, 10, 255, 255, 255, 255 );
> > fprintf(stdout, "resp: %d\n", resp);
> >
> > SDL_BlitSurface(image, &srect, display, &drect);
> >
> > SDL_UpdateRects(display,1,&drect);
> > }
> >
> > SDL_Delay(6000);
> >
> > SDL_FreeSurface(image);
> > }
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000071
More information about the SDL
mailing list