extern int netdatanew;
extern float mapinfo;
extern bool stillloading;
-extern ImageRec texture;
extern short vRefNum;
extern long dirID;
extern int mainmenu;
}
OPENAL_Close();
- if (texture.data) {
- free(texture.data);
- }
- texture.data = 0;
#endif
}
texdetail = 1;
//Load Image
- upload_image(ConvertFileName(fileName));
+ ImageRec texture;
+ load_image(ConvertFileName(fileName), texture);
texdetail = temptexdetail;
int bytesPerPixel = texture.bpp / 8;
stillloading = 1;
- texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
-
int temptexdetail = texdetail;
texdetail = 1;
text->LoadFontTexture(":Data:Textures:Font.png");
extern int maptype;
extern int editoractive;
extern int editorpathtype;
-extern ImageRec texture;
extern float hostiletime;
{
LOGFUNC;
//Load Image
- bool opened = upload_image(fileName);
+ ImageRec texture;
+ bool opened = load_image(fileName, texture);
float alphanum;
//Is it valid?
bool midweird = false;
bool proportionweird = false;
bool vertexweird[6] = {0};
-ImageRec texture;
bool debugmode = false;
#include "Game.h"
#include "ImageIO.h"
-extern ImageRec texture;
extern bool visibleloading;
/* These two are needed for screenshot */
static bool load_jpg(const char * fname, ImageRec & tex);
static bool save_screenshot_png(const char * fname);
-bool upload_image(const char* fileName)
+ImageRec::ImageRec()
{
- return load_image(fileName, texture);
+ data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
+}
+
+ImageRec::~ImageRec()
+{
+ free(data);
+ data = NULL;
}
bool load_image(const char *file_name, ImageRec &tex)
#endif
/**> DATA STRUCTURES <**/
-typedef struct ImageRec {
+class ImageRec {
+public:
GLubyte *data; // Image Data (Up To 32 Bits)
GLuint bpp; // Image Color Depth In Bits Per Pixel.
GLuint sizeX;
GLuint sizeY;
-} ImageRec;
+ ImageRec();
+ ~ImageRec();
+private:
+ /* Make sure this class cannot be copied to avoid memory problems */
+ ImageRec(ImageRec const &);
+ ImageRec& operator=(ImageRec const &);
+};
-bool upload_image(const char* filePath);
bool load_image(const char * fname, ImageRec & tex);
bool save_screenshot(const char * fname);
extern float blurness;
extern float targetblurness;
extern Objects objects;
-extern ImageRec texture;
extern bool visibleloading;
extern bool skyboxtexture;
extern int tutoriallevel;
float temptexdetail = texdetail;
+ ImageRec texture;
+
//Load Image
- upload_image(ConvertFileName(fileName));
+ load_image(ConvertFileName(fileName), texture);
//Is it valid?
if (texture.bpp > 24) {
using namespace std;
-extern ImageRec texture;
extern bool trilinear;
vector<TextureRes*> TextureRes::list;
void TextureRes::load()
{
- //load image into 'texture' global var
- upload_image(ConvertFileName(filename.c_str()));
+ ImageRec texture;
+
+ //load image into 'texture'
+ load_image(ConvertFileName(filename.c_str()), texture);
skinsize = texture.sizeX;
GLuint type = GL_RGBA;