mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-06-03 18:51:22 +00:00
- grouped all external entry points of the GL renderer in gl_functions.h so that non-GL files don't need to include anything else.
git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@489 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
a06e74ec06
commit
2e45aa8d26
21 changed files with 114 additions and 138 deletions
|
@ -66,7 +66,7 @@
|
|||
#include "v_palette.h"
|
||||
#include "v_font.h"
|
||||
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/gl_functions.h"
|
||||
|
||||
static FRandom pr_script("FScript");
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include "gl/common/glc_dynlight.h"
|
||||
#include "gl/common/glc_templates.h"
|
||||
|
||||
#include "gl/data/gl_data.h"
|
||||
|
||||
EXTERN_CVAR (Float, gl_lights_size);
|
||||
EXTERN_CVAR (Bool, gl_lights_additive);
|
||||
|
||||
|
|
|
@ -52,6 +52,11 @@ public:
|
|||
FDrawInfo *GlobalDrawInfo;
|
||||
int gl_spriteindex;
|
||||
|
||||
FTexture *glpart2;
|
||||
FTexture *glpart;
|
||||
FTexture *mirrortexture;
|
||||
FTexture *gllight;
|
||||
|
||||
float mSky1Pos, mSky2Pos;
|
||||
|
||||
FRotator mAngles;
|
||||
|
@ -74,6 +79,7 @@ public:
|
|||
mVBO = NULL;
|
||||
gl_spriteindex = 0;
|
||||
GlobalDrawInfo = NULL;
|
||||
glpart2 = glpart = gllight = mirrortexture = NULL;
|
||||
}
|
||||
~FGLRenderer() ;
|
||||
|
||||
|
@ -132,7 +138,6 @@ public:
|
|||
};
|
||||
|
||||
// Global functions. Make them members of GLRenderer later?
|
||||
FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t angle, bool *mirror);
|
||||
void gl_RenderBSPNode (void *node);
|
||||
bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
|
||||
void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
||||
|
|
|
@ -80,29 +80,6 @@ CUSTOM_CVAR(Bool, gl_nocoloredspritelighting, false, 0)
|
|||
|
||||
void gl_CreateSections();
|
||||
|
||||
FTexture *glpart2;
|
||||
FTexture *glpart;
|
||||
FTexture *mirrortexture;
|
||||
FTexture *gllight;
|
||||
|
||||
void gl_FreeSpecialTextures()
|
||||
{
|
||||
if (glpart2) delete glpart2;
|
||||
if (glpart) delete glpart;
|
||||
if (mirrortexture) delete mirrortexture;
|
||||
if (gllight) delete gllight;
|
||||
|
||||
glpart = glpart2 = gllight = mirrortexture = NULL;
|
||||
}
|
||||
|
||||
void gl_InitSpecialTextures()
|
||||
{
|
||||
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch);
|
||||
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
||||
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch);
|
||||
gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Adjust sprite offsets for GL rendering (IWAD resources only)
|
||||
|
|
|
@ -21,27 +21,7 @@ extern GLRenderSettings glset;
|
|||
|
||||
#include "r_defs.h"
|
||||
|
||||
struct sector_t;
|
||||
struct line_t;
|
||||
class FTexture;
|
||||
|
||||
void gl_FreeSpecialTextures();
|
||||
void gl_InitSpecialTextures();
|
||||
void gl_RecalcVertexHeights(vertex_t * v);
|
||||
void gl_PreprocessLevel();
|
||||
void gl_CleanLevelData();
|
||||
FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, bool *mirror);
|
||||
|
||||
struct MapData;
|
||||
void gl_CheckNodes(MapData * map);
|
||||
bool gl_LoadGLNodes(MapData * map);
|
||||
|
||||
|
||||
extern FTexture *glpart2;
|
||||
extern FTexture *glpart;
|
||||
extern FTexture *mirrortexture;
|
||||
extern FTexture *gllight;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,96 +1,27 @@
|
|||
#ifndef __GL_FUNCT
|
||||
#define __GL_FUNCT
|
||||
|
||||
#include "doomtype.h"
|
||||
#include "templates.h"
|
||||
#include "m_fixed.h"
|
||||
#include "tables.h"
|
||||
#include "textures/textures.h"
|
||||
#include "gl/old_renderer/gl1_renderer.h"
|
||||
|
||||
class FArchive;
|
||||
#include "v_palette.h"
|
||||
|
||||
class AActor;
|
||||
class FTexture;
|
||||
class FFont;
|
||||
struct sector_t;
|
||||
class player_s;
|
||||
struct GL_IRECT;
|
||||
class FCanvasTexture;
|
||||
struct texcoord;
|
||||
struct MapData;
|
||||
struct FColormap;
|
||||
struct particle_t;
|
||||
struct subsector_t;
|
||||
struct vertex_t;
|
||||
class DCanvas;
|
||||
union FRenderStyle;
|
||||
struct side_t;
|
||||
|
||||
|
||||
// Light + color
|
||||
|
||||
void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon=false);
|
||||
void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false);
|
||||
void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor=0xffffff, bool weapon=false);
|
||||
|
||||
void gl_GetSpriteLight(AActor *Self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out);
|
||||
void gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false);
|
||||
|
||||
void gl_GetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm,
|
||||
float *red, float *green, float *blue,
|
||||
PalEntry ThingColor, bool weapon);
|
||||
|
||||
void gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm,
|
||||
PalEntry ThingColor, float alpha, bool fullbright, bool weapon);
|
||||
|
||||
|
||||
void gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor = 0xffffff);
|
||||
|
||||
void gl_InitFog();
|
||||
void gl_SetFog(int lightlevel, int rellight, const FColormap *cm, bool isadditive);
|
||||
|
||||
inline bool gl_isBlack(PalEntry color)
|
||||
{
|
||||
return color.r + color.g + color.b == 0;
|
||||
}
|
||||
|
||||
inline bool gl_isWhite(PalEntry color)
|
||||
{
|
||||
return color.r + color.g + color.b == 3*0xff;
|
||||
}
|
||||
|
||||
inline bool gl_isFullbright(PalEntry color, int lightlevel)
|
||||
{
|
||||
return gl_fixedcolormap || (gl_isWhite(color) && lightlevel==255);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Scene
|
||||
// External entry points for the GL renderer
|
||||
void gl_PreprocessLevel();
|
||||
void gl_CleanLevelData();
|
||||
void gl_LinkLights();
|
||||
void gl_SetActorLights(AActor *);
|
||||
void gl_DeleteAllAttachedLights();
|
||||
void gl_RecreateAllAttachedLights();
|
||||
void gl_ParseDefs();
|
||||
void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog);
|
||||
void gl_CheckNodes(MapData * map);
|
||||
bool gl_LoadGLNodes(MapData * map);
|
||||
|
||||
|
||||
|
||||
inline float Dist2(float x1,float y1,float x2,float y2)
|
||||
{
|
||||
return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
|
||||
}
|
||||
|
||||
__forceinline void gl_Desaturate(int gray, int ired, int igreen, int iblue, BYTE & red, BYTE & green, BYTE & blue, int fac)
|
||||
{
|
||||
red = (ired*(31-fac) + gray*fac)/31;
|
||||
green = (igreen*(31-fac) + gray*fac)/31;
|
||||
blue = (iblue*(31-fac) + gray*fac)/31;
|
||||
}
|
||||
|
||||
void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm);
|
||||
|
||||
|
||||
extern int currentrenderer;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -362,8 +362,8 @@ bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & u
|
|||
bool gl_SetupLightTexture()
|
||||
{
|
||||
|
||||
if (gllight == NULL) return false;
|
||||
FMaterial * pat = FMaterial::ValidateTexture(gllight);
|
||||
if (GLRenderer->gllight == NULL) return false;
|
||||
FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight);
|
||||
pat->BindPatch(CM_DEFAULT, 0);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,76 @@
|
|||
|
||||
extern unsigned int frameStartMS;
|
||||
|
||||
class AActor;
|
||||
class FTexture;
|
||||
class FFont;
|
||||
struct sector_t;
|
||||
class player_s;
|
||||
struct GL_IRECT;
|
||||
class FCanvasTexture;
|
||||
struct texcoord;
|
||||
struct MapData;
|
||||
struct FColormap;
|
||||
struct particle_t;
|
||||
struct subsector_t;
|
||||
struct vertex_t;
|
||||
class DCanvas;
|
||||
union FRenderStyle;
|
||||
struct side_t;
|
||||
|
||||
|
||||
// Light + color
|
||||
|
||||
void gl_GetLightColor(int lightlevel, int rellight, const FColormap * cm, float * pred, float * pgreen, float * pblue, bool weapon=false);
|
||||
void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false);
|
||||
void gl_SetColor(int light, int rellight, const FColormap * cm, float *red, float *green, float *blue, PalEntry ThingColor=0xffffff, bool weapon=false);
|
||||
|
||||
void gl_GetSpriteLight(AActor *Self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec, int desaturation, float * out);
|
||||
void gl_SetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm, float alpha, PalEntry ThingColor = 0xffffff, bool weapon=false);
|
||||
|
||||
void gl_GetSpriteLight(AActor * thing, int lightlevel, int rellight, FColormap * cm,
|
||||
float *red, float *green, float *blue,
|
||||
PalEntry ThingColor, bool weapon);
|
||||
|
||||
void gl_SetSpriteLighting(FRenderStyle style, AActor *thing, int lightlevel, int rellight, FColormap *cm,
|
||||
PalEntry ThingColor, float alpha, bool fullbright, bool weapon);
|
||||
|
||||
|
||||
void gl_SetSpriteLight(particle_t * thing, int lightlevel, int rellight, FColormap *cm, float alpha, PalEntry ThingColor = 0xffffff);
|
||||
|
||||
void gl_SetFog(int lightlevel, int rellight, const FColormap *cm, bool isadditive);
|
||||
|
||||
inline bool gl_isBlack(PalEntry color)
|
||||
{
|
||||
return color.r + color.g + color.b == 0;
|
||||
}
|
||||
|
||||
inline bool gl_isWhite(PalEntry color)
|
||||
{
|
||||
return color.r + color.g + color.b == 3*0xff;
|
||||
}
|
||||
|
||||
extern DWORD gl_fixedcolormap;
|
||||
|
||||
inline bool gl_isFullbright(PalEntry color, int lightlevel)
|
||||
{
|
||||
return gl_fixedcolormap || (gl_isWhite(color) && lightlevel==255);
|
||||
}
|
||||
|
||||
|
||||
bool gl_SetupLight(Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, float & scale, int desaturation, bool checkside=true, bool forceadditive=true);
|
||||
bool gl_SetupLightTexture();
|
||||
void gl_GetLightForThing(AActor * thing, float upper, float lower, float & r, float & g, float & b);
|
||||
|
||||
extern bool i_useshaders;
|
||||
__forceinline void gl_Desaturate(int gray, int ired, int igreen, int iblue, BYTE & red, BYTE & green, BYTE & blue, int fac)
|
||||
{
|
||||
red = (ired*(31-fac) + gray*fac)/31;
|
||||
green = (igreen*(31-fac) + gray*fac)/31;
|
||||
blue = (iblue*(31-fac) + gray*fac)/31;
|
||||
}
|
||||
|
||||
void gl_ModifyColor(BYTE & red, BYTE & green, BYTE & blue, int cm);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "r_main.h"
|
||||
#include "m_png.h"
|
||||
#include "m_crc32.h"
|
||||
#include "w_wad.h"
|
||||
#include "gl/common/glc_templates.h"
|
||||
#include "gl/gl_struct.h"
|
||||
#include "gl/gl_intern.h"
|
||||
|
@ -69,6 +70,7 @@
|
|||
// Renderer interface
|
||||
//
|
||||
//===========================================================================
|
||||
void gl_InitFog();
|
||||
|
||||
|
||||
EXTERN_CVAR(Bool, gl_render_segs)
|
||||
|
@ -81,6 +83,11 @@ EXTERN_CVAR(Bool, gl_render_segs)
|
|||
|
||||
void FGLRenderer::Initialize()
|
||||
{
|
||||
glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch);
|
||||
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
||||
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch);
|
||||
gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch);
|
||||
|
||||
mVBO = new FVertexBuffer;
|
||||
GlobalDrawInfo = new FDrawInfo;
|
||||
gl_InitShaders();
|
||||
|
@ -93,6 +100,10 @@ FGLRenderer::~FGLRenderer()
|
|||
gl_ClearShaders();
|
||||
if (GlobalDrawInfo != NULL) delete GlobalDrawInfo;
|
||||
if (mVBO != NULL) delete mVBO;
|
||||
if (glpart2) delete glpart2;
|
||||
if (glpart) delete glpart;
|
||||
if (mirrortexture) delete mirrortexture;
|
||||
if (gllight) delete gllight;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "doomdata.h"
|
||||
#include "gl/gl_include.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/gl_lights.h"
|
||||
#include "gl/gl_intern.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "gl/common/glc_clock.h"
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "gl/common/glc_clock.h"
|
||||
#include "gl/old_renderer/gl1_renderer.h"
|
||||
#include "gl/common/glc_glow.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/gl_lights.h"
|
||||
#include "gl/gl_intern.h"
|
||||
#include "gl/common/glc_templates.h"
|
||||
#include "gl/common/glc_geometric.h"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "sc_man.h"
|
||||
#include "w_wad.h"
|
||||
#include "gl/old_renderer/gl1_renderer.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/gl_lights.h"
|
||||
#include "gl/gl_intern.h"
|
||||
#include "gl/old_renderer/gl1_shader.h"
|
||||
#include "gl/common/glc_convert.h"
|
||||
|
|
|
@ -803,11 +803,11 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
FTexture *lump = NULL;
|
||||
if (gl_particles_style == 1)
|
||||
{
|
||||
lump = glpart2;
|
||||
lump = GLRenderer->glpart2;
|
||||
}
|
||||
else if (gl_particles_style == 2)
|
||||
{
|
||||
lump = glpart;
|
||||
lump = GLRenderer->glpart;
|
||||
}
|
||||
|
||||
if (lump != NULL)
|
||||
|
|
|
@ -326,4 +326,10 @@ public:
|
|||
double CalcIntersectionVertex(GLWall * w2);
|
||||
};
|
||||
|
||||
inline float Dist2(float x1,float y1,float x2,float y2)
|
||||
{
|
||||
return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -240,7 +240,7 @@ void GLWall::RenderFogBoundary()
|
|||
//==========================================================================
|
||||
void GLWall::RenderMirrorSurface()
|
||||
{
|
||||
if (mirrortexture == NULL) return;
|
||||
if (GLRenderer->mirrortexture == NULL) return;
|
||||
|
||||
// Use sphere mapping for this
|
||||
gl.Enable(GL_TEXTURE_GEN_T);
|
||||
|
@ -254,7 +254,7 @@ void GLWall::RenderMirrorSurface()
|
|||
gl.DepthFunc(GL_LEQUAL);
|
||||
gl_SetFog(lightlevel, extralight*gl_weaponlight, &Colormap, true);
|
||||
|
||||
FMaterial * pat=FMaterial::ValidateTexture(mirrortexture);
|
||||
FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture);
|
||||
pat->BindPatch(Colormap.colormap, 0);
|
||||
|
||||
flags &= ~GLWF_GLOW;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "v_video.h"
|
||||
#include "doomstat.h"
|
||||
#include "gl/gl_struct.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/gl_lights.h"
|
||||
#include "gl/gl_intern.h"
|
||||
#include "gl/old_renderer/gl1_renderer.h"
|
||||
|
||||
|
|
|
@ -86,12 +86,10 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(int width, int height, int bits, int refres
|
|||
|
||||
InitializeState();
|
||||
gl_GenerateGlobalBrightmapFromColormap();
|
||||
gl_InitSpecialTextures();
|
||||
}
|
||||
|
||||
OpenGLFrameBuffer::~OpenGLFrameBuffer()
|
||||
{
|
||||
gl_FreeSpecialTextures();
|
||||
delete GLRenderer;
|
||||
GLRenderer = NULL;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "r_translate.h"
|
||||
#include "v_palette.h"
|
||||
#include "templates.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/gl_lights.h"
|
||||
#include "gl/textures/gl_translate.h"
|
||||
#include "gl/textures/gl_bitmap.h"
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#include "md5.h"
|
||||
#include "compatibility.h"
|
||||
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/gl_functions.h"
|
||||
|
||||
#include "fragglescript/t_fs.h"
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "r_bsp.h"
|
||||
#include "r_plane.h"
|
||||
#include "v_palette.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
//#include "gl/data/gl_data.h"
|
||||
#include "gl/gl_functions.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "gl/common/glc_templates.h"
|
||||
#include "gl/gl_intern.h"
|
||||
#include "gl/gl_struct.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/common/glc_renderer.h"
|
||||
#include "gl/old_renderer/gl1_shader.h"
|
||||
#include "templates.h"
|
||||
#include "version.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue