Main Page | Report this Page
Computers Forum Index  »  Computer - Graphics - API (Opengl)  »  RedBook, Chapter 8, examples...
Page 1 of 1    

RedBook, Chapter 8, examples...

Author Message
Georg Fuss...
Posted: Thu Sep 10, 2009 11:38 pm
Guest
The funktion readImage(), used in some example in the chapter 8, does
not work.

This functions reads the file .../data/leeds.bin. The first things read
from the file are sizes of the window, but for me the function reads
impossible values.
readImage(): width = 1459748864 height = -1862205440
These values make no sense as dimensions for a window.

I am working on a 64-Bit linux-system.
The most example are easy to compile and to run.

The file ..../data/leeds.bin I get from
http://www.opengl-redbook.com/source/OpenGL-1.4.tgz
 
fungus...
Posted: Thu Sep 10, 2009 11:38 pm
Guest
On Sep 10, 9:38 pm, Georg Fuss <f... at (no spam) math.TU-Berlin.DE> wrote:
Quote:
The first things read
from the file are sizes of the window, but for me the function reads
impossible values.
readImage(): width = 1459748864   height = -1862205440
These values make no sense as dimensions for a window.

I am working on a 64-Bit linux-system.
The most example are easy to compile and to run.


Maybe there's a bug in the loader so it reads 64-bit
ints instead of 32 bits.

--
<\___/>
/ O O \
\_____/ FTB.

http://www.topaz3d.com/
 
jbwest...
Posted: Fri Sep 11, 2009 4:41 am
Guest
"Georg Fuss" <fuss at (no spam) math.TU-Berlin.DE> wrote in message
news:7gt2t7F2qp10hU1 at (no spam) mid.dfncis.de...
Quote:
The funktion readImage(), used in some example in the chapter 8, does
not work.

This functions reads the file .../data/leeds.bin. The first things read
from the file are sizes of the window, but for me the function reads
impossible values.
readImage(): width = 1459748864 height = -1862205440
These values make no sense as dimensions for a window.

I am working on a 64-Bit linux-system.
The most example are easy to compile and to run.

The file ..../data/leeds.bin I get from
http://www.opengl-redbook.com/source/OpenGL-1.4.tgz


probably an endian-ness or 64-bit-ness error in the code.

jbw
 
Paul at (no spam) Tcl3D...
Posted: Fri Sep 11, 2009 9:37 pm
Guest
Hi Georg,

The RedBook examples were written on and for SGI computers, so the
header data of the images is stored in big-endian format.
The code to read the width and height does not account for little-endianess.

Something like the following will help:

static unsigned int byteToUInt32 (const unsigned char buf[4])
{
return (buf[3] & 0x000000ff) |
((buf[2] << Cool & 0x0000ff00) |
((buf[1] << 16) & 0x00ff0000) |
(buf[0] << 24);
}

In function readImage:

....
unsigned char bufWidth[4], bufHeight[4];

FILE* infile = fopen( filename, "rb" );

if ( !infile ) {
fprintf( stderr, "Unable to open file '%s'\n", filename );
return NULL;
}

fread( bufWidth, sizeof( GLsizei ), 1, infile );
fread( bufHeight, sizeof( GLsizei ), 1, infile );
*width = byteToUInt32 (bufWidth);
*height = byteToUInt32 (bufHeight);
....

Paul


Georg Fuss wrote:
Quote:
The funktion readImage(), used in some example in the chapter 8, does
not work.

This functions reads the file .../data/leeds.bin. The first things read
from the file are sizes of the window, but for me the function reads
impossible values.
readImage(): width = 1459748864 height = -1862205440
These values make no sense as dimensions for a window.

I am working on a 64-Bit linux-system.
The most example are easy to compile and to run.

The file ..../data/leeds.bin I get from
http://www.opengl-redbook.com/source/OpenGL-1.4.tgz
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 2:13 pm