At 19.59 20/08/01 +0200, you wrote:
something is not right – not only is the Logo format the same as the
screen, it also has an alpha channel despite being loaded from a BMP
file. What have you done with the surface more than LoadBMP() and
SetColorKey() ?
LoadBMP() never creates an alpha channel, and SetColorKey() should
not affect the image format either. Please check your code again
(and print the surface flags for each of the involved surfaces)
I know. I do ABSOLUTELY NOTHING to the surfaces other than
loading/creating and blitting. The code is the one I attached 2 mails
ago (when i started the thread). Anyway, look at this snippet:
if(SDL_Init(SDL_INIT_VIDEO)<0)
{
fprintf(stderr, "Can't init SDL: %s\n", SDL_GetError() );
exit(1);
}
atexit(SDL_Quit);
if(!(Tmp = SDL_LoadBMP("logo.bmp")))
{
fprintf( stderr, "Can't load logo: %s\n", SDL_GetError() );
exit(1);
}
SDL_SetColorKey(Tmp, SDL_SRCCOLORKEY|SDL_RLEACCEL,
SDL_MapRGB(Tmp->format, 0, 0, 0) );
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if(!(Screen = SDL_SetVideoMode(640, 480, 16,
SDL_HWSURFACE|SDL_OPENGLBLIT)))
{
fprintf(stderr, "Can't open video: %s\n", SDL_GetError() );
exit(1);
}
#ifdef USE_DISPLAYFORMAT
Logo = SDL_DisplayFormat(Tmp);
SDL_FreeSurface(Tmp);
#else
Logo = Tmp;
#endif
I do not create any alpha channel and the logo is in .bmp format.
My drawing function:
void Draw(void)
{
SDL_Rect src;
static int x = 0, y = 0;
static int Ox = 2, Oy = 2;
static bool BlitFlag = false;
assert(Screen);
/* 3D drawing */
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.38f, -6.0f);
glBegin(GL_TRIANGLES);
glColor3f (1.f, 1.f, 0.f);
glVertex3f( 0.0f, 2.0f, 0.0f);
glColor3f (0.f, 1.f, 1.f);
glVertex3f(-2.0f,-2.0f, 2.0f);
glColor3f (1.f, 0.f, 1.f);
glVertex3f( 2.0f,-2.0f, 2.0f);
glEnd();
glFlush();
/* 2d drawing */
src.x = x+=Ox;
src.y = y+=Oy;
src.w = Logo->w;
src.h = Logo->h;
if(!BlitFlag)
{
fprintf( Log, "Screen[%ld]:\n", Screen );
PrintFormat(Screen->format);
fprintf( Log, "Logo[%ld]:\n", Logo );
PrintFormat(Logo->format);
BlitFlag = true;
}
SDL_BlitSurface(Logo, NULL, Screen, &src);
SDL_UpdateRects(Screen, 1, &src);
if(x<0 || x>640-Logo->w)
{
Ox = -Ox;
}
if(y<0 || y>480-Logo->h)
{
Oy = -Oy;
}
return;
}
I do nothing more than this.
Thanks,__
Fabio " ‘- nowDruid " Franchello
—’---------
— snowdruid at tiscalinet.it —