From 72da1fed7e3c8dfce8d7920b8bf0da1f06230702 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Mar 2017 11:31:09 +0100 Subject: [PATCH] - removed many 'extern "C"' declarations, now that assembly is no longer a concern. - some concepts about building a RenderViewpoint struct. No actual work yet. --- src/doomstat.h | 4 +-- src/r_data/colormaps.cpp | 2 -- src/r_data/colormaps.h | 3 -- src/r_state.h | 10 +++---- src/r_utility.cpp | 20 ++++++------- src/r_utility.h | 64 ++++++++++++++++++++++++++++++---------- src/v_pfx.cpp | 7 ++--- src/v_pfx.h | 7 ++--- src/v_video.cpp | 2 -- src/v_video.h | 10 +++---- src/x86.cpp | 5 +--- src/x86.h | 2 +- 12 files changed, 75 insertions(+), 61 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index a73f134478..3ebf07f92d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -122,8 +122,8 @@ extern bool noblit; extern int viewwindowx; extern int viewwindowy; -extern "C" int viewheight; -extern "C" int viewwidth; +extern int viewheight; +extern int viewwidth; diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index eca7767162..d1dfc07e1f 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -57,10 +57,8 @@ static bool R_CheckForFixedLights(const uint8_t *colormaps); -extern "C" { FDynamicColormap NormalLight; FDynamicColormap FullNormalLight; //[SP] Emulate GZDoom brightness -} bool NormalLightHasFixedLights; diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 6caccdf30d..942c0a961a 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -77,11 +77,8 @@ int AddSpecialColormap(float r1, float g1, float b1, float r2, float g2, float b extern uint8_t DesaturateColormap[31][256]; -extern "C" -{ extern FDynamicColormap NormalLight; extern FDynamicColormap FullNormalLight; -} extern bool NormalLightHasFixedLights; FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate); diff --git a/src/r_state.h b/src/r_state.h index 7685405d38..6223c40b47 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -33,8 +33,10 @@ // for rendering. // -extern "C" int viewwidth; -extern "C" int viewheight; +extern int viewwindowx; +extern int viewwindowy; +extern int viewwidth; +extern int viewheight; // // Lookup tables for map data. @@ -65,10 +67,6 @@ extern int numgamesubsectors; // // POV data. // -extern AActor* camera; // [RH] camera instead of viewplayer -extern sector_t* viewsector; // [RH] keep track of sector viewing from - -extern DAngle FieldOfView; int R_FindSkin (const char *name, int pclass); // [RH] Find a skin diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 54016ac390..02c22cba9a 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -103,6 +103,8 @@ CUSTOM_CVAR(Float, r_quakeintensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) int viewwindowx; int viewwindowy; +int viewwidth; +int viewheight; DVector3 ViewPos; DVector3 ViewActorPos; // the actual position of the viewing actor, without interpolation and quake offsets. @@ -110,27 +112,23 @@ DAngle ViewAngle; DAngle ViewPitch; DAngle ViewRoll; DVector3 ViewPath[2]; +double ViewCos, ViewTanCos; +double ViewSin, ViewTanSin; -extern "C" -{ - int viewwidth; - int viewheight; - int centerx; - int centery; - int centerxwide; -} + +int centerx; +int centery; +int centerxwide; int otic; sector_t *viewsector; -double ViewCos, ViewTanCos; -double ViewSin, ViewTanSin; AActor *camera; // [RH] camera to draw from. doesn't have to be a player double r_TicFracF; // same as floating point -uint32_t r_FrameTime; // [RH] Time this frame started drawing (in ms) +uint32_t r_FrameTime; // [RH] Time this frame started drawing (in ms) bool r_NoInterpolate; bool r_showviewer; diff --git a/src/r_utility.h b/src/r_utility.h index 1487371b4f..2c474d5571 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -12,43 +12,77 @@ class FSerializer; // There a 0-31, i.e. 32 LUT in the COLORMAP lump. #define NUMCOLORMAPS 32 +struct FRenderViewpoint +{ + player_t *player; // For which player is this viewpoint being renderered? (can be null for camera textures) + DVector3 Pos; // Camera position + DVector3 ActorPos; // Camera actor's position + DRotator Angles; // Camera angles + DVector3 Path; // View path for portal calculations + double Cos; // cos(Angles.Yaw) + double Sin; // sin(Angles.Yaw) + double TanCos; // FocalTangent * cos(Angles.Yaw) + double TanSin; // FocalTangent * sin(Angles.Yaw) + + AActor *camera; // camera actor + sector_t *sector; // [RH] keep track of sector viewing from + DAngle FieldOfView; // current field of view + + double TicFrac; // fraction of tic for interpolation + uint32_t FrameTime; // current frame's time in tics. + + int extralight; // extralight to be added to this viewpoint + bool showviewer; // show the camera actor? +}; + extern DVector3 ViewPos; extern DVector3 ViewActorPos; extern DAngle ViewAngle; extern DAngle ViewPitch; extern DAngle ViewRoll; extern DVector3 ViewPath[2]; - extern double ViewCos; extern double ViewSin; -extern int viewwindowx; -extern int viewwindowy; - -extern "C" int centerx, centerxwide; -extern "C" int centery; - -extern int setblocks; - extern double ViewTanCos; extern double ViewTanSin; -extern double FocalTangent; +extern AActor* camera; // [RH] camera instead of viewplayer +extern sector_t* viewsector; // [RH] keep track of sector viewing from +extern DAngle FieldOfView; +extern double r_TicFracF; +extern uint32_t r_FrameTime; +extern int extralight; +extern bool r_showviewer; +//----------------------------------- +struct FViewWindow +{ + double FocalTangent; + int centerx; + int centerxwide; + int centery; + float WidescreenRatio; +}; + +extern int centerx, centerxwide; +extern int centery; +extern double FocalTangent; +extern float WidescreenRatio; + +//----------------------------------- + + +extern int setblocks; extern bool r_NoInterpolate; extern int validcount; 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 WidescreenRatio; -extern double r_TicFracF; -extern uint32_t r_FrameTime; -extern int extralight; extern unsigned int R_OldBlend; const double r_Yaspect = 200.0; // Why did I make this a variable? It's never set anywhere. -extern bool r_showviewer; //========================================================================== // diff --git a/src/v_pfx.cpp b/src/v_pfx.cpp index 96f9b05926..292ede574b 100644 --- a/src/v_pfx.cpp +++ b/src/v_pfx.cpp @@ -37,11 +37,8 @@ #include "v_palette.h" #include "v_pfx.h" -extern "C" -{ - PfxUnion GPfxPal; - PfxState GPfx; -} +PfxUnion GPfxPal; +PfxState GPfx; static bool AnalyzeMask (uint32_t mask, uint8_t *shift); diff --git a/src/v_pfx.h b/src/v_pfx.h index 230b30c8da..5ae1af0659 100644 --- a/src/v_pfx.h +++ b/src/v_pfx.h @@ -77,10 +77,7 @@ struct PfxState fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); }; -extern "C" -{ - extern PfxUnion GPfxPal; - extern PfxState GPfx; -} +extern PfxUnion GPfxPal; +extern PfxState GPfx; #endif //__V_PFX_H__ diff --git a/src/v_video.cpp b/src/v_video.cpp index 6b3e19330d..4fcce944cf 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -142,13 +142,11 @@ int DisplayWidth, DisplayHeight, DisplayBits; FFont *SmallFont, *SmallFont2, *BigFont, *ConFont, *IntermissionFont; -extern "C" { uint32_t Col2RGB8[65][256]; uint32_t *Col2RGB8_LessPrecision[65]; uint32_t Col2RGB8_Inverse[65][256]; ColorTable32k RGB32k; ColorTable256k RGB256k; -} static uint32_t Col2RGB8_2[63][256]; diff --git a/src/v_video.h b/src/v_video.h index e3285f0269..891174d8eb 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -475,7 +475,7 @@ union ColorTable32k uint8_t RGB[32][32][32]; uint8_t All[32 *32 *32]; }; -extern "C" ColorTable32k RGB32k; +extern ColorTable32k RGB32k; // [SP] RGB666 support union ColorTable256k @@ -483,24 +483,24 @@ union ColorTable256k uint8_t RGB[64][64][64]; uint8_t All[64 *64 *64]; }; -extern "C" ColorTable256k RGB256k; +extern ColorTable256k RGB256k; // Col2RGB8 is a pre-multiplied palette for color lookup. It is stored in a // special R10B10G10 format for efficient blending computation. // --RRRRRrrr--BBBBBbbb--GGGGGggg-- at level 64 // --------rrrr------bbbb------gggg at level 1 -extern "C" uint32_t Col2RGB8[65][256]; +extern uint32_t Col2RGB8[65][256]; // Col2RGB8_LessPrecision is the same as Col2RGB8, but the LSB for red // and blue are forced to zero, so if the blend overflows, it won't spill // over into the next component's value. // --RRRRRrrr-#BBBBBbbb-#GGGGGggg-- at level 64 // --------rrr#------bbb#------gggg at level 1 -extern "C" uint32_t *Col2RGB8_LessPrecision[65]; +extern uint32_t *Col2RGB8_LessPrecision[65]; // Col2RGB8_Inverse is the same as Col2RGB8_LessPrecision, except the source // palette has been inverted. -extern "C" uint32_t Col2RGB8_Inverse[65][256]; +extern uint32_t Col2RGB8_Inverse[65][256]; // "Magic" numbers used during the blending: // --000001111100000111110000011111 = 0x01f07c1f diff --git a/src/x86.cpp b/src/x86.cpp index f8b3a35293..dff76c9576 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -2,10 +2,7 @@ #include "doomdef.h" #include "x86.h" -extern "C" -{ - CPUInfo CPU; -} +CPUInfo CPU; #if !defined(__amd64__) && !defined(__i386__) && !defined(_M_IX86) && !defined(_M_X64) void CheckCPUID(CPUInfo *cpu) diff --git a/src/x86.h b/src/x86.h index c821d18024..1839e2c352 100644 --- a/src/x86.h +++ b/src/x86.h @@ -100,7 +100,7 @@ struct CPUInfo // 92 bytes }; -extern "C" CPUInfo CPU; +extern CPUInfo CPU; struct PalEntry; void CheckCPUID (CPUInfo *cpu);