Difference for arch/ogl/ogl.c from version 1.6 to 1.7


version 1.6 version 1.7
Line 22
 
Line 22
 #include "powerup.h"  #include "powerup.h"
 #include "polyobj.h"  #include "polyobj.h"
   
   
   int GL_TEXTURE_2D_enabled=-1;
   int GL_texclamp_enabled=-1;
   
 //crude texture precaching  //crude texture precaching
 //handles: powerups, walls, weapons, polymodels, etc.  //handles: powerups, walls, weapons, polymodels, etc.
 //it is done with the horrid do_special_effects kludge so that sides that have to be texmerged and have animated textures will be correctly cached.  //it is done with the horrid do_special_effects kludge so that sides that have to be texmerged and have animated textures will be correctly cached.
Line 193
 
Line 197
  r_polyc++;   r_polyc++;
  c=grd_curcanv->cv_color;   c=grd_curcanv->cv_color;
 // glColor3f((gr_palette[c*3]+gr_palette_gamma)/63.0,(gr_palette[c*3+1]+gr_palette_gamma)/63.0,(gr_palette[c*3+2]+gr_palette_gamma)/63.0);  // glColor3f((gr_palette[c*3]+gr_palette_gamma)/63.0,(gr_palette[c*3+1]+gr_palette_gamma)/63.0,(gr_palette[c*3+2]+gr_palette_gamma)/63.0);
  glBegin(GL_POLYGON);   OGL_DISABLE(GL_TEXTURE_2D);
    glBegin(GL_TRIANGLE_FAN);
  glColor3f(PAL2Tr(c),PAL2Tg(c),PAL2Tb(c));   glColor3f(PAL2Tr(c),PAL2Tg(c),PAL2Tb(c));
  for (c=0;c<nv;c++){   for (c=0;c<nv;c++){
  // glVertex3f(f2glf(pointlist[c]->p3_vec.x),f2glf(pointlist[c]->p3_vec.y),f2glf(pointlist[c]->p3_vec.z));   // glVertex3f(f2glf(pointlist[c]->p3_vec.x),f2glf(pointlist[c]->p3_vec.y),f2glf(pointlist[c]->p3_vec.z));
Line 209
 
Line 214
  r_tpolyc++;   r_tpolyc++;
 /* if (bm->bm_w !=64||bm->bm_h!=64)  /* if (bm->bm_w !=64||bm->bm_h!=64)
  printf("g3_draw_tmap w %i h %i\n",bm->bm_w,bm->bm_h);*/   printf("g3_draw_tmap w %i h %i\n",bm->bm_w,bm->bm_h);*/
  glEnable(GL_TEXTURE_2D);   //glEnable(GL_TEXTURE_2D);
    OGL_ENABLE(GL_TEXTURE_2D);
  if (bm->gltexture<0)   if (bm->gltexture<0)
  ogl_loadbmtexture(bm);   ogl_loadbmtexture(bm);
  glBindTexture(GL_TEXTURE_2D, bm->gltexture);   glBindTexture(GL_TEXTURE_2D, bm->gltexture);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);  // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);  // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glBegin(GL_POLYGON);   OGL_TEXREPEAT();
    glBegin(GL_TRIANGLE_FAN);
  for (c=0;c<nv;c++){   for (c=0;c<nv;c++){
  if (bm->bm_flags&BM_FLAG_NO_LIGHTING){   if (bm->bm_flags&BM_FLAG_NO_LIGHTING){
  l=1.0;   l=1.0;
Line 230
 
Line 237
  glVertex3f(f2glf(pointlist[c]->p3_vec.x),f2glf(pointlist[c]->p3_vec.y),-f2glf(pointlist[c]->p3_vec.z));   glVertex3f(f2glf(pointlist[c]->p3_vec.x),f2glf(pointlist[c]->p3_vec.y),-f2glf(pointlist[c]->p3_vec.z));
  }   }
  glEnd();   glEnd();
  glDisable(GL_TEXTURE_2D);  // glDisable(GL_TEXTURE_2D);
  return 0;   return 0;
 }  }
   
Line 244
 
Line 251
 // printf("g3_draw_bitmap: %f,%f,%f - ",f2glf(pos->x),f2glf(pos->y),-f2glf(pos->z));  // printf("g3_draw_bitmap: %f,%f,%f - ",f2glf(pos->x),f2glf(pos->y),-f2glf(pos->z));
 // printf("(%f,%f,%f) ",f2glf(View_position.x),f2glf(View_position.y),-f2glf(View_position.z));  // printf("(%f,%f,%f) ",f2glf(View_position.x),f2glf(View_position.y),-f2glf(View_position.z));
   
  glEnable(GL_TEXTURE_2D);   //glEnable(GL_TEXTURE_2D);
    OGL_ENABLE(GL_TEXTURE_2D);
  if (bm->gltexture<0)   if (bm->gltexture<0)
  ogl_loadbmtexture(bm);   ogl_loadbmtexture(bm);
  glBindTexture(GL_TEXTURE_2D, bm->gltexture);   glBindTexture(GL_TEXTURE_2D, bm->gltexture);
    
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);   //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);   //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    OGL_TEXCLAMP();
   
  glBegin(GL_QUADS);   glBegin(GL_QUADS);
  glColor3f(1.0,1.0,1.0);   glColor3f(1.0,1.0,1.0);
