Added cv_fade_level to canvas structure to replace Gr_scanline_darkening_level; Added cv_blend_func to canvas structure to set blending; Introduced gr_settransblend to set cv_fade_level and cv_blend_func; Added function to set normal blending, additive alpha blending and additive color blending; Moved Special transparency effects from g3_draw_bitmap to render_object to set individual transparency and/or blending for each object outside of OpenGL-specific code; Added special blending for fuelcenter and force field effects as well; Removed unused LASER_HACK code; Renamed OglAlphaEffects variable of PalyerCfg to AlphaEffects as I plan to implement this kind of effects for Software renderer, too

This commit is contained in:
zicodxx 2011-02-23 17:46:39 +01:00
parent 635dcfee4f
commit c960d5505a
23 changed files with 193 additions and 194 deletions

View file

@ -23,8 +23,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "grdef.h"
#include "error.h"
int Gr_scanline_darkening_level = GR_FADE_LEVELS;
void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) {
register int i;
@ -41,7 +39,7 @@ void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes) {
void gr_uscanline( int x1, int x2, int y )
{
if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
if (grd_curcanv->cv_fade_level >= GR_FADE_OFF) {
switch(TYPE)
{
case BM_LINEAR:
@ -58,7 +56,7 @@ void gr_uscanline( int x1, int x2, int y )
#ifdef OGL
case BM_OGL:
#endif
gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
gr_linear_darken( DATA + ROWSIZE*y + x1, grd_curcanv->cv_fade_level, x2-x1+1, gr_fade_table);
break;
}
}
@ -76,7 +74,7 @@ void gr_scanline( int x1, int x2, int y )
if (x1 < MINX) x1 = MINX;
if (x2 > MAXX) x2 = MAXX;
if (Gr_scanline_darkening_level >= GR_FADE_LEVELS ) {
if (grd_curcanv->cv_fade_level >= GR_FADE_OFF) {
switch(TYPE)
{
case BM_LINEAR:
@ -93,7 +91,7 @@ void gr_scanline( int x1, int x2, int y )
#ifdef OGL
case BM_OGL:
#endif
gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
gr_linear_darken( DATA + ROWSIZE*y + x1, grd_curcanv->cv_fade_level, x2-x1+1, gr_fade_table);
break;
}
}

View file

@ -16,10 +16,11 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include <stdio.h>
#include "u_mem.h"
#include "gr.h"
#include "grdef.h"
#ifdef OGL
#include "ogl_init.h"
#endif
grs_canvas * grd_curcanv; //active canvas
grs_screen * grd_curscreen; //active screen
@ -107,3 +108,11 @@ void gr_setcolor(int color)
grd_curcanv->cv_color=color;
}
void gr_settransblend(int fade_level, ubyte blend_func)
{
grd_curcanv->cv_fade_level=fade_level;
grd_curcanv->cv_blend_func=blend_func;
#ifdef OGL
ogl_set_blending();
#endif
}

View file

@ -1,5 +1,9 @@
D2X-Rebirth Changelog
20110223
--------
2d/2dsline.c, 2d/canvas.c, arch/ogl/gr.c, arch/ogl/ogl.c, arch/sdl/gr.c, include/3d.h, include/gr.h, include/ogl_init.h, main/ai.c, main/ai.h, main/console.c, main/effects.h, main/gamerend.c, main/gauges.c, main/hud.c, main/menu.c, main/multibot.c, main/newmenu.c, main/object.c, main/playsave.c, main/playsave.h, main/render.c, texmap/tmapflat.c: Added cv_fade_level to canvas structure to replace Gr_scanline_darkening_level; Added cv_blend_func to canvas structure to set blending; Introduced gr_settransblend to set cv_fade_level and cv_blend_func; Added function to set normal blending, additive alpha blending and additive color blending; Moved Special transparency effects from g3_draw_bitmap to render_object to set individual transparency and/or blending for each object outside of OpenGL-specific code; Added special blending for fuelcenter and force field effects as well; Removed unused LASER_HACK code; Renamed OglAlphaEffects variable of PalyerCfg to AlphaEffects as I plan to implement this kind of effects for Software renderer, too
20110221
--------
misc/strutil.c: Fix a critical bug in string_array_add - when d_reallocing the buffer containing the string data, update all the pointers in '*list' as well as next_str, preventing ugly crashes

View file

@ -498,6 +498,8 @@ int gr_init(int mode)
return retcode;
grd_curscreen->sc_canvas.cv_color = 0;
grd_curscreen->sc_canvas.cv_fade_level = GR_FADE_OFF;
grd_curscreen->sc_canvas.cv_blend_func = GR_BLEND_NORMAL;
grd_curscreen->sc_canvas.cv_drawmode = 0;
grd_curscreen->sc_canvas.cv_font = NULL;
grd_curscreen->sc_canvas.cv_font_fg_color = 0;
@ -572,10 +574,10 @@ void ogl_urect(int left,int top,int right,int bot)
color_g = CPAL2Tg(c);
color_b = CPAL2Tb(c);
if (Gr_scanline_darkening_level >= GR_FADE_LEVELS)
if (grd_curcanv->cv_fade_level >= GR_FADE_OFF)
color_a = 1.0;
else
color_a = 1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0);
color_a = 1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0);
color_array[0] = color_array[4] = color_array[8] = color_array[12] = color_r;
color_array[1] = color_array[5] = color_array[9] = color_array[13] = color_g;
@ -600,7 +602,7 @@ void ogl_urect(int left,int top,int right,int bot)
void ogl_ulinec(int left,int top,int right,int bot,int c)
{
GLfloat xo,yo,xf,yf;
GLfloat color_array[] = { CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (Gr_scanline_darkening_level >= GR_FADE_LEVELS)?1.0:1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (Gr_scanline_darkening_level >= GR_FADE_LEVELS)?1.0:1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (Gr_scanline_darkening_level >= GR_FADE_LEVELS)?1.0:1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0) };
GLfloat color_array[] = { CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0), CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), 1.0, CPAL2Tr(c), CPAL2Tg(c), CPAL2Tb(c), (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0) };
GLfloat vertex_array[] = { 0.0, 0.0, 0.0, 0.0 };
glEnableClientState(GL_VERTEX_ARRAY);

