Difference for arch/ogl/ogl.c from version 1.2 to 1.3


version 1.2 version 1.3
Line 2
 
Line 2
 #include <GL/gl.h>  #include <GL/gl.h>
 #include <GL/glu.h>  #include <GL/glu.h>
 #include "3d.h"  #include "3d.h"
   #include "piggy.h"
 #include "../../3d/globvars.h"  #include "../../3d/globvars.h"
 #include "error.h"  #include "error.h"
 #include "texmap.h"  #include "texmap.h"
Line 10
 
Line 11
 #include "ogl_init.h"  #include "ogl_init.h"
 #include "mono.h"  #include "mono.h"
   
   #include "segment.h"
   #include "textures.h"
   #include "texmerge.h"
   #include "effects.h"
   
   //crude texture precaching
   //handles: powerups, walls, 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.
   //should add : weapons/doors/polymodel-textures
   
   void ogl_cache_level_textures(void){
    int seg,side,i;
    eclip *ec;
    vclip *vc;
    short tmap1,tmap2;
    grs_bitmap *bm;
    struct side *sidep;
    int max_efx=0,ef;
    for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
    if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
    continue;
    if (ec->vc.num_frames>max_efx)
    max_efx=ec->vc.num_frames;
    }
    mprintf((0,"max_efx:%i\n",max_efx));
    for (ef=0;ef<max_efx;ef++){
    for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
    if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
    continue;
   // if (ec->vc.num_frames>max_efx)
   // max_efx=ec->vc.num_frames;
    ec->time_left=-1;
    }
    do_special_effects();
   
    for (seg=0;seg<Num_segments;seg++){
    for (side=0;side<MAX_SIDES_PER_SEGMENT;side++){
    sidep=&Segments[seg].sides[side];
    tmap1=sidep->tmap_num;
    tmap2=sidep->tmap_num2;
    if (tmap1<0 || tmap1>=NumTextures){
    mprintf((0,"ogl_cache_level_textures %i %i %i %i\n",seg,side,tmap1,NumTextures));
    // tmap1=0;
    continue;
    }
    if (tmap2 != 0){
    bm = texmerge_get_cached_bitmap( tmap1, tmap2 );
    // mprintf((0,"ogl_cache_level_textures seg %i side %i t1 %i t2 %x bm %p NT %i\n",seg,side,tmap1,tmap2,bm,NumTextures));
    }
    else    {
    PIGGY_PAGE_IN(Textures[tmap1]);
    bm = &GameBitmaps[Textures[tmap1].index];
    // mprintf((0,"ogl_cache_level_textures seg %i side %i t1 %i t2 %x idx %i bm %p NT %i\n",seg,side,tmap1,tmap2,Textures[tmap1].index,bm,NumTextures));
    }
    ogl_loadbmtexture(bm);
    }
    }
    mprintf((0,"finished ef:%i\n",ef));
    }
    reset_special_effects();
    init_special_effects();
    for (i=0;i<Highest_object_index;i++){
    if(Objects[i].render_type==RT_POWERUP){
    vc=&Vclip[Objects[i].rtype.vclip_info.vclip_num];
    for (seg=0;seg<vc->num_frames;seg++){
    PIGGY_PAGE_IN(vc->frames[seg]);
    bm=&GameBitmaps[vc->frames[seg].index];
    ogl_loadbmtexture(bm);
    }
    //possibly add in caching of the weapon firing bitmaps for all weapons in levels?
    }
    else if(Objects[i].render_type==RT_POLYOBJ){
    //cache its textures...
    }
    }
    mprintf((0,"finished caching\n"));
   }
   
 GLfloat tempmatrix[16];  GLfloat tempmatrix[16];
 int r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc;  int r_polyc,r_tpolyc,r_bitmapc,r_ubitmapc;
 int r_texcount=0;  int r_texcount=0;
 #define f2glf(x) (f2fl(x))  #define f2glf(x) (f2fl(x))
   /*
   bool g3_draw_line(g3s_point *p0,g3s_point *p1)
   {
    int c;
   
    if (p0->p3_codes & p1->p3_codes)
    return 0;
   
   // r_polyc++;
    c=grd_curcanv->cv_color;
    glColor3f(PAL2Tr(c),PAL2Tg(c),PAL2Tb(c));
    glBegin(GL_LINES);
    glVertex2f(p0->p3_sx/(float)grd_curscreen->sc_w,p0->p3_sy/(float)grd_curscreen->sc_h);
    glVertex2f(p1->p3_sx/(float)grd_curscreen->sc_w,p1->p3_sy/(float)grd_curscreen->sc_h);
    glEnd();
    return 1;
   }
   */
   /*
   int g3_draw_sphere(g3s_point *pnt,fix rad){
    if (! (pnt->p3_codes & CC_BEHIND)) {
    if (! (pnt->p3_flags & PF_PROJECTED))
    g3_project_point(pnt);
    }
    return 0;
   
   }*/
 bool g3_draw_poly(int nv,g3s_point **pointlist)  bool g3_draw_poly(int nv,g3s_point **pointlist)
 {  {
  int c;   int c;
Line 160
 
Line 265
   
 vms_vector aoeupos={0,0,-1000*f1_0};  vms_vector aoeupos={0,0,-1000*f1_0};
 vms_matrix aoeuorient=IDENTITY_MATRIX;  vms_matrix aoeuorient=IDENTITY_MATRIX;
   //int blag=0;
 void ogl_start_frame(void){  void ogl_start_frame(void){
   /* if (blag==0){
    ogl_cache_level_textures();
    blag=1;
    }*/
  r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;   r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitmapc=0;
  glClearColor(0.0, 0.0, 0.0, 0.0);   glClearColor(0.0, 0.0, 0.0, 0.0);
 // glEnable(GL_ALPHA_TEST);  // glEnable(GL_ALPHA_TEST);
Line 230
 
Line 340
  glBindTexture(GL_TEXTURE_2D, *texid);   glBindTexture(GL_TEXTURE_2D, *texid);
   
 //TODO: make texturing mode an option  //TODO: make texturing mode an option
 // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 //    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  //    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);  // glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);  //  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);  //  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
   //  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
   //  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    
 /* glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, // RGBA textures.  /* glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, // RGBA textures.
  width, height, 0, GL_RGBA,   width, height, 0, GL_RGBA,
Line 250
 
Line 362
 unsigned char decodebuf[512*512];  unsigned char decodebuf[512*512];
 void ogl_loadbmtexture(grs_bitmap *bm){  void ogl_loadbmtexture(grs_bitmap *bm){
  unsigned char *buf=bm->bm_data;   unsigned char *buf=bm->bm_data;
    if (bm->gltexture>=0)
    return;
  if (bm->bm_flags & BM_FLAG_RLE){   if (bm->bm_flags & BM_FLAG_RLE){
  unsigned char * dbits;   unsigned char * dbits;
  unsigned char * sbits;   unsigned char * sbits;

Legend:
line(s) removed in v.1.2 
line(s) changed
 line(s) added in v.1.3