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;
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
extern BYTE* 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);
|
|
|
|
extern void (*hcolfunc_post4) (int sx, int yl, int yh);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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();
|
|
|
|
friend void setinterpolation(EInterpType, void *interptr);
|
|
|
|
friend void stopinterpolation(EInterpType, void *interptr);
|
|
|
|
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();
|
|
|
|
void setinterpolation(EInterpType, void *interptr);
|
|
|
|
void stopinterpolation(EInterpType, void *interptr);
|
|
|
|
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__
|