version 1.14 | | version 1.15 |
---|
| | |
#ifdef __WINDOWS__ | | #ifdef __WINDOWS__ |
#include <windows.h> | | #include <windows.h> |
#endif | | #endif |
#include <GL/gl.h> | | |
#include <GL/glu.h> | | //#include <GL/gl.h> |
#include <unistd.h> | | #include <unistd.h> |
#include <sys/types.h> | | #include <sys/types.h> |
#include <sys/stat.h> | | #include <sys/stat.h> |
| | |
#include "mono.h" | | #include "mono.h" |
#include "args.h" | | #include "args.h" |
#include "key.h" | | #include "key.h" |
| | |
| | #include "gamefont.h" |
| | |
| | #define DECLARE_VARS |
#include "ogl_init.h" | | #include "ogl_init.h" |
| | #include <GL/glu.h> |
| | |
| | int ogl_voodoohack=0; |
| | |
int gr_installed = 0; | | int gr_installed = 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 |
} | | } |
| | |
void ogl_swap_buffers(void){ | | |
ogl_do_palfx(); | | |
ogl_swap_buffers_internal(); | | |
glClear(GL_COLOR_BUFFER_BIT); | | |
} | | |
int last_screen_mode=-1; | | int last_screen_mode=-1; |
void ogl_set_screen_mode(void){ | | void ogl_set_screen_mode(void){ |
if (last_screen_mode==Screen_mode) | | if (last_screen_mode==Screen_mode) |
| | |
gr_set_current_canvas(NULL); | | gr_set_current_canvas(NULL); |
//gr_enable_default_palette_loading(); | | //gr_enable_default_palette_loading(); |
| | |
| | OGL_VIEWPORT(0,0,w,h); |
| | |
ogl_set_screen_mode(); | | ogl_set_screen_mode(); |
| | |
| | gamefont_choose_game_font(w,h); |
| | |
return 0; | | return 0; |
} | | } |
| | |
| | |
Error("unknown texture filter %x\n",i); | | Error("unknown texture filter %x\n",i); |
// return -1; | | // return -1; |
} | | } |
| | #ifdef OGL_RUNTIME_LOAD |
| | #ifdef __WINDOWS__ |
| | char *OglLibPath="opengl32.dll"; |
| | #endif |
| | #ifdef __LINUX__ |
| | char *OglLibPath="libGL.so"; |
| | #endif |
| | |
| | int ogl_rt_loaded=0; |
| | int ogl_init_load_library(void) |
| | { |
| | int retcode=-1; |
| | if (!ogl_rt_loaded){ |
| | int t; |
| | if ((t=FindArg("-gl_library"))) |
| | OglLibPath=Args[t+1]; |
| | |
| | retcode = OpenGL_LoadLibrary(true); |
| | if(retcode) |
| | { |
| | mprintf((0,"Opengl loaded ok\n")); |
| | |
| | if(!glEnd) |
| | { |
| | Error("Opengl: Functions not imported\n"); |
| | } |
| | }else{ |
| | Error("Opengl: error loading %s\n",OglLibPath); |
| | } |
| | ogl_rt_loaded=1; |
| | } |
| | return retcode; |
| | } |
| | #endif |
| | |
int gr_init(int mode) | | int gr_init(int mode) |
{ | | { |
int retcode,t,glt=0; | | int retcode,t,glt=0; |
// Only do this function once! | | // Only do this function once! |
if (gr_installed==1) | | if (gr_installed==1) |
return -1; | | return -1; |
| | |
| | if (FindArg("-gl_voodoo")) |
| | ogl_voodoohack=1; |
| | |
| | #ifdef OGL_RUNTIME_LOAD |
| | ogl_init_load_library(); |
| | #endif |
| | |
#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 ((glt=FindArg("-gl_alttexmerge"))) |
| | ogl_alttexmerge=1; |
| | if ((t=FindArg("-gl_oldtexmerge"))) |
| | if (t>=glt)//allow overriding of earlier args |
| | ogl_alttexmerge=0; |
| | |
| | if ((glt=FindArg("-gl_16bittextures"))) |
| | ogl_16bittextures=1; |
| | |
if ((glt=FindArg("-gl_mipmap"))){ | | if ((glt=FindArg("-gl_mipmap"))){ |
GL_texmagfilt=GL_LINEAR; | | GL_texmagfilt=GL_LINEAR; |
GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST; | | GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST; |
| | |
GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt); | | GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt); |
mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps)); | | mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps)); |
| | |
| | if ((t=FindArg("-gl_vidmem"))){ |
| | ogl_mem_target=atoi(Args[t+1])*1024*1024; |
| | } |
| | //printf("ogl_mem_target=%i\n",ogl_mem_target); |
| | |
ogl_init();//platform specific initialization | | ogl_init();//platform specific initialization |
| | |
| | ogl_init_texture_list_internal(); |
| | |
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)); |
grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL; | | grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL; |
| | |
| | |
void gr_close() | | void gr_close() |
{ | | { |
| | // mprintf((0,"ogl init: %s %s %s - %s\n",glGetString(GL_VENDOR),glGetString(GL_RENDERER),glGetString(GL_VERSION),glGetString,(GL_EXTENSIONS))); |
| | |
if (grd_curscreen){ | | if (grd_curscreen){ |
if (grd_curscreen->sc_canvas.cv_bitmap.bm_data) | | if (grd_curscreen->sc_canvas.cv_bitmap.bm_data) |
free(grd_curscreen->sc_canvas.cv_bitmap.bm_data); | | free(grd_curscreen->sc_canvas.cv_bitmap.bm_data); |
free(grd_curscreen); | | free(grd_curscreen); |
} | | } |
ogl_close();//platform specific code | | ogl_close();//platform specific code |
| | #ifdef OGL_RUNTIME_LOAD |
| | if (ogl_rt_loaded) |
| | OpenGL_LoadLibrary(false); |
| | #endif |
} | | } |
extern int r_upixelc; | | extern int r_upixelc; |
void ogl_upixelc(int x, int y, int c){ | | void ogl_upixelc(int x, int y, int c){ |
| | |
// if(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; | | // grd_curcanv->cv_bitmap.bm_data[y*grd_curscreen->sc_canvas.cv_bitmap.bm_w+x]=c; |
// }else{ | | // }else{ |
OGL_DISABLE(GL_TEXTURE_2D); | | OGL_DISABLE(TEXTURE_2D); |
glPointSize(1.0); | | glPointSize(1.0); |
glBegin(GL_POINTS); | | glBegin(GL_POINTS); |
// glBegin(GL_LINES); | | // glBegin(GL_LINES); |
| | |
yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; | | yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; |
yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; | | yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; |
| | |
OGL_DISABLE(GL_TEXTURE_2D); | | OGL_DISABLE(TEXTURE_2D); |
glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c)); | | glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c)); |
glBegin(GL_QUADS); | | glBegin(GL_QUADS); |
glVertex2f(xo,yo); | | glVertex2f(xo,yo); |
| | |
yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; | | yo=1.0-(top+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; |
yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; | | yf=1.0-(bot+grd_curcanv->cv_bitmap.bm_y)/(float)last_height; |
| | |
OGL_DISABLE(GL_TEXTURE_2D); | | OGL_DISABLE(TEXTURE_2D); |
glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c)); | | glColor3f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c)); |
glBegin(GL_LINES); | | glBegin(GL_LINES); |
glVertex2f(xo,yo); | | glVertex2f(xo,yo); |
| | |
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); | | OGL_DISABLE(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);*/ |
| | |
//if we got really spiffy, we could optionally link in libpng or something, and use that. | | //if we got really spiffy, we could optionally link in libpng or something, and use that. |
void write_bmp(char *savename,int w,int h,unsigned char *buf){ | | void write_bmp(char *savename,int w,int h,unsigned char *buf){ |
int f; | | int f; |
| | #ifdef __WINDOWS__ |
| | f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR); |
| | #else |
f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); | | f=open(savename,O_CREAT|O_EXCL|O_WRONLY,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); |
| | #endif |
if (f>=0){ | | if (f>=0){ |
int r; | | int r; |
int i=w*h*3; | | int i=w*h*3; |