SGTexture::~SGTexture()
{
- if ( texture_data ) {
- delete texture_data;
- }
+ delete texture_data;
if ( texture_id != 0 ) {
free_id();
SGTexture::ImageRec *image;
int y;
- if (texture_data)
- delete texture_data;
+ delete[] texture_data;
image = ImageOpen(name);
if(!image) {
SGTexture::ImageRec *image;
int y;
- if (texture_data)
- delete texture_data;
+ delete[] texture_data;
image = ImageOpen(name);
if(!image) {
bbuf = new GLubyte[ image->xsize ];
abuf = new GLubyte[ image->xsize ];
if(!texture_data || !rbuf || !gbuf || !bbuf || !abuf) {
- delete texture_data;
- delete rbuf;
- delete gbuf;
- delete bbuf;
- delete abuf;
+ delete[] texture_data;
+ delete[] rbuf;
+ delete[] gbuf;
+ delete[] bbuf;
+ delete[] abuf;
errstr = OUT_OF_MEMORY;
return;
}
}
ImageClose(image);
- delete rbuf;
- delete gbuf;
- delete bbuf;
- delete abuf;
+ delete[] rbuf;
+ delete[] gbuf;
+ delete[] bbuf;
+ delete[] abuf;
}
SGTexture::ImageRec *image;
int y;
- if (texture_data)
- delete texture_data;
+ delete[] texture_data;
image = ImageOpen(name);
if(!image) {
bbuf = new GLubyte[ image->xsize ];
abuf = new GLubyte[ image->xsize ];
if(!texture_data || !rbuf || !gbuf || !bbuf || !abuf) {
- delete texture_data;
- delete rbuf;
- delete gbuf;
- delete bbuf;
- delete abuf;
+ delete[] texture_data;
+ delete[] rbuf;
+ delete[] gbuf;
+ delete[] bbuf;
+ delete[] abuf;
errstr = OUT_OF_MEMORY;
return;
}
}
ImageClose(image);
- delete rbuf;
- delete gbuf;
- delete bbuf;
- delete abuf;
+ delete[] rbuf;
+ delete[] gbuf;
+ delete[] bbuf;
+ delete[] abuf;
}
void
SGTexture::ImageRec *image;
int y;
- if (texture_data)
- delete texture_data;
+ delete[] texture_data;
image = RawImageOpen(name);
SGTexture::ImageRec *image;
int xy;
- if (texture_data)
- delete texture_data;
+ delete[] texture_data;
//it wouldn't make sense to write a new function ...
image = RawImageOpen(name);
SGTexture::ImageClose(SGTexture::ImageRec *image) {
if (image->file) gzclose(image->file);
if (file) fclose(file);
- delete image->tmp;
+ delete[] image->tmp;
delete image;
}
//just allocate a pseudo value as I'm too lazy to change ImageClose()...
- image->tmp = new GLubyte;
+ image->tmp = new GLubyte[1];
if (image->tmp == 0) {
errstr = OUT_OF_MEMORY;
return;
int colors = (num_colors == 3) ? 1 : 2;
- GLubyte *map = (GLubyte *)malloc (texture_width * texture_height * colors);
+ GLubyte *map = new GLubyte[ texture_width * texture_height * colors ];
for (int y=0; y<texture_height; y++)
for (int x=0; x<texture_width; x++)
map[pos+1] = rgb[3];
}
- free (texture_data);
+ delete[] texture_data;
texture_data = map;
num_colors = colors;
}
SGTexture::make_maxcolorwindow() {
GLubyte minmaxc[2] = {255, 0};
- unsigned int pos = 0;
- unsigned int max = num_colors;
+ int pos = 0;
+ int max = num_colors;
if (num_colors == 2) max = 1;
if (num_colors == 4) max = 3;
while (pos < texture_width * texture_height * num_colors) {
int colors = (num_colors == 1) ? 3 : 4;
bool alpha = (colors > 3);
int tsize = texture_width * texture_height * colors;
- GLubyte *map = (GLubyte *)malloc (tsize);
+ GLubyte *map = new GLubyte[ tsize ];
int mpos = 0, dpos = 0;
for (int y=0; y<texture_height; y++) {
}
}
- free (texture_data);
+ delete[] texture_data;
texture_data = map;
num_colors = colors;
}
make_grayscale(contrast);
int colors = (num_colors == 1) ? 1 : 2;
- GLubyte *map = (GLubyte *)malloc (texture_width * texture_height * colors);
+ GLubyte *map = new GLubyte[ texture_width * texture_height * colors ];
for (int y=0; y<texture_height; y++)
for (int x=0; x<texture_width; x++)
map[mpos+1] = texture_data[dpos+1];
}
- free (texture_data);
+ delete[] texture_data;
texture_data = map;
num_colors = colors;
}