From ca88f30ad11bf20e237ad8b0f278f95ecc7b6c9f Mon Sep 17 00:00:00 2001 From: Oliver Wang Date: Tue, 23 Sep 2003 19:53:30 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2351 --- api/gutil.C | 35 +++++++++++++++++++++++++++++++++-- api/gutil.h | 3 +++ api/reduce.C | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/api/gutil.C b/api/gutil.C index 5250dc6880..5935062178 100755 --- a/api/gutil.C +++ b/api/gutil.C @@ -17,7 +17,8 @@ // Contributor(s): // -#include "config.h" +//#include "config.h" +#define HAVE_GLUT_H #include #include #include @@ -976,7 +977,6 @@ bool CreateTextureBMP(UINT textureArray[], LPSTR strFileName, int textureID) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); return true; } - bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID) { unsigned char* pixels; @@ -992,6 +992,37 @@ bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID) return true; } +bool CreateTextureTGA(UINT textureArray[], LPSTR strFileName, int textureID) +{ + if(!strFileName) // Return from the function if no file name was passed in + return false; + + tImageTGA *pImage = LoadTGA(strFileName); // Load the image and store the data + if(pImage == NULL) // If we can't load the file, quit! + exit(0); + glGenTextures(1, &textureArray[textureID]); + glBindTexture(GL_TEXTURE_2D, textureArray[textureID]); + int textureType = GL_RGB; + if(pImage->channels == 4) + { + textureType = GL_RGBA; + } + gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->sizeX, + pImage->sizeY, textureType, GL_UNSIGNED_BYTE, pImage->data); +// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); +// glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); + + if (pImage) // If we loaded the image + { + if (pImage->data) // If there is texture data + { + delete[] pImage->data; // Free the texture data, we don't need it anymore + } + free(pImage); // Free the image structure + } + return true; +} + //text UINT listBase[MAX_TEXTURES]; diff --git a/api/gutil.h b/api/gutil.h index 37b160fe51..6e58bbba6a 100755 --- a/api/gutil.h +++ b/api/gutil.h @@ -123,6 +123,8 @@ extern void replaceStar(Star* tmpStar); #include "jpeglib.h" #include "bmplib.h" +#include "tgalib.h" + #define MAX_TEXTURES 16 #define MAX_FONTS 16 extern UINT g_Texture[MAX_TEXTURES]; @@ -130,6 +132,7 @@ extern UINT listBase[MAX_FONTS]; extern bool CreateTextureJPG(UINT textureArray[], LPSTR strFileName, int textureID); extern bool CreateTextureBMP(UINT textureArray[], LPSTR strFileName, int textureID); extern bool CreateTexturePPM(UINT textureArray[], LPSTR strFileName, int textureID); +extern bool CreateTextureTGA(UINT textureArray[], LPSTR strFileName, int textureID); extern tImageJPG *LoadJPG(const char *filename); extern void print_text(unsigned int base, char *string); extern void MyCreateFont(unsigned int &base, char *fontName, int Size, int weight); \ No newline at end of file diff --git a/api/reduce.C b/api/reduce.C index bc183688a9..509ebeb90b 100644 --- a/api/reduce.C +++ b/api/reduce.C @@ -768,7 +768,7 @@ void REDUCED_ARRAY::draw_axes() { glEnd(); glBegin(GL_QUADS); - glColor4d(1,1,1,.3); + glColor4d(1,1,1,.2); glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+adj); glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+adj);