Difference for arch/ogl/ogl.c from version 1.14 to 1.15


version 1.14 version 1.15
Line 5
 
Line 5
 #endif  #endif
 #include <GL/gl.h>  #include <GL/gl.h>
 #include <GL/glu.h>  #include <GL/glu.h>
   #include <string.h>
 #include "ogl_init.h"  #include "ogl_init.h"
 #include "3d.h"  #include "3d.h"
 #include "piggy.h"  #include "piggy.h"
Line 37
 
Line 38
 extern int gr_renderstats;  extern int gr_renderstats;
 extern int gr_badtexture;  extern int gr_badtexture;
 int ogl_alttexmerge=1;//merge textures by just printing the seperate textures?  int ogl_alttexmerge=1;//merge textures by just printing the seperate textures?
 int ogl_16bittextures=0;  int ogl_rgba_format=4;
   int ogl_intensity4_ok=1;
   int ogl_luminance4_alpha4_ok=1;
   int ogl_rgba2_ok=1;
   int ogl_readpixels_ok=1;
   
 /*int lastbound=-1;  /*int lastbound=-1;
   
Line 57
 
Line 62
 }  }
 void ogl_init_texture(ogl_texture* t){  void ogl_init_texture(ogl_texture* t){
  t->handle=0;   t->handle=0;
  if (ogl_16bittextures)   t->internalformat=ogl_rgba_format;
  t->internalformat=GL_RGB5_A1;  
  else  
  t->internalformat=4;  
  t->format=GL_RGBA;   t->format=GL_RGBA;
  t->wrapstate=-1;   t->wrapstate=-1;
  t->w=t->h=0;   t->w=t->h=0;
Line 86
 
Line 88
  ogl_texture_list[i].wrapstate=-1;   ogl_texture_list[i].wrapstate=-1;
  }   }
 }  }
   void ogl_vivify_texture_list_internal(void){
   /*
      int i;
    ogl_texture* t;
    for (i=0;i<OGL_TEXTURE_LIST_SIZE;i++){
    t=&ogl_texture_list[i];
    if (t->w>0){//erk, realised this can't be done since we'd need the texture bm_data too. hmmm.
    ogl_loadbmtexture(t);
    }
   */
   }
   
 ogl_texture* ogl_get_free_texture(void){  ogl_texture* ogl_get_free_texture(void){
  int i;   int i;
Line 98
 
Line 111
  Error("OGL: texture list full!\n");   Error("OGL: texture list full!\n");
 // return NULL;  // return NULL;
 }  }
 int ogl_texture_bytes_used(ogl_texture* t){  
  switch (t->internalformat){  
  case GL_LUMINANCE4_ALPHA4:  
  return t->tw*t->th;  
  case GL_RGB5_A1:  
  return t->tw*t->th*2;  
  default:  
  return t->tw*t->th*4;  
  }  
 }  
 int ogl_texture_stats(void){  int ogl_texture_stats(void){
  int used=0,usedl4a4=0,usedrgba=0,databytes=0,truebytes=0,datatexel=0,truetexel=0,i;   int used=0,usedl4a4=0,usedrgba=0,databytes=0,truebytes=0,datatexel=0,truetexel=0,i;
  int prio0=0,prio1=0,prio2=0,prio3=0,prioh=0;   int prio0=0,prio1=0,prio2=0,prio3=0,prioh=0;
Line 119
 
Line 122
  used++;   used++;
  datatexel+=t->w*t->h;   datatexel+=t->w*t->h;
  truetexel+=t->tw*t->th;   truetexel+=t->tw*t->th;
  switch (t->internalformat){   databytes+=t->bytesu;
  case GL_LUMINANCE4_ALPHA4:   truebytes+=t->bytes;
  databytes+=t->w*t->h;  
  truebytes+=t->tw*t->th;  
  usedl4a4++;  
  break;  
  case GL_RGB5_A1:  
  databytes+=t->w*t->h*2;  
  truebytes+=t->tw*t->th*2;  
  usedrgba++;  
  break;  
  default:  
  databytes+=t->w*t->h*4;  
  truebytes+=t->tw*t->th*4;  
  usedrgba++;  
  }  
  if (t->prio<0.299)prio0++;   if (t->prio<0.299)prio0++;
  else if (t->prio<0.399)prio1++;   else if (t->prio<0.399)prio1++;
  else if (t->prio<0.499)prio2++;   else if (t->prio<0.499)prio2++;
Line 169
 
Line 158
  if (t->handle>0){   if (t->handle>0){
  if (t->lastrend+f1_0*time<GameTime){   if (t->lastrend+f1_0*time<GameTime){
  ogl_freetexture(t);   ogl_freetexture(t);
  bytes-=ogl_texture_bytes_used(t);   bytes-=t->bytes;
  if (bytes<ogl_mem_target)   if (bytes<ogl_mem_target)
  return;   return;
  }   }
Line 442
 
Line 431
  }   }
  return 0;   return 0;
 }  }
 //int orient2uv[4][4]={{0,1,2,3},{;  
 bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm,int orient)  bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm,int orient)
 {  {
  int c;   int c;
Line 458
 
Line 446
  ogl_texwrap(bm->gltexture,GL_REPEAT);   ogl_texwrap(bm->gltexture,GL_REPEAT);
  glBegin(GL_TRIANGLE_FAN);   glBegin(GL_TRIANGLE_FAN);
  for (c=0;c<nv;c++){   for (c=0;c<nv;c++){
 // oc=(c-orient);  
 // if (oc<0)oc+=4;  
 // else if (oc>4)oc-=4;  
  switch(orient){   switch(orient){
  case 1:   case 1:
  u1=1.0-f2glf(uvl_list[c].v);   u1=1.0-f2glf(uvl_list[c].v);
Line 620
 
Line 605
  GLfloat xo,yo;//,xs,ys;   GLfloat xo,yo;//,xs,ys;
  mprintf((0,"ogl_ubitblt(w=%i,h=%i,dx=%i,dy=%i,sx=%i,sy=%i,src=%p,dest=%p\n",w,h, dx, dy,sx, sy,  src,dest));   mprintf((0,"ogl_ubitblt(w=%i,h=%i,dx=%i,dy=%i,sx=%i,sy=%i,src=%p,dest=%p\n",w,h, dx, dy,sx, sy,  src,dest));
    
  dx+=grd_curcanv->cv_bitmap.bm_x;   dx+=dest->bm_x;
  dy+=grd_curcanv->cv_bitmap.bm_y;   dy+=dest->bm_y;
    
  xo=dx/(float)last_width;   xo=dx/(float)last_width;
 // xo=dx/(float)grd_curscreen->sc_w;  // xo=dx/(float)grd_curscreen->sc_w;
Line 634
 
Line 619
    
  OGL_DISABLE(TEXTURE_2D);   OGL_DISABLE(TEXTURE_2D);
  glRasterPos2f(xo,yo);   glRasterPos2f(xo,yo);
  ogl_filltexbuf(src->bm_data,texbuf,src->bm_w,w,h,sx,sy,w,h);   ogl_filltexbuf(src->bm_data,texbuf,src->bm_w,w,h,sx,sy,w,h,GL_RGBA);
  glDrawPixels(w,h,GL_RGBA,GL_UNSIGNED_BYTE,texbuf);   glDrawPixels(w,h,GL_RGBA,GL_UNSIGNED_BYTE,texbuf);
  glRasterPos2f(0,0);   glRasterPos2f(0,0);
    
Line 643
 
Line 628
 #else  #else
 bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)  bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
 {  {
 // r_ubitbltc++;  
 // return 0;  
 //#if 0  
  GLfloat xo,yo,xs,ys;   GLfloat xo,yo,xs,ys;
  GLfloat u1,v1;//,u2,v2;   GLfloat u1,v1;//,u2,v2;
  ogl_texture tex;   ogl_texture tex;
 // int gltexture=0;  
 // unsigned char *oldpal;  // unsigned char *oldpal;
  r_ubitbltc++;   r_ubitbltc++;
   
  ogl_init_texture(&tex);   ogl_init_texture(&tex);
  tex.w=w;tex.h=h;   tex.w=w;tex.h=h;
  tex.prio=0.0;   tex.prio=0.0;tex.wantmip=0;
    tex.lw=src->bm_rowsize;
   
 /* if (w==src->bm_w && sx==0){  /* if (w==src->bm_w && sx==0){
  u1=0;u2=src->glu;   u1=0;u2=src->glu;
Line 671
 
Line 653
  }*/   }*/
  u1=v1=0;   u1=v1=0;
    
  dx+=grd_curcanv->cv_bitmap.bm_x;   dx+=dest->bm_x;
  dy+=grd_curcanv->cv_bitmap.bm_y;   dy+=dest->bm_y;
  xo=dx/(float)last_width;   xo=dx/(float)last_width;
  xs=w/(float)last_width;   xs=w/(float)last_width;
  yo=1.0-dy/(float)last_height;   yo=1.0-dy/(float)last_height;
Line 680
 
Line 662
    
  OGL_ENABLE(TEXTURE_2D);   OGL_ENABLE(TEXTURE_2D);
    
 // if (src->gltexture<0)  
 // oldpal=ogl_pal;  // oldpal=ogl_pal;
  ogl_pal=gr_current_pal;   ogl_pal=gr_current_pal;
  ogl_loadtexture(src->bm_data,0,0,&tex,0);   ogl_loadtexture(src->bm_data,sx,sy,&tex);
 // ogl_pal=oldpal;  // ogl_pal=oldpal;
  ogl_pal=gr_palette;   ogl_pal=gr_palette;
 // ogl_loadbmtexture(src);  
 // else  
 // alreadygl=1;  
  OGL_BINDTEXTURE(tex.handle);   OGL_BINDTEXTURE(tex.handle);
    
  ogl_texwrap(&tex,GL_CLAMP);   ogl_texwrap(&tex,GL_CLAMP);
Line 700
 
Line 678
  glTexCoord2f(tex.u, tex.v); glVertex2f(xo+xs, yo-ys);   glTexCoord2f(tex.u, tex.v); glVertex2f(xo+xs, yo-ys);
  glTexCoord2f(u1, tex.v); glVertex2f(xo, yo-ys);   glTexCoord2f(u1, tex.v); glVertex2f(xo, yo-ys);
  glEnd();   glEnd();
 // if(!alreadygl)   
 // ogl_freebmtexture(src);  
  ogl_freetexture(&tex);   ogl_freetexture(&tex);
  return 0;   return 0;
 //#endif  
 }  }
 #endif  #endif
   bool ogl_ubitblt_tolinear(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest){
    int i,j;
    unsigned char *d,*s;
    sx+=src->bm_x;
    sy+=src->bm_y;
   #if 0//also seems to cause a mess.  need to look into it a bit more..
    if (ogl_readpixels_ok){
    OGL_DISABLE(TEXTURE_2D);
    glReadBuffer(GL_FRONT);
   // glReadPixels(0,0,w,h,GL_RGB,GL_UNSIGNED_BYTE,texbuf);
    glReadPixels(sx,grd_curscreen->sc_h-(sy+h),w,h,GL_RGB,GL_UNSIGNED_BYTE,texbuf);
    }else
   #endif
    memset(texbuf,0,w*h*3);
    for (i=0;i<h;i++){
    s=texbuf+w*(h-(i+1))*3;
   // s=texbuf+w*i*3;
    if (s<texbuf){Error("blah1\n");}
    d=dest->bm_data+dx+(dy+i)*dest->bm_rowsize;
    if (d<dest->bm_data){Error("blah3\n");}
   // d=dest->bm_data+(i*dest->bm_rowsize);
   
    for (j=0;j<w;j++){
    if (s>texbuf+w*h*3-3){Error("blah2\n");}
    if (d>dest->bm_data+dest->bm_rowsize*h){Error("blah4\n");}
    *d=gr_find_closest_color(s[0]/4,s[1]/4,s[2]/4);
    s+=3;
    d++;
    }
    }
    return 0;
   }
   
   bool ogl_ubitblt_copy(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest){
   #if 0 //just seems to cause a mess.
    GLfloat xo,yo;//,xs,ys;
   
    dx+=dest->bm_x;
    dy+=dest->bm_y;
   
   // xo=dx/(float)last_width;
    xo=dx/(float)grd_curscreen->sc_w;
   // yo=1.0-(dy+h)/(float)last_height;
    yo=1.0-(dy+h)/(float)grd_curscreen->sc_h;
    sx+=src->bm_x;
    sy+=src->bm_y;
    OGL_DISABLE(TEXTURE_2D);
    glReadBuffer(GL_FRONT);
    glRasterPos2f(xo,yo);
   // glReadPixels(0,0,w,h,GL_RGB,GL_UNSIGNED_BYTE,texbuf);
    glCopyPixels(sx,grd_curscreen->sc_h-(sy+h),w,h,GL_COLOR);
    glRasterPos2f(0,0);
   #endif
    return 0;
   }
   
 void ogl_start_frame(void){  void ogl_start_frame(void){
  r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;r_ubitbltc=0;r_upixelc=0;   r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;r_ubitbltc=0;r_upixelc=0;
Line 776
 
Line 806
  glClear(GL_COLOR_BUFFER_BIT);   glClear(GL_COLOR_BUFFER_BIT);
 }  }
   
   int tex_format_supported(int iformat,int format){
    int internalFormat;
    glTexImage2D(GL_PROXY_TEXTURE_2D, 0, iformat, 64, 64, 0,
    format, GL_UNSIGNED_BYTE, texbuf);//NULL?
    glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0,
    GL_TEXTURE_INTERNAL_FORMAT,
    &internalFormat);
    return (internalFormat==iformat);
   }
   
 //little hack to find the largest or equal multiple of 2 for a given number  //little hack to find the largest or equal multiple of 2 for a given number
 int pow2ize(int x){  int pow2ize(int x){
  int i;   int i;
Line 802
 
Line 842
  else   else
  c=255;//fill the pad space with transparancy   c=255;//fill the pad space with transparancy
  if (c==255){   if (c==255){
  if (type==-2){   switch (type){
    case GL_LUMINANCE:
  (*(texp++))=0;   (*(texp++))=0;
    break;
    case GL_LUMINANCE_ALPHA:
  (*(texp++))=0;   (*(texp++))=0;
  }else{   (*(texp++))=0;
    break;
    case GL_RGBA:
  (*(texp++))=0;   (*(texp++))=0;
  (*(texp++))=0;   (*(texp++))=0;
  (*(texp++))=0;   (*(texp++))=0;
  (*(texp++))=0;//transparent pixel   (*(texp++))=0;//transparent pixel
    break;
  }   }
 // (*(tex++))=0;  // (*(tex++))=0;
  }else{   }else{
  if (type==-2){   switch (type){
    case GL_LUMINANCE://these could prolly be done to make the intensity based upon the intensity of the resulting color, but its not needed for anything (yet?) so no point. :)
  (*(texp++))=255;   (*(texp++))=255;
    break;
    case GL_LUMINANCE_ALPHA:
  (*(texp++))=255;   (*(texp++))=255;
  }else{   (*(texp++))=255;
    break;
    case GL_RGBA:
  //(*(texp++))=gr_palette[c*3]*4;   //(*(texp++))=gr_palette[c*3]*4;
  //(*(texp++))=gr_palette[c*3+1]*4;   //(*(texp++))=gr_palette[c*3+1]*4;
  //(*(texp++))=gr_palette[c*3+2]*4;   //(*(texp++))=gr_palette[c*3+2]*4;
Line 825
 
Line 876
  (*(texp++))=ogl_pal[c*3+2]*4;   (*(texp++))=ogl_pal[c*3+2]*4;
  (*(texp++))=255;//not transparent   (*(texp++))=255;//not transparent
  // (*(tex++))=(ogl_pal[c*3]>>1) + ((ogl_pal[c*3+1]>>1)<<5) + ((ogl_pal[c*3+2]>>1)<<10) + (1<<15);   // (*(tex++))=(ogl_pal[c*3]>>1) + ((ogl_pal[c*3+1]>>1)<<5) + ((ogl_pal[c*3+2]>>1)<<10) + (1<<15);
    break;
    }
    }
    }
    }
   }
   int tex_format_verify(ogl_texture *tex){
    while (!tex_format_supported(tex->internalformat,tex->format)){
    mprintf((0,"tex format %x not supported",tex->internalformat));
    switch (tex->internalformat){
    case GL_INTENSITY4:
    if (ogl_luminance4_alpha4_ok){
    tex->internalformat=GL_LUMINANCE4_ALPHA4;
    tex->format=GL_LUMINANCE_ALPHA;
    break;
    }//note how it will fall through here if the statement is false
    case GL_LUMINANCE4_ALPHA4:
    if (ogl_rgba2_ok){
    tex->internalformat=GL_RGBA2;
    tex->format=GL_RGBA;
    break;
    }//note how it will fall through here if the statement is false
    case GL_RGBA2:
    tex->internalformat=ogl_rgba_format;
    tex->format=GL_RGBA;
    break;
    default:
    mprintf((0,"...no tex format to fall back on\n"));
    return 1;
    }
    mprintf((0,"...falling back to %x\n",tex->internalformat));
  }   }
    return 0;
   }
   void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){
    int u;
    if (tex->tw!=w || tex->th!=h){
    u=(tex->w/(float)tex->tw*w) * (tex->h/(float)tex->th*h);
    mprintf((0,"shrunken texture?\n"));
    }else
    u=tex->w*tex->h;
    if (bits<=0){//the beta nvidia GLX serverdoesn't ever return any bit sizes, so just use some assumptions.
    tex->bytes=((float)w*h*dbits)/8.0;
    tex->bytesu=((float)u*dbits)/8.0;
    }else{
    tex->bytes=((float)w*h*bits)/8.0;
    tex->bytesu=((float)u*bits)/8.0;
  }   }
    mprintf((0,"tex_set_size1: %ix%i, %ib(%i) %iB\n",w,h,bits,dbits,tex->bytes));
  }   }
   void tex_set_size(ogl_texture *tex){
   // int w,h,r,g,b,a;
    int w,h,bi=16,a=0,t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&w);
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&h);
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_LUMINANCE_SIZE,&t);a+=t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_INTENSITY_SIZE,&t);a+=t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_RED_SIZE,&t);a+=t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_GREEN_SIZE,&t);a+=t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_BLUE_SIZE,&t);a+=t;
    glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_ALPHA_SIZE,&t);a+=t;
    switch (tex->format){
    case GL_LUMINANCE:
    bi=8;
    break;
    case GL_LUMINANCE_ALPHA:
    bi=8;
    break;
    case GL_RGBA:
    bi=16;
    break;
    default:
    Error("tex_set_size unknown texformat\n");
    break;
  }   }
    tex_set_size1(tex,bi,a,w,h);
 }  }
 //loads a palettized bitmap into a ogl RGBA texture.  //loads a palettized bitmap into a ogl RGBA texture.
 //Sizes and pads dimensions to multiples of 2 if necessary.  //Sizes and pads dimensions to multiples of 2 if necessary.
 //In theory this could be a problem for repeating textures, but all real  //In theory this could be a problem for repeating textures, but all real
 //textures (not sprites, etc) in descent are 64x64, so we are ok.  //textures (not sprites, etc) in descent are 64x64, so we are ok.
 //stores OpenGL textured id in *texid and u/v values required to get only the real data in *u/*v  //stores OpenGL textured id in *texid and u/v values required to get only the real data in *u/*v
 void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex,char domipmap){  void ogl_loadtexture(unsigned char * data, int dxo,int dyo, ogl_texture *tex){
 //void ogl_loadtexture(unsigned char * data, int width, int height,int dxo,int dyo, int *texid,float *u,float *v,char domipmap,float prio){  //void ogl_loadtexture(unsigned char * data, int width, int height,int dxo,int dyo, int *texid,float *u,float *v,char domipmap,float prio){
 // int internalformat=GL_RGBA;  // int internalformat=GL_RGBA;
 // int format=GL_RGBA;  // int format=GL_RGBA;
  int filltype=0;   //int filltype=0;
  tex->tw=pow2ize(tex->w);tex->th=pow2ize(tex->h);//calculate smallest texture size that can accomodate us (must be multiples of 2)   tex->tw=pow2ize(tex->w);tex->th=pow2ize(tex->h);//calculate smallest texture size that can accomodate us (must be multiples of 2)
    
  if(gr_badtexture>0) return;   if(gr_badtexture>0) return;
   
  if (tex->handle==-2){   if (tex_format_verify(tex))
 // internalformat=GL_INTENSITY4;   return;
 // format=GL_LUMINANCE;  
  tex->internalformat=GL_LUMINANCE4_ALPHA4;  
  tex->format=GL_LUMINANCE_ALPHA;  
  }  
  if (tex->format==GL_LUMINANCE_ALPHA)  
  filltype=-2;  
    
  //calculate u/v values that would make the resulting texture correctly sized   //calculate u/v values that would make the resulting texture correctly sized
  tex->u=(float)tex->w/(float)tex->tw;   tex->u=(float)tex->w/(float)tex->tw;
Line 859
 
Line 976
   
  // if (width!=twidth || height!=theight)   // if (width!=twidth || height!=theight)
  // mprintf((0,"sizing %ix%i texture up to %ix%i\n",width,height,twidth,theight));   // mprintf((0,"sizing %ix%i texture up to %ix%i\n",width,height,twidth,theight));
  ogl_filltexbuf(data,texbuf,tex->w,tex->w,tex->h,dxo,dyo,tex->tw,tex->th,filltype);   ogl_filltexbuf(data,texbuf,tex->lw,tex->w,tex->h,dxo,dyo,tex->tw,tex->th,tex->format);
   
  // Generate OpenGL texture IDs.   // Generate OpenGL texture IDs.
  glGenTextures(1, &tex->handle);   glGenTextures(1, &tex->handle);
Line 872
 
Line 989
  OGL_BINDTEXTURE(tex->handle);   OGL_BINDTEXTURE(tex->handle);
   
  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    if (tex->wantmip){
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_texmagfilt);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_texmagfilt);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_texminfilt);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_texminfilt);
    }else{
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    }
 // domipmap=0;//mipmaps aren't used in GL_NEAREST anyway, and making the mipmaps is pretty slow  // domipmap=0;//mipmaps aren't used in GL_NEAREST anyway, and making the mipmaps is pretty slow
  //however, if texturing mode becomes an ingame option, they would need to be made regardless, so it could switch to them later.  OTOH, texturing mode could just be made a command line arg.   //however, if texturing mode becomes an ingame option, they would need to be made regardless, so it could switch to them later.  OTOH, texturing mode could just be made a command line arg.
   
  if (domipmap && GL_needmipmaps)   if (tex->wantmip && GL_needmipmaps)
  gluBuild2DMipmaps( GL_TEXTURE_2D, tex->internalformat, tex->tw,   gluBuild2DMipmaps( GL_TEXTURE_2D, tex->internalformat, tex->tw,
  tex->th, tex->format, GL_UNSIGNED_BYTE, texbuf);   tex->th, tex->format, GL_UNSIGNED_BYTE, texbuf);
  else   else
