Skip to content
Snippets Groups Projects
Commit 23968592 authored by slevy's avatar slevy
Browse files

Oops, make sure image values are treated as *unsigned*, for TXF_INTENSITY.

parent 44416af3
No related branches found
No related tags found
No related merge requests found
...@@ -118,16 +118,18 @@ int txbind( Texture *tx, int *enabled ) ...@@ -118,16 +118,18 @@ int txbind( Texture *tx, int *enabled )
if(wanted) { if(wanted) {
static float black[4] = {0,0,0,0}; static float black[4] = {0,0,0,0};
char *txdata = tx->data; unsigned char *txdata = (unsigned char *)tx->data;
int channels = tx->channels; int channels = tx->channels;
if((tx->flags&TXF_INTENSITY) && (channels == 1 || channels == 3)) { if((tx->flags&TXF_INTENSITY) && (channels == 1 || channels == 3)) {
int npix = tx->xsize * tx->ysize; int npix = tx->xsize * tx->ysize;
int k; int k;
char *ip, *op; unsigned char *ip, *op;
channels++; channels++;
txdata = (char *)malloc( npix * channels ); txdata = (unsigned char *)malloc( npix * channels );
k = npix, ip = tx->data, op = txdata; k = npix;
ip = (unsigned char *)tx->data;
op = txdata;
switch(channels) { switch(channels) {
case 2: case 2:
do { do {
...@@ -156,7 +158,7 @@ int txbind( Texture *tx, int *enabled ) ...@@ -156,7 +158,7 @@ int txbind( Texture *tx, int *enabled )
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
txdata); txdata);
if(txdata != tx->data) if(txdata != (unsigned char *)tx->data)
free(txdata); free(txdata);
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment