version 1.9 | | version 1.10 |
---|
| | |
| | |
#include "inferno.h" | | #include "inferno.h" |
| | |
| | #include "strutil.h" |
| | #include "mono.h" |
#include "args.h" | | #include "args.h" |
#include "ogl_init.h" | | #include "ogl_init.h" |
| | |
| | |
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 |
} | | } |
| | |
float gr_fpal[768]; | | |
void gr_update() | | void gr_update() |
{ | | { |
if (gl_initialized){ | | if (gl_initialized){ |
| | |
| | |
ogl_init_state(); | | ogl_init_state(); |
OGL_ENABLE(GL_TEXTURE_2D); | | OGL_ENABLE(GL_TEXTURE_2D); |
| | OGL_TEXENV(GL_TEXTURE_ENV_MODE,GL_DECAL); |
| | OGL_TEXPARAM(GL_TEXTURE_MAG_FILTER,GL_NEAREST); |
| | OGL_TEXPARAM(GL_TEXTURE_MIN_FILTER,GL_NEAREST); |
// glEnable( GL_TEXTURE_2D ); | | // glEnable( GL_TEXTURE_2D ); |
| | // glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); |
| | // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST ); |
| | // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); |
| | // if wrap is true, the texture wraps over at the edges (repeat) |
| | // ... false, the texture ends at the edges (clamp) |
| | // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP ); |
| | // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP ); |
| | OGL_TEXCLAMP(); |
| | |
| | glColor3f(1.0,1.0,1.0); |
for (i=0; i<grd_curscreen->sc_w/32; i++) { | | for (i=0; i<grd_curscreen->sc_w/32; i++) { |
for (j=0; j<grd_curscreen->sc_h/32; j++) { | | for (j=0; j<grd_curscreen->sc_h/32; j++) { |
int y,x,c,t; | | int y,x,c,t; |
| | |
| | |
// 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_DECAL ); | | |
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST ); | | |
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); | | |
| | |
// if wrap is true, the texture wraps over at the edges (repeat) | | |
// ... false, the texture ends at the edges (clamp) | | |
// glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP ); | | |
// glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP ); | | |
OGL_TEXCLAMP(); | | |
| | |
glTexImage2D( GL_TEXTURE_2D, 0, 3, 32, | | glTexImage2D( GL_TEXTURE_2D, 0, 3, 32, |
32, 0, GL_RGB, GL_UNSIGNED_BYTE, kludgetexturedata ); | | 32, 0, GL_RGB, GL_UNSIGNED_BYTE, kludgetexturedata ); |
| | |
| | |
glBegin( GL_QUADS ); | | glBegin( GL_QUADS ); |
glColor3f(1.0,1.0,1.0); | | |
glTexCoord2d(0.0,0.0); glVertex2f(kx*(float)i,ky*(float)j); | | glTexCoord2d(0.0,0.0); glVertex2f(kx*(float)i,ky*(float)j); |
glTexCoord2d(1.0,0.0); glVertex2f(kx*(float)(i+1),ky*(float)j); | | glTexCoord2d(1.0,0.0); glVertex2f(kx*(float)(i+1),ky*(float)j); |
glTexCoord2d(1.0,1.0); glVertex2f(kx*(float)(i+1),ky*(float)(j+1)); | | glTexCoord2d(1.0,1.0); glVertex2f(kx*(float)(i+1),ky*(float)(j+1)); |
| | |
return 0; | | return 0; |
} | | } |
| | |
| | #define GLstrcmptestr(a,b) if (stricmp(a,#b)==0 || stricmp(a,"GL_" #b)==0)return GL_ ## b; |
| | int ogl_atotexfilti(char *a){ |
| | GLstrcmptestr(a,NEAREST); |
| | GLstrcmptestr(a,LINEAR); |
| | GLstrcmptestr(a,NEAREST_MIPMAP_NEAREST); |
| | GLstrcmptestr(a,NEAREST_MIPMAP_LINEAR); |
| | GLstrcmptestr(a,LINEAR_MIPMAP_NEAREST); |
| | GLstrcmptestr(a,LINEAR_MIPMAP_LINEAR); |
| | return GL_NEAREST; |
| | } |
| | int ogl_testneedmipmaps(int i){ |
| | switch (i){ |
| | case GL_NEAREST: |
| | case GL_LINEAR: |
| | return 0; |
| | case GL_NEAREST_MIPMAP_NEAREST: |
| | case GL_NEAREST_MIPMAP_LINEAR: |
| | case GL_LINEAR_MIPMAP_NEAREST: |
| | case GL_LINEAR_MIPMAP_LINEAR: |
| | return 1; |
| | } |
| | return -1; |
| | } |
int gr_init(int mode) | | int gr_init(int mode) |
{ | | { |
int retcode; | | int retcode,t; |
// Only do this function once! | | // Only do this function once! |
if (gr_installed==1) | | if (gr_installed==1) |
return -1; | | return -1; |
| | |
#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE | | #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE |
if (FindArg("-fullscreen")) | | if (FindArg("-fullscreen")) |
gr_toggle_fullscreen(); | | gr_toggle_fullscreen(); |
#endif | | #endif |
| | if ((t=FindArg("-gl_texmagfilt"))){ |
| | // t=atoi(Args[t+1]); |
| | GL_texmagfilt=ogl_atotexfilti(Args[t+1]); |
| | } |
| | if ((t=FindArg("-gl_texminfilt"))){ |
| | GL_texminfilt=ogl_atotexfilti(Args[t+1]); |
| | } |
| | GL_needmipmaps=(ogl_testneedmipmaps(GL_texminfilt) || ogl_testneedmipmaps(GL_texmagfilt)); |
| | mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps)); |
| | |
ogl_init();//platform specific initialization | | ogl_init();//platform specific initialization |
| | |
| | |
OGL_DISABLE(GL_TEXTURE_2D); | | OGL_DISABLE(GL_TEXTURE_2D); |
glPointSize(1.0); | | glPointSize(1.0); |
glBegin(GL_POINTS); | | glBegin(GL_POINTS); |
| | // glBegin(GL_LINES); |
glColor3f(PAL2Tr(c),PAL2Tg(c),PAL2Tb(c)); | | 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)last_width,1.0-y/(float)last_height); | | glVertex2f(x/(float)last_width,1.0-y/(float)last_height); |
| | // glVertex2f(x/((float)last_width+1),1.0-y/((float)last_height+1)); |
glEnd(); | | glEnd(); |
} | | } |
} | | } |
| | |
// 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;} | | |
//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; | | |
GLfloat last_r=0, last_g=0, last_b=0; | | GLfloat last_r=0, last_g=0, last_b=0; |
int do_pal_step=0; | | int do_pal_step=0; |
void ogl_do_palfx(void){ | | void ogl_do_palfx(void){ |
// GLfloat r,g,b,a; | | // GLfloat r,g,b,a; |
| | OGL_DISABLE(GL_TEXTURE_2D); |
if (gr_palette_faded_out){ | | if (gr_palette_faded_out){ |
/* glEnable(GL_BLEND); | | /* glEnable(GL_BLEND); |
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ | | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);*/ |