Difference for arch/ogl/gr.c from version 1.5 to 1.6


version 1.5 version 1.6
Line 3
 
Line 3
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdio.h>  #include <stdio.h>
 #include <string.h>  #include <string.h>
   #ifdef __WINDOWS__
   #include <windows.h>
   #endif
   #include <GL/gl.h>
   #include <GL/glu.h>
 #include "gr.h"  #include "gr.h"
 #include "grdef.h"  #include "grdef.h"
 #include "palette.h"  #include "palette.h"
Line 18
 
Line 23
   
   
 void gr_palette_clear(); // Function prototype for gr_init;  void gr_palette_clear(); // Function prototype for gr_init;
   
 #include <GL/glu.h>  
 int gl_initialized=0;  int gl_initialized=0;
   
 //kludge can either use points, or a texture.. texture doesn't work so well since its not a multiple of 2, and so the texture loading thingy resizes it, I guess.  
 #define KLUDGEPOINT  
 #ifndef KLUDGEPOINT  
 GLuint kludgetexture;  GLuint kludgetexture;
 unsigned char *kludgetexturedata=NULL;  unsigned char *kludgetexturedata=NULL;
 #endif  
   
   
 void ogl_init_state(void){  void ogl_init_state(void){
  /* select clearing (background) color   */   /* select clearing (background) color   */
Line 39
 
Line 37
  glMatrixMode(GL_PROJECTION);   glMatrixMode(GL_PROJECTION);
  glLoadIdentity();   glLoadIdentity();
  glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);   glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
           glScalef(1.0, -1.0, 1.0);
           glTranslatef(0.0, -1.0, 0.0);
  gr_palette_step_up(0,0,0);//in case its left over from in game   gr_palette_step_up(0,0,0);//in case its left over from in game
 }  }
   
Line 48
 
