diff options
Diffstat (limited to 'progs/redbook')
-rw-r--r-- | progs/redbook/combiner.c | 2 | ||||
-rw-r--r-- | progs/redbook/convolution.c | 11 | ||||
-rw-r--r-- | progs/redbook/histogram.c | 11 | ||||
-rw-r--r-- | progs/redbook/minmax.c | 12 |
4 files changed, 26 insertions, 10 deletions
diff --git a/progs/redbook/combiner.c b/progs/redbook/combiner.c index 92e4de484ad..7682e0c0324 100644 --- a/progs/redbook/combiner.c +++ b/progs/redbook/combiner.c @@ -249,7 +249,7 @@ static void display(void) glCallList(1); glPopMatrix(); - constColor[4] = 0.8; + constColor[3] = 0.8; glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor); glPushMatrix(); glTranslatef(4.0, 3.0, 0.0); diff --git a/progs/redbook/convolution.c b/progs/redbook/convolution.c index 0543379f241..c04a8727a71 100644 --- a/progs/redbook/convolution.c +++ b/progs/redbook/convolution.c @@ -75,6 +75,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) { int n; GLubyte* pixels; + size_t num_read; FILE* infile = fopen( filename, "rb" ); @@ -83,8 +84,10 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) exit(1); } - fread( width, sizeof( GLsizei ), 1, infile ); - fread( height, sizeof( GLsizei ), 1, infile ); + num_read = fread( width, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); + num_read = fread( height, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); *width = bswap(*width); *height = bswap(*height); @@ -97,10 +100,12 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); if ( !pixels ) { fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); + fclose( infile ); return NULL; } - fread( pixels, sizeof( GLubyte ), n, infile ); + num_read = fread( pixels, sizeof( GLubyte ), n, infile ); + assert(num_read == n); fclose( infile ); diff --git a/progs/redbook/histogram.c b/progs/redbook/histogram.c index de1e59edea6..12b0e315ca1 100644 --- a/progs/redbook/histogram.c +++ b/progs/redbook/histogram.c @@ -83,6 +83,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) { int n; GLubyte* pixels; + size_t num_read; FILE* infile = fopen( filename, "rb" ); @@ -91,8 +92,10 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) exit(1); } - fread( width, sizeof( GLsizei ), 1, infile ); - fread( height, sizeof( GLsizei ), 1, infile ); + num_read = fread( width, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); + num_read = fread( height, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); *width = bswap(*width); *height = bswap(*height); @@ -102,10 +105,12 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); if ( !pixels ) { fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); + fclose( infile ); return NULL; } - fread( pixels, sizeof( GLubyte ), n, infile ); + num_read = fread( pixels, sizeof( GLubyte ), n, infile ); + assert(num_read == n); fclose( infile ); diff --git a/progs/redbook/minmax.c b/progs/redbook/minmax.c index da5b875a475..2c1356c9de4 100644 --- a/progs/redbook/minmax.c +++ b/progs/redbook/minmax.c @@ -47,6 +47,7 @@ */ #include <GL/glew.h> #include <GL/glut.h> +#include <assert.h> #include <stdlib.h> #include <stdio.h> @@ -78,6 +79,7 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) { int n; GLubyte* pixels; + size_t num_read; FILE* infile = fopen( filename, "rb" ); @@ -86,8 +88,10 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) return NULL; } - fread( width, sizeof( GLsizei ), 1, infile ); - fread( height, sizeof( GLsizei ), 1, infile ); + num_read = fread( width, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); + num_read = fread( height, sizeof( GLsizei ), 1, infile ); + assert(num_read == 1); *width = bswap(*width); *height = bswap(*height); @@ -97,10 +101,12 @@ readImage( const char* filename, GLsizei* width, GLsizei *height ) pixels = (GLubyte *) malloc( n * sizeof( GLubyte )); if ( !pixels ) { fprintf( stderr, "Unable to malloc() bytes for pixels\n" ); + fclose( infile ); return NULL; } - fread( pixels, sizeof( GLubyte ), n, infile ); + num_read = fread( pixels, sizeof( GLubyte ), n, infile ); + assert(num_read == n); fclose( infile ); |