View file

@ -774,7 +774,7 @@ int gr_ucircle(fix xc1, fix yc1, fix r1)
int c, nsides;
c=grd_curcanv->cv_color;
OGL_DISABLE(TEXTURE_2D);
glColor4f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c),(Gr_scanline_darkening_level >= GR_FADE_LEVELS)?1.0:1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0));
glColor4f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c),(grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0));
glPushMatrix();
glTranslatef(
(f2fl(xc1) + grd_curcanv->cv_bitmap.bm_x + 0.5) / (float)last_width,
@ -797,7 +797,7 @@ int gr_disk(fix x,fix y,fix r)
int c, nsides;
c=grd_curcanv->cv_color;
OGL_DISABLE(TEXTURE_2D);
glColor4f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c),(Gr_scanline_darkening_level >= GR_FADE_LEVELS)?1.0:1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0));
glColor4f(CPAL2Tr(c),CPAL2Tg(c),CPAL2Tb(c),(grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0));
glPushMatrix();
glTranslatef(
(f2fl(x) + grd_curcanv->cv_bitmap.bm_x + 0.5) / (float)last_width,
@ -811,28 +811,6 @@ int gr_disk(fix x,fix y,fix r)
return 0;
}
/*
* set/revert blending for laser rendering (intersecting polygons)
*/
void ogl_toggle_laser_blending(int enable)
{
static GLint prev_sfactor = -1, prev_dfactor = -1;
if ( !enable && (prev_sfactor == -1 || prev_dfactor == -1) )
return;
if ( enable )
{
glGetIntegerv( GL_BLEND_SRC, &prev_sfactor );
glGetIntegerv(GL_BLEND_DST, &prev_dfactor );
glBlendFunc(GL_ONE,GL_ONE);
}
else
{
glBlendFunc(prev_sfactor,prev_dfactor);
prev_sfactor = prev_dfactor = -1;
}
}
/*
* Draw flat-shaded Polygon (Lasers, Drone-arms, Driller-ears)
*/
@ -852,10 +830,10 @@ bool g3_draw_poly(int nv,g3s_point **pointlist)
color_g = PAL2Tg(c);
color_b = PAL2Tb(c);
if (Gr_scanline_darkening_level >= GR_FADE_LEVELS)
if (grd_curcanv->cv_fade_level >= GR_FADE_OFF)
color_a = 1.0;
else
color_a = 1.0 - (float)Gr_scanline_darkening_level / ((float)GR_FADE_LEVELS - 1.0);
color_a = 1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0);
for (c=0; c<nv; c++){
index3 = c * 3;
@ -908,10 +886,11 @@ bool g3_draw_tmap(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bm)
ogl_bindbmtex(bm);
ogl_texwrap(bm->gltexture, GL_REPEAT);
r_tpolyc++;
color_alpha = (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:(1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0));
} else if (tmap_drawer_ptr == draw_tmap_flat) {
OGL_DISABLE(TEXTURE_2D);
/* for cloaked state faces */
color_alpha = 1.0 - (Gr_scanline_darkening_level/(GLfloat)NUM_LIGHTING_LEVELS);
color_alpha = 1.0 - (grd_curcanv->cv_fade_level/(GLfloat)NUM_LIGHTING_LEVELS);
} else {
glmprintf((0,"g3_draw_tmap: unhandled tmap_drawer %p\n",tmap_drawer_ptr));
return 0;
@ -998,7 +977,7 @@ bool g3_draw_tmap_2(int nv, g3s_point **pointlist, g3s_uvl *uvl_list, grs_bitmap
color_array[index4] = bm->bm_flags & BM_FLAG_NO_LIGHTING ? 1.0 : f2glf(uvl_list[c].l);
color_array[index4+1] = color_array[c*4];
color_array[index4+2] = color_array[c*4];
color_array[index4+3] = 1.0;
color_array[index4+3] = (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:(1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0));
vertex_array[index3] = f2glf(pointlist[c]->p3_vec.x);
vertex_array[index3+1] = f2glf(pointlist[c]->p3_vec.y);
@ -1019,16 +998,11 @@ bool g3_draw_tmap_2(int nv, g3s_point **pointlist, g3s_uvl *uvl_list, grs_bitmap
/*
* 2d Sprites (Fireaballs, powerups, explosions). NOT hostages
*/
bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, object *obj)
bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm)
{
vms_vector pv,v1;
int i;
float color_a;
GLfloat vertex_array[12], color_array[16], texcoord_array[8];
GLint prev_sfactor, prev_dfactor;
glGetIntegerv( GL_BLEND_SRC, &prev_sfactor );
glGetIntegerv(GL_BLEND_DST, &prev_dfactor );
r_bitmapc++;
v1.z=0;
@ -1041,23 +1015,6 @@ bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, object
ogl_bindbmtex(bm);
ogl_texwrap(bm->gltexture,GL_CLAMP_TO_EDGE);
// 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 (PlayerCfg.OglAlphaEffects && // if -gl_transparency draw following bitmaps
(obj->type==OBJ_FIREBALL || // all types of explosions and energy-effects
(obj->type==OBJ_WEAPON && (obj->id != PROXIMITY_ID && obj->id != SUPERPROX_ID && obj->id != ROBOT_SUPERPROX_ID && obj->id != PMINE_ID)) || // weapon fire except bombs
obj->id==POW_EXTRA_LIFE || // extra life
obj->id==POW_ENERGY || // energy powerup
obj->id==POW_SHIELD_BOOST || // shield boost
obj->id==POW_CLOAK || // cloak
obj->id==POW_INVULNERABILITY || // invulnerability
obj->id==POW_HOARD_ORB)) // Hoard Orb
{
color_a = 0.7; // ... with 0.7 alpha
glBlendFunc( GL_SRC_ALPHA, GL_ONE ); // and special blending to keep intensity as well as nice ... blending - yeah
}
else
color_a = 1.0;
width = fixmul(width,Matrix_scale.x);
height = fixmul(height,Matrix_scale.y);
for (i=0;i<4;i++){
@ -1090,13 +1047,10 @@ bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, object
break;
}
if (obj->id == 5 && obj->type == 1) // create small z-Offset for missile exploding effect - prevents ugly wall-clipping
pv.z -= F1_0;
color_array[i*4] = 1.0;
color_array[i*4+1] = 1.0;
color_array[i*4+2] = 1.0;
color_array[i*4+3] = color_a;
color_array[i*4+3] = (grd_curcanv->cv_fade_level >= GR_FADE_OFF)?1.0:(1.0 - (float)grd_curcanv->cv_fade_level / ((float)GR_FADE_LEVELS - 1.0));
vertex_array[i*3] = f2glf(pv.x);
vertex_array[i*3+1] = f2glf(pv.y);
@ -1109,7 +1063,6 @@ bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm, object
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glBlendFunc(prev_sfactor,prev_dfactor);
return 0;
}
@ -1187,6 +1140,9 @@ bool ogl_ubitblt(int w,int h,int dx,int dy, int sx, int sy, grs_bitmap * src, gr
return ogl_ubitblt_i(w,h,dx,dy,w,h,sx,sy,src,dest,0);
}
/*
* set depth testing on or off
*/
void ogl_toggle_depth_test(int enable)
{
if (enable)
@ -1195,6 +1151,26 @@ void ogl_toggle_depth_test(int enable)
glDisable(GL_DEPTH_TEST);
}
/*
* set blending function
*/
void ogl_set_blending()
{
switch ( grd_curcanv->cv_blend_func )
{
case GR_BLEND_ADDITIVE_A:
glBlendFunc( GL_SRC_ALPHA, GL_ONE );
break;
case GR_BLEND_ADDITIVE_C:
glBlendFunc( GL_SRC_COLOR, GL_ONE );
break;
case GR_BLEND_NORMAL:
default:
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
break;
}
}
GLubyte *pixels = NULL;
void ogl_start_frame(void){

View file

@ -202,6 +202,8 @@ int gr_init(int mode)
return retcode;
grd_curscreen->sc_canvas.cv_color = 0;
grd_curscreen->sc_canvas.cv_fade_level = GR_FADE_OFF;
grd_curscreen->sc_canvas.cv_blend_func = GR_BLEND_NORMAL;
grd_curscreen->sc_canvas.cv_drawmode = 0;
grd_curscreen->sc_canvas.cv_font = NULL;
grd_curscreen->sc_canvas.cv_font_fg_color = 0;

View file

@ -208,11 +208,7 @@ 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
#ifdef OGL
, struct object *obj
#endif
);
bool g3_draw_bitmap(vms_vector *pos,fix width,fix height,grs_bitmap *bm);
//specifies 2d drawing routines to use instead of defaults. Passing
//NULL for either or both restores defaults

