Code: Select all
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
Thx.
Code: Select all
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
Code: Select all
class->loadMedia("Name of Media");
Code: Select all
#define LVIDEO_MAX_SURFACES 100
class LVideoManager
{
public:
void loadImage(const char *, const char *); // Load an image (name, filename)
SDL_Surface * getImage(const char *); // Get an image by name
SDL_Surface * getImage(int); // Get an image by ID
void drawImage(const char *, int, int, int); // Draw an image, x, y, alpha
private:
SDL_Surface * LVideoSurfaceIndex[LVIDEO_MAX_SURFACES]; // Where surfaces are stored
const char * LVideoSurfaceNames[LVIDEO_MAX_SURFACES]; // Names for our surfaces.
int LVideoSurfaceIndexer; // Surface indexer for ids.
};
// ---- IMPLEMENTATIONS ----
void LVideoManager::loadImage(const char * LTitle, const char * LFilename)
{
LVideoSurfaceIndex[LVideoSurfaceIndexer] = IMG_Load(LFilename);
if (!LVideoSurfaceIndex[LVideoSurfaceIndexer])
{
printf("%s could not be loaded from %s\n", LTitle, LFilename);
return;
}
LVideoSurfaceNames[LVideoSurfaceIndexer] = LTitle;
LVideoSurfaceIndexer++;
return;
}
SDL_Surface * LVideoManager::getImage(int LID)
{
return LVideoSurfaceIndex[LID];
}
SDL_Surface * LVideoManager::getImage(const char * LTitle)
{
for (int i = 0; i < LVIDEO_MAX_SURFACES; i++)
{
if (LVideoSurfaceNames[i] == LTitle)
{
return LVideoSurfaceIndex[i];
}
}
printf("The image titled %s was not found.", LTitle);
return 0;
}
void LVideoManager::drawImage(const char * LName, int LX, int LY, int LA = 255)
{
SDL_Rect LSurfaceDestination = { LX, LY, 0, 0 };
SDL_SetAlpha(getImage(LName), SDL_SRCALPHA, LA);
SDL_BlitSurface(getImage(LName), NULL, LVideoScreen, &LSurfaceDestination);
}