2006-02-24 04:48:15 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// System specific interface stuff.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __R_MAIN_H__
|
|
|
|
#define __R_MAIN_H__
|
|
|
|
|
2006-05-09 03:40:15 +00:00
|
|
|
// Number of diminishing brightness levels.
|
|
|
|
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
|
|
|
#define NUMCOLORMAPS 32
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "d_player.h"
|
|
|
|
#include "r_data.h"
|
|
|
|
#include "r_bsp.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// POV related.
|
|
|
|
//
|
|
|
|
extern DCanvas *RenderTarget;
|
|
|
|
extern bool bRenderingToCanvas;
|
|
|
|
extern fixed_t viewcos;
|
|
|
|
extern fixed_t viewsin;
|
|
|
|
extern fixed_t viewtancos;
|
|
|
|
extern fixed_t viewtansin;
|
|
|
|
extern fixed_t FocalTangent;
|
|
|
|
extern fixed_t FocalLengthX, FocalLengthY;
|
|
|
|
extern float FocalLengthXfloat;
|
|
|
|
extern fixed_t InvZtoScale;
|
|
|
|
extern int WidescreenRatio;
|
|
|
|
|
|
|
|
extern angle_t LocalViewAngle; // [RH] Added to consoleplayer's angle
|
|
|
|
extern int LocalViewPitch; // [RH] Used directly instead of consoleplayer's pitch
|
|
|
|
extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard to turn, so interpolate
|
|
|
|
|
|
|
|
extern float WallTMapScale;
|
|
|
|
extern float WallTMapScale2;
|
|
|
|
|
|
|
|
extern int viewwidth;
|
|
|
|
extern int viewheight;
|
|
|
|
extern int viewwindowx;
|
|
|
|
extern int viewwindowy;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" int centerx;
|
|
|
|
extern "C" int centery;
|
|
|
|
|
|
|
|
extern fixed_t centerxfrac;
|
|
|
|
extern fixed_t centeryfrac;
|
|
|
|
extern fixed_t yaspectmul;
|
|
|
|
extern float iyaspectmulfloat;
|
|
|
|
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
extern FDynamicColormap*basecolormap; // [RH] Colormap for sector currently being drawn
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern int validcount;
|
|
|
|
|
|
|
|
extern int linecount;
|
|
|
|
extern int loopcount;
|
|
|
|
|
|
|
|
extern int r_Yaspect;
|
|
|
|
|
2006-06-18 15:49:00 +00:00
|
|
|
extern bool r_dontmaplines;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// Lighting.
|
|
|
|
//
|
|
|
|
// [RH] This has changed significantly from Doom, which used lookup
|
|
|
|
// tables based on 1/z for walls and z for flats and only recognized
|
|
|
|
// 16 discrete light levels. The terminology I use is borrowed from Build.
|
|
|
|
//
|
|
|
|
|
2006-05-03 14:54:48 +00:00
|
|
|
#define INVERSECOLORMAP 32
|
|
|
|
#define GOLDCOLORMAP 33
|
2007-01-09 16:32:44 +00:00
|
|
|
#define REDCOLORMAP 34
|
|
|
|
#define GREENCOLORMAP 35
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// The size of a single colormap, in bits
|
|
|
|
#define COLORMAPSHIFT 8
|
|
|
|
|
|
|
|
// Convert a light level into an unbounded colormap index (shade). Result is
|
|
|
|
// fixed point. Why the +12? I wish I knew, but experimentation indicates it
|
|
|
|
// is necessary in order to best reproduce Doom's original lighting.
|
|
|
|
#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*FRACUNIT*NUMCOLORMAPS/128))
|
|
|
|
|
|
|
|
// Convert a shade and visibility to a clamped colormap index.
|
|
|
|
// Result is not fixed point.
|
|
|
|
#define GETPALOOKUP(vis,shade) (clamp<int> (((shade)-(vis))>>FRACBITS, 0, NUMCOLORMAPS-1))
|
|
|
|
|
|
|
|
extern fixed_t GlobVis;
|
|
|
|
|
|
|
|
void R_SetVisibility (float visibility);
|
|
|
|
float R_GetVisibility ();
|
|
|
|
|
|
|
|
extern fixed_t r_BaseVisibility;
|
|
|
|
extern fixed_t r_WallVisibility;
|
|
|
|
extern fixed_t r_FloorVisibility;
|
|
|
|
extern float r_TiltVisibility;
|
|
|
|
extern fixed_t r_SpriteVisibility;
|
|
|
|
extern fixed_t r_SkyVisibility;
|
|
|
|
|
|
|
|
extern fixed_t r_TicFrac;
|
|
|
|
extern DWORD r_FrameTime;
|
|
|
|
extern bool r_NoInterpolate;
|
|
|
|
|
|
|
|
extern int extralight, r_actualextralight;
|
|
|
|
extern bool foggy;
|
|
|
|
extern int fixedlightlev;
|
|
|
|
extern lighttable_t* fixedcolormap;
|
|
|
|
|
|
|
|
|
|
|
|
// [RH] New detail modes
|
|
|
|
extern "C" int detailxshift;
|
|
|
|
extern "C" int detailyshift;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Function pointers to switch refresh/drawing functions.
|
|
|
|
// Used to select shadow mode etc.
|
|
|
|
//
|
|
|
|
extern void (*colfunc) (void);
|
|
|
|
extern void (*basecolfunc) (void);
|
|
|
|
extern void (*fuzzcolfunc) (void);
|
|
|
|
extern void (*transcolfunc) (void);
|
|
|
|
// No shadow effects on floors.
|
|
|
|
extern void (*spanfunc) (void);
|
|
|
|
|
|
|
|
// [RH] Function pointers for the horizontal column drawers.
|
|
|
|
extern void (*hcolfunc_pre) (void);
|
|
|
|
extern void (*hcolfunc_post1) (int hx, int sx, int yl, int yh);
|
|
|
|
extern void (*hcolfunc_post2) (int hx, int sx, int yl, int yh);
|
2008-02-27 03:11:35 +00:00
|
|
|
extern void (STACK_ARGS *hcolfunc_post4) (int sx, int yl, int yh);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Utility functions.
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PointOnSide
|
|
|
|
//
|
|
|
|
// Traverse BSP (sub) tree, check point against partition plane.
|
|
|
|
// Returns side 0 (front/on) or 1 (back).
|
|
|
|
//
|
|
|
|
// [RH] inlined, stripped down, and made more precise
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
inline int R_PointOnSide (fixed_t x, fixed_t y, const node_t *node)
|
|
|
|
{
|
|
|
|
return DMulScale32 (y-node->y, node->dx, node->x-x, node->dy) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern fixed_t viewx;
|
|
|
|
extern fixed_t viewy;
|
|
|
|
|
|
|
|
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
|
|
|
|
inline angle_t R_PointToAngle (fixed_t x, fixed_t y) { return R_PointToAngle2 (viewx, viewy, x, y); }
|
|
|
|
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
|
|
|
|
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy);
|
|
|
|
|
|
|
|
void R_SetFOV (float fov);
|
|
|
|
float R_GetFOV ();
|
|
|
|
void R_InitTextureMapping ();
|
|
|
|
|
|
|
|
void R_SetViewAngle ();
|
|
|
|
|
|
|
|
//
|
|
|
|
// REFRESH - the actual rendering functions.
|
|
|
|
//
|
|
|
|
|
|
|
|
// Called by G_Drawer.
|
2006-06-18 15:49:00 +00:00
|
|
|
void R_RenderActorView (AActor *actor, bool dontmaplines = false);
|
2006-02-24 04:48:15 +00:00
|
|
|
void R_RefreshViewBorder ();
|
|
|
|
void R_SetupBuffer (bool inview);
|
|
|
|
|
2006-06-18 15:49:00 +00:00
|
|
|
void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void R_ResetViewInterpolation ();
|
|
|
|
|
|
|
|
// Called by startup code.
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
int R_GuesstimateNumTextures ();
|
2006-02-24 04:48:15 +00:00
|
|
|
void R_Init (void);
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
void R_ExecuteSetViewSize (void);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Called by M_Responder.
|
|
|
|
void R_SetViewSize (int blocks);
|
|
|
|
|
|
|
|
// [RH] Initialize multires stuff for renderer
|
|
|
|
void R_MultiresInit (void);
|
|
|
|
|
|
|
|
// BUILD stuff for interpolating between frames, but modified (rather a lot)
|
|
|
|
#define INTERPOLATION_BUCKETS 107
|
|
|
|
|
|
|
|
enum EInterpType
|
|
|
|
{
|
|
|
|
INTERP_SectorFloor, // Pass a sector_t *
|
|
|
|
INTERP_SectorCeiling, // Pass a sector_t *
|
|
|
|
INTERP_Vertex, // Pass a vertex_t *
|
|
|
|
INTERP_FloorPanning, // Pass a sector_t *
|
|
|
|
INTERP_CeilingPanning, // Pass a sector_t *
|
|
|
|
INTERP_WallPanning, // Pass a side_t *
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FActiveInterpolation
|
|
|
|
{
|
|
|
|
FActiveInterpolation *Next;
|
|
|
|
void *Address;
|
|
|
|
EInterpType Type;
|
|
|
|
|
|
|
|
friend FArchive &operator << (FArchive &arc, FActiveInterpolation *&interp);
|
|
|
|
|
|
|
|
static int CountInterpolations ();
|
|
|
|
static int CountInterpolations (int *usedbuckets, int *minbucketfill, int *maxbucketfill);
|
|
|
|
|
|
|
|
private:
|
|
|
|
fixed_t oldipos[2], bakipos[2];
|
|
|
|
|
|
|
|
void CopyInterpToOld();
|
|
|
|
void CopyBakToInterp();
|
|
|
|
void DoAnInterpolation(fixed_t smoothratio);
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
static size_t HashKey(EInterpType type, void *interptr);
|
2006-02-24 04:48:15 +00:00
|
|
|
static FActiveInterpolation *FindInterpolation(EInterpType, void *interptr, FActiveInterpolation **&interp_p);
|
|
|
|
|
|
|
|
friend void updateinterpolations();
|
2008-03-20 21:12:03 +00:00
|
|
|
friend void setinterpolation(EInterpType, void *interptr, bool dolinks);
|
|
|
|
friend void stopinterpolation(EInterpType, void *interptr, bool dolinks);
|
2006-02-24 04:48:15 +00:00
|
|
|
friend void dointerpolations(fixed_t smoothratio);
|
|
|
|
friend void restoreinterpolations();
|
|
|
|
friend void clearinterpolations();
|
|
|
|
friend void SerializeInterpolations(FArchive &arc);
|
|
|
|
|
|
|
|
static FActiveInterpolation *curiposhash[INTERPOLATION_BUCKETS];
|
|
|
|
};
|
|
|
|
|
2006-05-25 04:32:20 +00:00
|
|
|
void updateinterpolations();
|
2008-03-20 21:12:03 +00:00
|
|
|
void setinterpolation(EInterpType, void *interptr, bool dolinks = true);
|
|
|
|
void stopinterpolation(EInterpType, void *interptr, bool dolinks = true);
|
2006-05-25 04:32:20 +00:00
|
|
|
void dointerpolations(fixed_t smoothratio);
|
|
|
|
void restoreinterpolations();
|
|
|
|
void clearinterpolations();
|
|
|
|
void SerializeInterpolations(FArchive &arc);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
extern void R_FreePastViewers ();
|
2007-02-04 01:12:50 +00:00
|
|
|
extern void R_ClearPastViewer (AActor *actor);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern int stacked_extralight;
|
|
|
|
extern float stacked_visibility;
|
|
|
|
extern fixed_t stacked_viewx, stacked_viewy, stacked_viewz;
|
|
|
|
extern angle_t stacked_angle;
|
|
|
|
|
|
|
|
extern void R_CopyStackedViewParameters();
|
|
|
|
|
|
|
|
#endif // __R_MAIN_H__
|