mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
0023281: Removed unused OpenGl_ImageBox
This commit is contained in:
parent
26920f3892
commit
43c34303a7
@ -404,9 +404,9 @@ public:
|
||||
template<typename ColorType_t>
|
||||
inline ColorType_t Image_ColorSumm3 (const ColorType_t& theA, const ColorType_t& theB)
|
||||
{
|
||||
ColorType_t aRes = { theA.v[0] + theB.v[0],
|
||||
ColorType_t aRes = {{theA.v[0] + theB.v[0],
|
||||
theA.v[1] + theB.v[1],
|
||||
theA.v[2] + theB.v[2] };
|
||||
theA.v[2] + theB.v[2]}};
|
||||
return aRes;
|
||||
}
|
||||
|
||||
@ -433,10 +433,10 @@ inline Image_ColorBGRF operator+ (const Image_ColorBGRF& theA, const Image_Color
|
||||
template<typename ColorType_t>
|
||||
inline ColorType_t Image_ColorSumm4 (const ColorType_t& theA, const ColorType_t& theB)
|
||||
{
|
||||
ColorType_t aRes = { theA.v[0] + theB.v[0],
|
||||
ColorType_t aRes = {{theA.v[0] + theB.v[0],
|
||||
theA.v[1] + theB.v[1],
|
||||
theA.v[2] + theB.v[2],
|
||||
theA.v[3] + theB.v[3] };
|
||||
theA.v[3] + theB.v[3]}};
|
||||
return aRes;
|
||||
}
|
||||
|
||||
@ -474,9 +474,9 @@ inline Image_ColorBGRAF operator+ (const Image_ColorBGRAF& theA, const Image_Col
|
||||
template<typename ColorType_t>
|
||||
inline ColorType_t Image_ColorSub3 (const ColorType_t& theA, const ColorType_t& theB)
|
||||
{
|
||||
ColorType_t aRes = { theA.v[0] - theB.v[0],
|
||||
ColorType_t aRes = {{theA.v[0] - theB.v[0],
|
||||
theA.v[1] - theB.v[1],
|
||||
theA.v[2] - theB.v[2] };
|
||||
theA.v[2] - theB.v[2]}};
|
||||
return aRes;
|
||||
}
|
||||
|
||||
@ -503,10 +503,10 @@ inline Image_ColorBGRF operator- (const Image_ColorBGRF& theA, const Image_Color
|
||||
template<typename ColorType_t>
|
||||
inline ColorType_t Image_ColorSub4 (const ColorType_t& theA, const ColorType_t& theB)
|
||||
{
|
||||
ColorType_t aRes = { theA.v[0] - theB.v[0],
|
||||
ColorType_t aRes = {{theA.v[0] - theB.v[0],
|
||||
theA.v[1] - theB.v[1],
|
||||
theA.v[2] - theB.v[2],
|
||||
theA.v[3] - theB.v[3] };
|
||||
theA.v[3] - theB.v[3]}};
|
||||
return aRes;
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,6 @@ OpenGl_FrameBuffer.hxx
|
||||
OpenGl_FrameBuffer.cxx
|
||||
OpenGl_TextureBox.cxx
|
||||
OpenGl_TextureBox.hxx
|
||||
OpenGl_ImageBox.cxx
|
||||
OpenGl_ImageBox.hxx
|
||||
OpenGl_Resource.hxx
|
||||
OpenGl_Resource.cxx
|
||||
OpenGl_ResourceTexture.hxx
|
||||
|
@ -1,379 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*
|
||||
* Fonction
|
||||
* ~~~~~~~~
|
||||
* Gestion des images sous OpenGL
|
||||
*
|
||||
*
|
||||
* Attention:
|
||||
* ~~~~~~~~~~~
|
||||
* Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
|
||||
*
|
||||
*
|
||||
* Historique des modifications
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* 22-05-97: PCT ; creation
|
||||
* 10-07-98: FGU ; Ajout : ReadScaledImage
|
||||
* Mise a jour des dimensions de l image
|
||||
* 02.15.100 JR : Implicit convertion
|
||||
*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Includes
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <OpenGl_ImageBox.hxx>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Types definis
|
||||
*/
|
||||
|
||||
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;
|
||||
FILE *file;
|
||||
unsigned char *tmp, *tmpR, *tmpG, *tmpB;
|
||||
unsigned long rleEnd;
|
||||
unsigned int *rowStart;
|
||||
int *rowSize;
|
||||
} ImageRec;
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions privees
|
||||
*/
|
||||
|
||||
static void
|
||||
ConvertShort(unsigned short *array, long length) {
|
||||
unsigned long b1, b2;
|
||||
unsigned char *ptr;
|
||||
|
||||
ptr = (unsigned char *)array;
|
||||
while (length--) {
|
||||
b1 = *ptr++;
|
||||
b2 = *ptr++;
|
||||
*array++ = (unsigned short )((b1 << 8) | (b2));
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
ConvertLong(unsigned *array, long length) {
|
||||
unsigned long 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(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 = new ImageRec();
|
||||
if (image == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((image->file = fopen(fileName, "rb")) == NULL) {
|
||||
perror(fileName);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fread(image, 1, 12, image->file);
|
||||
|
||||
if (swapFlag) {
|
||||
ConvertShort(&image->imagic, 6);
|
||||
}
|
||||
|
||||
image->tmp = new unsigned char[image->xsize*256];
|
||||
image->tmpR = new unsigned char[image->xsize*256];
|
||||
image->tmpG = new unsigned char[image->xsize*256];
|
||||
image->tmpB = new unsigned char[image->xsize*256];
|
||||
if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||
|
||||
image->tmpB == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((image->type & 0xFF00) == 0x0100) {
|
||||
x = image->ysize * image->zsize * sizeof(unsigned);
|
||||
image->rowStart = new unsigned[x];
|
||||
image->rowSize = new int[x];
|
||||
if (image->rowStart == NULL || image->rowSize == NULL) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
image->rleEnd = 512 + (2 * x);
|
||||
fseek(image->file, 512, SEEK_SET);
|
||||
fread(image->rowStart, 1, x, image->file);
|
||||
fread(image->rowSize, 1, x, image->file);
|
||||
if (swapFlag) {
|
||||
ConvertLong(image->rowStart, x/sizeof(unsigned));
|
||||
ConvertLong((unsigned *)image->rowSize, x/sizeof(int));
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
ImageClose(ImageRec *image) {
|
||||
fclose(image->file);
|
||||
delete [] image->tmp;
|
||||
delete [] image->tmpR;
|
||||
delete [] image->tmpG;
|
||||
delete [] image->tmpB;
|
||||
delete [] image->rowStart;
|
||||
delete [] image->rowSize;
|
||||
delete 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) {
|
||||
fseek(image->file, image->rowStart[y+z*image->ysize], SEEK_SET);
|
||||
fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
|
||||
image->file);
|
||||
|
||||
iPtr = image->tmp;
|
||||
oPtr = buf;
|
||||
while (1) {
|
||||
pixel = *iPtr++;
|
||||
count = (int)(pixel & 0x7F);
|
||||
if (!count) {
|
||||
return;
|
||||
}
|
||||
if (pixel & 0x80) {
|
||||
while (count--) {
|
||||
*oPtr++ = *iPtr++;
|
||||
}
|
||||
} else {
|
||||
pixel = *iPtr++;
|
||||
while (count--) {
|
||||
*oPtr++ = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize),
|
||||
SEEK_SET);
|
||||
fread(buf, 1, image->xsize, image->file);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions publiques
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void ReadScaledImage(char *file, int xsize, int ysize, char *buf, unsigned short *zsize)
|
||||
{
|
||||
ImageRec *image = ImageOpen(file);
|
||||
unsigned char *rbuf, *gbuf=NULL, *bbuf=NULL;
|
||||
int row, rrow, i, ri;
|
||||
char *p = buf;
|
||||
|
||||
*zsize = image->zsize;
|
||||
|
||||
/* Allocation memoire */
|
||||
rbuf = new unsigned char[image->xsize];
|
||||
|
||||
if (image->zsize > 2) {
|
||||
gbuf = new unsigned char[image->xsize];
|
||||
bbuf = new unsigned char[image->xsize];
|
||||
}
|
||||
|
||||
/* Lecture image rang apres rang */
|
||||
for (row = 0; row < ysize; row++) {
|
||||
/* rang a lire */
|
||||
rrow = (row*image->ysize)/ysize;
|
||||
|
||||
if (*zsize > 2) {
|
||||
ImageGetRow(image, rbuf, rrow, 0);
|
||||
ImageGetRow(image, gbuf, rrow, 1);
|
||||
ImageGetRow(image, bbuf, rrow, 2);
|
||||
}
|
||||
else
|
||||
ImageGetRow(image, rbuf, rrow, 0);
|
||||
|
||||
/* stockage au format RGB */
|
||||
for (i=0; i < xsize; i++) {
|
||||
ri = (i*image->xsize)/xsize;
|
||||
if (*zsize > 2) {
|
||||
*p++ = rbuf[ri];
|
||||
*p++ = gbuf[ri];
|
||||
*p++ = bbuf[ri];
|
||||
}
|
||||
else {
|
||||
*p++ = rbuf[ri];
|
||||
*p++ = rbuf[ri];
|
||||
*p++ = rbuf[ri];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* delete image buffers */
|
||||
delete [] rbuf;
|
||||
if (*zsize > 2) {
|
||||
delete [] gbuf;
|
||||
delete [] bbuf;
|
||||
}
|
||||
|
||||
ImageClose(image);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void ReadSizeImage(char *file, int *xsize, int *ysize)
|
||||
{
|
||||
/* Lecture image */
|
||||
ImageRec *image = ImageOpen(file);
|
||||
|
||||
/* Affectation taille */
|
||||
*xsize = image->xsize;
|
||||
*ysize = image->ysize;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void bwtorgba(unsigned char *b,unsigned char *l,int n) {
|
||||
while(n--) {
|
||||
l[0] = *b;
|
||||
l[1] = *b;
|
||||
l[2] = *b;
|
||||
l[3] = 0xff;
|
||||
l += 4; b++;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void rgbtorgba(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] = 0xff;
|
||||
l += 4; r++; g++; b++;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void rgbatorgba(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *a,unsigned char *l,int n) {
|
||||
while(n--) {
|
||||
l[0] = r[0];
|
||||
l[1] = g[0];
|
||||
l[2] = b[0];
|
||||
l[3] = a[0];
|
||||
l += 4; r++; g++; b++; a++;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
unsigned *
|
||||
read_texture(char *name, int *width, int *height, int *components) {
|
||||
unsigned *base, *lptr;
|
||||
unsigned char *rbuf, *gbuf, *bbuf, *abuf;
|
||||
ImageRec *image;
|
||||
int y;
|
||||
|
||||
image = ImageOpen(name);
|
||||
|
||||
if(!image)
|
||||
return NULL;
|
||||
(*width)=image->xsize;
|
||||
(*height)=image->ysize;
|
||||
(*components)=image->zsize;
|
||||
base = new unsigned[image->xsize*image->ysize];
|
||||
rbuf = new unsigned char[image->xsize];
|
||||
gbuf = new unsigned char[image->xsize];
|
||||
bbuf = new unsigned char[image->xsize];
|
||||
abuf = new unsigned char[image->xsize];
|
||||
if(!base || !rbuf || !gbuf || !bbuf)
|
||||
return NULL;
|
||||
lptr = base;
|
||||
for(y=0; y<image->ysize; 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);
|
||||
rgbatorgba(rbuf,gbuf,bbuf,abuf,(unsigned char *)lptr,image->xsize);
|
||||
lptr += image->xsize;
|
||||
} else if(image->zsize==3) {
|
||||
ImageGetRow(image,rbuf,y,0);
|
||||
ImageGetRow(image,gbuf,y,1);
|
||||
ImageGetRow(image,bbuf,y,2);
|
||||
rgbtorgba(rbuf,gbuf,bbuf,(unsigned char *)lptr,image->xsize);
|
||||
lptr += image->xsize;
|
||||
} else {
|
||||
ImageGetRow(image,rbuf,y,0);
|
||||
bwtorgba(rbuf,(unsigned char *)lptr,image->xsize);
|
||||
lptr += image->xsize;
|
||||
}
|
||||
}
|
||||
ImageClose(image);
|
||||
delete [] rbuf;
|
||||
delete [] gbuf;
|
||||
delete [] bbuf;
|
||||
delete [] abuf;
|
||||
|
||||
return (unsigned *) base;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
@ -1,64 +0,0 @@
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
/*
|
||||
* Fonction
|
||||
* ~~~~~~~~
|
||||
* Gestion des images sous OpenGL
|
||||
*
|
||||
*
|
||||
* Attention:
|
||||
* ~~~~~~~~~~~
|
||||
* Ce package a ete teste sur SGI, OSF, SUN, HP et WNT.
|
||||
*
|
||||
*
|
||||
* Historique des modifications
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* 22-05-97: PCT ; creation
|
||||
* 19-06-98: FMN ; Portage Optimizer (C++)
|
||||
* 22-06-98: FGU ; Ajout ReadScaledImage et ReadSizeImage
|
||||
*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _OPENGL_IMAGEBOX_H__
|
||||
#define _OPENGL_IMAGEBOX_H__
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Points d'entree Public du module
|
||||
*/
|
||||
|
||||
unsigned * read_texture(char *name, int *width, int *height, int *components);
|
||||
|
||||
void ReadScaledImage(char *file, int xsize, int ysize, char *buf, unsigned short *zsize);
|
||||
|
||||
void ReadSizeImage(char *, int *, int *);
|
||||
|
||||
void bwtorgba(unsigned char *b,unsigned char *l,int n);
|
||||
|
||||
void rgbtorgba(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n);
|
||||
|
||||
void rgbatorgba(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *a,unsigned char *l,int n);
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#endif /* _OPENGL_IMAGEBOX_H__ */
|
@ -63,7 +63,7 @@
|
||||
* 17-12-97: FMN ; Probleme sur Optimisation sur MyBindTextureEXT()
|
||||
* Le test sur la texture courante doit tenir compte du contexte.
|
||||
* 22-07-98: FGU ; Ajout fonctions TransferTexture_To_Data() et TransferData_To_Texture()
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@ -73,7 +73,6 @@
|
||||
#include <OpenGl_GlCore11.hxx>
|
||||
#include <OpenGl_Display.hxx>
|
||||
#include <OpenGl_TextureBox.hxx>
|
||||
#include <OpenGl_ImageBox.hxx>
|
||||
#include <OpenGl_ResourceTexture.hxx>
|
||||
#include <OpenGl_Context.hxx>
|
||||
|
||||
@ -84,7 +83,7 @@
|
||||
typedef enum {TEXDATA_NONE, TEXDATA_1D, TEXDATA_2D, TEXDATA_2DMM} texDataStatus;
|
||||
typedef enum {TEX_NONE, TEX_ALLOCATED} texStatus;
|
||||
|
||||
typedef GLfloat SizeType[4];
|
||||
typedef GLfloat SizeType[4];
|
||||
|
||||
typedef int TextureDataID;
|
||||
#define TEXTUREDATA_ERROR -1
|
||||
@ -98,7 +97,7 @@ struct texData
|
||||
GLint type;
|
||||
int share_count;
|
||||
DEFINE_STANDARD_ALLOC
|
||||
};
|
||||
};
|
||||
|
||||
struct contextData
|
||||
{
|
||||
@ -232,7 +231,7 @@ static void LoadTexture(TextureID ID)
|
||||
switch (texdata(data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, 4,
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, 4,
|
||||
texdata(data).imageWidth, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
|
||||
break;
|
||||
@ -245,7 +244,7 @@ static void LoadTexture(TextureID ID)
|
||||
|
||||
case TEXDATA_2DMM:
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
|
||||
texdata(data).imageWidth,
|
||||
texdata(data).imageWidth,
|
||||
texdata(data).imageHeight,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
|
||||
break;
|
||||
@ -349,7 +348,7 @@ static void SetTextureParam(TextureID ID)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -403,7 +402,7 @@ static void MyBindTextureEXT (TextureID ID, int Context)
|
||||
if (texdata(data).status == TEXDATA_NONE)
|
||||
return;
|
||||
|
||||
GLenum aParamName = texdata(data).status == TEXDATA_1D ?
|
||||
GLenum aParamName = texdata(data).status == TEXDATA_1D ?
|
||||
GL_TEXTURE_BINDING_1D : GL_TEXTURE_BINDING_2D;
|
||||
|
||||
GLint aCurrTex = -1;
|
||||
@ -429,63 +428,8 @@ static int InstallTextureInContext(TextureID ID)
|
||||
printf("InstallTextureInContext::context ok\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static TextureID GetTexture(char *FileName, texDataStatus status)
|
||||
{
|
||||
TextureDataID i;
|
||||
TextureID j;
|
||||
int dummy;
|
||||
|
||||
/* essait de trouver la texture */
|
||||
i = FindTextureData(FileName);
|
||||
if (i == TEXTUREDATA_ERROR)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTexture::la texture %s n'existe pas => chargement\n", FileName);
|
||||
#endif
|
||||
/* creation d'une texture */
|
||||
i = FindFreeTextureData();
|
||||
if (i == TEXTUREDATA_ERROR) return TEXTUREBOX_ERROR;
|
||||
|
||||
texdata(i).share_count = 0;
|
||||
strcpy(texdata(i).imageFileName, FileName);
|
||||
texdata(i).image = (GLubyte *)read_texture(FileName,
|
||||
&texdata(i).imageWidth,
|
||||
&texdata(i).imageHeight,
|
||||
&dummy);
|
||||
if (texdata(i).image == NULL) return TEXTUREBOX_ERROR;
|
||||
|
||||
texdata(i).status = status;
|
||||
texdata(i).type = status2type[status];
|
||||
}
|
||||
|
||||
j = FindFreeTexture();
|
||||
if (j != TEXTUREBOX_ERROR)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTexture::installation texture pour obj %d\n", j);
|
||||
#endif
|
||||
textab(j).contextdata.Clear();
|
||||
textab(j).data = i;
|
||||
textab(j).status = TEX_ALLOCATED;
|
||||
texdata(i).share_count++;
|
||||
|
||||
SetTextureDefaultParams(j);
|
||||
|
||||
#ifdef PRINT
|
||||
printf("GetTexture::texture %s(%d) texture %d count=%d\n", texdata(i).imageFileName, i, j, texdata(i).share_count);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
if (texdata(i).share_count != 0)
|
||||
delete [] texdata(i).image;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static TextureID GetTextureData(char *FileName, texDataStatus status, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
@ -512,7 +456,7 @@ static TextureID GetTextureData(char *FileName, texDataStatus status, const GLin
|
||||
|
||||
if (texdata(i).image == NULL) return TEXTUREBOX_ERROR;
|
||||
|
||||
texdata(i).status = status;
|
||||
texdata(i).status = status;
|
||||
texdata(i).type = status2type[status];
|
||||
}
|
||||
|
||||
@ -535,14 +479,14 @@ static TextureID GetTextureData(char *FileName, texDataStatus status, const GLin
|
||||
}
|
||||
else
|
||||
if (texdata(i).share_count != 0)
|
||||
delete [] texdata(i).image;
|
||||
delete [] texdata(i).image;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Fonctions publiques
|
||||
* Fonctions publiques
|
||||
*/
|
||||
|
||||
|
||||
@ -553,7 +497,7 @@ GLboolean IsTextureValid(TextureID ID)
|
||||
if ( (ID < 0) || (ID >= textab.Length()) )
|
||||
return GL_FALSE;
|
||||
|
||||
if (textab.Length() > 0)
|
||||
if (textab.Length() > 0)
|
||||
{
|
||||
return textab(ID).status == TEX_ALLOCATED;
|
||||
}
|
||||
@ -565,36 +509,6 @@ GLboolean IsTextureValid(TextureID ID)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTexture1D(char *FileName)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTexture1D::loading 1d %s \n", FileName);
|
||||
#endif
|
||||
return GetTexture(FileName, TEXDATA_1D);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTexture2D(char *FileName)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTexture2D::loading 2d %s \n", FileName);
|
||||
#endif
|
||||
return GetTexture(FileName, TEXDATA_2D);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTexture2DMipMap(char *FileName)
|
||||
{
|
||||
#ifdef PRINT
|
||||
printf("GetTexture2DMipMap::loading 2dmm %s \n", FileName);
|
||||
#endif
|
||||
return GetTexture(FileName, TEXDATA_2DMM);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
TextureID GetTextureData1D(char *FileName, const GLint width, const GLint height, const void *data)
|
||||
{
|
||||
#ifdef PRINT
|
||||
@ -655,7 +569,7 @@ void SetCurrentTexture(TextureID ID)
|
||||
#ifdef PRINT
|
||||
printf("SetCurrentTexture: utilisation du bind %d\n", ID);
|
||||
#endif
|
||||
MyBindTextureEXT(ID, context);
|
||||
MyBindTextureEXT(ID, context);
|
||||
SetTextureParam(ID);
|
||||
}
|
||||
|
||||
@ -710,7 +624,7 @@ void EnableTexture(void)
|
||||
switch (texdata(current_texture_data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
break;
|
||||
@ -733,15 +647,15 @@ void EnableTexture(void)
|
||||
|
||||
void DisableTexture(void)
|
||||
{
|
||||
if ( !IsTextureEnabled() )
|
||||
if ( !IsTextureEnabled() )
|
||||
return;
|
||||
if ( !IsTextureValid( current_texture ) )
|
||||
if ( !IsTextureValid( current_texture ) )
|
||||
return;
|
||||
|
||||
switch (texdata(current_texture_data).status)
|
||||
{
|
||||
case TEXDATA_1D:
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
if (textab(current_texture).Gen != GL_NONE)
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
break;
|
||||
@ -835,7 +749,7 @@ void SetModeSphere(TextureID ID)
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4])
|
||||
{
|
||||
{
|
||||
if (!IsTextureValid(ID)) return;
|
||||
|
||||
textab(ID).Gen = GL_EYE_LINEAR;
|
||||
@ -918,8 +832,8 @@ void SetTextureDefaultParams(TextureID ID)
|
||||
/* Transfere de donnee des donnees internes a la structure TransferData */
|
||||
void TransferTexture_To_Data(TextureID ID, TextureData *TransfDt)
|
||||
{
|
||||
/* affectations */
|
||||
strcpy(TransfDt->path, texdata(textab(ID).data).imageFileName);
|
||||
/* affectations */
|
||||
strcpy(TransfDt->path, texdata(textab(ID).data).imageFileName);
|
||||
TransfDt->gen = textab(ID).Gen;
|
||||
TransfDt->wrap = textab(ID).Wrap;
|
||||
TransfDt->render = textab(ID).Light;
|
||||
@ -927,7 +841,7 @@ void TransferTexture_To_Data(TextureID ID, TextureData *TransfDt)
|
||||
TransfDt->scaley = textab(ID).scaley;
|
||||
TransfDt->transx = textab(ID).transx;
|
||||
TransfDt->transy = textab(ID).transy;
|
||||
TransfDt->angle = textab(ID).angle;
|
||||
TransfDt->angle = textab(ID).angle;
|
||||
memcpy(TransfDt->plane1, textab(ID).Plane1, sizeof(SizeType));
|
||||
memcpy(TransfDt->plane2, textab(ID).Plane2, sizeof(SizeType));
|
||||
memcpy(TransfDt->plane2, textab(ID).Plane2, sizeof(SizeType));
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ typedef int TextureID;
|
||||
struct _TextureData
|
||||
{
|
||||
/* Donnees propre au fichier */
|
||||
char path[256];
|
||||
char path[256];
|
||||
|
||||
/* Donnees propre a la texture */
|
||||
GLint gen;
|
||||
@ -85,16 +85,11 @@ struct _TextureData
|
||||
};
|
||||
typedef _TextureData TextureData;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Gestion des textures
|
||||
*/
|
||||
|
||||
/* Get texture a partir d'un nom de fichier */
|
||||
TextureID GetTexture1D(char *FileName);
|
||||
TextureID GetTexture2D(char *FileName);
|
||||
TextureID GetTexture2DMipMap(char *FileName);
|
||||
|
||||
/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
|
||||
/* Get texture a partir des donnees (format RGBA) GLubyte data[width][height][4]
|
||||
* Le nom est utiliser pour la gesiton en interne, il permet d'eviter de charger
|
||||
* plusieurs textures avec le meme noms.
|
||||
*/
|
||||
@ -113,8 +108,8 @@ void EnableTexture(void);
|
||||
void DisableTexture(void);
|
||||
GLboolean IsTextureEnabled(void);
|
||||
|
||||
/*
|
||||
* Configuration d'une texture
|
||||
/*
|
||||
* Configuration d'une texture
|
||||
*/
|
||||
|
||||
void SetTextureModulate(TextureID ID);
|
||||
|
Loading…
x
Reference in New Issue
Block a user