version 1.2 | | version 1.3 |
---|
| | |
unsigned char *kludgetexturedata=NULL; | | unsigned char *kludgetexturedata=NULL; |
#endif | | #endif |
| | |
| | |
void ogl_init_state(void){ | | void ogl_init_state(void){ |
/* select clearing (background) color */ | | /* select clearing (background) color */ |
glClearColor(0.0, 0.0, 0.0, 0.0); | | glClearColor(0.0, 0.0, 0.0, 0.0); |
| | |
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); |
| | gr_palette_step_up(0,0,0);//in case its left over from in game |
} | | } |
| | |
float gr_fpal[768]; | | float gr_fpal[768]; |
| | |
{ | | { |
if (gl_initialized){ | | if (gl_initialized){ |
| | |
| | if(Function_mode != FMODE_GAME){ |
| | ogl_init_state(); |
| | { |
#ifdef KLUDGEPOINT | | #ifdef KLUDGEPOINT |
int x,y,yoff; | | int x,y,yoff; |
float gly; | | float gly; |
int c; | | int c; |
glPointSize(1.0); | | glPointSize(1.0); |
for (y=0;y<768;y++) | | 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++){ | | for (y=0;y<grd_curscreen->sc_h;y++){ |
yoff=y*grd_curscreen->sc_w; | | yoff=y*grd_curscreen->sc_w; |
//gly=(grd_curscreen->sc_h-y)/(float)grd_curscreen->sc_h; | | //gly=(grd_curscreen->sc_h-y)/(float)grd_curscreen->sc_h; |
| | |
c=grd_curscreen->sc_canvas.cv_bitmap.bm_data[yoff+x]; | | 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]); | | //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(gr_current_pal[c*3]/63.0,gr_current_pal[c*3+1]/63.0,gr_current_pal[c*3+2]/63.0); |
glColor3f(gr_fpal[c*3],gr_fpal[c*3+1],gr_fpal[c*3+2]); | | |
// glColor3f(0.5, green, 0.5); | | // glColor3f(0.5, green, 0.5); |
//glVertex2i(x,y); | | //glVertex2i(x,y); |
glBegin(GL_POINTS); | | 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); | | glVertex2f(x/(float)grd_curscreen->sc_w,gly); |
glEnd(); | | glEnd(); |
} | | } |
| | |
*data=gr_palette[c*3+2]*4;data++; | | *data=gr_palette[c*3+2]*4;data++; |
} | | } |
| | |
glColor3f(1.0,1.0,1.0); | | |
glEnable( GL_TEXTURE_2D ); | | glEnable( GL_TEXTURE_2D ); |
// select our current texture | | // select our current texture |
glBindTexture( GL_TEXTURE_2D, kludgetexture ); | | glBindTexture( GL_TEXTURE_2D, kludgetexture ); |
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); | | 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_LINEAR_MIPMAP_NEAREST ); | | glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST ); |
// glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NONE ); | | // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NONE ); |
| | |
| | |
| | |
glBegin( GL_QUADS ); | | glBegin( GL_QUADS ); |
| | glColor3f(1.0,1.0,1.0); |
/*glTexCoord2d(0.0,0.0); glVertex2d(0.0,0.0); | | /*glTexCoord2d(0.0,0.0); glVertex2d(0.0,0.0); |
glTexCoord2d(1.0,0.0); glVertex2d(1.0,0.0); | | glTexCoord2d(1.0,0.0); glVertex2d(1.0,0.0); |
glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0); | | glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0); |
| | |
glTexCoord2d(1.0,0.0); glVertex2d(1.0,1.0); | | glTexCoord2d(1.0,0.0); glVertex2d(1.0,1.0); |
glTexCoord2d(0.0,0.0); glVertex2d(0.0,1.0); | | glTexCoord2d(0.0,0.0); glVertex2d(0.0,1.0); |
glEnd(); | | glEnd(); |
| | glDisable( GL_TEXTURE_2D ); |
| | |
#endif | | #endif |
| | |
ogl_swap_buffers();//platform specific code | | ogl_swap_buffers();//platform specific code |
glClear(GL_COLOR_BUFFER_BIT); | | glClear(GL_COLOR_BUFFER_BIT); |
#ifndef KLUDGEPOINT | | #ifndef KLUDGEPOINT |
if (Function_mode!=FMODE_GAME){ | | |
glDeleteTextures( 1, &kludgetexture ); | | glDeleteTextures( 1, &kludgetexture ); |
} | | |
#endif | | #endif |
| | } |
| | } |
} | | } |
} | | } |
| | |
| | |
//if (screen != NULL) gr_palette_clear(); | | //if (screen != NULL) gr_palette_clear(); |
| | |
ogl_init_window(w,h);//platform specific code | | ogl_init_window(w,h);//platform specific code |
ogl_init_state(); | | // ogl_init_state(); |
| | |
memset( grd_curscreen, 0, sizeof(grs_screen)); | | memset( grd_curscreen, 0, sizeof(grs_screen)); |
grd_curscreen->sc_mode = mode; | | grd_curscreen->sc_mode = mode; |
| | |
ogl_close();//platform specific code | | ogl_close();//platform specific code |
} | | } |
| | |
| | void gr_upixelc(int x, int y, int c){ |
| | // printf("gr_upixelc(%i,%i,%i)%i\n",x,y,c,Function_mode==FMODE_GAME); |
| | if(Function_mode != FMODE_GAME){ |
| | grd_curcanv->cv_bitmap.bm_data[y*grd_curscreen->sc_canvas.cv_bitmap.bm_w+x]=c; |
| | }else{ |
| | glPointSize(1.0); |
| | glBegin(GL_POINTS); |
| | glColor3f(PAL2Tr(c),PAL2Tg(c),PAL2Tb(c)); |
| | // 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); |
| | // if (x<50) printf("%f,%f,%f\n",(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); |
| | glVertex2f(x/(float)grd_curscreen->sc_w,1.0-y/(float)grd_curscreen->sc_h); |
| | glEnd(); |
| | } |
| | } |
| | |
// Palette functions follow. | | // Palette functions follow. |
| | //inline GLfloat PAL2Tr(int c) {return (gr_palette[c*3]+gr_palette_gamma)/63.0;} |
| | //inline GLfloat PAL2Tg(int c) {return (gr_palette[c*3+1]+gr_palette_gamma)/63.0;} |
| | //inline GLfloat PAL2Tb(int c) {return (gr_palette[c*3+2]+gr_palette_gamma)/63.0;} |
| | inline GLfloat PAL2Tr(int c) {return (gr_current_pal[c*3]+gr_palette_gamma)/63.0;} |
| | inline GLfloat PAL2Tg(int c) {return (gr_current_pal[c*3+1]+gr_palette_gamma)/63.0;} |
| | inline GLfloat PAL2Tb(int c) {return (gr_current_pal[c*3+2]+gr_palette_gamma)/63.0;} |
| | |
//static int last_r=0, last_g=0, last_b=0; | | //static int last_r=0, last_g=0, last_b=0; |
| | GLfloat last_r=0, last_g=0, last_b=0; |
| | int do_pal_step=0; |
| | void ogl_do_palfx(void){ |
| | // GLfloat r,g,b,a; |
| | if (gr_palette_faded_out){ |
| | /* glEnable(GL_BLEND); |
| | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ |
| | glColor3f(0,0,0); |
| | // r=g=b=0.0;a=1.0; |
| | }else{ |
| | if (do_pal_step){ |
| | //glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR); |
| | glEnable(GL_BLEND); |
| | glBlendFunc(GL_ONE,GL_ONE); |
| | glColor3f(last_r,last_g,last_b); |
| | // r=f2fl(last_r);g=f2fl(last_g);b=f2fl(last_b);a=0.5; |
| | }else |
| | return; |
| | } |
| | |
| | |
| | glBegin(GL_QUADS); |
| | glVertex2f(0,0); |
| | glVertex2f(0,1); |
| | glVertex2f(1,1); |
| | glVertex2f(1,0); |
| | glEnd(); |
| | |
| | glDisable(GL_BLEND); |
| | } |
| | |
void gr_palette_clear() | | void gr_palette_clear() |
{ | | { |
| | gr_palette_faded_out=1; |
} | | } |
| | |
| | |
void gr_palette_step_up( int r, int g, int b ) | | void gr_palette_step_up( int r, int g, int b ) |
{ | | { |
| | if (gr_palette_faded_out) return; |
| | |
| | // if ( (r==last_r) && (g==last_g) && (b==last_b) ) return; |
| | |
| | last_r = r/63.0; |
| | last_g = g/63.0; |
| | last_b = b/63.0; |
| | |
| | do_pal_step=(r || g || b); |
| | |
} | | } |
| | |
//added on 980913 by adb to fix palette problems | | //added on 980913 by adb to fix palette problems |
| | |
} | | } |
//palette = screen->format->palette; | | //palette = screen->format->palette; |
| | |
// init_computed_colors(); | | gr_palette_faded_out=0; |
| | |
| | init_computed_colors(); |
} | | } |
| | |
| | |
| | |
int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys) | | int gr_palette_fade_out(ubyte *pal, int nsteps, int allow_keys) |
{ | | { |
return -1; | | gr_palette_faded_out=1; |
| | return 0; |
} | | } |
| | |
| | |
| | |
int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) | | int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys) |
{ | | { |
return -1; | | gr_palette_faded_out=0; |
| | return 0; |
} | | } |
| | |
| | |