Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
117 results
Select Git revision
Show changes
Commits on Source (5)
Showing
with 1032 additions and 1234 deletions
......@@ -16,7 +16,7 @@
// The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture.
GLMipmap_t *current_texture = NULL;
HWRTexture_t *current_texture = NULL;
boolean currently_batching = false;
......@@ -61,7 +61,7 @@ void HWR_StartBatching(void)
// This replaces the direct calls to pfnSetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon.
void HWR_SetCurrentTexture(GLMipmap_t *texture)
void HWR_SetCurrentTexture(HWRTexture_t *texture)
{
if (currently_batching)
{
......@@ -76,7 +76,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
// If batching is enabled, this function collects the polygon data and the chosen texture
// for later use in HWR_RenderBatches. Otherwise the rendering backend is used to
// render the polygon immediately.
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial)
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, int shader, boolean horizonSpecial)
{
if (currently_batching)
{
......@@ -165,11 +165,11 @@ static int comparePolygons(const void *p1, const void *p2)
diff64 = poly1->surf.FadeColor.rgba - poly2->surf.FadeColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
diff = poly1->surf.LightInfo.light_level - poly2->surf.LightInfo.light_level;
diff = poly1->surf.LightInfo.LightLevel - poly2->surf.LightInfo.LightLevel;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_start - poly2->surf.LightInfo.fade_start;
diff = poly1->surf.LightInfo.FadeStart - poly2->surf.LightInfo.FadeStart;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
diff = poly1->surf.LightInfo.FadeEnd - poly2->surf.LightInfo.FadeEnd;
return diff;
}
......@@ -182,8 +182,8 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
int diff;
INT64 diff64;
GLMipmap_t *texture1 = poly1->texture;
GLMipmap_t *texture2 = poly2->texture;
HWRTexture_t *texture1 = poly1->texture;
HWRTexture_t *texture2 = poly2->texture;
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
texture1 = NULL;
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
......@@ -215,10 +215,10 @@ void HWR_RenderBatches(void)
int currentShader;
int nextShader = 0;
GLMipmap_t *currentTexture;
GLMipmap_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0;
HWRTexture_t *currentTexture;
HWRTexture_t *nextTexture = NULL;
UINT32 currentPolyFlags = 0;
UINT32 nextPolyFlags = 0;
FSurfaceInfo currentSurfaceInfo;
FSurfaceInfo nextSurfaceInfo;
......@@ -227,9 +227,9 @@ void HWR_RenderBatches(void)
if (!currently_batching)
I_Error("HWR_RenderBatches called without starting batching");
nextSurfaceInfo.LightInfo.fade_end = 0;
nextSurfaceInfo.LightInfo.fade_start = 0;
nextSurfaceInfo.LightInfo.light_level = 0;
nextSurfaceInfo.LightInfo.FadeEnd = 0;
nextSurfaceInfo.LightInfo.FadeStart = 0;
nextSurfaceInfo.LightInfo.LightLevel = 0;
currently_batching = false;// no longer collecting batches
if (!polygonArraySize)
......@@ -374,9 +374,9 @@ void HWR_RenderBatches(void)
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end)
currentSurfaceInfo.LightInfo.LightLevel != nextSurfaceInfo.LightInfo.LightLevel ||
currentSurfaceInfo.LightInfo.FadeStart != nextSurfaceInfo.LightInfo.FadeStart ||
currentSurfaceInfo.LightInfo.FadeEnd != nextSurfaceInfo.LightInfo.FadeEnd)
{
changeState = true;
changeSurfaceInfo = true;
......
......@@ -20,17 +20,17 @@ typedef struct
{
FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused
unsigned int vertsIndex;// location of verts in unsortedVertexArray
FUINT numVerts;
FBITFIELD polyFlags;
GLMipmap_t *texture;
UINT32 numVerts;
UINT32 polyFlags;
HWRTexture_t *texture;
int shader;
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
boolean horizonSpecial;
} PolygonArrayEntry;
void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_SetCurrentTexture(HWRTexture_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void);
#endif
This diff is collapsed.
......@@ -22,37 +22,36 @@
#include "../doomdef.h"
#include "../screen.h"
// ==========================================================================
// TEXTURE INFO
// ==========================================================================
typedef enum GLTextureFormat_e
enum GLTextureFormat_e
{
GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */
GPU_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GPU_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */
GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */
GPU_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */
GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t;
GPU_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GPU_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GPU_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
};
typedef enum GLTextureFormat_e GLTextureFormat_t;
// Colormap structure for mipmaps.
struct GLColormap_s
// Colormap structure for textures.
struct HWRColormap_s
{
const UINT8 *source;
UINT8 data[256];
};
typedef struct GLColormap_s GLColormap_t;
typedef struct HWRColormap_s HWRColormap_t;
// data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache.
struct GLMipmap_s
// NULL if the texture is not in Doom heap cache.
struct HWRTexture_s
{
// for TexDownloadMipMap
GLTextureFormat_t format;
void *data;
......@@ -61,31 +60,25 @@ struct GLMipmap_s
UINT16 width;
UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap;
struct GLColormap_s *colormap;
struct GLMipmap_s *nextmipmap; // Linked list of all textures
struct HWRTexture_s *nextcolormap;
struct HWRColormap_s *colormap;
};
typedef struct GLMipmap_s GLMipmap_t;
typedef struct HWRTexture_s HWRTexture_t;
//
// Doom texture info, as cached for hardware rendering
//
// Texture info, as cached for hardware rendering
struct GLMapTexture_s
{
GLMipmap_t mipmap;
float scaleX; //used for scaling textures on walls
float scaleY;
HWRTexture_t texture;
float scaleX;
float scaleY;
};
typedef struct GLMapTexture_s GLMapTexture_t;
// a cached patch as converted to hardware format
// A cached patch, as converted to hardware format
struct GLPatch_s
{
float max_s,max_t;
GLMipmap_t *mipmap;
HWRTexture_t *texture;
};
typedef struct GLPatch_s GLPatch_t;
......
......@@ -18,52 +18,26 @@
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
// ==========================================================================
// SIMPLE TYPES
// ==========================================================================
typedef long FINT;
typedef unsigned long FUINT;
typedef unsigned char FUBYTE;
typedef unsigned long FBITFIELD;
#ifndef __MINGW32__
typedef float FLOAT;
#endif
typedef unsigned char FBOOLEAN;
// ==========================================================================
// COLORS
// ==========================================================================
// byte value for paletted graphics, which represent the transparent color
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255
//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130
#define GPU_PATCHES_CHROMAKEY_COLORINDEX 255
// the chroma key color shows on border sprites, set it to black
#define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()
#define GPU_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()
#define GPU_DEFAULTMIX 0x00000000
#define GPU_DEFAULTFOG 0xFF000000
// RGBA Color components with float type ranging [ 0 ... 1 ]
struct FRGBAFloat
{
FLOAT red;
FLOAT green;
FLOAT blue;
FLOAT alpha;
float red, green, blue, alpha;
};
typedef struct FRGBAFloat FRGBAFloat;
struct FColorARGB
{
FUBYTE alpha;
FUBYTE red;
FUBYTE green;
FUBYTE blue;
};
typedef struct FColorARGB ARGB_t;
typedef struct FColorARGB FColorARGB;
// ==========================================================================
// VECTORS
// ==========================================================================
......@@ -71,21 +45,15 @@ typedef struct FColorARGB FColorARGB;
// Simple 2D coordinate
typedef struct
{
FLOAT x,y;
float x,y;
} F2DCoord, v2d_t;
// Simple 3D vector
typedef struct FVector
{
FLOAT x,y,z;
float x,y,z;
} FVector;
// ======================
// wallVert3D
// ----------------------
// :crab: IS GONE! :crab:
// ======================
// -----------
// structures
// -----------
......@@ -102,21 +70,21 @@ typedef struct FVector
typedef struct
{
FLOAT x,y,z; // position
float x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle
float anglex,angley,anglez; // aimingangle / viewangle
#else
FLOAT anglex,angley; // aimingangle / viewangle
float anglex,angley; // aimingangle / viewangle
#endif
FLOAT scalex,scaley,scalez;
FLOAT fovxangle, fovyangle;
float scalex,scaley,scalez;
float fovxangle, fovyangle;
UINT8 splitscreen;
boolean flip; // screenflip
boolean roll;
SINT8 rollflip;
FLOAT rollangle; // done to not override USE_FTRANSFORM_ANGLEZ
float rollangle; // done to not override USE_FTRANSFORM_ANGLEZ
UINT8 rotaxis;
FLOAT centerx, centery;
float centerx, centery;
#ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode
#endif
......@@ -127,83 +95,11 @@ typedef struct
// Transformed vector, as passed to HWR API
typedef struct
{
FLOAT x,y,z;
FLOAT s; // s texture ordinate (s over w)
FLOAT t; // t texture ordinate (t over w)
float x, y, z;
float s; // s texture ordinate (s over w)
float t; // t texture ordinate (t over w)
} FOutVector;
#ifdef GL_SHADERS
// Predefined shader types
enum
{
SHADER_DEFAULT = 0,
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL, SHADER_MODEL_LIGHTING,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMBASESHADERS,
};
// Maximum amount of shader programs
// Must be higher than NUMBASESHADERS
#define HWR_MAXSHADERS 16
// Shader sources (vertex and fragment)
typedef struct
{
char *vertex;
char *fragment;
} shadersource_t;
// Custom shader reference table
typedef struct
{
const char *type;
INT32 id;
} customshaderxlat_t;
#endif
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} gl_skyvertex_t;
typedef enum gl_skyloopmode_e
{
HWD_SKYLOOP_FAN,
HWD_SKYLOOP_STRIP
} gl_skyloopmode_t;
typedef struct
{
gl_skyloopmode_t mode;
int vertexcount;
int vertexindex;
boolean use_texture;
} gl_skyloopdef_t;
typedef struct
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
gl_skyloopdef_t *loops;
gl_skyvertex_t *data;
} gl_sky_t;
// ==========================================================================
// RENDER MODES
// ==========================================================================
......@@ -240,7 +136,6 @@ enum EPolyFlags
PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y
};
enum ESurfFlags
{
SF_DYNLIGHT = 0x00000001,
......@@ -255,71 +150,141 @@ enum ETextureFlags
TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0
};
typedef struct GLMipmap_s FTextureInfo;
struct FTextureInfo
{
UINT32 width, height;
UINT32 name;
UINT32 format;
struct HWRTexture_s *texture;
struct FTextureInfo *prev, *next;
};
typedef struct FTextureInfo FTextureInfo;
// jimita 14032019
struct FLightInfo
{
FUINT light_level;
FUINT fade_start;
FUINT fade_end;
UINT32 LightLevel;
UINT32 FadeStart, FadeEnd;
};
typedef struct FLightInfo FLightInfo;
// Description of a renderable surface
struct FSurfaceInfo
{
FUINT PolyFlags;
UINT32 PolyFlags;
RGBA_t PolyColor;
RGBA_t TintColor;
RGBA_t FadeColor;
FLightInfo LightInfo; // jimita 14032019
FLightInfo LightInfo;
};
typedef struct FSurfaceInfo FSurfaceInfo;
#define GL_DEFAULTMIX 0x00000000
#define GL_DEFAULTFOG 0xFF000000
// Hurdler: added for backward compatibility
enum EGPUState
{
GPU_STATE_TEXTUREFILTERMODE,
GPU_STATE_TEXTUREANISOTROPICMODE,
GPU_STATE_SHADERS,
GPU_STATE_MODEL_LIGHTING
};
//Hurdler: added for backward compatibility
enum hwdsetspecialstate
enum EShaderOption
{
HWD_SET_MODEL_LIGHTING = 1,
HWD_SET_SHADERS,
HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE,
HWD_NUMSTATE
GPU_SHADEROPTION_OFF,
GPU_SHADEROPTION_ON,
GPU_SHADEROPTION_NOCUSTOM,
};
typedef enum hwdsetspecialstate hwdspecialstate_t;
enum EShaderInfo
{
GPU_SHADERINFO_LEVELTIME = 1,
};
// Lactozilla: Shader options
enum hwdshaderoption
enum EFilterMode
{
HWD_SHADEROPTION_OFF,
HWD_SHADEROPTION_ON,
HWD_SHADEROPTION_NOCUSTOM,
GPU_TEXFILTER_POINTSAMPLED,
GPU_TEXFILTER_BILINEAR,
GPU_TEXFILTER_TRILINEAR,
GPU_TEXFILTER_MIXED1,
GPU_TEXFILTER_MIXED2,
GPU_TEXFILTER_MIXED3,
};
typedef enum hwdshaderoption hwdshaderoption_t;
#ifdef GL_SHADERS
// Predefined shader types
enum
{
SHADER_DEFAULT = 0,
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL, SHADER_MODEL_LIGHTING,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMBASESHADERS,
};
// Maximum amount of shader programs
// Must be higher than NUMBASESHADERS
#define HWR_MAXSHADERS 16
// Lactozilla: Shader info
// Generally set at the start of the frame.
enum hwdshaderinfo
// Shader sources (vertex and fragment)
struct FShaderSource
{
char *vertex;
char *fragment;
};
typedef struct FShaderSource FShaderSource;
// Custom shader reference table
struct FShaderReferenceArray
{
const char *type;
INT32 id;
};
typedef struct FShaderReferenceArray FShaderReferenceArray;
#endif
struct FSkyVertex
{
HWD_SHADERINFO_LEVELTIME = 1,
float x, y, z;
float u, v;
unsigned char r, g, b, a;
};
typedef struct FSkyVertex FSkyVertex;
typedef enum hwdshaderinfo hwdshaderinfo_t;
enum ESkyLoopMode
{
GPU_SKYLOOP_FAN,
GPU_SKYLOOP_STRIP
};
enum hwdfiltermode
struct FSkyLoopDef
{
HWD_SET_TEXTUREFILTER_POINTSAMPLED,
HWD_SET_TEXTUREFILTER_BILINEAR,
HWD_SET_TEXTUREFILTER_TRILINEAR,
HWD_SET_TEXTUREFILTER_MIXED1,
HWD_SET_TEXTUREFILTER_MIXED2,
HWD_SET_TEXTUREFILTER_MIXED3,
int mode;
int vertexcount;
int vertexindex;
boolean use_texture;
};
typedef struct FSkyLoopDef FSkyLoopDef;
struct FSkyDome
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
FSkyLoopDef *loops;
FSkyVertex *data;
};
typedef struct FSkyDome FSkyDome;
#endif //_HWR_DEFS_
......@@ -71,7 +71,7 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
GLPatch_t *hwrPatch;
// 3--2
......@@ -131,7 +131,7 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT);
......@@ -385,7 +385,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT);
......
......@@ -35,21 +35,20 @@ EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes);
EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (FSkyDome *sky);
EXPORT void HWRAPI(SetBlend) (UINT32 PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (boolean ColorMask, boolean DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
EXPORT void HWRAPI(ClearCacheList) (void);
EXPORT void HWRAPI(ClearTextureCache) (void);
//Hurdler: added for backward compatibility
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
EXPORT void HWRAPI(SetState) (INT32 State, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
......@@ -75,7 +74,7 @@ EXPORT void HWRAPI(CleanShaders) (void);
EXPORT void HWRAPI(SetShader) (int type);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(SetShaderInfo) (INT32 info, INT32 value);
EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment);
// ==========================================================================
......@@ -100,9 +99,8 @@ struct hwdriver_s
DeleteTexture pfnDeleteTexture;
ReadRect pfnReadRect;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
ClearCacheList pfnClearCacheList;
SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility
ClearTextureCache pfnClearTextureCache;
SetState pfnSetState;
DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform;
......
......@@ -121,10 +121,9 @@ void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
void HWR_FreeTexture(patch_t *patch);
void HWR_FreeTextureData(patch_t *patch);
void HWR_FreeTextureColormaps(patch_t *patch);
void HWR_ClearAllTextures(void);
void HWR_FreeColormapCache(void);
void HWR_ClearColormapCache(void);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette);
......@@ -133,7 +132,7 @@ void HWR_SetPalette(RGBA_t *palette);
// --------
// hw_draw.c
// --------
extern INT32 patchformat;
extern INT32 textureformat;
extern INT32 gl_patchformat;
extern INT32 gl_textureformat;
#endif //_HW_GLOB_
......@@ -1207,8 +1207,8 @@ void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch)
dynlights->nb++;
}
static GLMipmap_t lightmappatchmipmap;
static GLPatch_t lightmappatch = { .mipmap = &lightmappatchmipmap };
static HWRTexture_t lightmappatchtexture;
static GLPatch_t lightmappatch = { .texture = &lightmappatchtexture };
void HWR_InitLight(void)
{
......@@ -1218,7 +1218,7 @@ void HWR_InitLight(void)
for (i = 0;i < NUMLIGHTS;i++)
lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius;
lightmappatch.mipmap->downloaded = false;
lightmappatch.texture->downloaded = false;
coronalumpnum = W_CheckNumForName("CORONA");
}
......@@ -1229,10 +1229,10 @@ static void HWR_SetLight(void)
{
int i, j;
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
if (!lightmappatch.texture->downloaded && !lightmappatch.texture->data)
{
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.texture->data);
for (i = 0; i < 128; i++)
{
......@@ -1245,18 +1245,18 @@ static void HWR_SetLight(void)
Data[i*128+j] = 0;
}
}
lightmappatch.mipmap->format = GL_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.texture->format = GPU_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.width = 128;
lightmappatch.height = 128;
lightmappatch.mipmap->width = 128;
lightmappatch.mipmap->height = 128;
lightmappatch.mipmap->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw !
lightmappatch.texture->width = 128;
lightmappatch.texture->height = 128;
lightmappatch.texture->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw !
}
HWD.pfnSetTexture(lightmappatch.mipmap);
HWD.pfnSetTexture(lightmappatch.texture);
// The system-memory data can be purged now.
Z_ChangeTag(lightmappatch.mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(lightmappatch.texture->data, PU_HWRCACHE_UNLOCKED);
}
//**********************************************************
......
This diff is collapsed.
......@@ -40,7 +40,7 @@ void HWR_SetViewSize(void);
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, HWRTexture_t *hwrTexture, boolean makebitmap);
void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
......@@ -69,9 +69,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum);
FBITFIELD HWR_GetBlendModeFlag(INT32 ast);
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
UINT32 HWR_GetBlendModeFlag(INT32 ast);
UINT32 HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
UINT32 HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
boolean HWR_CompileShaders(void);
......@@ -79,7 +79,7 @@ void HWR_LoadAllCustomShaders(void);
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3);
const char *HWR_GetShaderName(INT32 shader);
extern customshaderxlat_t shaderxlat[];
extern FShaderReferenceArray shaderxlat[];
extern CV_PossibleValue_t glanisotropicmode_cons_t[];
......
......@@ -201,7 +201,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE);
Z_Free(grpatch->mipmap->data);
Z_Free(grpatch->texture->data);
return 0;
}
#ifdef USE_FAR_KEYWORD
......@@ -242,7 +242,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
{
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->texture->data);
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch;
......@@ -255,7 +255,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
fclose(png_FILE);
*w = (int)width;
*h = (int)height;
return GL_TEXFMT_RGBA;
return GPU_TEXFMT_RGBA;
}
#endif
......@@ -322,7 +322,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 1;
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->texture->data);
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{
......@@ -356,7 +356,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
}
}
fclose(file);
return GL_TEXFMT_RGBA;
return GPU_TEXFMT_RGBA;
}
// -----------------+
......@@ -373,7 +373,7 @@ static void md2_loadTexture(md2_t *model)
patch = model->grpatch;
grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch)
Z_Free(grPatch->mipmap->data);
Z_Free(grPatch->texture->data);
}
else
model->grpatch = patch = Patch_Create(NULL, 0, NULL);
......@@ -384,33 +384,33 @@ static void md2_loadTexture(md2_t *model)
if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data)
if (!grPatch->texture->downloaded && !grPatch->texture->data)
{
int w = 0, h = 0;
UINT32 size;
RGBA_t *image;
#ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
#endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
{
model->notexturefile = true; // mark it so its not searched for again repeatedly
return;
}
grPatch->mipmap->downloaded = 0;
grPatch->mipmap->flags = 0;
grPatch->texture->downloaded = 0;
grPatch->texture->flags = 0;
patch->width = (INT16)w;
patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h;
grPatch->texture->width = (UINT16)w;
grPatch->texture->height = (UINT16)h;
// Lactozilla: Apply colour cube
image = grPatch->mipmap->data;
image = grPatch->texture->data;
size = w*h;
while (size--)
{
......@@ -418,7 +418,7 @@ static void md2_loadTexture(md2_t *model)
image++;
}
}
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
}
// -----------------+
......@@ -438,7 +438,7 @@ static void md2_loadBlendTexture(md2_t *model)
patch = model->blendgrpatch;
grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch)
Z_Free(grPatch->mipmap->data);
Z_Free(grPatch->texture->data);
}
else
model->blendgrpatch = patch = Patch_Create(NULL, 0, NULL);
......@@ -449,30 +449,30 @@ static void md2_loadBlendTexture(md2_t *model)
if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data)
if (!grPatch->texture->downloaded && !grPatch->texture->data)
{
int w = 0, h = 0;
#ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
#endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
{
model->noblendfile = true; // mark it so its not searched for again repeatedly
Z_Free(filename);
return;
}
grPatch->mipmap->downloaded = 0;
grPatch->mipmap->flags = 0;
grPatch->texture->downloaded = 0;
grPatch->texture->flags = 0;
patch->width = (INT16)w;
patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h;
grPatch->texture->width = (UINT16)w;
grPatch->texture->height = (UINT16)h;
}
HWD.pfnSetTexture(grPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWD.pfnSetTexture(grPatch->texture); // We do need to do this so that it can be cleared and knows to recreate it when necessary
Z_Free(filename);
}
......@@ -702,7 +702,7 @@ spritemodelfound:
#define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000))
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color)
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, HWRTexture_t *hwrTexture, INT32 skinnum, skincolornum_t color)
{
GLPatch_t *hwrPatch = gpatch->hardware;
GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
......@@ -718,29 +718,29 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff));
if (grMipmap->width == 0)
if (hwrTexture->width == 0)
{
grMipmap->width = gpatch->width;
grMipmap->height = gpatch->height;
hwrTexture->width = gpatch->width;
hwrTexture->height = gpatch->height;
// no wrap around, no chroma key
grMipmap->flags = 0;
hwrTexture->flags = 0;
// setup the texture info
grMipmap->format = GL_TEXFMT_RGBA;
hwrTexture->format = GPU_TEXFMT_RGBA;
}
if (grMipmap->data)
if (hwrTexture->data)
{
Z_Free(grMipmap->data);
grMipmap->data = NULL;
Z_Free(hwrTexture->data);
hwrTexture->data = NULL;
}
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grMipmap->data);
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &hwrTexture->data);
memset(cur, 0x00, size*4);
image = hwrPatch->mipmap->data;
blendimage = hwrBlendPatch->mipmap->data;
image = hwrPatch->texture->data;
blendimage = hwrBlendPatch->texture->data;
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
if (skinnum == TC_METALSONIC)
......@@ -1084,42 +1084,42 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLPatch_t *grPatch = patch->hardware;
GLPatch_t *grBlendPatch = NULL;
GLMipmap_t *grMipmap, *newMipmap;
HWRTexture_t *hwrTexture, *newTexture;
if (blendpatch == NULL || colormap == colormaps || colormap == NULL)
{
// Don't do any blending
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
return;
}
if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->mipmap->format)
if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->texture->format)
&& (patch->width != blendpatch->width || patch->height != blendpatch->height))
{
// Blend image exists, but it's bad.
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
return;
}
// search for the mipmap
// search for the texture
// skip the first (no colormap translated)
for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; )
for (hwrTexture = grPatch->texture; hwrTexture->nextcolormap; )
{
grMipmap = grMipmap->nextcolormap;
if (grMipmap->colormap && grMipmap->colormap->source == colormap)
hwrTexture = hwrTexture->nextcolormap;
if (hwrTexture->colormap && hwrTexture->colormap->source == colormap)
{
if (grMipmap->downloaded && grMipmap->data)
if (hwrTexture->downloaded && hwrTexture->data)
{
if (memcmp(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)))
if (memcmp(hwrTexture->colormap->data, colormap, 256 * sizeof(UINT8)))
{
M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendpatch, grMipmap, skinnum, color);
HWD.pfnUpdateTexture(grMipmap);
M_Memcpy(hwrTexture->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendpatch, hwrTexture, skinnum, color);
HWD.pfnUpdateTexture(hwrTexture);
}
else
HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture
HWD.pfnSetTexture(hwrTexture); // found the colormap, set it to the correct texture
Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
Z_ChangeTag(hwrTexture->data, PU_HWRMODELTEXTURE_UNLOCKED);
return;
}
}
......@@ -1127,24 +1127,19 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
// If here, the blended texture has not been created
// So we create it
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
newTexture = calloc(1, sizeof (*newTexture));
if (newTexture == NULL)
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
grMipmap->nextcolormap = newMipmap;
hwrTexture->nextcolormap = newTexture;
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
newMipmap->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
newTexture->colormap = Z_Calloc(sizeof(*newTexture->colormap), PU_HWRPATCHCOLTEXTURE, NULL);
newTexture->colormap->source = colormap;
M_Memcpy(newTexture->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color);
HWR_CreateBlendedTexture(patch, blendpatch, newTexture, skinnum, color);
HWD.pfnSetTexture(newMipmap);
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
HWD.pfnSetTexture(newTexture);
Z_ChangeTag(newTexture->data, PU_HWRMODELTEXTURE_UNLOCKED);
}
#define NORMALFOG 0x00000000
......@@ -1387,7 +1382,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
if (!gpatch || !hwrPatch
|| ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile))
|| ((!hwrPatch->texture->format || !hwrPatch->texture->downloaded) && !md2->notexturefile))
md2_loadTexture(md2);
// Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
......@@ -1400,9 +1395,9 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
if ((gpatch && hwrPatch && hwrPatch->mipmap->format) // don't load the blend texture if the base texture isn't available
if ((gpatch && hwrPatch && hwrPatch->texture->format) // don't load the blend texture if the base texture isn't available
&& (!blendgpatch || !hwrBlendPatch
|| ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile)))
|| ((!hwrBlendPatch->texture->format || !hwrBlendPatch->texture->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2);
if (md2->error)
......@@ -1418,7 +1413,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
md2_printModelInfo(md2->model);
// If model uses sprite patch as texture, then
// adjust texture coordinates to take power of two textures into account
if (!gpatch || !hwrPatch->mipmap->format)
if (!gpatch || !hwrPatch->texture->format)
adjustTextureCoords(md2->model, spr->gpatch);
// note down the max_s and max_t that end up in the VBO
md2->model->vbo_max_s = md2->model->max_s;
......@@ -1437,7 +1432,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy
if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
if (gpatch && hwrPatch && hwrPatch->texture->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
{
INT32 skinnum = TC_DEFAULT;
......
......@@ -58,7 +58,6 @@ PFNglGetString pglGetString;
#define MAX_VIDEO_MODES 32
static vmode_t video_modes[MAX_VIDEO_MODES];
INT32 oglflags = 0;
// **************************************************************************
// FUNCTIONS
......@@ -239,7 +238,6 @@ int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepth
// -----------------+
static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
{
LPCSTR renderer;
BOOL WantFullScreen = !(lvid->u.windowed); //(lvid->u.windowed ? 0 : CDS_FULLSCREEN);
UNREFERENCED_PARAMETER(pcurrentmode);
......@@ -332,40 +330,37 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
}
}
gl_extensions = pglGetString(GL_EXTENSIONS);
// Get info and extensions.
//BP: why don't we make it earlier ?
//Hurdler: we cannot do that before intialising gl context
renderer = (LPCSTR)pglGetString(GL_RENDERER);
GL_DBG_Printf("Vendor : %s\n", pglGetString(GL_VENDOR));
GL_DBG_Printf("Renderer : %s\n", renderer);
GL_DBG_Printf("Version : %s\n", pglGetString(GL_VERSION));
GL_DBG_Printf("Extensions : %s\n", gl_extensions);
GLVersion = pglGetString(GL_VERSION);
GLRenderer = pglGetString(GL_RENDERER);
GLExtensions = pglGetString(GL_EXTENSIONS);
// BP: disable advenced feature that don't work on somes hardware
// Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04
if (strstr(renderer, "810")) oglflags |= GLF_NOZBUFREAD;
GL_DBG_Printf("oglflags : 0x%X\n", oglflags);
GL_DBG_Printf("OpenGL %s\n", GLVersion);
GL_DBG_Printf("GPU: %s\n", GLRenderer);
GL_DBG_Printf("Vendor: %s\n", pglGetString(GL_VENDOR));
GL_DBG_Printf("Extensions: %s\n", GLExtensions);
#ifdef USE_WGL_SWAP
if (isExtAvailable("WGL_EXT_swap_control",gl_extensions))
if (isExtAvailable("WGL_EXT_swap_control", GLExtensions))
wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT");
else
wglSwapIntervalEXT = NULL;
#endif
if (isExtAvailable("GL_EXT_texture_filter_anisotropic",gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", GLExtensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GPUMaximumAnisotropy);
else
maximumAnisotropy = 0;
GPUMaximumAnisotropy = 0;
SetupGLFunc13();
screen_depth = (GLbyte)(lvid->bpp*8);
if (screen_depth > 16)
textureformatGL = GL_RGBA;
GPUScreenDepth = (GLbyte)(lvid->bpp*8);
if (GPUScreenDepth > 16)
GPUTextureFormat = GL_RGBA;
else
textureformatGL = GL_RGB5_A1;
GPUTextureFormat = GL_RGB5_A1;
SetModelView(lvid->width, lvid->height);
SetStates();
......@@ -568,9 +563,9 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{
size_t palsize = (sizeof(RGBA_t) * 256);
// on a palette change, you have to reload all of the textures
if (memcmp(&myPaletteData, pal, palsize))
if (memcmp(&GPUTexturePalette, pal, palsize))
{
memcpy(&myPaletteData, pal, palsize);
memcpy(&GPUTexturePalette, pal, palsize);
Flush();
}
}
......
This diff is collapsed.
......@@ -117,25 +117,15 @@ static PFNglEnableClientState pglEnableClientState;
// GLOBAL
// ==========================================================================
extern const GLubyte *gl_version;
extern const GLubyte *gl_renderer;
extern const GLubyte *gl_extensions;
extern RGBA_t myPaletteData[];
extern GLint screen_width;
extern GLint screen_height;
extern GLbyte screen_depth;
extern GLint maximumAnisotropy;
/** \brief OpenGL flags for video driver
*/
extern INT32 oglflags;
extern GLint textureformatGL;
typedef enum
{
GLF_NOZBUFREAD = 0x01,
GLF_NOTEXENV = 0x02,
} oglflags_t;
extern const GLubyte *GLVersion;
extern const GLubyte *GLRenderer;
extern const GLubyte *GLExtensions;
extern GLint GPUTextureFormat;
extern RGBA_t GPUTexturePalette[256];
extern GLint GPUScreenWidth;
extern GLint GPUScreenHeight;
extern GLbyte GPUScreenDepth;
extern GLint GPUMaximumAnisotropy;
#endif
......@@ -4134,9 +4134,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
R_FlushTranslationColormapCache();
#ifdef HWRENDER
// Free GPU textures before freeing patches.
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
HWR_ClearColormapCache();
#endif
Patch_FreeTag(PU_PATCH_LOWPRIORITY);
......@@ -4499,7 +4498,7 @@ boolean P_AddWadFile(const char *wadfilename)
CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces));
#ifdef HWRENDER
// Free GPU textures before freeing patches.
// Free all GPU textures.
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
#endif
......
......@@ -79,7 +79,7 @@ typedef struct
// for textures
UINT8 *picture;
#ifdef HWRENDER
void *mipmap;
void *hwrTexture;
#endif
} levelflat_t;
......
......@@ -141,7 +141,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
if (!patch->hardware)
{
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware);
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &grPatch->mipmap);
grPatch->texture = Z_Calloc(sizeof(HWRTexture_t), PU_HWRPATCHINFO, &grPatch->texture);
}
return (void *)(patch->hardware);
}
......@@ -153,8 +153,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
void *Patch_CreateGL(patch_t *patch)
{
GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch);
if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
if (!grPatch->texture->data) // Run HWR_MakePatch in all cases, to recalculate some things
HWR_MakePatch(patch, grPatch, grPatch->texture, false);
return grPatch;
}
#endif // HWRENDER
......@@ -89,9 +89,8 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DeleteTexture);
GETFUNC(ReadRect);
GETFUNC(GClipRect);
GETFUNC(ClearMipMapCache);
GETFUNC(ClearCacheList);
GETFUNC(SetSpecialState);
GETFUNC(ClearTextureCache);
GETFUNC(SetState);
GETFUNC(GetTextureUsed);
GETFUNC(DrawModel);
GETFUNC(CreateModelVBOs);
......
......@@ -1568,6 +1568,9 @@ boolean VID_CheckRenderer(void)
}
SCR_SetDrawFuncs();
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
}
#ifdef HWRENDER
else if (rendermode == render_opengl && rendererchanged)
......@@ -1861,9 +1864,8 @@ void VID_StartupOpenGL(void)
HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
HWD.pfnClearCacheList = hwSym("ClearCacheList",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
HWD.pfnClearTextureCache= hwSym("ClearTextureCache",NULL);
HWD.pfnSetState = hwSym("SetState",NULL);
HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawModel = hwSym("DrawModel",NULL);
......