Line 48
  if (gl_initialized){   if (gl_initialized){
   
  if(Function_mode != FMODE_GAME){   if(Function_mode != FMODE_GAME){
                           int i,j;
                           float kx = (32.0/(float)grd_curscreen->sc_w),
                                 ky = (32.0/(float)grd_curscreen->sc_h);
   
  ogl_init_state();   ogl_init_state();
  {                          for (i=0; i<grd_curscreen->sc_w/32; i++) {
 #ifdef KLUDGEPOINT                            for (j=0; j<grd_curscreen->sc_h/32; j++) {
  int x,y,yoff;                          int y,x,c,t;
  float gly;  
  int c;  
  glPointSize(1.0);  
  for (y=0;y<768;y++)  
  gr_fpal[y]=(gr_palette[y])/63.0;  
  //gr_fpal[y]=(gr_palette[y]+gr_palette_gamma)/63.0;  
  for (y=0;y<grd_curscreen->sc_h;y++){  
  yoff=y*grd_curscreen->sc_w;  
  //gly=(grd_curscreen->sc_h-y)/(float)grd_curscreen->sc_h;  
  gly=1.0-y/(float)grd_curscreen->sc_h;  
  for (x=0;x<grd_curscreen->sc_w;x++){  
  /* if (x%5==0&&y%5==0)  
  c=rand() % 253 + 1;  
  else*/  
  c=grd_curscreen->sc_canvas.cv_bitmap.bm_data[yoff+x];  
  //glColor3i(gr_current_pal[c*3],gr_current_pal[c*3+1],gr_current_pal[c*3+2]);  
  //glColor3f(gr_current_pal[c*3]/63.0,gr_current_pal[c*3+1]/63.0,gr_current_pal[c*3+2]/63.0);  
  // glColor3f(0.5, green, 0.5);  
  //glVertex2i(x,y);  
  glBegin(GL_POINTS);  
  glColor3f(gr_fpal[c*3],gr_fpal[c*3+1],gr_fpal[c*3+2]);  
  glVertex2f(x/(float)grd_curscreen->sc_w,gly);  
  glEnd();  
  }  
  }  
 #else  
  int y,c;  
  unsigned char*data=kludgetexturedata;   unsigned char*data=kludgetexturedata;
  for (y=0;y<grd_curscreen->sc_h*grd_curscreen->sc_w;y++){                          t = j*32*grd_curscreen->sc_w+i*32;
  c=grd_curscreen->sc_canvas.cv_bitmap.bm_data[y];                          for (y=0;y<32;y++){
                                   for (x=0;x<32; x++) {
                                     c=grd_curscreen->sc_canvas.cv_bitmap.bm_data[t+x];
  *data=gr_palette[c*3]*4;data++;   *data=gr_palette[c*3]*4;data++;
  *data=gr_palette[c*3+1]*4;data++;   *data=gr_palette[c*3+1]*4;data++;
  *data=gr_palette[c*3+2]*4;data++;   *data=gr_palette[c*3+2]*4;data++;
  }   }
                                   t+=grd_curscreen->sc_w;
    }
   
  glEnable( GL_TEXTURE_2D );   glEnable( GL_TEXTURE_2D );
  // select our current texture   // select our current texture
Line 93
 
Line 75
  glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );   glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
  // when texture area is small, bilinear filter the closest MIP map   // when texture area is small, bilinear filter the closest MIP map
  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_MIN_FILTER,GL_NONE );  
  // when texture area is large, bilinear filter the first MIP map   // when texture area is large, bilinear filter the first MIP map
  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_MAG_FILTER, GL_NONE );  
   
  // if wrap is true, the texture wraps over at the edges (repeat)   // if wrap is true, the texture wraps over at the edges (repeat)
  //       ... false, the texture ends at the edges (clamp)   //       ... false, the texture ends at the edges (clamp)
Line 104
 
Line 84
  0 ? GL_REPEAT : GL_CLAMP );   0 ? GL_REPEAT : GL_CLAMP );
  glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,   glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
  0 ? GL_REPEAT : GL_CLAMP );   0 ? GL_REPEAT : GL_CLAMP );
  gluBuild2DMipmaps( GL_TEXTURE_2D, 3, grd_curscreen->sc_w,                          glTexImage2D( GL_TEXTURE_2D, 0, 3, 32,
  grd_curscreen->sc_h, GL_RGB, GL_UNSIGNED_BYTE, kludgetexturedata );                                        32, 0, GL_RGB, GL_UNSIGNED_BYTE, kludgetexturedata );
  // glTexImage2D( GL_TEXTURE_2D, 0,GL_RGB, grd_curscreen->sc_w,  
  //   grd_curscreen->sc_h,0, GL_RGB, GL_UNSIGNED_BYTE, kludgetexturedata );  
   
  /* WINGDIAPI void APIENTRY glTexImage2D( GLenum target, GLint level,  
  GLint internalFormat,  
  GLsizei width, GLsizei height,  
  GLint border, GLenum format, GLenum type,  
  const GLvoid *pixels );*/  
   
   
  glBegin( GL_QUADS );   glBegin( GL_QUADS );
  glColor3f(1.0,1.0,1.0);   glColor3f(1.0,1.0,1.0);
  /*glTexCoord2d(0.0,0.0); glVertex2d(0.0,0.0);                          glTexCoord2d(0.0,0.0); glVertex2f(kx*(float)i,ky*(float)j);
    glTexCoord2d(1.0,0.0); glVertex2d(1.0,0.0);                          glTexCoord2d(1.0,0.0); glVertex2f(kx*(float)(i+1),ky*(float)j);
    glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0);                          glTexCoord2d(1.0,1.0); glVertex2f(kx*(float)(i+1),ky*(float)(j+1));
    glTexCoord2d(0.0,1.0); glVertex2d(0.0,1.0);*/                          glTexCoord2d(0.0,1.0); glVertex2f(kx*(float)i,ky*(float)(j+1));
  glTexCoord2d(0.0,1.0); glVertex2d(0.0,0.0);  
  glTexCoord2d(1.0,1.0); glVertex2d(1.0,0.0);  
  glTexCoord2d(1.0,0.0); glVertex2d(1.0,1.0);  
  glTexCoord2d(0.0,0.0); glVertex2d(0.0,1.0);  
  glEnd();   glEnd();
  glDisable( GL_TEXTURE_2D );   glDisable( GL_TEXTURE_2D );
                           }
                           }
   
 #endif  
   
  ogl_swap_buffers();//platform specific code   ogl_swap_buffers();//platform specific code
 #ifndef KLUDGEPOINT  
  glDeleteTextures( 1, &kludgetexture );   glDeleteTextures( 1, &kludgetexture );
 #endif  
  }  
  }   }
 // else  // else
 // ogl_swap_buffers();//platform specific code  // ogl_swap_buffers();//platform specific code
Line 199
 
Line 164
  grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR;   grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR;
  //grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels;   //grd_curscreen->sc_canvas.cv_bitmap.bm_data = (unsigned char *)screen->pixels;
  grd_curscreen->sc_canvas.cv_bitmap.bm_data = realloc(grd_curscreen->sc_canvas.cv_bitmap.bm_data,w*h);   grd_curscreen->sc_canvas.cv_bitmap.bm_data = realloc(grd_curscreen->sc_canvas.cv_bitmap.bm_data,w*h);
 #ifndef KLUDGEPOINT  
  kludgetexturedata=realloc(kludgetexturedata,w*h*3);   kludgetexturedata=realloc(kludgetexturedata,w*h*3);
 #endif  
  gr_set_current_canvas(NULL);   gr_set_current_canvas(NULL);
  //gr_enable_default_palette_loading();   //gr_enable_default_palette_loading();
   
Line 219
 
Line 182
   
  ogl_init();//platform specific initialization   ogl_init();//platform specific initialization
   
 #ifndef KLUDGEPOINT  
  // allocate a texture name   // allocate a texture name
  glGenTextures( 1, &kludgetexture );   glGenTextures( 1, &kludgetexture );
 #endif  
   
    
  MALLOC( grd_curscreen,grs_screen,1 );   MALLOC( grd_curscreen,grs_screen,1 );
  memset( grd_curscreen, 0, sizeof(grs_screen));   memset( grd_curscreen, 0, sizeof(grs_screen));

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