View file

@ -24,11 +24,13 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "pstypes.h"
#include "fix.h"
// #define SWAP_0_255 0 // swap black and white
#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC
#define GR_FADE_LEVELS 34
#define GR_ACTUAL_FADE_LEVELS 32
// some defines for transparency and blending
#define TRANSPARENCY_COLOR 255 // palette entry of transparency color -- 255 on the PC
#define GR_FADE_LEVELS 34
#define GR_FADE_OFF GR_FADE_LEVELS // yes, max means OFF - don't screw that up
#define GR_BLEND_NORMAL 0 // normal blending
#define GR_BLEND_ADDITIVE_A 1 // additive alpha blending
#define GR_BLEND_ADDITIVE_C 2 // additive color blending
#define GWIDTH grd_curcanv->cv_bitmap.bm_w
#define GHEIGHT grd_curcanv->cv_bitmap.bm_h
@ -40,8 +42,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define SCRNS_DIR "screenshots/"
extern int Gr_scanline_darkening_level;
typedef struct _grs_point {
fix x,y;
} grs_point;
@ -125,6 +125,8 @@ typedef struct _grs_font {
typedef struct _grs_canvas {
grs_bitmap cv_bitmap; // the bitmap for this canvas
short cv_color; // current color
int cv_fade_level; // transparency level
ubyte cv_blend_func; // blending function to use
short cv_drawmode; // fill,XOR,etc.
grs_font * cv_font; // the currently selected font
short cv_font_fg_color; // current font foreground color (-1==Invisible)
@ -249,9 +251,10 @@ void gr_copy_palette(ubyte *gr_palette, ubyte *pal, int size);
// For solid, XOR, or other fill modes.
int gr_set_drawmode(int mode);
// Sets the color in the current canvas. should be a macro
// Use: gr_setcolor(int color);
// Sets the color in the current canvas.
void gr_setcolor(int color);
// Sets transparency and blending function
void gr_settransblend(int fade_level, ubyte blend_func);
// Draw a polygon into the current canvas in the current color and drawmode.
// verts points to an ordered list of x,y pairs. the polygon should be

View file

@ -104,7 +104,7 @@ void ogl_ulinec(int left, int top, int right, int bot, int c);
bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,grs_bitmap *bmbot,grs_bitmap *bm, int orient);
void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs);
void ogl_toggle_laser_blending(int enable);
void ogl_toggle_depth_test(int enable);
void ogl_set_blending();
#endif /* _OGL_INIT_H_ */

