From 8ddde586d10286044e28a19e17758b022ae5fafb Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 13 Apr 2003 21:26:13 +0000 Subject: [PATCH] remove files which are moved to Simgear --- src/Objects/colours.h | 289 -------------------------------- src/Objects/texload.c | 382 ------------------------------------------ src/Objects/texload.h | 40 ----- 3 files changed, 711 deletions(-) delete mode 100644 src/Objects/colours.h delete mode 100644 src/Objects/texload.c delete mode 100644 src/Objects/texload.h diff --git a/src/Objects/colours.h b/src/Objects/colours.h deleted file mode 100644 index ba3b89149..000000000 --- a/src/Objects/colours.h +++ /dev/null @@ -1,289 +0,0 @@ -// colours.h -- This header file contains colour definitions in the -// same way as MS FS5 does -// -// Contributed by "Christian Mayer" , started April 1999. -// -// Copyright (C) 1998 Christian Mayer - Vader@t-online.de -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// -// $Id$ - - -#ifndef COLOURS_H -#define COLOURS_H - -unsigned char msfs_colour[256][3]= -{ - { 0, 0, 0}, - { 8, 8, 8}, - { 16, 16, 16}, - { 24, 24, 24}, - { 32, 32, 32}, - { 40, 40, 40}, - { 48, 48, 48}, - { 56, 56, 56}, - { 65, 65, 65}, - { 73, 73, 73}, - { 81, 81, 81}, - { 89, 89, 89}, - { 97, 97, 97}, - {105, 105, 105}, - {113, 113, 113}, - {121, 121, 121}, - {130, 130, 130}, - {138, 138, 138}, - {146, 146, 146}, - {154, 154, 154}, - {162, 162, 162}, - {170, 170, 170}, - {178, 178, 178}, - {186, 186, 186}, - {195, 195, 195}, - {203, 203, 203}, - {211, 211, 211}, - {219, 219, 219}, - {227, 227, 227}, - {235, 235, 235}, - {247, 247, 247}, - {255, 255, 255}, - { 21, 5, 5}, - { 42, 10, 10}, - { 63, 15, 15}, - { 84, 20, 20}, - {105, 25, 25}, - {126, 30, 30}, - {147, 35, 35}, - {168, 40, 40}, - {189, 45, 45}, - {210, 50, 50}, - {231, 55, 55}, - {252, 60, 60}, - { 5, 21, 5}, - { 10, 42, 10}, - { 15, 63, 15}, - { 20, 84, 20}, - { 25, 105, 25}, - { 30, 126, 30}, - { 35, 147, 35}, - { 40, 168, 40}, - { 45, 189, 45}, - { 50, 210, 50}, - { 55, 231, 55}, - { 60, 252, 60}, - { 0, 7, 23}, - { 0, 15, 40}, - { 0, 23, 58}, - { 0, 40, 84}, - { 0, 64, 104}, - { 0, 71, 122}, - { 0, 87, 143}, - { 0, 99, 156}, - { 0, 112, 179}, - { 0, 128, 199}, - { 0, 143, 215}, - { 0, 153, 230}, - { 28, 14, 0}, - { 56, 28, 0}, - { 84, 42, 0}, - {112, 56, 0}, - {140, 70, 0}, - {168, 84, 0}, - {196, 98, 0}, - {224, 112, 0}, - {252, 126, 0}, - { 28, 28, 0}, - { 56, 56, 0}, - { 84, 84, 0}, - {112, 112, 0}, - {140, 140, 0}, - {168, 168, 0}, - {196, 196, 0}, - {224, 224, 0}, - {252, 252, 0}, - { 25, 21, 16}, - { 50, 42, 32}, - { 75, 63, 48}, - {100, 84, 64}, - {125, 105, 80}, - {150, 126, 96}, - {175, 147, 112}, - {200, 168, 128}, - {225, 189, 144}, - { 28, 11, 7}, - { 56, 22, 14}, - { 84, 33, 21}, - {112, 44, 28}, - {140, 55, 35}, - {168, 66, 42}, - {196, 77, 49}, - {224, 88, 56}, - {252, 99, 63}, - { 17, 22, 9}, - { 34, 44, 18}, - { 51, 66, 27}, - { 68, 88, 36}, - { 85, 110, 45}, - {102, 132, 54}, - {119, 154, 63}, - {136, 176, 72}, - {153, 198, 81}, - { 0, 58, 104}, - { 0, 87, 112}, - { 43, 112, 128}, - {255, 0, 0}, - { 64, 255, 64}, - { 0, 0, 192}, - { 0, 105, 105}, - {255, 128, 0}, - {255, 255, 0}, - { 81, 81, 81}, - {121, 121, 121}, - {146, 146, 146}, - {170, 170, 170}, - {195, 195, 195}, - {227, 227, 227}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - {192, 192, 255}, - {200, 200, 255}, - {208, 208, 255}, - {216, 216, 255}, - {224, 224, 255}, - {232, 232, 255}, - {240, 240, 255}, - {248, 248, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - {255, 255, 255}, - { 16, 72, 16}, - { 32, 80, 32}, - { 48, 88, 48}, - { 64, 96, 64}, - { 80, 104, 80}, - { 96, 112, 96}, - {112, 120, 112}, - {120, 124, 120}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - {128, 128, 128}, - { 33, 140, 189}, - { 57, 132, 165}, - {189, 66, 66}, - {156, 66, 66}, - {132, 74, 74}, - { 33, 82, 107}, - {214, 90, 82}, - {189, 90, 82}, - {165, 90, 82}, - {123, 57, 49}, - { 99, 57, 49}, - {107, 74, 66}, - {123, 90, 82}, - {181, 90, 66}, - { 74, 49, 41}, - {189, 115, 90}, - {140, 90, 49}, - { 33, 49, 74}, - {181, 115, 49}, - { 99, 66, 33}, - {165, 115, 66}, - { 49, 41, 33}, - {165, 140, 115}, - {189, 165, 140}, - { 57, 99, 123}, - {181, 107, 24}, - {206, 123, 33}, - {156, 99, 33}, - {148, 107, 49}, - {107, 82, 49}, - { 33, 33, 57}, - { 33, 115, 165}, - {214, 214, 33}, - {173, 173, 33}, - {198, 198, 41}, - {140, 140, 33}, - {115, 115, 33}, - {189, 189, 57}, - {156, 156, 49}, - {173, 173, 57}, - {123, 123, 49}, - {123, 123, 66}, - { 74, 74, 49}, - {123, 123, 90}, - { 41, 41, 33}, - { 90, 99, 57}, - {107, 115, 74}, - {123, 148, 82}, - {140, 173, 99}, - {132, 156, 99}, - { 49, 66, 41}, - { 99, 165, 90}, - { 74, 214, 74}, - { 57, 140, 57}, - { 74, 181, 74}, - { 90, 198, 90}, - { 57, 123, 57}, - { 49, 99, 49}, - { 90, 165, 90}, - { 82, 148, 82}, - { 74, 99, 74}, - { 57, 115, 132}, - { 33, 99, 123}, - { 74, 115, 132} -}; - - -#endif diff --git a/src/Objects/texload.c b/src/Objects/texload.c deleted file mode 100644 index 6e2192ce3..000000000 --- a/src/Objects/texload.c +++ /dev/null @@ -1,382 +0,0 @@ - -/* texture.c - by David Blythe, SGI */ - -/* texload is a simplistic routine for reading an SGI .rgb image file. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_WINDOWS_H -# include -#endif - -#include -#include -#include - -#include - -#include "texload.h" -#include "colours.h" - -typedef struct _ImageRec { - unsigned short imagic; - unsigned short type; - unsigned short dim; - unsigned short xsize, ysize, zsize; - unsigned int min, max; - unsigned int wasteBytes; - char name[80]; - unsigned long colorMap; - sgFile file; - unsigned char *tmp; - unsigned long rleEnd; - unsigned int *rowStart; - int *rowSize; -} ImageRec; - -void -rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n) { - while(n--) { - l[0] = r[0]; - l[1] = g[0]; - l[2] = b[0]; - l += 3; r++; g++; b++; - } -} - -static void -ConvertShort(unsigned short *array, unsigned int length) { - unsigned short b1, b2; - unsigned char *ptr; - - ptr = (unsigned char *)array; - while (length--) { - b1 = *ptr++; - b2 = *ptr++; - *array++ = (b1 << 8) | (b2); - } -} - -static void -ConvertUint(unsigned *array, unsigned int length) { - unsigned int b1, b2, b3, b4; - unsigned char *ptr; - - ptr = (unsigned char *)array; - while (length--) { - b1 = *ptr++; - b2 = *ptr++; - b3 = *ptr++; - b4 = *ptr++; - *array++ = (b1 << 24) | (b2 << 16) | (b3 << 8) | (b4); - } -} - -static ImageRec *ImageOpen(const char *fileName) -{ - union { - int testWord; - char testByte[4]; - } endianTest; - - ImageRec *image; - int swapFlag; - int x; - - endianTest.testWord = 1; - if (endianTest.testByte[0] == 1) { - swapFlag = 1; - } else { - swapFlag = 0; - } - - image = (ImageRec *)malloc(sizeof(ImageRec)); - if (image == NULL) { - fprintf(stderr, "Out of memory!\n"); - exit(1); - } - if ((image->file = sgopen(fileName, "rb")) == NULL) { - return NULL; - } - - // fread(image, 1, 12, image->file); - sgread(image->file, image, 12); - - if (swapFlag) { - ConvertShort(&image->imagic, 6); - } - - image->tmp = (unsigned char *)malloc(image->xsize*256); - if (image->tmp == NULL) { - fprintf(stderr, "\nOut of memory!\n"); - exit(1); - } - - if ((image->type & 0xFF00) == 0x0100) { - x = image->ysize * image->zsize * (int) sizeof(unsigned); - image->rowStart = (unsigned *)malloc(x); - image->rowSize = (int *)malloc(x); - if (image->rowStart == NULL || image->rowSize == NULL) { - fprintf(stderr, "\nOut of memory!\n"); - exit(1); - } - image->rleEnd = 512 + (2 * x); - sgseek(image->file, 512, SEEK_SET); - // fread(image->rowStart, 1, x, image->file); - sgread(image->file, image->rowStart, x); - // fread(image->rowSize, 1, x, image->file); - sgread(image->file, image->rowSize, x); - if (swapFlag) { - ConvertUint(image->rowStart, x/(int) sizeof(unsigned)); - ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int)); - } - } - return image; -} - -static void -ImageClose(ImageRec *image) { - sgclose(image->file); - free(image->tmp); - free(image); -} - -static void -ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { - unsigned char *iPtr, *oPtr, pixel; - int count; - - if ((image->type & 0xFF00) == 0x0100) { - sgseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); - // fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], - // image->file); - sgread(image->file, image->tmp, - (unsigned int)image->rowSize[y+z*image->ysize]); - - iPtr = image->tmp; - oPtr = buf; - for (;;) { - pixel = *iPtr++; - count = (int)(pixel & 0x7F); - if (!count) { - return; - } - if (pixel & 0x80) { - while (count--) { - *oPtr++ = *iPtr++; - } - } else { - pixel = *iPtr++; - while (count--) { - *oPtr++ = pixel; - } - } - } - } else { - sgseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), - SEEK_SET); - // fread(buf, 1, image->xsize, image->file); - sgread(image->file, buf, image->xsize); - } -} - -GLubyte * -read_alpha_texture(const char *name, int *width, int *height) -{ - unsigned char *base, *lptr; - ImageRec *image; - int y; - - image = ImageOpen(name); - if(!image) { - return NULL; - } - - (*width)=image->xsize; - (*height)=image->ysize; - - printf("image->zsize = %d\n", image->zsize); - - if (image->zsize != 1) { - ImageClose(image); - return NULL; - } - - base = (unsigned char *)malloc(image->xsize*image->ysize*sizeof(unsigned char)); - lptr = base; - for(y=0; yysize; y++) { - ImageGetRow(image,lptr,y,0); - lptr += image->xsize; - } - ImageClose(image); - - return (unsigned char *) base; -} - -GLubyte * -read_rgb_texture(const char *name, int *width, int *height) -{ - unsigned char *base, *ptr; - unsigned char *rbuf, *gbuf, *bbuf, *abuf; - ImageRec *image; - int y; - - image = ImageOpen(name); - - if(!image) - return NULL; - (*width)=image->xsize; - (*height)=image->ysize; - if (image->zsize != 3 && image->zsize != 4) { - ImageClose(image); - return NULL; - } - - base = (unsigned char*)malloc(image->xsize*image->ysize*sizeof(unsigned int)*3); - rbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); - gbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); - bbuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); - abuf = (unsigned char *)malloc(image->xsize*sizeof(unsigned char)); - if(!base || !rbuf || !gbuf || !bbuf || !abuf) { - if (base) free(base); - if (rbuf) free(rbuf); - if (gbuf) free(gbuf); - if (bbuf) free(bbuf); - if (abuf) free(abuf); - return NULL; - } - ptr = base; - for(y=0; yysize; y++) { - if(image->zsize == 4) { - ImageGetRow(image,rbuf,y,0); - ImageGetRow(image,gbuf,y,1); - ImageGetRow(image,bbuf,y,2); - ImageGetRow(image,abuf,y,3); /* Discard. */ - rgbtorgb(rbuf,gbuf,bbuf,ptr,image->xsize); - ptr += (image->xsize * 3); - } else { - ImageGetRow(image,rbuf,y,0); - ImageGetRow(image,gbuf,y,1); - ImageGetRow(image,bbuf,y,2); - rgbtorgb(rbuf,gbuf,bbuf,ptr,image->xsize); - ptr += (image->xsize * 3); - } - } - ImageClose(image); - free(rbuf); - free(gbuf); - free(bbuf); - free(abuf); - - return (GLubyte *) base; -} - - -static ImageRec *RawImageOpen(const char *fileName) -{ - union { - int testWord; - char testByte[4]; - } endianTest; - - ImageRec *image; - int swapFlag; - - endianTest.testWord = 1; - if (endianTest.testByte[0] == 1) { - swapFlag = 1; - } else { - swapFlag = 0; - } - - image = (ImageRec *)malloc(sizeof(ImageRec)); - if (image == NULL) { - fprintf(stderr, "Out of memory!\n"); - exit(1); - } - if ((image->file = sgopen(fileName, "rb")) == NULL) { - return NULL; - } - - sgread(image->file, image, 12); - - if (swapFlag) { - ConvertShort(&image->imagic, 6); - } - - - image->tmp = (unsigned char *)malloc(1); //just allocate a pseudo value as I'm too lazy to change ImageClose()... - if (image->tmp == NULL) { - fprintf(stderr, "\nOut of memory!\n"); - exit(1); - } - - return image; -} - - -GLubyte * -read_raw_texture(const char *name, int *width, int *height) -{ - unsigned char *base, *ptr; - ImageRec *image; - int y; - - image = RawImageOpen(name); - - if(!image) - return NULL; - (*width)=256; - (*height)=256; - - base = (unsigned char*)malloc(256*256*sizeof(unsigned char)*3); - if(!base) { - if (base) free(base); - return NULL; - } - ptr = base; - for(y=0; y<256; y++) { - sgread(image->file, ptr, 256*3); - ptr+=256*3; - } - ImageClose(image); - - return (GLubyte *) base; -} - - -GLubyte * -read_r8_texture(const char *name, int *width, int *height) -{ - unsigned char *base, *ptr; - ImageRec *image; - int xy; - unsigned char c[1]; - - image = RawImageOpen(name); //it wouldn't make sense to write a new function... - - if(!image) - return NULL; - (*width)=256; - (*height)=256; - - base = (unsigned char*)malloc(256*256*sizeof(unsigned char)*3); - if(!base) { - if (base) free(base); - return NULL; - } - ptr = base; - for(xy=0; xy<(256*256); xy++) { - sgread(image->file,c,1); - ptr[0]=msfs_colour[c[0]][0]; //look in the table for the right colours - ptr[1]=msfs_colour[c[0]][1]; - ptr[2]=msfs_colour[c[0]][2]; - - ptr+=3; - } - ImageClose(image); - - return (GLubyte *) base; -} diff --git a/src/Objects/texload.h b/src/Objects/texload.h deleted file mode 100644 index 0eed56dcc..000000000 --- a/src/Objects/texload.h +++ /dev/null @@ -1,40 +0,0 @@ - -/* Copyright (c) Mark J. Kilgard, 1997. */ - -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or - implied. This program is -not- in the public domain. */ - - -#ifndef _TEXLOAD_H -#define _TEXLOAD_H - - -#ifdef HAVE_CONFIG_H -# include -#endif - -#ifdef HAVE_WINDOWS_H -# include -#endif - -#include GLUT_H - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern GLubyte *read_alpha_texture(const char *name, int *width, int *height); -extern GLubyte *read_rgb_texture(const char *name, int *width, int *height); -extern GLubyte *read_raw_texture(const char *name, int *width, int *height); -extern GLubyte *read_r8_texture(const char *name, int *width, int *height); - - -#ifdef __cplusplus -} -#endif - - -#endif /* _TEXLOAD_H */