0022734: Memory allocation error in OpenGl
authordbv <dbv@opencascade.com>
Thu, 29 Mar 2012 15:29:26 +0000 (19:29 +0400)
committerdbv <dbv@opencascade.com>
Thu, 29 Mar 2012 15:29:26 +0000 (19:29 +0400)
src/OpenGl/FILES
src/OpenGl/OpenGl_GraphicDriver_9.cxx
src/OpenGl/OpenGl_GraphicDriver_Layer.cxx
src/OpenGl/OpenGl_ImageBox.cxx
src/OpenGl/OpenGl_Memory.hxx [deleted file]
src/OpenGl/OpenGl_Polygon.cxx
src/OpenGl/OpenGl_Polygon.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_TextureBox.cxx

index 48ecf1d..db20318 100755 (executable)
@@ -100,7 +100,6 @@ OpenGl_TextureBox.cxx
 OpenGl_TextureBox.hxx
 OpenGl_ImageBox.cxx
 OpenGl_ImageBox.hxx
 OpenGl_TextureBox.hxx
 OpenGl_ImageBox.cxx
 OpenGl_ImageBox.hxx
-OpenGl_Memory.hxx
 OpenGl_Resource.hxx
 OpenGl_ResourceVBO.hxx
 OpenGl_ResourceVBO.cxx
 OpenGl_Resource.hxx
 OpenGl_ResourceVBO.hxx
 OpenGl_ResourceVBO.cxx
index 52e90a0..982f9b9 100755 (executable)
@@ -171,7 +171,7 @@ Standard_Integer OpenGl_GraphicDriver::CreateTexture (const Graphic3d_TypeOfText
   TexUpperBounds->SetValue(1, ((Standard_Real) (MyPic->Width())/((Standard_Real) aGlWidth)));
   TexUpperBounds->SetValue(2, ((Standard_Real) (MyPic->Height())/((Standard_Real) aGlHeight)));
 
   TexUpperBounds->SetValue(1, ((Standard_Real) (MyPic->Width())/((Standard_Real) aGlWidth)));
   TexUpperBounds->SetValue(2, ((Standard_Real) (MyPic->Height())/((Standard_Real) aGlHeight)));
 
-  unsigned char *MyImageData = (unsigned char *)malloc(aGlWidth*aGlHeight*4);
+  unsigned char *MyImageData = new unsigned char[aGlWidth*aGlHeight*4];
   unsigned char *MyData = MyImageData;
   int TexId;
   int i,j;
   unsigned char *MyData = MyImageData;
   int TexId;
   int i,j;
@@ -228,7 +228,7 @@ Standard_Integer OpenGl_GraphicDriver::CreateTexture (const Graphic3d_TypeOfText
           TexId = -1;
         }
 
           TexId = -1;
         }
 
-        free(MyImageData);
+        delete [] MyImageData;
         return TexId;
 
 }
         return TexId;
 
 }
index c129e9d..849edec 100755 (executable)
@@ -98,7 +98,7 @@ void InitLayerProp (const int AListId)
 
 void OpenGl_GraphicDriver::Layer (Aspect_CLayer2d& ACLayer)
 {
 
 void OpenGl_GraphicDriver::Layer (Aspect_CLayer2d& ACLayer)
 {
-  ACLayer.ptrLayer = (call_def_ptrLayer) malloc (sizeof (CALL_DEF_PTRLAYER));
+  ACLayer.ptrLayer = new CALL_DEF_PTRLAYER();
   ACLayer.ptrLayer->listIndex = glGenLists(1);
 }
 
   ACLayer.ptrLayer->listIndex = glGenLists(1);
 }
 
index 0bb07ad..09c363c 100755 (executable)
@@ -119,7 +119,7 @@ static ImageRec *ImageOpen(char *fileName)
     swapFlag = 0;
   }
 
     swapFlag = 0;
   }
 
-  image = (ImageRec *)malloc(sizeof(ImageRec));
+  image = new ImageRec();
   if (image == NULL) {
     fprintf(stderr, "Out of memory!\n");
     exit(1);
   if (image == NULL) {
     fprintf(stderr, "Out of memory!\n");
     exit(1);
@@ -135,10 +135,10 @@ static ImageRec *ImageOpen(char *fileName)
     ConvertShort(&image->imagic, 6);
   }
 
     ConvertShort(&image->imagic, 6);
   }
 
-  image->tmp = (unsigned char *)malloc(image->xsize*256);
-  image->tmpR = (unsigned char *)malloc(image->xsize*256);
-  image->tmpG = (unsigned char *)malloc(image->xsize*256);
-  image->tmpB = (unsigned char *)malloc(image->xsize*256);
+  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");
   if (image->tmp == NULL || image->tmpR == NULL || image->tmpG == NULL ||
     image->tmpB == NULL) {
       fprintf(stderr, "Out of memory!\n");
@@ -147,8 +147,8 @@ static ImageRec *ImageOpen(char *fileName)
 
     if ((image->type & 0xFF00) == 0x0100) {
       x = image->ysize * image->zsize * sizeof(unsigned);
 
     if ((image->type & 0xFF00) == 0x0100) {
       x = image->ysize * image->zsize * sizeof(unsigned);
-      image->rowStart = (unsigned *)malloc(x);
-      image->rowSize = (int *)malloc(x);
+      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);
       if (image->rowStart == NULL || image->rowSize == NULL) {
         fprintf(stderr, "Out of memory!\n");
         exit(1);
@@ -169,11 +169,13 @@ static ImageRec *ImageOpen(char *fileName)
 static void
 ImageClose(ImageRec *image) {
   fclose(image->file);
 static void
 ImageClose(ImageRec *image) {
   fclose(image->file);
-  free(image->tmp);
-  free(image->tmpR);
-  free(image->tmpG);
-  free(image->tmpB);
-  free(image);
+  delete [] image->tmp;
+  delete [] image->tmpR;
+  delete [] image->tmpG;
+  delete [] image->tmpB;
+  delete [] image->rowStart;
+  delete [] image->rowSize;
+  delete image;
 }
 /*----------------------------------------------------------------------*/
 
 }
 /*----------------------------------------------------------------------*/
 
@@ -229,11 +231,11 @@ void ReadScaledImage(char *file, int xsize, int ysize, char *buf, unsigned short
   *zsize = image->zsize;
 
   /* Allocation memoire */
   *zsize = image->zsize;
 
   /* Allocation memoire */
-  rbuf=(unsigned char *)malloc(image->xsize * sizeof(unsigned char));
+  rbuf = new unsigned char[image->xsize];
 
   if (image->zsize > 2) {
 
   if (image->zsize > 2) {
-    gbuf = (unsigned char *) malloc (image->xsize * sizeof(unsigned char));
-    bbuf = (unsigned char *) malloc (image->xsize * sizeof(unsigned char));
+    gbuf = new unsigned char[image->xsize];
+    bbuf = new unsigned char[image->xsize];
   }
 
   /* Lecture image rang apres rang */    
   }
 
   /* Lecture image rang apres rang */    
@@ -266,10 +268,10 @@ void ReadScaledImage(char *file, int xsize, int ysize, char *buf, unsigned short
   }
 
   /* delete image buffers */
   }
 
   /* delete image buffers */
-  free(rbuf);
+  delete [] rbuf;
   if (*zsize > 2) {
   if (*zsize > 2) {
-    free(gbuf);
-    free(bbuf);
+    delete [] gbuf;
+    delete [] bbuf;
   }
 
   ImageClose(image);    
   }
 
   ImageClose(image);    
@@ -337,11 +339,11 @@ read_texture(char *name, int *width, int *height, int *components) {
   (*width)=image->xsize;
   (*height)=image->ysize;
   (*components)=image->zsize;
   (*width)=image->xsize;
   (*height)=image->ysize;
   (*components)=image->zsize;
-  base = (unsigned *)malloc(image->xsize*image->ysize*sizeof(unsigned));
-  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));
+  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;
   if(!base || !rbuf || !gbuf || !bbuf)
     return NULL;
   lptr = base;
@@ -366,10 +368,10 @@ read_texture(char *name, int *width, int *height, int *components) {
     }
   }
   ImageClose(image);
     }
   }
   ImageClose(image);
-  free(rbuf);
-  free(gbuf);
-  free(bbuf);
-  free(abuf);
+  delete [] rbuf;
+  delete [] gbuf;
+  delete [] bbuf;
+  delete [] abuf;
 
   return (unsigned *) base;
 }
 
   return (unsigned *) base;
 }