Line 289
 
Line 298
 // printf("%f,%f,%f ",f2glf(v1.x),f2glf(v1.y),-f2glf(v1.z));  // printf("%f,%f,%f ",f2glf(v1.x),f2glf(v1.y),-f2glf(v1.z));
  }   }
  glEnd();   glEnd();
  glDisable(GL_TEXTURE_2D);  // glDisable(GL_TEXTURE_2D);
 // printf("\n");  // printf("\n");
   
  return 0;   return 0;
Line 309
 
Line 318
 /* glEnable(GL_ALPHA_TEST);  /* glEnable(GL_ALPHA_TEST);
  glAlphaFunc(GL_GREATER,0.0);*/   glAlphaFunc(GL_GREATER,0.0);*/
   
  glEnable(GL_TEXTURE_2D);   OGL_ENABLE(GL_TEXTURE_2D);
    //glEnable(GL_TEXTURE_2D);
  if (bm->gltexture<0)   if (bm->gltexture<0)
  ogl_loadbmtexture(bm);   ogl_loadbmtexture(bm);
  glBindTexture(GL_TEXTURE_2D, bm->gltexture);   glBindTexture(GL_TEXTURE_2D, bm->gltexture);
    
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);  // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);  // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    OGL_TEXCLAMP();
   
  glBegin(GL_QUADS);   glBegin(GL_QUADS);
  glColor3f(1.5,1.5,1.5);   glColor3f(1.5,1.5,1.5);
Line 324
 
Line 335
  glTexCoord2f(bm->glu, bm->glv); glVertex2f(xo+xs, yo-ys);   glTexCoord2f(bm->glu, bm->glv); glVertex2f(xo+xs, yo-ys);
  glTexCoord2f(0.0, bm->glv); glVertex2f(xo, yo-ys);   glTexCoord2f(0.0, bm->glv); glVertex2f(xo, yo-ys);
  glEnd();   glEnd();
  glDisable(GL_TEXTURE_2D);  // glDisable(GL_TEXTURE_2D);
 // glDisable(GL_ALPHA_TEST);  // glDisable(GL_ALPHA_TEST);
    
  return 0;   return 0;
Line 341
 
Line 352
  glMatrixMode(GL_PROJECTION);   glMatrixMode(GL_PROJECTION);
  glLoadIdentity();//clear matrix   glLoadIdentity();//clear matrix
  //gluPerspective(90.0,(GLfloat)(grd_curscreen->sc_w*3)/(GLfloat)(grd_curscreen->sc_h*4),1.0,1000000.0);   //gluPerspective(90.0,(GLfloat)(grd_curscreen->sc_w*3)/(GLfloat)(grd_curscreen->sc_h*4),1.0,1000000.0);
  gluPerspective(90.0,(GLfloat)(grd_curscreen->sc_w*3)/(GLfloat)(grd_curscreen->sc_h*4),0.1,1000000.0);   gluPerspective(90.0,(GLfloat)(grd_curscreen->sc_w*3)/(GLfloat)(grd_curscreen->sc_h*4),0.01,1000000.0);
 // gluPerspective(75.0,(GLfloat)Canvas_width/(GLfloat)Canvas_height,1.0,1000000.0);  // gluPerspective(75.0,(GLfloat)Canvas_width/(GLfloat)Canvas_height,1.0,1000000.0);
  glMatrixMode(GL_MODELVIEW);   glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();//clear matrix   glLoadIdentity();//clear matrix
Line 376
 
Line 387
 }  }
   
 GLubyte texbuf[512*512*4];  GLubyte texbuf[512*512*4];
   //loads a palettized bitmap into a ogl RGBA texture.
   //Sizes and pads dimensions to multiples of 2 if necessary.
   //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.
   //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 width, int height, int *texid,float *u,float *v){  void ogl_loadtexture(unsigned char * data, int width, int height, int *texid,float *u,float *v){
  int x,y,c,i;   int x,y,c,i;
  GLubyte *texp=texbuf;   GLubyte *texp=texbuf;

Legend:
line(s) removed in v.1.6 
line(s) changed
 line(s) added in v.1.7