From f9788e5b5ff7f5b8e985826209c564b3d78e46ac Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Mon, 29 Jan 2007 23:31:20 +0000 Subject: [PATCH] added transparency effects for some bitmaps like explosions, powerups, weapons, etc. - to enable with -gl_transparency --- arch/ogl/gr.c | 3 +++ arch/ogl/ogl.c | 9 +++++++-- d2x.ini | 1 + dxx-changelog.txt | 4 ++++ include/3d.h | 7 ++++++- main/inferno.c | 1 + main/object.c | 21 ++++++++++++++------- 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 746d46114..64c824e3d 100755 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -67,6 +67,7 @@ int gl_initialized=0; int gl_reticle = 0; int ogl_fullscreen; int ogl_scissor_ok=1; +int glalpha_effects=0; void gr_palette_clear(); // Function prototype for gr_init; @@ -523,6 +524,8 @@ int gr_init() if ((t=FindArg("-gl_reticle"))){ gl_reticle=atoi(Args[t+1]); } + if (FindArg("-gl_transparency")) + glalpha_effects=1; //printf("ogl_mem_target=%i\n",ogl_mem_target); ogl_init();//platform specific initialization diff --git a/arch/ogl/ogl.c b/arch/ogl/ogl.c index 860d8c7d6..203744665 100755 --- a/arch/ogl/ogl.c +++ b/arch/ogl/ogl.c @@ -114,6 +114,7 @@ int cross_lh[2]={0,0}; int primary_lh[3]={0,0,0}; int secondary_lh[5]={0,0,0,0,0}; int bNoDepthTest=0; +extern int glalpha_effects; /*int lastbound=-1; #define OGL_BINDTEXTURE(a) if(gr_badtexture>0) glBindTexture(GL_TEXTURE_2D, 0);\ @@ -1108,7 +1109,7 @@ bool g3_draw_tmap_2(int nv, g3s_point **pointlist, g3s_uvl *uvl_list, grs_bitmap return 0; } -bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation) +bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation, object *obj) { vms_vector pv,v1;//,v2; int i; @@ -1122,7 +1123,11 @@ bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int ori glDisable(GL_DEPTH_TEST); // ZICO - disable to prevent sprites get cutted by polygons glBegin(GL_QUADS); - glColor3f(1.0,1.0,1.0); + // Define alpha by looking for object TYPE or ID. We do this here so we have it seperated from the rest of the code. + if (glalpha_effects && (obj->type==OBJ_FIREBALL || obj->type==OBJ_WEAPON || obj->id==POW_EXTRA_LIFE || obj->id==POW_ENERGY || obj->id==POW_SHIELD_BOOST || obj->id==POW_HOARD_ORB || obj->id==POW_CLOAK || obj->id==POW_INVULNERABILITY)) + glColor4f(1.0,1.0,1.0,0.6); + else + glColor3f(1.0,1.0,1.0); width = fixmul(width,Matrix_scale.x); height = fixmul(height,Matrix_scale.y); for (i=0;i<4;i++){ diff --git a/d2x.ini b/d2x.ini index f8a97afc8..ee1326458 100755 --- a/d2x.ini +++ b/d2x.ini @@ -39,6 +39,7 @@ ;-gl_simple Set gl texture filters to gl_nearest for "original" look. (default) ;-gl_mipmap Set gl texture filters to "standard" options for mipmapping ;-gl_trilinear Set gl texture filters to trilinear mipmapping +;-gl_transparency Enable transparency effects ;-gl_reticle Use OGL reticle 0=never 1=above 320x* 2=always ;-fixedfont Do not scale fonts to current resolution ;-gl_scissor_ok Set glScissor. 0=off 1=on (default) diff --git a/dxx-changelog.txt b/dxx-changelog.txt index 09746209d..836d905b0 100755 --- a/dxx-changelog.txt +++ b/dxx-changelog.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20070130 +-------- +d2x.ini, arch/ogl/gr.c, arch/ogl/ogl.c, include/3d.h, main/inferno.c, main/object.c: added transparency effects for some bitmaps like explosions, powerups, weapons, etc. - to enable with -gl_transparency + 20070129 -------- main/gamecntl.c: fixed energy->shield transfer message output showing 'No transfer: Shields already at max' everytime if there is enough energy diff --git a/include/3d.h b/include/3d.h index 587455271..04b3f20ab 100755 --- a/include/3d.h +++ b/include/3d.h @@ -25,6 +25,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "fix.h" #include "vecmat.h" //the vector/matrix library #include "gr.h" +#include "object.h" extern int g3d_interp_outline; //if on, polygon models outlined in white @@ -215,7 +216,11 @@ bool g3_draw_rod_tmap(grs_bitmap *bitmap,g3s_point *bot_point,fix bot_width,g3s_ //draws a bitmap with the specified 3d width & height //returns 1 if off screen, 0 if drew -bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation); +bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, int orientation +#ifdef OGL + ,object *obj +#endif + ); //specifies 2d drawing routines to use instead of defaults. Passing //NULL for either or both restores defaults diff --git a/main/inferno.c b/main/inferno.c index 675596dcc..4953ff43c 100755 --- a/main/inferno.c +++ b/main/inferno.c @@ -226,6 +226,7 @@ void print_commandline_help() printf( " -gl_simple %s\n", "Set gl texture filters to gl_nearest for \"original\" look. (default)"); printf( " -gl_mipmap %s\n", "Set gl texture filters to \"standard\" options for mipmapping"); printf( " -gl_trilinear %s\n", "Set gl texture filters to trilinear mipmapping"); + printf( " -gl_transparency %s\n", "Enable transparency effects"); printf( " -gl_reticle %s\n", "Use OGL reticle 0=never 1=above 320x* 2=always"); printf( " -gl_scissor_ok %s\n", "Set glScissor. 0=off 1=on (default)"); printf( " -fixedfont %s\n", "Do not scale fonts to current resolution"); diff --git a/main/object.c b/main/object.c index 812d3fdee..64913f834 100755 --- a/main/object.c +++ b/main/object.c @@ -246,13 +246,20 @@ void draw_object_blob(object *obj,bitmap_index bmi) PIGGY_PAGE_IN( bmi ); - if (bm->bm_w > bm->bm_h) - - g3_draw_bitmap(&obj->pos,obj->size,fixmuldiv(obj->size,bm->bm_h,bm->bm_w),bm, orientation); - - else - - g3_draw_bitmap(&obj->pos,fixmuldiv(obj->size,bm->bm_w,bm->bm_h),obj->size,bm, orientation); + if (bm->bm_w > bm->bm_h) { + g3_draw_bitmap(&obj->pos,obj->size,fixmuldiv(obj->size,bm->bm_h,bm->bm_w),bm, orientation +#ifdef OGL + ,obj +#endif + ); + } + else { + g3_draw_bitmap(&obj->pos,fixmuldiv(obj->size,bm->bm_w,bm->bm_h),obj->size,bm, orientation +#ifdef OGL + ,obj +#endif + ); + } } //draw an object that is a texture-mapped rod