示例#1
0
GLuint	loadTextureFromFile(const string&	filename)
{
	SDL_Surface	*imageSurface = IMG_Load(filename.c_str());
	if (!imageSurface){

		cout << "Can't Load	image " << filename << " " << IMG_GetError();
		return	0;
	}
	GLuint textureID = convertSDLSurfaceToTexture(imageSurface);
	SDL_FreeSurface(imageSurface);

	return textureID;
}
示例#2
0
GLuint	loadTextureFromFont(const string& fontFilename, int	pointSize, const string& text)
{
    TTF_Font	*	font = TTF_OpenFont(fontFilename.c_str(), pointSize);
    if (!font)
    {
        cout << "Unable	to load font	" << fontFilename << "	" << TTF_GetError();
        return	0;
    }
    SDL_Surface	*textSurface = TTF_RenderText_Blended(font, text.c_str(), { 255, 255, 255 });

    GLuint textureID = convertSDLSurfaceToTexture(textSurface);
    SDL_FreeSurface(textSurface);

    TTF_CloseFont(font);

    return textureID;
}