Problem z przezroczystością SDL_ttf

0

Witam wszystkich!
Otoz chcialbym wyswietlac tekst w swoim projekcie za pomoca biblioteki SDL_ttf. Problem polega na tym, ze tekst wyswietla sie na czarnym tle albo w ogole sie nie wyswietla. Gdy uzyje:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.1);

tekst sie w ogole nie wyswietla, zas sprity wyswietlaja sie z tlem przezroczystym... a bez powyzszych 2 linijek tekst i sprity wyswietlaja sie na czarnym tle. Oto kod wyswietlania tekstu:

void ClassProgram::LoadFont(std::string font_name, int font_size, std::string text, int pos_x, int pos_y,
                            Uint8 r, Uint8 g, Uint8 b){

    if(TTF_Init() == -1) exit(0);
    SDL_Surface *message = NULL;
    SDL_Surface *background = NULL;
TTF_Font *font = NULL;
GLuint texture;
    SDL_Color fontcolor = {r, g, b};

font = TTF_OpenFont(font_name.c_str(), font_size);
message = TTF_RenderText_Blended(font, text.c_str(), fontcolor);

int w = 256;
int h = 64;

background = SDL_CreateRGBSurface(0, w, h, 32,
			0x00ff0000, 0x0000ff00, 0x000000ff, 0);
SDL_BlitSurface(message, 0, background, 0);

glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	glTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA,
			GL_UNSIGNED_BYTE, background->pixels );

	/* GL_NEAREST looks horrible, if scaled... */
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

	/* prepare to render our texture */
	glBindTexture(GL_TEXTURE_2D, texture);
	glColor3f(1, 1, 1);

	/* Draw a quad at location */
	glBegin(GL_QUADS);
		/* Recall that the origin is in the lower-left corner
		   That is why the TexCoords specify different corners
		   than the Vertex coors seem to. */
		glTexCoord2f(0.0f, 1.0f);
			glVertex2f(pos_x    , pos_y);
		glTexCoord2f(1.0f, 1.0f);
			glVertex2f(pos_x + w, pos_y);
		glTexCoord2f(1.0f, 0.0f);
			glVertex2f(pos_x + w, pos_y + h);
		glTexCoord2f(0.0f, 0.0f);
			glVertex2f(pos_x    , pos_y + h);
	glEnd();

	/* Bad things happen if we delete the texture before it finishes */
	glFinish();

SDL_FreeSurface(message);
SDL_FreeSurface(background);
TTF_CloseFont(font);
TTF_Quit();
}

Ma ktos jakis pomysl jak sporzadzic przezroczystosc tla dla tekstu w sdl_ttf?

0

A zapomnialem dodac ze projekt uzywa Opengl i SDL

1 użytkowników online, w tym zalogowanych: 0, gości: 1