diff --git a/src/OpenGl/OpenGl_Memory.hxx b/src/OpenGl/OpenGl_Memory.hxx
deleted file mode 100755 (executable)
index 801f4a4..0000000
+++ /dev/null
@@ -1,37 +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.
-
-#ifndef OPENGL_MEMORY_H
-#define OPENGL_MEMORY_H
-
-#include <Standard.hxx>
-
-template <class XType> XType *cmn_resizemem( XType *ptr, Tint size )
-{
-  size *= sizeof(XType);
-
-  ptr = (XType*)realloc( ptr, size );
-
-  if ( !ptr ) {
-    fprintf(stderr, "Could not reallocate '%d'\
-                    bytes of memory.\n", size);
-  }
-
-  return ptr;
-}
-
-#endif //OPENGL_MEMORY_H
index 8d445f9..902297f 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <OpenGl_telem_util.hxx>
 #include <OpenGl_TextureBox.hxx>
 
 #include <OpenGl_telem_util.hxx>
 #include <OpenGl_TextureBox.hxx>
-#include <OpenGl_Memory.hxx>
 
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_Structure.hxx>
 
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_Structure.hxx>
@@ -47,20 +46,11 @@ typedef EXTRA_VERTEX* extra_vertex;
 
 struct SEQ_
 {
 
 struct SEQ_
 {
-  Tint ts_num, ts_alloc;
-  void **tmesh_sequence;
+  NCollection_Vector<void *> tmesh_sequence;
   GLenum triangle_type; /* FSXXX OPTI */
   DEFINE_STANDARD_ALLOC
 };
 
   GLenum triangle_type; /* FSXXX OPTI */
   DEFINE_STANDARD_ALLOC
 };
 
-struct OPENGL_DISPLAY_PGN
-{
-  Tint num_of_seq;
-  Tint num_alloc;
-  SEQ_ *seq;
-  DEFINE_STANDARD_ALLOC
-};
-
 static void bgntriangulate( const TEL_POLYGON_DATA *, void (APIENTRY*)() );
 static void endtriangulate(void);
 
 static void bgntriangulate( const TEL_POLYGON_DATA *, void (APIENTRY*)() );
 static void endtriangulate(void);
 