View file

@ -31,7 +31,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define MAX_DEPTH_TO_SEARCH_FOR_PLAYER 10
#define BOSS_GATE_MATCEN_NUM -1
#define MAX_BOSS_TELEPORT_SEGS 100
#define BOSS_ECLIP_NUM 53
#define ROBOT_BRAIN 7
#define ROBOT_BOSS1 17

View file

@ -115,9 +115,9 @@ void con_draw(void)
gr_set_current_canvas(NULL);
gr_set_curfont(GAME_FONT);
gr_setcolor(BM_XRGB(0,0,0));
Gr_scanline_darkening_level = 1*7;
gr_settransblend(7, GR_BLEND_NORMAL);
gr_rect(0,0,SWIDTH,(LINE_SPACING*(con_size))+FSPACY(1));
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
y=FSPACY(1)+(LINE_SPACING*con_size);
i+=con_scroll_offset;
while (!done)

View file

@ -32,6 +32,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define EF_ONE_SHOT 2 //this is a special that gets played once
#define EF_STOPPED 4 //this has been stopped
#define ECLIP_NUM_FUELCEN 2
#define ECLIP_NUM_BOSS 53
#define ECLIP_NUM_FORCE_FIELD 78
typedef struct eclip {
vclip vc; //imbedded vclip
fix time_left; //for sequencing

View file

@ -148,10 +148,10 @@ void show_netplayerinfo()
x=(SWIDTH/2)-FSPACX(120);
y=(SHEIGHT/2)-FSPACY(84);
Gr_scanline_darkening_level = 2*7;
gr_settransblend(14, GR_BLEND_NORMAL);
gr_setcolor( BM_XRGB(0,0,0) );
gr_rect((SWIDTH/2)-FSPACX(120),(SHEIGHT/2)-FSPACY(84),(SWIDTH/2)+FSPACX(120),(SHEIGHT/2)+FSPACY(84));
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
// general game information
y+=LINE_SPACING;

View file

@ -1814,9 +1814,9 @@ void draw_player_ship(int cloak_state,int x, int y)
gr_set_current_canvas(NULL);
hud_bitblt( HUD_SCALE_X(x), HUD_SCALE_Y(y), bm);
Gr_scanline_darkening_level = cloak_fade_value;
gr_settransblend(cloak_fade_value, GR_BLEND_NORMAL);
gr_rect(HUD_SCALE_X(x-3), HUD_SCALE_Y(y-3), HUD_SCALE_X(x+bm->bm_w+3), HUD_SCALE_Y(y+bm->bm_h+3));
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
gr_set_current_canvas( NULL );
}
@ -2049,10 +2049,10 @@ void draw_weapon_box(int weapon_type,int weapon_num)
int fade_value = f2i(weapon_box_fade_values[weapon_type]);
int boxofs = (PlayerCfg.CockpitMode[1]==CM_STATUS_BAR)?SB_PRIMARY_BOX:COCKPIT_PRIMARY_BOX;
Gr_scanline_darkening_level = fade_value;
gr_settransblend(fade_value, GR_BLEND_NORMAL);
gr_rect(HUD_SCALE_X(gauge_boxes[boxofs+weapon_type].left),HUD_SCALE_Y(gauge_boxes[boxofs+weapon_type].top),HUD_SCALE_X(gauge_boxes[boxofs+weapon_type].right),HUD_SCALE_Y(gauge_boxes[boxofs+weapon_type].bot));
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
gr_set_current_canvas(NULL);
@ -2320,7 +2320,7 @@ void show_reticle(int reticle_type, int secondary_display)
Assert(cross_bm_num <= 1);
gr_setcolor(BM_XRGB(PlayerCfg.ReticleRGBA[0],PlayerCfg.ReticleRGBA[1],PlayerCfg.ReticleRGBA[2]));
Gr_scanline_darkening_level = PlayerCfg.ReticleRGBA[3];
gr_settransblend(PlayerCfg.ReticleRGBA[3], GR_BLEND_NORMAL);
switch (reticle_type)
{
@ -2421,7 +2421,7 @@ void show_reticle(int reticle_type, int secondary_display)
default:
break;
}
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
void show_mousefs_indicator(int mx, int my, int mz, int x, int y, int size)
@ -2429,13 +2429,13 @@ void show_mousefs_indicator(int mx, int my, int mz, int x, int y, int size)
int axscale = (MOUSEFS_DELTA_RANGE*2)/size, xaxpos = x+(mx/axscale), yaxpos = y+(my/axscale), zaxpos = y+(mz/axscale);
gr_setcolor(BM_XRGB(PlayerCfg.ReticleRGBA[0],PlayerCfg.ReticleRGBA[1],PlayerCfg.ReticleRGBA[2]));
Gr_scanline_darkening_level = PlayerCfg.ReticleRGBA[3];
gr_settransblend(PlayerCfg.ReticleRGBA[3], GR_BLEND_NORMAL);
gr_uline(i2f(xaxpos), i2f(y-(size/2)), i2f(xaxpos), i2f(y-(size/4)));
gr_uline(i2f(xaxpos), i2f(y+(size/2)), i2f(xaxpos), i2f(y+(size/4)));
gr_uline(i2f(x-(size/2)), i2f(yaxpos), i2f(x-(size/4)), i2f(yaxpos));
gr_uline(i2f(x+(size/2)), i2f(yaxpos), i2f(x+(size/4)), i2f(yaxpos));
gr_uline(i2f(x+(size/2)+HUD_SCALE_X_AR(2)), i2f(y), i2f(x+(size/2)+HUD_SCALE_X_AR(2)), i2f(zaxpos));
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
#ifdef NETWORK