Line 885
 
Line 1007
  tex->tw, tex->th, 0, tex->format, // RGBA textures.   tex->tw, tex->th, 0, tex->format, // RGBA textures.
  GL_UNSIGNED_BYTE, // imageData is a GLubyte pointer.   GL_UNSIGNED_BYTE, // imageData is a GLubyte pointer.
  texbuf);   texbuf);
   
    tex_set_size(tex);
   
  r_texcount++;   r_texcount++;
  mprintf((0,"ogl_loadtexture(%p,%i,%i,%ix%i,%p):%i u=%f v=%f (%i)\n",data,tex->tw,tex->th,dxo,dyo,tex,tex->handle,tex->u,tex->v,r_texcount));   mprintf((0,"ogl_loadtexture(%p,%i,%i,%ix%i,%p):%i u=%f v=%f b=%i bu=%i (%i)\n",data,tex->tw,tex->th,dxo,dyo,tex,tex->handle,tex->u,tex->v,tex->bytes,tex->bytesu,r_texcount));
   
 }  }
 unsigned char decodebuf[512*512];  unsigned char decodebuf[512*512];
Line 897
 
Line 1022
  buf=bm->bm_data;   buf=bm->bm_data;
  if (bm->gltexture==NULL){   if (bm->gltexture==NULL){
  ogl_init_texture(bm->gltexture=ogl_get_free_texture());   ogl_init_texture(bm->gltexture=ogl_get_free_texture());
    bm->gltexture->lw=bm->bm_w;
  bm->gltexture->w=bm->bm_w;   bm->gltexture->w=bm->bm_w;
  bm->gltexture->h=bm->bm_h;   bm->gltexture->h=bm->bm_h;
    bm->gltexture->wantmip=domipmap;
  }   }
  else {   else {
  if (bm->gltexture->handle>0)   if (bm->gltexture->handle>0)
  return;   return;
  if (bm->gltexture->w==0){   if (bm->gltexture->w==0){
    bm->gltexture->lw=bm->bm_w;
  bm->gltexture->w=bm->bm_w;   bm->gltexture->w=bm->bm_w;
  bm->gltexture->h=bm->bm_h;   bm->gltexture->h=bm->bm_h;
  }   }
Line 922
 
Line 1050
  }   }
  buf=decodebuf;   buf=decodebuf;
  }   }
  ogl_loadtexture(buf,0,0,bm->gltexture,domipmap);   ogl_loadtexture(buf,0,0,bm->gltexture);
 }  }
 void ogl_loadbmtexture(grs_bitmap *bm){  void ogl_loadbmtexture(grs_bitmap *bm){
  ogl_loadbmtexture_m(bm,1);   ogl_loadbmtexture_m(bm,1);

Legend:
line(s) removed in v.1.14 
line(s) changed
 line(s) added in v.1.15