PDA

View Full Version : Library glaux?



Boubou
12-20-2000, 02:50 AM
Hello,

I'm sorry but I don't speak vera good english.

I'm juste a question: is the library glaux is portable? Can I use it with an another OS?

Thank you for your help!

Best regards
Jérôme

Boubou
12-20-2000, 07:00 AM
Nobody know?

Please!

Jérôme

Kev~
12-20-2000, 08:09 AM
Dont do it!

glaux is poo - i had all sorts of problems with it. also it is not as easy to get hold of as other API's

if you have to use something higher than glu
then use glut.

Moz
12-20-2000, 08:45 AM
And if you want an image loader,
then do it yourself ! http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Boubou
12-20-2000, 09:18 AM
hello,

Thank you for your answer!

But the glaux is portable? We can change OS after use glaux?

Thanks

Jérôme

Moz
12-20-2000, 10:01 AM
Glaux is Windows only.
For portability, use glut. The problem with glut is that you don't have functions to load images. That's why I wrote that you'll have to implement that yourself.
If you want, I can send you some code for a bitmap or a TGA loader (even commented in french if you'd like http://www.opengl.org/discussion_boards/ubb/wink.gif).

Boubou
12-20-2000, 10:14 AM
Hi,

Thank you very well for your answer...

OK! glaux is only for windows! (A person said me that he saw glaux in Linux???) Now it's doesn't existe... but before, glaux existe in Linux!?!

Yes I search code for load texture with glut! But for tga file, because bmp is not portability.
I take the nehe code for tga file, but I find it's diffucult for me now... and I don't understand very well english!

If you have code in french it's better for me ( http://www.opengl.org/discussion_boards/ubb/smile.gif )! But I don't want to take your time!


Thank you a lot for your time and your answer!

You have my e-mail address in my profile!

Best regards
Jérôme

jtwoods
12-21-2000, 09:17 AM
Here's some code to parse a TGA...A portion of the targaParseTarga() is irrelevant, but I suggest leaving it in anyway. So, here's the deal with this code: It doesn't support the developer and extension areas of a targa, but you run targaParseTarga() with the filename, and suddenly, the whole file is organized in a nice struct that you can use. Call targaFreeImageColorMapData() to free up memory allocated for the image and color map buffers. I think this version has a little targaCreateTexture2D_BGR...but this has a requirement. Texture must be 24-bit in BGR format, which most TGA's are. Here ya go:

#define SIGNATURE "TRUEVISION-XFILE"

typedef struct {
char cIDLength;
char cColorMapType;
char cImageType;
struct {
short sFirstEntryIndex;
short sColorMapLength;
char cColorMapEntrySize;
} ColorMapSpecification;
struct {
short sXOrigin;
short sYOrigin;
short sImageWidth;
short sImageHeight;
char cPixelDepth;
char cImageDescriptor;
} ImageMapSpecification;
} TGAFileHeader_t;

typedef struct {
char* pImageID;
char* pColorMapData;
char* pImageData;
} ImageColorMapData_t;

typedef struct {
long lExtensionOffset;
long lDeveloperOffset;
char cSignature[16];
char cCharacter;
char cTerminator;
} TGAFileFooter_t;

typedef struct {
TGAFileHeader_t TGAFileHeader;
ImageColorMapData_t ImageColorMapData;
} Targa_t;

Targa_t targaParseTarga(char* filename);

Targa_t targaParseTarga(char* filename)
{
Targa_t file;
TGAFileHeader_t header;
ImageColorMapData_t data;
TGAFileFooter_t footer;

FILE *stream = 0;
int nInteger = 0;
bool bNewFormat = false;
stream = fopen(filename, "rb");

fseek(stream, -26, SEEK_END);
fread(&footer.lExtensionOffset, sizeof(long), 1, stream);
fread(&footer.lDeveloperOffset, sizeof(long), 1, stream);
fread(&footer.cSignature, sizeof(char), 16, stream);
fread(&footer.cCharacter, sizeof(char), 1, stream);
fread(&footer.cTerminator, sizeof(char), 1, stream);
footer.cSignature[16] = 0x00;

fseek(stream, 0, SEEK_SET);
fread(&header.cIDLength, sizeof(char), 1, stream);
fread(&header.cColorMapType, sizeof(char), 1, stream);
fread(&header.cImageType, sizeof(char), 1, stream);
fread(&header.ColorMapSpecification.sFirstEntryIndex, sizeof(short), 1, stream);
fread(&header.ColorMapSpecification.sColorMapLength, sizeof(short), 1, stream);
fread(&header.ColorMapSpecification.cColorMapEntrySize, sizeof(char), 1, stream);
fread(&header.ImageMapSpecification.sXOrigin, sizeof(short), 1, stream);
fread(&header.ImageMapSpecification.sYOrigin, sizeof(short), 1, stream);
fread(&header.ImageMapSpecification.sImageWidth, sizeof(short), 1, stream);
fread(&header.ImageMapSpecification.sImageHeight, sizeof(short), 1, stream);
fread(&header.ImageMapSpecification.cPixelDepth, sizeof(char), 1, stream);
fread(&header.ImageMapSpecification.cImageDescriptor, sizeof(char), 1, stream);

if (header.cIDLength != 0)
{
data.pImageID = (char*)malloc(header.cIDLength);
fread(data.pImageID, sizeof(char), header.cIDLength, stream);
}
else
data.pImageID = (char*)0;

if (header.cColorMapType != 0)
{
data.pColorMapData = (char*)malloc((header.ColorMapSpecification.sColor MapLength-header.ColorMapSpecification.cColorMapEntrySize)*( (header.ColorMapSpecification.cColorMapEntrySize/8)+0.5));
fseek(stream, (header.ColorMapSpecification.sFirstEntryIndex * header.ColorMapSpecification.cColorMapEntrySize), SEEK_CUR);
fread(data.pColorMapData, sizeof(char), (header.ColorMapSpecification.sColorMapLength-header.ColorMapSpecification.cColorMapEntrySize)*( (header.ColorMapSpecification.cColorMapEntrySize/8)+0.5), stream);
}
else
data.pColorMapData = (char*)0;

data.pImageData = (char*)malloc(header.ImageMapSpecification.sImageW idth*header.ImageMapSpecification.sImageHeight*((h eader.ImageMapSpecification.cPixelDepth/8)+0.5));
fread(data.pImageData, sizeof(char), header.ImageMapSpecification.sImageWidth*header.Im ageMapSpecification.sImageHeight*((header.ImageMap Specification.cPixelDepth/8)+0.5), stream);

nInteger = fclose(stream);

file.TGAFileHeader = header;
file.ImageColorMapData = data;

return file;
}

#ifdef __gl_h_
GLboolean targaCreateTexture2D_BGR(Targa_t tTarga, GLuint *pTexture);

GLboolean targaCreateTexture2D_BGR(Targa_t tTarga, GLuint *pTexture)
{
glGenTextures(1, pTexture);
glBindTexture(GL_TEXTURE_2D, *pTexture);

GLsizei nWidth = tTarga.TGAFileHeader.ImageMapSpecification.sImageW idth;
GLsizei nHeight = tTarga.TGAFileHeader.ImageMapSpecification.sImageH eight;

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, nWidth, nHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, tTarga.ImageColorMapData.pImageData);

return true;
}
#endif // !defined __gl_h_

bool targaFreeImageColorMapData(Targa_t tTarga);

bool targaFreeImageColorMapData(Targa_t tTarga)
{
free(tTarga.ImageColorMapData.pImageID);
free(tTarga.ImageColorMapData.pColorMapData);
free(tTarga.ImageColorMapData.pImageData);

tTarga.ImageColorMapData.pImageID = (char*)0;
tTarga.ImageColorMapData.pColorMapData = (char*)0;
tTarga.ImageColorMapData.pImageData = (char*)0;

return true;
}

P.S. If anyone has any pointers to give me on this code, please do. I'm always looking for suggestions on how to make things better.

[This message has been edited by jtwoods (edited 12-21-2000).]

Boubou
12-22-2000, 01:30 AM
Thank you a lot jtwoods...

I try that!

Have a happy christmas, and new year!

Best regards

Jérôme

12-22-2000, 03:54 PM
I think that glaux started in UNIX and was extended by MS for their OpenGL implementation. The linux version probably do not have the bitmap loader.

If I remember correctly do glaux have some bug and "features" so everybody is using glut.