Advertisement

[Sdl] sdl opengl alph problem

Started by August 26, 2011 05:47 PM
-1 comments, last by AlexanderBladh 13 years, 3 months ago
ok so this problem might be hard to picture but anyway what im trying to do is bliting a blended text onto a sdl_surface and then convert it the surface to a oglsurface.

the problem is when i render the fixed ogltexture it still looks like a solid rendered text.

uploadou.png


so hers my code:
surfaceFixed = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, surface->w, surface->h, 32
, R_Mask, G_Mask, B_Mask, A_Mask);


saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
saved_alpha = surface->format->alpha;
if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
{
SDL_SetAlpha(surface, 0, 0);
}

SDL_BlitSurface(surface, NULL, surfaceFixed, NULL);

if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
{
SDL_SetAlpha(surfaceFixed, saved_flags, saved_alpha);
}

text = TTF_RenderText_Blended(ButtonsFont, buttonText, textColor);


rect.x = (w / 2) - (text->w / 2);
rect.y = (h / 2 + 1) - (text->h / 2);

SDL_BlitSurface(text, 0, surfaceFixed, &rect);


glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glGenTextures( 1, &OGL_Texture );

glBindTexture( GL_TEXTURE_2D, OGL_Texture );

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glTexImage2D( GL_TEXTURE_2D, 0, numberOfColors, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surfaceFixed->pixels );

This topic is closed to new replies.

Advertisement