View file

@ -217,10 +217,10 @@ void player_dead_message(void)
x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
Gr_scanline_darkening_level = 2*7;
gr_settransblend(14, GR_BLEND_NORMAL);
gr_setcolor( BM_XRGB(0,0,0) );
gr_rect( x, y, x+w, y+h );
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
}

View file

@ -1317,7 +1317,7 @@ void graphics_config()
m[nitems].type = NM_TYPE_MENU; m[nitems].text = "Reticle Options"; nitems++;
#ifdef OGL
opt_gr_alphafx = nitems;
m[nitems].type = NM_TYPE_CHECK; m[nitems].text = "Transparency Effects"; m[nitems].value = PlayerCfg.OglAlphaEffects; nitems++;
m[nitems].type = NM_TYPE_CHECK; m[nitems].text = "Transparency Effects"; m[nitems].value = PlayerCfg.AlphaEffects; nitems++;
opt_gr_vsync = nitems;
m[nitems].type = NM_TYPE_CHECK; m[nitems].text="VSync"; m[nitems].value = GameCfg.VSync; nitems++;
opt_gr_multisample = nitems;
@ -1339,7 +1339,7 @@ void graphics_config()
if (m[i+opt_gr_texfilt].value)
GameCfg.TexFilt = i;
GameCfg.MovieTexFilt = m[opt_gr_movietexfilt].value;
PlayerCfg.OglAlphaEffects = m[opt_gr_alphafx].value;
PlayerCfg.AlphaEffects = m[opt_gr_alphafx].value;
GameCfg.VSync = m[opt_gr_vsync].value;
GameCfg.Multisample = m[opt_gr_multisample].value;
#endif

View file

@ -1053,10 +1053,10 @@ multi_do_boss_actions(char *buf)
}
break;
case 4: // Start effect
restart_effect(BOSS_ECLIP_NUM);
restart_effect(ECLIP_NUM_BOSS);
break;
case 5: // Stop effect
stop_effect(BOSS_ECLIP_NUM);
stop_effect(ECLIP_NUM_BOSS);
break;
default:
Int3(); // Illegal type to boss actions

View file

@ -187,14 +187,14 @@ void nm_draw_background(int x1, int y1, int x2, int y2 )
gr_set_current_canvas(old);
gr_free_sub_canvas(tmp);
Gr_scanline_darkening_level = 2*7;
gr_settransblend(14, GR_BLEND_NORMAL);
gr_setcolor( BM_XRGB(1,1,1) );
for (w=5*BGScaleX;w>0;w--)
gr_urect( x2-w, y1+w*(BGScaleY/BGScaleX), x2-w, y2-w*(BGScaleY/BGScaleX) );//right edge
gr_setcolor( BM_XRGB(0,0,0) );
for (h=5*BGScaleY;h>0;h--)
gr_urect( x1+h*(BGScaleX/BGScaleY), y2-h, x2-h*(BGScaleX/BGScaleY), y2-h );//bottom edge
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
// Draw a left justfied string