@@ -160,45 +150,22 @@ void OpenGl_Polygon::draw_polygon (const Handle(OpenGl_Workspace) &AWorkspace, T
 
 /* JWR - allow varying the size */
 
 
 /* JWR - allow varying the size */
 
-#define INCREMENT    8
-
-static int seq_increment = INCREMENT;
-
 static const TEL_POLYGON_DATA *DaTa;
 static GLUtesselator *tripak = 0;
 
 STATIC void APIENTRY
 out_bgntmesh( GLenum triangle_type )
 {
 static const TEL_POLYGON_DATA *DaTa;
 static GLUtesselator *tripak = 0;
 
 STATIC void APIENTRY
 out_bgntmesh( GLenum triangle_type )
 {
-  OPENGL_DISPLAY_PGN *dis = DaTa->dsply;
-
-  dis->num_of_seq++;
-  if( dis->num_alloc < dis->num_of_seq )
-  {
-    dis->num_alloc += seq_increment;
-
-    if( dis->seq == 0 )
-    {
-      dis->seq = new SEQ_[dis->num_alloc];
-    }
-    else
-    {
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-      dis->seq = (SEQ_*)realloc( dis->seq, dis->num_alloc*sizeof(SEQ_) );
-#else
-      dis->seq = cmn_resizemem<SEQ_>( dis->seq, dis->num_alloc );
-#endif
-    }
-  }
-  dis->seq[ dis->num_of_seq - 1 ].ts_num = 0;
-  dis->seq[ dis->num_of_seq - 1 ].ts_alloc = 0;
-  dis->seq[ dis->num_of_seq - 1 ].tmesh_sequence = 0;
+  NCollection_Vector<SEQ_> *dis = DaTa->dsply;
 
 
+  SEQ_ aSeq;
 #ifdef JWR_DEC_TRIFAN_BUG
 #ifdef JWR_DEC_TRIFAN_BUG
-  dis->seq[ dis->num_of_seq - 1 ].triangle_type = GL_POLYGON;
+  aSeq.triangle_type = GL_POLYGON;
+  dis->Append(aSeq);
   glBegin(GL_POLYGON);
 #else
   glBegin(GL_POLYGON);
 #else
-  dis->seq[ dis->num_of_seq - 1 ].triangle_type = triangle_type;
+  aSeq.triangle_type = triangle_type;
+  dis->Append(aSeq);
   glBegin(triangle_type);
 #endif
 }
   glBegin(triangle_type);
 #endif
 }
@@ -208,28 +175,9 @@ out_bgntmesh( GLenum triangle_type )
 STATIC void APIENTRY
 out_vert1( void *data )
 {
 STATIC void APIENTRY
 out_vert1( void *data )
 {
-  SEQ_ *s = &( DaTa->dsply->seq[ DaTa->dsply->num_of_seq - 1 ] );
-
-  s->ts_num++;
-  if( s->ts_alloc < s->ts_num )
-  {
-    s->ts_alloc += seq_increment;
-
-    if( s->tmesh_sequence == 0 )
-    {
-      s->tmesh_sequence = new void*[s->ts_alloc];
-    }
-    else
-    {
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-      s->tmesh_sequence = (void**)realloc( s->tmesh_sequence, s->ts_alloc*sizeof(void*));
-#else
-      s->tmesh_sequence = cmn_resizemem<void*>( s->tmesh_sequence, s->ts_alloc);
-#endif
-    }
-  }
-  s->tmesh_sequence[ s->ts_num - 1 ] = data;
+  SEQ_ &s = DaTa->dsply->ChangeValue(DaTa->dsply->Length() - 1);
 
 
+  s.tmesh_sequence.Append(data);
 
   if ( data < (void *)0xffff ) {
     long a = (long)data;
 
   if ( data < (void *)0xffff ) {
     long a = (long)data;
@@ -249,27 +197,9 @@ out_vert1( void *data )
 STATIC void APIENTRY
 out_vert2( void *data )
 {
 STATIC void APIENTRY
 out_vert2( void *data )
 {
-  SEQ_ *s = &( DaTa->dsply->seq[ DaTa->dsply->num_of_seq - 1 ] );
+  SEQ_ &s = DaTa->dsply->ChangeValue(DaTa->dsply->Length() - 1);
 
 
-  s->ts_num++;
-  if( s->ts_alloc < s->ts_num )
-  {
-    s->ts_alloc += seq_increment;
-
-    if( s->tmesh_sequence == 0 )
-    {
-      s->tmesh_sequence = new void*[s->ts_alloc];
-    }
-    else
-    {
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-      s->tmesh_sequence = (void**)( s->tmesh_sequence, s->ts_alloc*sizeof(void*) );
-#else
-      s->tmesh_sequence = cmn_resizemem<void*>( s->tmesh_sequence, s->ts_alloc );
-#endif
-    }
-  }
-  s->tmesh_sequence[ s->ts_num - 1 ] = data;
+  s.tmesh_sequence.Append(data);
 
   if ( data < (void *)0xffff ) {
     long a = (long)data;
 
   if ( data < (void *)0xffff ) {
     long a = (long)data;
@@ -290,27 +220,9 @@ out_vert2( void *data )
 STATIC void APIENTRY
 out_vert3( void *data )
 {
 STATIC void APIENTRY
 out_vert3( void *data )
 {
-  SEQ_ *s = &( DaTa->dsply->seq[ DaTa->dsply->num_of_seq - 1 ] );
+  SEQ_ &s = DaTa->dsply->ChangeValue(DaTa->dsply->Length() - 1);
 
 
-  s->ts_num++;
-  if( s->ts_alloc < s->ts_num )
-  {
-    s->ts_alloc += seq_increment;
-
-    if( s->tmesh_sequence == 0 )
-    {
-      s->tmesh_sequence = new void*[s->ts_alloc];
-    }
-    else
-    {
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-      s->tmesh_sequence = (void**)realloc( s->tmesh_sequence, s->ts_alloc*sizeof(void*) );
-#else
-      s->tmesh_sequence = cmn_resizemem<void*>( s->tmesh_sequence, s->ts_alloc );
-#endif
-    }
-  }
-  s->tmesh_sequence[ s->ts_num - 1 ] = data;
+  s.tmesh_sequence.Append(data);
 
   if ( data <= (void *)0xffff ) {
     long a = (long)data;
 
   if ( data <= (void *)0xffff ) {
     long a = (long)data;
@@ -331,7 +243,7 @@ out_vert3( void *data )
 STATIC void APIENTRY
 mycombine( GLdouble coords[3], int *data, GLfloat w[4], void **dataout)
 {
 STATIC void APIENTRY
 mycombine( GLdouble coords[3], int *data, GLfloat w[4], void **dataout)
 {
-  extra_vertex new_vertex =  (extra_vertex) malloc(sizeof(EXTRA_VERTEX));
+  extra_vertex new_vertex = new EXTRA_VERTEX();
 
   new_vertex->vert[0] = ( float )coords[0];
   new_vertex->vert[1] = ( float )coords[1];
 
   new_vertex->vert[0] = ( float )coords[0];
   new_vertex->vert[1] = ( float )coords[1];
@@ -520,22 +432,22 @@ void OpenGl_Polygon::draw_tmesh ( Tint v ) const
   SEQ_     *s;
   extra_vertex b;
 
   SEQ_     *s;
   extra_vertex b;
 
-  OPENGL_DISPLAY_PGN *dis = myData.dsply;
-  for( i = 0; i < dis->num_of_seq; i++ )
+  NCollection_Vector<SEQ_> *dis = myData.dsply;
+  for( i = 0; i < dis->Length(); i++ )
   {
   {
-    s = &(dis->seq[i]);
+    s = &(dis->ChangeValue(i));
 
     glBegin(s->triangle_type);
     switch( v )
     {
     case 1:
       {
 
     glBegin(s->triangle_type);
     switch( v )
     {
     case 1:
       {
-        for( j = 0, k = 0; j < s->ts_num; j++ )
+        for( j = 0, k = 0; j < s->tmesh_sequence.Length(); j++ )
         {
         {
-          if ( s->tmesh_sequence[j] < (void *)0xffff )
-            glVertex3fv( myData.vertices[ (long)s->tmesh_sequence[ j ] ].xyz );
+          if ( s->tmesh_sequence(j) < (void *)0xffff )
+            glVertex3fv( myData.vertices[ (long)s->tmesh_sequence.Value(j) ].xyz );
           else {
           else {
-            extra_vertex b = (extra_vertex)s->tmesh_sequence[j];
+            b = (extra_vertex) s->tmesh_sequence(j);
             glVertex3fv( b->vert );
           }
 
             glVertex3fv( b->vert );
           }
 
@@ -544,13 +456,13 @@ void OpenGl_Polygon::draw_tmesh ( Tint v ) const
       }
     case 2:
       {
       }
     case 2:
       {
-        for( j = 0, k = 0; j < s->ts_num; j++ )
+        for( j = 0, k = 0; j < s->tmesh_sequence.Length(); j++ )
         {
         {
-          if ( s->tmesh_sequence[j] < (void *)0xffff ) {
-            glColor3fv( myData.vcolours[ (long) s->tmesh_sequence[ j ] ].rgb );
-            glVertex3fv( myData.vertices[ (long) s->tmesh_sequence[ j ] ].xyz );
+          if ( s->tmesh_sequence(j) < (void *)0xffff ) {
+            glColor3fv( myData.vcolours[ (long) s->tmesh_sequence(j) ].rgb );
+            glVertex3fv( myData.vertices[ (long) s->tmesh_sequence(j) ].xyz );
           } else {
           } else {
-            b = (extra_vertex) s->tmesh_sequence[j];
+            b = (extra_vertex) s->tmesh_sequence(j);
             glColor3fv( myData.vcolours[(b->ind)].rgb);
             glVertex3fv( b->vert );
           }
             glColor3fv( myData.vcolours[(b->ind)].rgb);
             glVertex3fv( b->vert );
           }
@@ -559,13 +471,13 @@ void OpenGl_Polygon::draw_tmesh ( Tint v ) const
       }
     case 3:
       {
       }
     case 3:
       {
-        for( j = 0, k = 0; j < s->ts_num; j++ )
+        for( j = 0, k = 0; j < s->tmesh_sequence.Length(); j++ )
         {
         {
-          if ( s->tmesh_sequence[j] < (void *)0xffff ) {
-            glNormal3fv( myData.vnormals[ (long) s->tmesh_sequence[ j ] ].xyz);
-            glVertex3fv( myData.vertices[ (long) s->tmesh_sequence[ j ] ].xyz);
+          if ( s->tmesh_sequence(j) < (void *)0xffff ) {
+            glNormal3fv( myData.vnormals[ (long) s->tmesh_sequence(j) ].xyz);
+            glVertex3fv( myData.vertices[ (long) s->tmesh_sequence(j) ].xyz);
           } else {
           } else {
-            b = (extra_vertex) s->tmesh_sequence[j];
+            b = (extra_vertex) s->tmesh_sequence(j);
             glNormal3fv( myData.vnormals[(b->ind)].xyz);
             glVertex3fv( b->vert );
           }
             glNormal3fv( myData.vnormals[(b->ind)].xyz);
             glVertex3fv( b->vert );
           }
@@ -625,10 +537,7 @@ OpenGl_Polygon::OpenGl_Polygon (const Graphic3d_Array1OfVertex& AListVertex,
   }
 #endif
 
   }
 #endif
 
-  myData.dsply = new OPENGL_DISPLAY_PGN();
-  myData.dsply->num_of_seq = 0;
-  myData.dsply->num_alloc = 0;
-  myData.dsply->seq = NULL;
+  myData.dsply = new NCollection_Vector<SEQ_>();
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -650,17 +559,15 @@ OpenGl_Polygon::~OpenGl_Polygon ()
   {
     Tint i, j;
 
   {
     Tint i, j;
 
-    for( i = 0; i <  myData.dsply->num_of_seq; i++ )
+    for( i = 0; i <  myData.dsply->Length(); i++ )
     {
     {
-      if(myData.dsply->seq[i].tmesh_sequence) {
-        for ( j = 0; j < myData.dsply->seq[i].ts_num ; j++ ) {
-          if ( myData.dsply->seq[i].tmesh_sequence[j] >= (void *)0xffff )
-            free(myData.dsply->seq[i].tmesh_sequence[j]);
-        }
+      for ( j = 0; j < myData.dsply->Value(i).tmesh_sequence.Length() ; j++ )
+      {
+        if ( myData.dsply->Value(i).tmesh_sequence(j) >= (void *)0xffff )
+          delete myData.dsply->Value(i).tmesh_sequence(j);
       }
       }
-      delete[] myData.dsply->seq[i].tmesh_sequence;
     }
     }
-    delete[] myData.dsply->seq;
+
     delete myData.dsply;
   }
 }
     delete myData.dsply;
   }
 }
index 2fd8b1a..b6638a8 100644 (file)
@@ -28,7 +28,9 @@
 
 #include <OpenGl_Element.hxx>
 
 
 #include <OpenGl_Element.hxx>
 
-struct OPENGL_DISPLAY_PGN;
+#include <NCollection_Vector.hxx>
+
+struct SEQ_;
 
 struct TEL_POLYGON_DATA
 {
 
 struct TEL_POLYGON_DATA
 {
@@ -44,7 +46,7 @@ struct TEL_POLYGON_DATA
   tel_colour vcolours;    /* Vertex colour values */
   tel_point  vnormals;    /* Vertex normals */
   tel_texture_coord vtexturecoord; /* Texture Coordinates */
   tel_colour vcolours;    /* Vertex colour values */
   tel_point  vnormals;    /* Vertex normals */
   tel_texture_coord vtexturecoord; /* Texture Coordinates */
-  OPENGL_DISPLAY_PGN *dsply;
+  NCollection_Vector<SEQ_> *dsply;
   DEFINE_STANDARD_ALLOC
 };
 
   DEFINE_STANDARD_ALLOC
 };
 
index f1d6d8e..893a7bb 100755 (executable)
@@ -25,7 +25,6 @@
 
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_GraphicDriver.hxx>
 
 #include <OpenGl_AspectFace.hxx>
 #include <OpenGl_GraphicDriver.hxx>
-#include <OpenGl_Memory.hxx>
 #include <OpenGl_ResourceCleaner.hxx>
 #include <OpenGl_ResourceVBO.hxx>
 #include <OpenGl_Structure.hxx>
 #include <OpenGl_ResourceCleaner.hxx>
 #include <OpenGl_ResourceVBO.hxx>
 #include <OpenGl_Structure.hxx>
index fec36cb..0bc7cc0 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <OpenGl_GlCore11.hxx>
 #include <OpenGl_Text.hxx>
 
 #include <OpenGl_GlCore11.hxx>
 #include <OpenGl_Text.hxx>
-#include <OpenGl_Memory.hxx>
 #include <OpenGl_AspectText.hxx>
 #include <OpenGl_Structure.hxx>
 
 #include <OpenGl_AspectText.hxx>
 #include <OpenGl_Structure.hxx>
 
index cc96690..d9ca2cf 100755 (executable)
 #include <OpenGl_Display.hxx>
 #include <OpenGl_TextureBox.hxx>
 #include <OpenGl_ImageBox.hxx>
 #include <OpenGl_Display.hxx>
 #include <OpenGl_TextureBox.hxx>
 #include <OpenGl_ImageBox.hxx>
-#include <OpenGl_Memory.hxx>
 #include <OpenGl_ResourceCleaner.hxx>
 #include <OpenGl_ResourceTexture.hxx>
 
 #include <GL/glu.h> // gluBuild2DMipmaps()
 
 #include <OpenGl_ResourceCleaner.hxx>
 #include <OpenGl_ResourceTexture.hxx>
 
 #include <GL/glu.h> // gluBuild2DMipmaps()
 
-#define GROW_TEXTURES 8
-#define GROW_TEXTURES_DATA 8
-#define GROW_CONTEXT 8
+#include <NCollection_Vector.hxx>
 
 typedef enum {TEXDATA_NONE, TEXDATA_1D, TEXDATA_2D, TEXDATA_2DMM} texDataStatus;
 typedef enum {TEX_NONE, TEX_ALLOCATED} texStatus;
 
 typedef enum {TEXDATA_NONE, TEXDATA_1D, TEXDATA_2D, TEXDATA_2DMM} texDataStatus;
 typedef enum {TEX_NONE, TEX_ALLOCATED} texStatus;
@@ -103,16 +100,18 @@ struct texData
   DEFINE_STANDARD_ALLOC
 };  
 
   DEFINE_STANDARD_ALLOC
 };  
 
+struct contextData
+{
+  GLuint number;
+  GLDRAWABLE drawable;
+  GLCONTEXT context;
+  char use_bind_texture;
+};
 
 struct texDraw
 {
   TextureDataID data;
 
 struct texDraw
 {
   TextureDataID data;
-  GLuint *number;
-  GLDRAWABLE *drawable;
-  GLCONTEXT *context;
-  char *use_bind_texture;
-  int context_count;
-  int context_size;  
+  NCollection_Vector<contextData> contextdata;
   texStatus status;
 
   GLint Gen;
   texStatus status;
 
   GLint Gen;
@@ -134,13 +133,9 @@ struct texDraw
 * Variables statiques
 */
 
 * Variables statiques
 */
 
-static texDraw *textab = NULL;
-static int textures_count = 0;
-static int textures_size = 0;
+static NCollection_Vector<texDraw> textab;
 
 
-static texData *texdata = NULL;
-static int textures_data_count = 0;
-static int textures_data_size = 0;
+static NCollection_Vector<texData> texdata;
 
 static TextureDataID current_texture_data = TEXTUREDATA_ERROR;
 static TextureID current_texture = TEXTUREBOX_ERROR;
 
 static TextureDataID current_texture_data = TEXTUREDATA_ERROR;
 static TextureID current_texture = TEXTUREBOX_ERROR;
@@ -161,11 +156,13 @@ static GLenum status2type[] = { GL_NONE, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTUR
 */
 static TextureDataID FindTextureData(char *FileName)
 {
 */
 static TextureDataID FindTextureData(char *FileName)
 {
-  int i;
-
-  for (i=0; i<textures_data_size; i++)
-    if ( texdata[i].status!=TEXDATA_NONE && strcmp(FileName, texdata[i].imageFileName)==0 )
+  for (int i = 0; i < texdata.Length(); i++)
+  {
+    if ( texdata(i).status != TEXDATA_NONE && strcmp(FileName, texdata(i).imageFileName) == 0 )
+    {
       return i;
       return i;
+    }
+  }
 
   return TEXTUREDATA_ERROR;
 }
 
   return TEXTUREDATA_ERROR;
 }
@@ -176,35 +173,17 @@ static TextureDataID FindTextureData(char *FileName)
 */
 static TextureDataID FindFreeTextureData(void)
 {
 */
 static TextureDataID FindFreeTextureData(void)
 {
-  int i;
-
-  /* ya encore de la place ? */
-  if (textures_data_count == textures_data_size)
+  for (int i = 0; i < texdata.Length(); i++)
   {
   {
-    textures_data_size += GROW_TEXTURES_DATA;
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-    texdata = (texData*)realloc(texdata, textures_data_size*sizeof(texData));
-#else
-    texdata = cmn_resizemem<texData>(texdata, textures_data_size);
-#endif
-    if (texdata == NULL) return TEXTUREDATA_ERROR;
-
-    for (i=textures_data_count; i<textures_data_size; i++)
-      texdata[i].status = TEXDATA_NONE;
-
-    /* on a deja assez perdu de temps comme ca => retourne un ID rapidement... */
-    return textures_data_count++;
-  }
-
-  /* recherche d'un ID libre */
-  for (i=0; i<textures_data_size; i++)
-    if (texdata[i].status == TEXDATA_NONE)
+    if (texdata(i).status == TEXDATA_NONE)
     {
     {
-      textures_data_count = Max (textures_data_count, i + 1);
       return i;
     }
       return i;
     }
+  }
 
 
-    return TEXTUREDATA_ERROR;
+  texData aTexData;
+  texdata.Append(aTexData);
+  return texdata.Length() - 1;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -213,34 +192,17 @@ static TextureDataID FindFreeTextureData(void)
 */
 static TextureID FindFreeTexture(void)
 {
 */
 static TextureID FindFreeTexture(void)
 {
-  int i;
-
-  /* ya encore de la place ? */
-  if (textures_count == textures_size)
+  for (int i = 0; i < textab.Length(); i++)
   {
   {
-    textures_size += GROW_TEXTURES;
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-    textab = (texDraw*)realloc(textab, textures_size*sizeof(texDraw));
-#else
-    textab = cmn_resizemem<texDraw>(textab, textures_size);
-#endif
-    if (textab == NULL) return TEXTUREBOX_ERROR;
-
-    for (i=textures_count; i<textures_size; i++)
-      textab[i].status = TEX_NONE;
-
-    /* on a deja assez perdu de temps comme ca => retourne un ID rapidement... */
-    return textures_count++;
-  }
-
-  for (i=0; i<textures_size; i++)
-    if (textab[i].status == TEX_NONE)
+    if (textab(i).status == TEX_NONE)
     {
     {
-      textures_count = Max (textures_count, i + 1);
       return i;
     }
       return i;
     }
+  }
 
 
-    return TEXTUREBOX_ERROR;
+  texDraw aTexDraw;
+  textab.Append(aTexDraw);
+  return textab.Length() - 1;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -252,8 +214,8 @@ static int FindTextureContext(TextureID ID)
   int i;
 
   GLCONTEXT cur = GET_GL_CONTEXT();
   int i;
 
   GLCONTEXT cur = GET_GL_CONTEXT();
-  for (i=0; i<textab[ID].context_count; i++)
-    if (textab[ID].context[i] == cur)
+  for (i=0; i<textab(ID).contextdata.Length(); i++)
+    if (textab(ID).contextdata(i).context == cur)
       return i;
 
   return TEXTUREBOX_ERROR;
       return i;
 
   return TEXTUREBOX_ERROR;
@@ -267,26 +229,26 @@ static void LoadTexture(TextureID ID)
 {
   TextureDataID data;
 
 {
   TextureDataID data;
 
-  data = textab[ID].data;
-  switch (texdata[data].status)
+  data = textab(ID).data;
+  switch (texdata(data).status)
   {
   case TEXDATA_1D:
     glTexImage1D(GL_TEXTURE_1D, 0, 4, 
   {
   case TEXDATA_1D:
     glTexImage1D(GL_TEXTURE_1D, 0, 4, 
-      texdata[data].imageWidth, 0,
-      GL_RGBA, GL_UNSIGNED_BYTE, texdata[data].image);
+      texdata(data).imageWidth, 0,
+      GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
     break;
 
   case TEXDATA_2D:
     glTexImage2D(GL_TEXTURE_2D, 0, 4,
     break;
 
   case TEXDATA_2D:
     glTexImage2D(GL_TEXTURE_2D, 0, 4,
-      texdata[data].imageWidth, texdata[data].imageHeight, 0,
-      GL_RGBA, GL_UNSIGNED_BYTE, texdata[data].image);
+      texdata(data).imageWidth, texdata(data).imageHeight, 0,
+      GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
     break;
 
   case TEXDATA_2DMM:
     gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
     break;
 
   case TEXDATA_2DMM:
     gluBuild2DMipmaps(GL_TEXTURE_2D, 4,
-      texdata[data].imageWidth, 
-      texdata[data].imageHeight,
-      GL_RGBA, GL_UNSIGNED_BYTE, texdata[data].image);
+      texdata(data).imageWidth, 
+      texdata(data).imageHeight,
+      GL_RGBA, GL_UNSIGNED_BYTE, texdata(data).image);
     break;
   default:
     break;
     break;
   default:
     break;
@@ -304,7 +266,7 @@ static void SetTextureParam(TextureID ID)
   TextureDataID data;
 
 
   TextureDataID data;
 
 
-  data = textab[ID].data;
+  data = textab(ID).data;
   glGetIntegerv(GL_MATRIX_MODE, &cur_matrix);
 
   /*
   glGetIntegerv(GL_MATRIX_MODE, &cur_matrix);
 
   /*
@@ -312,32 +274,32 @@ static void SetTextureParam(TextureID ID)
   */
   glMatrixMode(GL_TEXTURE);
   glLoadIdentity();
   */
   glMatrixMode(GL_TEXTURE);
   glLoadIdentity();
-  /* if (textab[ID].Gen != GL_SPHERE_MAP)
+  /* if (textab(ID).Gen != GL_SPHERE_MAP)
   {*/
   {*/
-  glScalef(textab[ID].scalex, textab[ID].scaley, 1.0);
-  glTranslatef(-textab[ID].transx, -textab[ID].transy, 0.0);
-  glRotatef(-textab[ID].angle, 0.0, 0.0, 1.0);
+  glScalef(textab(ID).scalex, textab(ID).scaley, 1.0);
+  glTranslatef(-textab(ID).transx, -textab(ID).transy, 0.0);
+  glRotatef(-textab(ID).angle, 0.0, 0.0, 1.0);
   /*}*/
 
 
   /*
   * GENERATION AUTOMATIQUE DE TEXTURE
   */
   /*}*/
 
 
   /*
   * GENERATION AUTOMATIQUE DE TEXTURE
   */
-  switch (textab[ID].Gen)
+  switch (textab(ID).Gen)
   {
   case GL_OBJECT_LINEAR:
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
   {
   case GL_OBJECT_LINEAR:
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-    glTexGenfv(GL_S, GL_OBJECT_PLANE, textab[ID].Plane1);
-    if (texdata[data].status != TEXDATA_1D)
+    glTexGenfv(GL_S, GL_OBJECT_PLANE, textab(ID).Plane1);
+    if (texdata(data).status != TEXDATA_1D)
     {
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
     {
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-      glTexGenfv(GL_T, GL_OBJECT_PLANE, textab[ID].Plane2);
+      glTexGenfv(GL_T, GL_OBJECT_PLANE, textab(ID).Plane2);
     }
     break;
 
   case GL_SPHERE_MAP:
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     }
     break;
 
   case GL_SPHERE_MAP:
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
-    if (texdata[data].status != TEXDATA_1D)
+    if (texdata(data).status != TEXDATA_1D)
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     break;
 
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
     break;
 
@@ -347,12 +309,12 @@ static void SetTextureParam(TextureID ID)
     glLoadIdentity();
 
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
     glLoadIdentity();
 
     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
-    glTexGenfv(GL_S, GL_EYE_PLANE, textab[ID].Plane1);
+    glTexGenfv(GL_S, GL_EYE_PLANE, textab(ID).Plane1);
 
 
-    if (texdata[data].status != TEXDATA_1D)
+    if (texdata(data).status != TEXDATA_1D)
     {
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
     {
       glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
-      glTexGenfv(GL_T, GL_EYE_PLANE, textab[ID].Plane2);
+      glTexGenfv(GL_T, GL_EYE_PLANE, textab(ID).Plane2);
     }
 
     glPopMatrix();
     }
 
     glPopMatrix();
@@ -363,22 +325,22 @@ static void SetTextureParam(TextureID ID)
   /*
   * RENDU DE LA TEXTURE AVEC LES LUMIERES
   */
   /*
   * RENDU DE LA TEXTURE AVEC LES LUMIERES
   */
-  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textab[ID].Light);
+  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textab(ID).Light);
 
 
   /*
   * LISSAGE DE LA TEXTURE
   */
 
 
   /*
   * LISSAGE DE LA TEXTURE
   */
-  switch (texdata[data].status)
+  switch (texdata(data).status)
   {
   case TEXDATA_1D:
   case TEXDATA_2D:
   {
   case TEXDATA_1D:
   case TEXDATA_2D:
-    glTexParameteri(texdata[data].type, GL_TEXTURE_MAG_FILTER, textab[ID].Render);
-    glTexParameteri(texdata[data].type, GL_TEXTURE_MIN_FILTER, textab[ID].Render);
+    glTexParameteri(texdata(data).type, GL_TEXTURE_MAG_FILTER, textab(ID).Render);
+    glTexParameteri(texdata(data).type, GL_TEXTURE_MIN_FILTER, textab(ID).Render);
     break;
 
   case TEXDATA_2DMM:
     break;
 
   case TEXDATA_2DMM:
-    if (textab[ID].Render == GL_NEAREST)
+    if (textab(ID).Render == GL_NEAREST)
     {
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
     {
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
@@ -397,16 +359,16 @@ static void SetTextureParam(TextureID ID)
   /*
   * WRAP DE LA TEXTURE
   */
   /*
   * WRAP DE LA TEXTURE
   */
-  switch (texdata[data].status)
+  switch (texdata(data).status)
   {
   case TEXDATA_1D:
   {
   case TEXDATA_1D:
-    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, textab[ID].Wrap);
+    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, textab(ID).Wrap);
     break;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
     break;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textab[ID].Wrap);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textab[ID].Wrap);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, textab(ID).Wrap);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, textab(ID).Wrap);
     break;
   default:
     break;
     break;
   default:
     break;
@@ -421,16 +383,16 @@ static void SetTextureParam(TextureID ID)
 */
 static void MyGenTextureEXT (TextureID ID)
 {
 */
 static void MyGenTextureEXT (TextureID ID)
 {
-  int Context = textab[ID].context_count;
-  TextureDataID data = textab[ID].data;
-
-  textab[ID].context[Context]  = GET_GL_CONTEXT();
-  textab[ID].drawable[Context] = GET_GLDEV_CONTEXT();
-  textab[ID].use_bind_texture[Context] = (char )GL_TRUE;
-  glGenTextures (1, &textab[ID].number[Context]);
-  glBindTexture (texdata[data].type, textab[ID].number[Context]);
+  TextureDataID data = textab(ID).data;
+  contextData aContextData;
+
+  aContextData.context = GET_GL_CONTEXT();
+  aContextData.drawable = GET_GLDEV_CONTEXT();
+  aContextData.use_bind_texture = (char )GL_TRUE;
+  glGenTextures (1, &aContextData.number);
+  textab(ID).contextdata.Append(aContextData);
+  glBindTexture (texdata(data).type, aContextData.number);
   LoadTexture (ID);
   LoadTexture (ID);
-  textab[ID].context_count++;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -439,18 +401,18 @@ static void MyGenTextureEXT (TextureID ID)
 */
 static void MyBindTextureEXT (TextureID ID, int Context)
 {
 */
 static void MyBindTextureEXT (TextureID ID, int Context)
 {
-  TextureDataID data = textab[ID].data;
-  if (texdata[data].status == TEXDATA_NONE)
+  TextureDataID data = textab(ID).data;
+  if (texdata(data).status == TEXDATA_NONE)
     return;
 
     return;
 
-  GLenum aParamName = texdata[data].status == TEXDATA_1D ? 
-       GL_TEXTURE_BINDING_1D : GL_TEXTURE_BINDING_2D;
+  GLenum aParamName = texdata(data).status == TEXDATA_1D ? 
+  GL_TEXTURE_BINDING_1D : GL_TEXTURE_BINDING_2D;
 
   GLint aCurrTex = -1;
   glGetIntegerv (aParamName, &aCurrTex);
 
   GLint aCurrTex = -1;
   glGetIntegerv (aParamName, &aCurrTex);
-  if (textab[ID].number[Context] != aCurrTex)
+  if (textab(ID).contextdata(Context).number != aCurrTex)
   {
   {
-    glBindTexture (texdata[data].type, textab[ID].number[Context]);
+    glBindTexture (texdata(data).type, textab(ID).contextdata(Context).number);
   }
 }
 
   }
 }
 
@@ -463,50 +425,6 @@ static int InstallTextureInContext(TextureID ID)
 #ifdef PRINT
   printf("InstallTextureInContext::installation de la texture dans le context\n");
 #endif
 #ifdef PRINT
   printf("InstallTextureInContext::installation de la texture dans le context\n");
 #endif
-
-
-  /* ya encore de la place dans le tableau de context ? */
-  if (textab[ID].context_count == textab[ID].context_size)
-  {
-#ifdef PRINT
-    printf("InstallTextureInContext::allocation dans le context\n");
-#endif
-    textab[ID].context_size += GROW_CONTEXT;
-#if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530)
-    textab[ID].number =
-      (GLuint*)realloc(textab[ID].number, textab[ID].context_size*sizeof(GLuint));
-    textab[ID].context =
-      (GLCONTEXT*)realloc(textab[ID].context, textab[ID].context_size*sizeof(GLCONTEXT));
-    textab[ID].drawable =
-      (GLDRAWABLE*)realloc(textab[ID].drawable, textab[ID].context_size*sizeof(GLDRAWABLE));
-    textab[ID].use_bind_texture =
-      (char*)realloc(textab[ID].use_bind_texture, textab[ID].context_size);
-#else
-    textab[ID].number =
-      cmn_resizemem<GLuint>(textab[ID].number, textab[ID].context_size);
-    textab[ID].context =
-      cmn_resizemem<GLCONTEXT>(textab[ID].context, textab[ID].context_size);
-    textab[ID].drawable =
-      cmn_resizemem<GLDRAWABLE>(textab[ID].drawable, textab[ID].context_size);
-    textab[ID].use_bind_texture =
-      cmn_resizemem<char>(textab[ID].use_bind_texture, textab[ID].context_size);
-#endif
-    if ( (textab[ID].number == NULL) ||
-      (textab[ID].context == NULL) ||
-      (textab[ID].drawable == NULL) ||
-      (textab[ID].use_bind_texture == NULL) )
-    {
-      /* erreur => libere tout */
-      free(textab[ID].number);
-      free(textab[ID].context);
-      free(textab[ID].drawable);
-      free(textab[ID].use_bind_texture);
-      textab[ID].context_size = 0;
-
-      return TEXTUREBOX_ERROR;
-    }
-  }
-
   MyGenTextureEXT(ID);
   SetTextureParam(ID);
 #ifdef PRINT
   MyGenTextureEXT(ID);
   SetTextureParam(ID);
 #ifdef PRINT
@@ -533,16 +451,16 @@ static TextureID GetTexture(char *FileName, texDataStatus status)
     i = FindFreeTextureData();
     if (i == TEXTUREDATA_ERROR) return TEXTUREBOX_ERROR;
 
     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,
+    texdata(i).share_count = 0;
+    strcpy(texdata(i).imageFileName, FileName);
+    texdata(i).image = (GLubyte *)read_texture(FileName, 
+      &texdata(i).imageWidth,
+      &texdata(i).imageHeight,
       &dummy);
       &dummy);
-    if (texdata[i].image == NULL) return TEXTUREBOX_ERROR;
+    if (texdata(i).image == NULL) return TEXTUREBOX_ERROR;
 
 
-    texdata[i].status = status;            
-    texdata[i].type = status2type[status];
+    texdata(i).status = status;            
+    texdata(i).type = status2type[status];
   }
 
   j = FindFreeTexture();
   }
 
   j = FindFreeTexture();
@@ -551,25 +469,20 @@ static TextureID GetTexture(char *FileName, texDataStatus status)
 #ifdef PRINT
     printf("GetTexture::installation texture pour obj %d\n", j);
 #endif
 #ifdef PRINT
     printf("GetTexture::installation texture pour obj %d\n", j);
 #endif
-    textab[j].context_count = 0;
-    textab[j].context_size = 0;
-    textab[j].number = NULL;
-    textab[j].drawable = NULL;
-    textab[j].context = NULL;
-    textab[j].use_bind_texture = NULL;
-    textab[j].data = i;
-    textab[j].status = TEX_ALLOCATED;
-    texdata[i].share_count++;
+    textab(j).contextdata.Clear();
+    textab(j).data = i;
+    textab(j).status = TEX_ALLOCATED;
+    texdata(i).share_count++;
 
     SetTextureDefaultParams(j);
 
 #ifdef PRINT
 
     SetTextureDefaultParams(j);
 
 #ifdef PRINT
-    printf("GetTexture::texture %s(%d)    texture %d   count=%d\n", texdata[i].imageFileName, i, j, texdata[i].share_count);
+    printf("GetTexture::texture %s(%d)    texture %d   count=%d\n", texdata(i).imageFileName, i, j, texdata(i).share_count);
 #endif
   }
   else
 #endif
   }
   else
-    if (texdata[i].share_count != 0)
-      free(texdata[i].image);  
+    if (texdata(i).share_count != 0)
+      delete [] texdata(i).image;  
 
   return j;
 }
 
   return j;
 }
@@ -592,17 +505,17 @@ static TextureID GetTextureData(char *FileName, texDataStatus status, const GLin
     i = FindFreeTextureData();
     if (i == TEXTUREDATA_ERROR) return TEXTUREBOX_ERROR;
 
     i = FindFreeTextureData();
     if (i == TEXTUREDATA_ERROR) return TEXTUREBOX_ERROR;
 
-    texdata[i].share_count = 0;
-    strcpy(texdata[i].imageFileName, FileName);
-    texdata[i].image = (GLubyte *)malloc(width*height*4*sizeof(GLubyte));
-    memcpy(texdata[i].image, data, (width*height*4));
-    texdata[i].imageWidth = width;
-    texdata[i].imageHeight = height;
+    texdata(i).share_count = 0;
+    strcpy(texdata(i).imageFileName, FileName);
+    texdata(i).image = new GLubyte[width*height*4];
+    memcpy(texdata(i).image, data, (width*height*4));
+    texdata(i).imageWidth = width;
+    texdata(i).imageHeight = height;
 
 
-    if (texdata[i].image == NULL) return TEXTUREBOX_ERROR;
+    if (texdata(i).image == NULL) return TEXTUREBOX_ERROR;
 
 
-    texdata[i].status = status;            
-    texdata[i].type = status2type[status];
+    texdata(i).status = status;            
+    texdata(i).type = status2type[status];
   }
 
   j = FindFreeTexture();
   }
 
   j = FindFreeTexture();
@@ -611,25 +524,20 @@ static TextureID GetTextureData(char *FileName, texDataStatus status, const GLin
 #ifdef PRINT
     printf("GetTextureData::installation texture pour obj %d\n", j);
 #endif
 #ifdef PRINT
     printf("GetTextureData::installation texture pour obj %d\n", j);
 #endif
-    textab[j].context_count = 0;
-    textab[j].context_size = 0;
-    textab[j].number = NULL;
-    textab[j].drawable = NULL;
-    textab[j].context = NULL;
-    textab[j].use_bind_texture = NULL;
-    textab[j].data = i;
-    textab[j].status = TEX_ALLOCATED;
-    texdata[i].share_count++;
+    textab(j).contextdata.Clear();
+    textab(j).data = i;
+    textab(j).status = TEX_ALLOCATED;
+    texdata(i).share_count++;
 
     SetTextureDefaultParams(j);
 
 #ifdef PRINT
 
     SetTextureDefaultParams(j);
 
 #ifdef PRINT
-    printf("GetTextureData::texture %s(%d)    texture %d   count=%d\n", texdata[i].imageFileName, i, j, texdata[i].share_count);
+    printf("GetTextureData::texture %s(%d)    texture %d   count=%d\n", texdata(i).imageFileName, i, j, texdata(i).share_count);
 #endif
   }
   else
 #endif
   }
   else
-    if (texdata[i].share_count != 0)
-      free(texdata[i].image);  
+    if (texdata(i).share_count != 0)
+      delete [] texdata(i).image;  
 
   return j;
 }
 
   return j;
 }
@@ -644,13 +552,17 @@ static TextureID GetTextureData(char *FileName, texDataStatus status, const GLin
 
 GLboolean IsTextureValid(TextureID ID)
 {
 
 GLboolean IsTextureValid(TextureID ID)
 {
-  if ((ID<0) | (ID>=textures_count))
+  if ( (ID < 0) || (ID >= textab.Length()) )
     return GL_FALSE;
 
     return GL_FALSE;
 
-  if (textab)
-    return textab[ID].status == TEX_ALLOCATED;
+  if (textab.Length() > 0) 
+  {
+    return textab(ID).status == TEX_ALLOCATED;
+  }
   else
   else
-    return GL_TRUE;
+  {
+    return GL_FALSE;
+  }
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -750,7 +662,7 @@ void SetCurrentTexture(TextureID ID)
   }
 
   current_texture = ID;
   }
 
   current_texture = ID;
-  current_texture_data = textab[ID].data;
+  current_texture_data = textab(ID).data;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -766,34 +678,34 @@ void FreeTexture(TextureID ID)
 
   if (!IsTextureValid(ID)) return;
 
 
   if (!IsTextureValid(ID)) return;
 
-  data = textab[ID].data;
-  texdata[data].share_count--;
-  if (texdata[data].share_count == 0)
+  data = textab(ID).data;
+  texdata(data).share_count--;
+  if (texdata(data).share_count == 0)
   {      
     // liberation des datas de la textures
   {      
     // liberation des datas de la textures
-    free(texdata[data].image);
+   delete [] texdata(data).image;
 
     // liberation de la texture dans tous les contextes
     cur_drawable = GET_GLDEV_CONTEXT();
 
     // liberation de la texture dans tous les contextes
     cur_drawable = GET_GLDEV_CONTEXT();
-    for (i = 0; i < textab[ID].context_count; ++i)
+    for (i = 0; i < textab(ID).contextdata.Length(); ++i)
     {
       cur_context = 0;
       bool isResource = false; 
 
     {
       cur_context = 0;
       bool isResource = false; 
 
-      if (textab[ID].use_bind_texture[i])
+      if (textab(ID).contextdata(i).use_bind_texture)
       {
       {
-        if( !OpenGl_ResourceCleaner::GetInstance()->AddResource(textab[ID].context[i]
-                     new OpenGl_ResourceTexture(textab[ID].number[i])) )
+        if( !OpenGl_ResourceCleaner::GetInstance()->AddResource(textab(ID).contextdata(i).context
+            new OpenGl_ResourceTexture(textab(ID).contextdata(i).number)) )
         {
           GL_MAKE_CURRENT((openglDisplay.IsNull() ? (Display* )NULL : (Display* )openglDisplay->GetDisplay()),
         {
           GL_MAKE_CURRENT((openglDisplay.IsNull() ? (Display* )NULL : (Display* )openglDisplay->GetDisplay()),
-            textab[ID].drawable[i],
-            textab[ID].context[i]);
+            textab(ID).contextdata(i).drawable,
+            textab(ID).contextdata(i).context);
 
           // This check has been added to avoid exception, 
           // which is raised when trying to delete textures when no rendering context is available
           cur_context = GET_GL_CONTEXT();
           if (cur_context)
 
           // This check has been added to avoid exception, 
           // which is raised when trying to delete textures when no rendering context is available
           cur_context = GET_GL_CONTEXT();
           if (cur_context)
-            glDeleteTextures (1, &textab[ID].number[i]);
+            glDeleteTextures (1, &textab(ID).contextdata(i).number);
           notResource = true;
         }
         else
           notResource = true;
         }
         else
@@ -810,23 +722,12 @@ void FreeTexture(TextureID ID)
       GL_MAKE_CURRENT((openglDisplay.IsNull() ? (Display* )NULL : (Display* )openglDisplay->GetDisplay()),
                       cur_drawable, cur_context);
 
       GL_MAKE_CURRENT((openglDisplay.IsNull() ? (Display* )NULL : (Display* )openglDisplay->GetDisplay()),
                       cur_drawable, cur_context);
 
-    texdata[data].status = TEXDATA_NONE;
-    if (data + 1 == textures_data_count)
-    {
-      --textures_data_count;
-    }
+    texdata(data).status = TEXDATA_NONE;
 
 
-    free(textab[ID].context);
-    free(textab[ID].drawable);
-    free(textab[ID].use_bind_texture);
-    free(textab[ID].number);
+    textab(ID).contextdata.Clear();
   }
 
   }
 
-  textab[ID].status = TEX_NONE;
-  if (ID + 1 == textures_count)
-  {
-    --textures_count;
-  }
+  textab(ID).status = TEX_NONE;
 
   current_texture_data = TEXTUREDATA_ERROR;
 }
 
   current_texture_data = TEXTUREDATA_ERROR;
 }
@@ -837,17 +738,17 @@ void EnableTexture(void)
 {
   if (!IsTextureValid(current_texture)) return;
 
 {
   if (!IsTextureValid(current_texture)) return;
 
-  switch (texdata[current_texture_data].status)
+  switch (texdata(current_texture_data).status)
   {
   case TEXDATA_1D:
   {
   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;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
       glEnable(GL_TEXTURE_GEN_S);
     glEnable(GL_TEXTURE_1D);
     break;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
-    if (textab[current_texture].Gen != GL_NONE)
+    if (textab(current_texture).Gen != GL_NONE)
     {
       glEnable(GL_TEXTURE_GEN_S);
       glEnable(GL_TEXTURE_GEN_T);
     {
       glEnable(GL_TEXTURE_GEN_S);
       glEnable(GL_TEXTURE_GEN_T);
@@ -868,17 +769,17 @@ void DisableTexture(void)
   if ( !IsTextureValid( current_texture ) ) 
     return;
 
   if ( !IsTextureValid( current_texture ) ) 
     return;
 
-  switch (texdata[current_texture_data].status)
+  switch (texdata(current_texture_data).status)
   {
   case TEXDATA_1D:
   {
   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;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
       glDisable(GL_TEXTURE_GEN_S);
     glDisable(GL_TEXTURE_1D);
     break;
 
   case TEXDATA_2D:
   case TEXDATA_2DMM:
-    if (textab[current_texture].Gen != GL_NONE)
+    if (textab(current_texture).Gen != GL_NONE)
     {
       glDisable(GL_TEXTURE_GEN_S);
       glDisable(GL_TEXTURE_GEN_T);
     {
       glDisable(GL_TEXTURE_GEN_S);
       glDisable(GL_TEXTURE_GEN_T);
@@ -906,7 +807,7 @@ void SetTextureModulate(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Light = GL_MODULATE;
+  textab(ID).Light = GL_MODULATE;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -915,7 +816,7 @@ void SetTextureDecal(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Light = GL_DECAL;
+  textab(ID).Light = GL_DECAL;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -924,7 +825,7 @@ void SetTextureClamp(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Wrap = GL_CLAMP;
+  textab(ID).Wrap = GL_CLAMP;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -933,7 +834,7 @@ void SetTextureRepeat(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Wrap = GL_REPEAT;
+  textab(ID).Wrap = GL_REPEAT;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -943,13 +844,13 @@ void SetModeObject(TextureID ID, const GLfloat sparams[4], const GLfloat tparams
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Gen = GL_OBJECT_LINEAR;
-  if (sparams != NULL) memcpy(textab[ID].Plane1, sparams, sizeof(sgenparams));
-  else                 memcpy(textab[ID].Plane1, sgenparams, sizeof(sgenparams));
+  textab(ID).Gen = GL_OBJECT_LINEAR;
+  if (sparams != NULL) memcpy(textab(ID).Plane1, sparams, sizeof(sgenparams));
+  else                 memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
 
 
-  if (texdata[textab[ID].data].status != TEXDATA_1D) {
-    if (tparams != NULL) memcpy(textab[ID].Plane2, tparams, sizeof(tgenparams));
-    else                 memcpy(textab[ID].Plane2, tgenparams, sizeof(tgenparams));
+  if (texdata(textab(ID).data).status != TEXDATA_1D) {
+    if (tparams != NULL) memcpy(textab(ID).Plane2, tparams, sizeof(tgenparams));
+    else                 memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
   }
 }
 
   }
 }
 
@@ -959,7 +860,7 @@ void SetModeSphere(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Gen = GL_SPHERE_MAP;
+  textab(ID).Gen = GL_SPHERE_MAP;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -968,13 +869,13 @@ void SetModeEye(TextureID ID, const GLfloat sparams[4], const GLfloat tparams[4]
 {  
   if (!IsTextureValid(ID)) return;
 
 {  
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Gen = GL_EYE_LINEAR;
-  if (sparams != NULL) memcpy(textab[ID].Plane1, sparams, sizeof(sgenparams));
-  else                 memcpy(textab[ID].Plane1, sgenparams, sizeof(sgenparams));
+  textab(ID).Gen = GL_EYE_LINEAR;
+  if (sparams != NULL) memcpy(textab(ID).Plane1, sparams, sizeof(sgenparams));
+  else                 memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
 
 
-  if (texdata[textab[ID].data].status != TEXDATA_1D) {
-    if (tparams != NULL) memcpy(textab[ID].Plane2, tparams, sizeof(tgenparams));
-    else                 memcpy(textab[ID].Plane2, tgenparams, sizeof(tgenparams));
+  if (texdata(textab(ID).data).status != TEXDATA_1D) {
+    if (tparams != NULL) memcpy(textab(ID).Plane2, tparams, sizeof(tgenparams));
+    else                 memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
   }
 }
 
   }
 }
 
@@ -984,7 +885,7 @@ void SetModeManual(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Gen = GL_NONE;
+  textab(ID).Gen = GL_NONE;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -993,7 +894,7 @@ void SetRenderNearest(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Render = GL_NEAREST;
+  textab(ID).Render = GL_NEAREST;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -1002,7 +903,7 @@ void SetRenderLinear(TextureID ID)
 {
   if (!IsTextureValid(ID)) return;
 
 {
   if (!IsTextureValid(ID)) return;
 
-  textab[ID].Render = GL_LINEAR;
+  textab(ID).Render = GL_LINEAR;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -1012,11 +913,11 @@ void SetTexturePosition(TextureID ID,
                         GLfloat transx, GLfloat transy,
                         GLfloat angle)
 {
                         GLfloat transx, GLfloat transy,
                         GLfloat angle)
 {
-  textab[ID].scalex = scalex;
-  textab[ID].scaley = scaley;
-  textab[ID].transx = transx;
-  textab[ID].transy = transy;
-  textab[ID].angle = angle;
+  textab(ID).scalex = scalex;
+  textab(ID).scaley = scaley;
+  textab(ID).transx = transx;
+  textab(ID).transy = transy;
+  textab(ID).angle = angle;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -1030,18 +931,18 @@ void SetTextureDefaultParams(TextureID ID)
 #endif
 
 
 #endif
 
 
-  textab[ID].scalex = 1.0;
-  textab[ID].scaley = 1.0;
-  textab[ID].transx = 0.0;
-  textab[ID].transy = 0.0;
-  textab[ID].angle = 0.0;
+  textab(ID).scalex = 1.0;
+  textab(ID).scaley = 1.0;
+  textab(ID).transx = 0.0;
+  textab(ID).transy = 0.0;
+  textab(ID).angle = 0.0;
 
 
-  textab[ID].Gen = GL_OBJECT_LINEAR;
-  textab[ID].Light = texdata[textab[ID].data].status == TEXDATA_1D ? GL_DECAL : GL_MODULATE;
-  textab[ID].Wrap = texdata[textab[ID].data].status == TEXDATA_1D ? GL_CLAMP : GL_REPEAT;
-  memcpy(textab[ID].Plane1, sgenparams, sizeof(sgenparams));
-  memcpy(textab[ID].Plane2, tgenparams, sizeof(tgenparams));
-  textab[ID].Render = texdata[textab[ID].data].status == TEXDATA_1D ? GL_NEAREST : GL_LINEAR;
+  textab(ID).Gen = GL_OBJECT_LINEAR;
+  textab(ID).Light = texdata(textab(ID).data).status == TEXDATA_1D ? GL_DECAL : GL_MODULATE;
+  textab(ID).Wrap = texdata(textab(ID).data).status == TEXDATA_1D ? GL_CLAMP : GL_REPEAT;
+  memcpy(textab(ID).Plane1, sgenparams, sizeof(sgenparams));
+  memcpy(textab(ID).Plane2, tgenparams, sizeof(tgenparams));
+  textab(ID).Render = texdata(textab(ID).data).status == TEXDATA_1D ? GL_NEAREST : GL_LINEAR;
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -1049,17 +950,17 @@ void SetTextureDefaultParams(TextureID ID)
 void TransferTexture_To_Data(TextureID ID, TextureData *TransfDt)
 {
   /* affectations */    
 void TransferTexture_To_Data(TextureID ID, TextureData *TransfDt)
 {
   /* affectations */    
-  strcpy(TransfDt->path, texdata[textab[ID].data].imageFileName);    
-  TransfDt->gen = textab[ID].Gen;
-  TransfDt->wrap  = textab[ID].Wrap;
-  TransfDt->render  = textab[ID].Light;
-  TransfDt->scalex  = textab[ID].scalex;
-  TransfDt->scaley  = textab[ID].scaley;
-  TransfDt->transx  = textab[ID].transx;
-  TransfDt->transy  = textab[ID].transy;
-  TransfDt->angle = textab[ID].angle;            
-  memcpy(TransfDt->plane1,  textab[ID].Plane1, sizeof(SizeType));
-  memcpy(TransfDt->plane2,  textab[ID].Plane2, sizeof(SizeType));                
+  strcpy(TransfDt->path, texdata(textab(ID).data).imageFileName);    
+  TransfDt->gen = textab(ID).Gen;
+  TransfDt->wrap  = textab(ID).Wrap;
+  TransfDt->render  = textab(ID).Light;
+  TransfDt->scalex  = textab(ID).scalex;
+  TransfDt->scaley  = textab(ID).scaley;
+  TransfDt->transx  = textab(ID).transx;
+  TransfDt->transy  = textab(ID).transy;
+  TransfDt->angle = textab(ID).angle;            
+  memcpy(TransfDt->plane1,  textab(ID).Plane1, sizeof(SizeType));
+  memcpy(TransfDt->plane2,  textab(ID).Plane2, sizeof(SizeType));                
 }
 
 /*----------------------------------------------------------------------*/
 }
 
 /*----------------------------------------------------------------------*/
@@ -1078,16 +979,16 @@ void TransferData_To_Texture(TextureData *TransfDt, TextureID *newID)
     *newID = ID;
 
     /* Donnees concernant les caracteristiques de la texture */ 
     *newID = ID;
 
     /* Donnees concernant les caracteristiques de la texture */ 
-    strcpy(texdata[textab[ID].data].imageFileName, TransfDt->path);       
-    textab[ID].Gen    = TransfDt->gen;
-    textab[ID].Wrap   = TransfDt->wrap;
-    textab[ID].Light  = TransfDt->render;
-    textab[ID].scalex = TransfDt->scalex;
-    textab[ID].scaley = TransfDt->scaley; 
-    textab[ID].transx = TransfDt->transx;
-    textab[ID].transy = TransfDt->transy;
-    textab[ID].angle  = TransfDt->angle;
-    memcpy(textab[ID].Plane1,  TransfDt->plane1, sizeof(SizeType));
-    memcpy(textab[ID].Plane2,  TransfDt->plane2, sizeof(SizeType)); 
+    strcpy(texdata(textab(ID).data).imageFileName, TransfDt->path);       
+    textab(ID).Gen    = TransfDt->gen;
+    textab(ID).Wrap   = TransfDt->wrap;
+    textab(ID).Light  = TransfDt->render;
+    textab(ID).scalex = TransfDt->scalex;
+    textab(ID).scaley = TransfDt->scaley; 
+    textab(ID).transx = TransfDt->transx;
+    textab(ID).transy = TransfDt->transy;
+    textab(ID).angle  = TransfDt->angle;
+    memcpy(textab(ID).Plane1,  TransfDt->plane1, sizeof(SizeType));
+    memcpy(textab(ID).Plane2,  TransfDt->plane2, sizeof(SizeType)); 
   }               
 }
   }               
 }