View file

@ -33,10 +33,9 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "gameseg.h"
#include "textures.h"
#include "byteswap.h"
#include "object.h"
#include "physics.h"
#include "slew.h"
#include "slew.h"
#include "render.h"
#include "wall.h"
#include "vclip.h"
@ -67,9 +66,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "switch.h"
#include "gameseq.h"
#include "playsave.h"
#ifdef OGL
#include "ogl_init.h"
#endif
#ifdef EDITOR
#include "editor/editor.h"
#endif
@ -223,7 +219,7 @@ void draw_object_blob(object *obj,bitmap_index bmi)
{
int orientation=0;
grs_bitmap * bm = &GameBitmaps[bmi.index];
vms_vector pos = obj->pos;
if (obj->type == OBJ_FIREBALL)
orientation = (obj-Objects) & 7;
@ -232,20 +228,18 @@ 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
#ifdef OGL
,obj
#endif
);
}
else {
g3_draw_bitmap(&obj->pos,fixmuldiv(obj->size,bm->bm_w,bm->bm_h),obj->size,bm
#ifdef OGL
,obj
#endif
);
// draw these with slight offset to viewer preventing too much ugly clipping
if ( obj->type == OBJ_FIREBALL && obj->id == VCLIP_VOLATILE_WALL_HIT )
{
vms_vector offs_vec;
vm_vec_normalized_dir_quick(&offs_vec,&Viewer->pos,&obj->pos);
vm_vec_scale_add2(&pos,&offs_vec,F1_0);
}
if (bm->bm_w > bm->bm_h)
g3_draw_bitmap(&pos,obj->size,fixmuldiv(obj->size,bm->bm_h,bm->bm_w),bm);
else
g3_draw_bitmap(&pos,fixmuldiv(obj->size,bm->bm_w,bm->bm_h),obj->size,bm);
}
//draw an object that is a texture-mapped rod
@ -388,7 +382,7 @@ void draw_cloaked_object(object *obj,fix light,fix *glow,fix64 cloak_start_time,
glow[0] = save_glow;
}
else {
Gr_scanline_darkening_level = cloak_value;
gr_settransblend(cloak_value, GR_BLEND_NORMAL);
gr_setcolor(BM_XRGB(0,0,0)); //set to black (matters for s3)
g3_set_special_render(draw_tmap_flat,NULL,NULL); //use special flat drawer
draw_polygon_model(&obj->pos,
@ -399,7 +393,7 @@ void draw_cloaked_object(object *obj,fix light,fix *glow,fix64 cloak_start_time,
glow,
NULL );
g3_set_special_render(NULL,NULL,NULL);
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
}
@ -508,9 +502,7 @@ void draw_polygon_object(object *obj)
if (obj->type == OBJ_WEAPON && (Weapon_info[obj->id].model_num_inner > -1 )) {
fix dist_to_eye = vm_vec_dist_quick(&Viewer->pos, &obj->pos);
#ifdef OGL
ogl_toggle_laser_blending(1);
#endif
gr_settransblend(GR_FADE_OFF, GR_BLEND_ADDITIVE_A);
if (dist_to_eye < Simple_model_threshhold_scale * F1_0*2)
draw_polygon_model(&obj->pos,
&obj->orient,
@ -529,10 +521,9 @@ void draw_polygon_object(object *obj)
light,
engine_glow_value,
alt_textures);
#ifdef OGL
if (obj->type == OBJ_WEAPON && (Weapon_info[obj->id].model_num_inner > -1 ))
ogl_toggle_laser_blending(0);
#endif
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
}
}
@ -701,11 +692,13 @@ void create_vclip_on_object(object *objp, fix size_scale, int vclip_num)
// Render an object. Calls one of several routines based on type
void render_object(object *obj)
{
int mld_save;
int mld_save;
if ( obj == Viewer ) return;
if ( obj == Viewer )
return;
if ( obj->type==OBJ_NONE ) {
if ( obj->type==OBJ_NONE )
{
#ifndef NDEBUG
Int3();
#endif
@ -715,43 +708,74 @@ void render_object(object *obj)
mld_save = Max_linear_depth;
Max_linear_depth = Max_linear_depth_objects;
switch (obj->render_type) {
case RT_NONE: break; //doesn't render, like the player
switch (obj->render_type)
{
case RT_NONE:
break; //doesn't render, like the player
case RT_POLYOBJ:
if ( PlayerCfg.AlphaEffects && obj->type == OBJ_MARKER ) // set nice transparency/blending for certrain objects
gr_settransblend( 10, GR_BLEND_ADDITIVE_A );
draw_polygon_object(obj);
//"warn" robot if being shot at
if (obj->type == OBJ_ROBOT)
if (obj->type == OBJ_ROBOT) //"warn" robot if being shot at
set_robot_location_info(obj);
//JOHN SAID TO: if ( (obj->type==OBJ_PLAYER) && ((keyd_pressed[KEY_W]) || (keyd_pressed[KEY_I])))
//JOHN SAID TO: object_render_id(obj);
// -- mk, 02/05/95 -- if (obj->type == OBJ_PLAYER)
// -- mk, 02/05/95 -- if (Players[obj->id].flags & PLAYER_FLAGS_INVULNERABLE)
// -- mk, 02/05/95 -- do_player_invulnerability_effect(obj);
break;
case RT_MORPH: draw_morph_object(obj); break;
case RT_MORPH:
draw_morph_object(obj);
break;
case RT_FIREBALL: draw_fireball(obj); break;
case RT_FIREBALL:
if ( PlayerCfg.AlphaEffects ) // set nice transparency/blending for certrain objects
gr_settransblend( GR_FADE_OFF, GR_BLEND_ADDITIVE_C );
case RT_WEAPON_VCLIP: draw_weapon_vclip(obj); break;
draw_fireball(obj);
break;
case RT_HOSTAGE: draw_hostage(obj); break;
case RT_WEAPON_VCLIP:
if ( PlayerCfg.AlphaEffects ) // set nice transparency/blending for certrain objects
gr_settransblend( 7, GR_BLEND_ADDITIVE_A );
case RT_POWERUP: draw_powerup(obj); break;
draw_weapon_vclip(obj);
break;
case RT_LASER: Laser_render(obj); break;
case RT_HOSTAGE:
draw_hostage(obj);
break;
default: Error("Unknown render_type <%d>",obj->render_type);
}
case RT_POWERUP:
if ( PlayerCfg.AlphaEffects ) // set nice transparency/blending for certrain objects
switch ( obj->id )
{
case POW_EXTRA_LIFE:
case POW_ENERGY:
case POW_SHIELD_BOOST:
case POW_CLOAK:
case POW_INVULNERABILITY:
case POW_HOARD_ORB:
gr_settransblend( 7, GR_BLEND_ADDITIVE_A );
break;
}
if (( obj->render_type != RT_NONE ) && ( Newdemo_state == ND_STATE_RECORDING ))
draw_powerup(obj);
break;
case RT_LASER:
if ( PlayerCfg.AlphaEffects ) // set nice transparency/blending for certrain objects
gr_settransblend( 7, GR_BLEND_ADDITIVE_A );
Laser_render(obj);
break;
default:
Error("Unknown render_type <%d>",obj->render_type);
}
gr_settransblend( GR_FADE_OFF, GR_BLEND_NORMAL ); // revert any transparency/blending setting back to normal
if ( obj->render_type != RT_NONE && Newdemo_state == ND_STATE_RECORDING )
newdemo_record_render_object(obj);
Max_linear_depth = mld_save;

View file

@ -116,7 +116,7 @@ int new_player_config()
PlayerCfg.NoRedundancy = 0;
PlayerCfg.MultiMessages = 0;
PlayerCfg.NoRankings = 0;
PlayerCfg.OglAlphaEffects = 0;
PlayerCfg.AlphaEffects = 0;
// Default taunt macros
#ifdef NETWORK
@ -289,7 +289,7 @@ int read_player_d2x(char *filename)
strupr(word);
}
}
else if (strstr(word,"OPENGL"))
else if (strstr(word,"GRAPHICS"))
{
d_free(word);
cfgets(line,50,f);
@ -298,8 +298,8 @@ int read_player_d2x(char *filename)
while(!strstr(word,"END") && !PHYSFS_eof(f))
{
if(!strcmp(word,"OGLALPHAEFFECTS"))
PlayerCfg.OglAlphaEffects = atoi(line);
if(!strcmp(word,"ALPHAEFFECTS"))
PlayerCfg.AlphaEffects = atoi(line);
d_free(word);
cfgets(line,50,f);
word=splitword(line,'=');
@ -400,8 +400,8 @@ int write_player_d2x(char *filename)
PHYSFSX_printf(fout,"multimessages=%i\n",PlayerCfg.MultiMessages);
PHYSFSX_printf(fout,"norankings=%i\n",PlayerCfg.NoRankings);
PHYSFSX_printf(fout,"[end]\n");
PHYSFSX_printf(fout,"[opengl]\n");
PHYSFSX_printf(fout,"oglalphaeffects=%i\n",PlayerCfg.OglAlphaEffects);
PHYSFSX_printf(fout,"[graphics]\n");
PHYSFSX_printf(fout,"alphaeffects=%i\n",PlayerCfg.AlphaEffects);
PHYSFSX_printf(fout,"[end]\n");
PHYSFSX_printf(fout,"[plx version]\n");
PHYSFSX_printf(fout,"plx version=%s\n", VERSION);

View file

@ -73,7 +73,7 @@ typedef struct player_config
ubyte NoRedundancy;
ubyte MultiMessages;
ubyte NoRankings;
int OglAlphaEffects;
int AlphaEffects;
} __pack__ player_config;
extern struct player_config PlayerCfg;

View file

@ -49,7 +49,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "u_mem.h"
#include "piggy.h"
#include "timer.h"
#include "effects.h"
#include "playsave.h"
#ifdef OGL
#include "ogl_init.h"
#endif
@ -220,12 +221,12 @@ void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap
if (wid_flags & WID_CLOAKED_FLAG) {
int wall_num = Segments[segnum].sides[sidenum].wall_num;
Assert(wall_num != -1);
Gr_scanline_darkening_level = Walls[wall_num].cloak_value;
gr_settransblend(Walls[wall_num].cloak_value, GR_BLEND_NORMAL);
gr_setcolor(BM_XRGB(0, 0, 0)); // set to black (matters for s3)
g3_draw_poly(nv, pointlist); // draw as flat poly
Gr_scanline_darkening_level = GR_FADE_LEVELS;
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
return;
}
@ -296,6 +297,9 @@ void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap
}
}
if ( PlayerCfg.AlphaEffects && ( TmapInfo[tmap1].eclip_num == ECLIP_NUM_FUELCEN || TmapInfo[tmap1].eclip_num == ECLIP_NUM_FORCE_FIELD ) ) // set nice transparency/blending for some special effects (if we do more, we should maybe use switch here)
gr_settransblend(GR_FADE_OFF, GR_BLEND_ADDITIVE_C);
#ifdef EDITOR
if ((Render_only_bottom) && (sidenum == WBOTTOM))
g3_draw_tmap(nv,pointlist,uvl_copy,&GameBitmaps[Textures[Bottom_bitmap_num].index]);
@ -309,6 +313,8 @@ void render_face(int segnum, int sidenum, int nv, short *vp, int tmap1, int tmap
#endif
g3_draw_tmap(nv,pointlist,uvl_copy,bm);
gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); // revert any transparency/blending setting back to normal
#ifndef NDEBUG
if (Outline_mode) draw_outline(nv, pointlist);
#endif
@ -1486,7 +1492,7 @@ void build_object_lists(int n_segs)
if (n_sort_items < SORT_LIST_SIZE-1) { //add if room
sort_list[n_sort_items].objnum = t;
//NOTE: maybe use depth, not dist - quicker computation
sort_list[n_sort_items].dist = vm_vec_dist_quick(&Objects[t].pos,&Viewer_eye);
sort_list[n_sort_items].dist = vm_vec_dist(&Objects[t].pos,&Viewer_eye);
n_sort_items++;
}
else { //no room for object
@ -1520,7 +1526,7 @@ void build_object_lists(int n_segs)
//replace debris & fireballs
if (type == OBJ_DEBRIS || type == OBJ_FIREBALL) {
fix dist = vm_vec_dist_quick(&Objects[t].pos,&Viewer_eye);
fix dist = vm_vec_dist(&Objects[t].pos,&Viewer_eye);
//don't replace same kind of object unless new
//one is closer
@ -1923,10 +1929,6 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num)
// Initialize number of objects (actually, robots!) rendered this frame.
Window_rendered_data[window_num].num_objects = 0;
#ifdef LASER_HACK
Hack_nlasers = 0;
#endif
#ifndef NDEBUG
for (i=0;i<=Highest_object_index;i++)
object_rendered[i] = 0;
@ -2057,19 +2059,7 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num)
int ObjNumber = render_obj_list[listnum][objnp];
if (ObjNumber >= 0) {
#ifdef LASER_HACK
if ( (Objects[ObjNumber].type==OBJ_WEAPON) && //if its a weapon
(Objects[ObjNumber].lifeleft==Laser_max_time ) && // and its in it's first frame
(Hack_nlasers< MAX_HACKED_LASERS) && // and we have space for it
(Objects[ObjNumber].laser_info.parent_num>-1) && // and it has a parent
((Viewer-Objects)==Objects[ObjNumber].laser_info.parent_num) // and it's parent is the viewer
) {
Hack_laser_list[Hack_nlasers++] = ObjNumber; //then make it draw after everything else.
} else
#endif
do_render_object(ObjNumber, window_num); // note link to above else
do_render_object(ObjNumber, window_num); // note link to above else
objnp++;
}
else {
@ -2244,14 +2234,6 @@ void render_mine(int start_seg_num,fix eye_offset, int window_num)
}
#endif
#ifdef LASER_HACK
// Draw the hacked lasers last
for (i=0; i < Hack_nlasers; i++ ) {
do_render_object(Hack_laser_list[i], window_num);
}
#endif
// -- commented out by mk on 09/14/94...did i do a good thing?? object_render_targets();
#ifdef EDITOR

View file

@ -47,10 +47,10 @@ void tmap_scanline_flat(int y, fix xleft, fix xright)
fx_xleft = xleft/F1_0; // (xleft >> 16) != xleft/F1_0 for negative numbers, f2i caused random crashes
fx_xright = xright/F1_0;
if ( Gr_scanline_darkening_level >= GR_FADE_LEVELS )
if ( grd_curcanv->cv_fade_level >= GR_FADE_OFF )
cur_tmap_scanline_flat();
else {
tmap_flat_shade_value = Gr_scanline_darkening_level;
tmap_flat_shade_value = grd_curcanv->cv_fade_level;
cur_tmap_scanline_shaded();
}
}