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
  • 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
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
Commits on Source (5)
Showing
with 1032 additions and 1234 deletions
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
// The texture for the next polygon given to HWR_ProcessPolygon. // The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture. // Set with HWR_SetCurrentTexture.
GLMipmap_t *current_texture = NULL; HWRTexture_t *current_texture = NULL;
boolean currently_batching = false; boolean currently_batching = false;
...@@ -61,7 +61,7 @@ void HWR_StartBatching(void) ...@@ -61,7 +61,7 @@ void HWR_StartBatching(void)
// This replaces the direct calls to pfnSetTexture in cases where batching is available. // This replaces the direct calls to pfnSetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call. // The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon. // 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) if (currently_batching)
{ {
...@@ -76,7 +76,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture) ...@@ -76,7 +76,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
// If batching is enabled, this function collects the polygon data and the chosen 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 // for later use in HWR_RenderBatches. Otherwise the rendering backend is used to
// render the polygon immediately. // 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) if (currently_batching)
{ {
...@@ -165,11 +165,11 @@ static int comparePolygons(const void *p1, const void *p2) ...@@ -165,11 +165,11 @@ static int comparePolygons(const void *p1, const void *p2)
diff64 = poly1->surf.FadeColor.rgba - poly2->surf.FadeColor.rgba; diff64 = poly1->surf.FadeColor.rgba - poly2->surf.FadeColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1; 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; 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; 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; return diff;
} }
...@@ -182,8 +182,8 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) ...@@ -182,8 +182,8 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
int diff; int diff;
INT64 diff64; INT64 diff64;
GLMipmap_t *texture1 = poly1->texture; HWRTexture_t *texture1 = poly1->texture;
GLMipmap_t *texture2 = poly2->texture; HWRTexture_t *texture2 = poly2->texture;
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
texture1 = NULL; texture1 = NULL;
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
...@@ -215,10 +215,10 @@ void HWR_RenderBatches(void) ...@@ -215,10 +215,10 @@ void HWR_RenderBatches(void)
int currentShader; int currentShader;
int nextShader = 0; int nextShader = 0;
GLMipmap_t *currentTexture; HWRTexture_t *currentTexture;
GLMipmap_t *nextTexture = NULL; HWRTexture_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0; UINT32 currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0; UINT32 nextPolyFlags = 0;
FSurfaceInfo currentSurfaceInfo; FSurfaceInfo currentSurfaceInfo;
FSurfaceInfo nextSurfaceInfo; FSurfaceInfo nextSurfaceInfo;
...@@ -227,9 +227,9 @@ void HWR_RenderBatches(void) ...@@ -227,9 +227,9 @@ void HWR_RenderBatches(void)
if (!currently_batching) if (!currently_batching)
I_Error("HWR_RenderBatches called without starting batching"); I_Error("HWR_RenderBatches called without starting batching");
nextSurfaceInfo.LightInfo.fade_end = 0; nextSurfaceInfo.LightInfo.FadeEnd = 0;
nextSurfaceInfo.LightInfo.fade_start = 0; nextSurfaceInfo.LightInfo.FadeStart = 0;
nextSurfaceInfo.LightInfo.light_level = 0; nextSurfaceInfo.LightInfo.LightLevel = 0;
currently_batching = false;// no longer collecting batches currently_batching = false;// no longer collecting batches
if (!polygonArraySize) if (!polygonArraySize)
...@@ -374,9 +374,9 @@ void HWR_RenderBatches(void) ...@@ -374,9 +374,9 @@ void HWR_RenderBatches(void)
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba || if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba || currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || currentSurfaceInfo.LightInfo.LightLevel != nextSurfaceInfo.LightInfo.LightLevel ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || currentSurfaceInfo.LightInfo.FadeStart != nextSurfaceInfo.LightInfo.FadeStart ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end) currentSurfaceInfo.LightInfo.FadeEnd != nextSurfaceInfo.LightInfo.FadeEnd)
{ {
changeState = true; changeState = true;
changeSurfaceInfo = true; changeSurfaceInfo = true;
......
...@@ -20,17 +20,17 @@ typedef struct ...@@ -20,17 +20,17 @@ typedef struct
{ {
FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused
unsigned int vertsIndex;// location of verts in unsortedVertexArray unsigned int vertsIndex;// location of verts in unsortedVertexArray
FUINT numVerts; UINT32 numVerts;
FBITFIELD polyFlags; UINT32 polyFlags;
GLMipmap_t *texture; HWRTexture_t *texture;
int shader; int shader;
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls // this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
boolean horizonSpecial; boolean horizonSpecial;
} PolygonArrayEntry; } PolygonArrayEntry;
void HWR_StartBatching(void); void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture); void HWR_SetCurrentTexture(HWRTexture_t *texture);
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);
void HWR_RenderBatches(void); void HWR_RenderBatches(void);
#endif #endif
This diff is collapsed.
...@@ -22,37 +22,36 @@ ...@@ -22,37 +22,36 @@
#include "../doomdef.h" #include "../doomdef.h"
#include "../screen.h" #include "../screen.h"
// ========================================================================== // ==========================================================================
// TEXTURE INFO // TEXTURE INFO
// ========================================================================== // ==========================================================================
typedef enum GLTextureFormat_e enum GLTextureFormat_e
{ {
GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */ GPU_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 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 */ GPU_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */ GPU_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22, GPU_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t; };
typedef enum GLTextureFormat_e GLTextureFormat_t;
// Colormap structure for mipmaps. // Colormap structure for textures.
struct GLColormap_s struct HWRColormap_s
{ {
const UINT8 *source; const UINT8 *source;
UINT8 data[256]; 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 // data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache. // NULL if the texture is not in Doom heap cache.
struct GLMipmap_s struct HWRTexture_s
{ {
// for TexDownloadMipMap
GLTextureFormat_t format; GLTextureFormat_t format;
void *data; void *data;
...@@ -61,31 +60,25 @@ struct GLMipmap_s ...@@ -61,31 +60,25 @@ struct GLMipmap_s
UINT16 width; UINT16 width;
UINT32 downloaded; // The GPU has this texture. UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap; struct HWRTexture_s *nextcolormap;
struct GLColormap_s *colormap; struct HWRColormap_s *colormap;
struct GLMipmap_s *nextmipmap; // Linked list of all textures
}; };
typedef struct GLMipmap_s GLMipmap_t; typedef struct HWRTexture_s HWRTexture_t;
// // Texture info, as cached for hardware rendering
// Doom texture info, as cached for hardware rendering
//
struct GLMapTexture_s struct GLMapTexture_s
{ {
GLMipmap_t mipmap; HWRTexture_t texture;
float scaleX; //used for scaling textures on walls float scaleX;
float scaleY; float scaleY;
}; };
typedef struct GLMapTexture_s GLMapTexture_t; 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 struct GLPatch_s
{ {
float max_s,max_t; float max_s,max_t;
GLMipmap_t *mipmap; HWRTexture_t *texture;
}; };
typedef struct GLPatch_s GLPatch_t; typedef struct GLPatch_s GLPatch_t;
......
...@@ -18,52 +18,26 @@ ...@@ -18,52 +18,26 @@
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing #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 #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 // COLORS
// ========================================================================== // ==========================================================================
// byte value for paletted graphics, which represent the transparent color // byte value for paletted graphics, which represent the transparent color
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255 #define GPU_PATCHES_CHROMAKEY_COLORINDEX 255
//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130
// the chroma key color shows on border sprites, set it to black // 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 ] // RGBA Color components with float type ranging [ 0 ... 1 ]
struct FRGBAFloat struct FRGBAFloat
{ {
FLOAT red; float red, green, blue, alpha;
FLOAT green;
FLOAT blue;
FLOAT alpha;
}; };
typedef struct FRGBAFloat FRGBAFloat; typedef struct FRGBAFloat FRGBAFloat;
struct FColorARGB
{
FUBYTE alpha;
FUBYTE red;
FUBYTE green;
FUBYTE blue;
};
typedef struct FColorARGB ARGB_t;
typedef struct FColorARGB FColorARGB;
// ========================================================================== // ==========================================================================
// VECTORS // VECTORS
// ========================================================================== // ==========================================================================
...@@ -71,21 +45,15 @@ typedef struct FColorARGB FColorARGB; ...@@ -71,21 +45,15 @@ typedef struct FColorARGB FColorARGB;
// Simple 2D coordinate // Simple 2D coordinate
typedef struct typedef struct
{ {
FLOAT x,y; float x,y;
} F2DCoord, v2d_t; } F2DCoord, v2d_t;
// Simple 3D vector // Simple 3D vector
typedef struct FVector typedef struct FVector
{ {
FLOAT x,y,z; float x,y,z;
} FVector; } FVector;
// ======================
// wallVert3D
// ----------------------
// :crab: IS GONE! :crab:
// ======================
// ----------- // -----------
// structures // structures
// ----------- // -----------
...@@ -102,21 +70,21 @@ typedef struct FVector ...@@ -102,21 +70,21 @@ typedef struct FVector
typedef struct typedef struct
{ {
FLOAT x,y,z; // position float x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ #ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle float anglex,angley,anglez; // aimingangle / viewangle
#else #else
FLOAT anglex,angley; // aimingangle / viewangle float anglex,angley; // aimingangle / viewangle
#endif #endif
FLOAT scalex,scaley,scalez; float scalex,scaley,scalez;
FLOAT fovxangle, fovyangle; float fovxangle, fovyangle;
UINT8 splitscreen; UINT8 splitscreen;
boolean flip; // screenflip boolean flip; // screenflip
boolean roll; boolean roll;
SINT8 rollflip; SINT8 rollflip;
FLOAT rollangle; // done to not override USE_FTRANSFORM_ANGLEZ float rollangle; // done to not override USE_FTRANSFORM_ANGLEZ
UINT8 rotaxis; UINT8 rotaxis;
FLOAT centerx, centery; float centerx, centery;
#ifdef USE_FTRANSFORM_MIRROR #ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode boolean mirror; // SRB2Kart: Encore Mode
#endif #endif
...@@ -127,83 +95,11 @@ typedef struct ...@@ -127,83 +95,11 @@ typedef struct
// Transformed vector, as passed to HWR API // Transformed vector, as passed to HWR API
typedef struct typedef struct
{ {
FLOAT x,y,z; float x, y, z;
FLOAT s; // s texture ordinate (s over w) float s; // s texture ordinate (s over w)
FLOAT t; // t texture ordinate (t over w) float t; // t texture ordinate (t over w)
} FOutVector; } 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 // RENDER MODES
// ========================================================================== // ==========================================================================
...@@ -240,7 +136,6 @@ enum EPolyFlags ...@@ -240,7 +136,6 @@ enum EPolyFlags
PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y
}; };
enum ESurfFlags enum ESurfFlags
{ {
SF_DYNLIGHT = 0x00000001, SF_DYNLIGHT = 0x00000001,
...@@ -255,71 +150,141 @@ enum ETextureFlags ...@@ -255,71 +150,141 @@ enum ETextureFlags
TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0 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 struct FLightInfo
{ {
FUINT light_level; UINT32 LightLevel;
FUINT fade_start; UINT32 FadeStart, FadeEnd;
FUINT fade_end;
}; };
typedef struct FLightInfo FLightInfo; typedef struct FLightInfo FLightInfo;
// Description of a renderable surface // Description of a renderable surface
struct FSurfaceInfo struct FSurfaceInfo
{ {
FUINT PolyFlags; UINT32 PolyFlags;
RGBA_t PolyColor; RGBA_t PolyColor;
RGBA_t TintColor; RGBA_t TintColor;
RGBA_t FadeColor; RGBA_t FadeColor;
FLightInfo LightInfo; // jimita 14032019 FLightInfo LightInfo;
}; };
typedef struct FSurfaceInfo FSurfaceInfo; typedef struct FSurfaceInfo FSurfaceInfo;
#define GL_DEFAULTMIX 0x00000000 // Hurdler: added for backward compatibility
#define GL_DEFAULTFOG 0xFF000000 enum EGPUState
{
GPU_STATE_TEXTUREFILTERMODE,
GPU_STATE_TEXTUREANISOTROPICMODE,
GPU_STATE_SHADERS,
GPU_STATE_MODEL_LIGHTING
};
//Hurdler: added for backward compatibility enum EShaderOption
enum hwdsetspecialstate
{ {
HWD_SET_MODEL_LIGHTING = 1, GPU_SHADEROPTION_OFF,
HWD_SET_SHADERS, GPU_SHADEROPTION_ON,
HWD_SET_TEXTUREFILTERMODE, GPU_SHADEROPTION_NOCUSTOM,
HWD_SET_TEXTUREANISOTROPICMODE,
HWD_NUMSTATE
}; };
typedef enum hwdsetspecialstate hwdspecialstate_t; enum EShaderInfo
{
GPU_SHADERINFO_LEVELTIME = 1,
};
// Lactozilla: Shader options enum EFilterMode
enum hwdshaderoption
{ {
HWD_SHADEROPTION_OFF, GPU_TEXFILTER_POINTSAMPLED,
HWD_SHADEROPTION_ON, GPU_TEXFILTER_BILINEAR,
HWD_SHADEROPTION_NOCUSTOM, 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 // Shader sources (vertex and fragment)
// Generally set at the start of the frame. struct FShaderSource
enum hwdshaderinfo {
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, int mode;
HWD_SET_TEXTUREFILTER_BILINEAR, int vertexcount;
HWD_SET_TEXTUREFILTER_TRILINEAR, int vertexindex;
HWD_SET_TEXTUREFILTER_MIXED1, boolean use_texture;
HWD_SET_TEXTUREFILTER_MIXED2,
HWD_SET_TEXTUREFILTER_MIXED3,
}; };
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_ #endif //_HWR_DEFS_
...@@ -71,7 +71,7 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111 ...@@ -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) void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
{ {
FOutVector v[4]; FOutVector v[4];
FBITFIELD flags; UINT32 flags;
GLPatch_t *hwrPatch; GLPatch_t *hwrPatch;
// 3--2 // 3--2
...@@ -131,7 +131,7 @@ void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option) ...@@ -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) 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]; FOutVector v[4];
FBITFIELD flags; UINT32 flags;
float cx = FIXED_TO_FLOAT(x); float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y); float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); 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 ...@@ -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) 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]; FOutVector v[4];
FBITFIELD flags; UINT32 flags;
float cx = FIXED_TO_FLOAT(x); float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y); float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT);
......
...@@ -35,21 +35,20 @@ EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes); ...@@ -35,21 +35,20 @@ EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes);
EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal); EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl); EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color); 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(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray); EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky); EXPORT void HWRAPI(RenderSkyDome) (FSkyDome *sky);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); EXPORT void HWRAPI(SetBlend) (UINT32 PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); EXPORT void HWRAPI(ClearBuffer) (boolean ColorMask, boolean DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(SetTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo); EXPORT void HWRAPI(UpdateTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *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(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(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
EXPORT void HWRAPI(ClearMipMapCache) (void); EXPORT void HWRAPI(ClearTextureCache) (void);
EXPORT void HWRAPI(ClearCacheList) (void);
//Hurdler: added for backward compatibility //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 //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); 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); ...@@ -75,7 +74,7 @@ EXPORT void HWRAPI(CleanShaders) (void);
EXPORT void HWRAPI(SetShader) (int type); EXPORT void HWRAPI(SetShader) (int type);
EXPORT void HWRAPI(UnSetShader) (void); 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); EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment);
// ========================================================================== // ==========================================================================
...@@ -100,9 +99,8 @@ struct hwdriver_s ...@@ -100,9 +99,8 @@ struct hwdriver_s
DeleteTexture pfnDeleteTexture; DeleteTexture pfnDeleteTexture;
ReadRect pfnReadRect; ReadRect pfnReadRect;
GClipRect pfnGClipRect; GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache; ClearTextureCache pfnClearTextureCache;
ClearCacheList pfnClearCacheList; SetState pfnSetState;
SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility
DrawModel pfnDrawModel; DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs; CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform; SetTransform pfnSetTransform;
......
...@@ -121,10 +121,9 @@ void HWR_GetLevelFlat(levelflat_t *levelflat); ...@@ -121,10 +121,9 @@ void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
void HWR_FreeTexture(patch_t *patch); void HWR_FreeTexture(patch_t *patch);
void HWR_FreeTextureData(patch_t *patch);
void HWR_FreeTextureColormaps(patch_t *patch); void HWR_FreeTextureColormaps(patch_t *patch);
void HWR_ClearAllTextures(void); void HWR_ClearAllTextures(void);
void HWR_FreeColormapCache(void); void HWR_ClearColormapCache(void);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch); void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette); void HWR_SetPalette(RGBA_t *palette);
...@@ -133,7 +132,7 @@ void HWR_SetPalette(RGBA_t *palette); ...@@ -133,7 +132,7 @@ void HWR_SetPalette(RGBA_t *palette);
// -------- // --------
// hw_draw.c // hw_draw.c
// -------- // --------
extern INT32 patchformat; extern INT32 gl_patchformat;
extern INT32 textureformat; extern INT32 gl_textureformat;
#endif //_HW_GLOB_ #endif //_HW_GLOB_
...@@ -1207,8 +1207,8 @@ void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch) ...@@ -1207,8 +1207,8 @@ void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch)
dynlights->nb++; dynlights->nb++;
} }
static GLMipmap_t lightmappatchmipmap; static HWRTexture_t lightmappatchtexture;
static GLPatch_t lightmappatch = { .mipmap = &lightmappatchmipmap }; static GLPatch_t lightmappatch = { .texture = &lightmappatchtexture };
void HWR_InitLight(void) void HWR_InitLight(void)
{ {
...@@ -1218,7 +1218,7 @@ void HWR_InitLight(void) ...@@ -1218,7 +1218,7 @@ void HWR_InitLight(void)
for (i = 0;i < NUMLIGHTS;i++) for (i = 0;i < NUMLIGHTS;i++)
lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius; lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius;
lightmappatch.mipmap->downloaded = false; lightmappatch.texture->downloaded = false;
coronalumpnum = W_CheckNumForName("CORONA"); coronalumpnum = W_CheckNumForName("CORONA");
} }
...@@ -1229,10 +1229,10 @@ static void HWR_SetLight(void) ...@@ -1229,10 +1229,10 @@ static void HWR_SetLight(void)
{ {
int i, j; 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++) for (i = 0; i < 128; i++)
{ {
...@@ -1245,18 +1245,18 @@ static void HWR_SetLight(void) ...@@ -1245,18 +1245,18 @@ static void HWR_SetLight(void)
Data[i*128+j] = 0; 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.width = 128;
lightmappatch.height = 128; lightmappatch.height = 128;
lightmappatch.mipmap->width = 128; lightmappatch.texture->width = 128;
lightmappatch.mipmap->height = 128; lightmappatch.texture->height = 128;
lightmappatch.mipmap->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw ! 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. // 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); ...@@ -40,7 +40,7 @@ void HWR_SetViewSize(void);
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); 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_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_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_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); 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 ...@@ -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_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum); UINT8 HWR_GetTranstableAlpha(INT32 transtablenum);
FBITFIELD HWR_GetBlendModeFlag(INT32 ast); UINT32 HWR_GetBlendModeFlag(INT32 ast);
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf); UINT32 HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); UINT32 HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
boolean HWR_CompileShaders(void); boolean HWR_CompileShaders(void);
...@@ -79,7 +79,7 @@ void HWR_LoadAllCustomShaders(void); ...@@ -79,7 +79,7 @@ void HWR_LoadAllCustomShaders(void);
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3); void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3);
const char *HWR_GetShaderName(INT32 shader); const char *HWR_GetShaderName(INT32 shader);
extern customshaderxlat_t shaderxlat[]; extern FShaderReferenceArray shaderxlat[];
extern CV_PossibleValue_t glanisotropicmode_cons_t[]; extern CV_PossibleValue_t glanisotropicmode_cons_t[];
......
...@@ -201,7 +201,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ ...@@ -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); //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE); fclose(png_FILE);
Z_Free(grpatch->mipmap->data); Z_Free(grpatch->texture->data);
return 0; return 0;
} }
#ifdef USE_FAR_KEYWORD #ifdef USE_FAR_KEYWORD
...@@ -242,7 +242,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ ...@@ -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_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)); png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++) for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch; row_pointers[i] = PNG_image + i*pitch;
...@@ -255,7 +255,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ ...@@ -255,7 +255,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
fclose(png_FILE); fclose(png_FILE);
*w = (int)width; *w = (int)width;
*h = (int)height; *h = (int)height;
return GL_TEXFMT_RGBA; return GPU_TEXFMT_RGBA;
} }
#endif #endif
...@@ -322,7 +322,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, ...@@ -322,7 +322,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1; pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 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) if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{ {
...@@ -356,7 +356,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h, ...@@ -356,7 +356,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
} }
} }
fclose(file); fclose(file);
return GL_TEXFMT_RGBA; return GPU_TEXFMT_RGBA;
} }
// -----------------+ // -----------------+
...@@ -373,7 +373,7 @@ static void md2_loadTexture(md2_t *model) ...@@ -373,7 +373,7 @@ static void md2_loadTexture(md2_t *model)
patch = model->grpatch; patch = model->grpatch;
grPatch = (GLPatch_t *)(patch->hardware); grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch) if (grPatch)
Z_Free(grPatch->mipmap->data); Z_Free(grPatch->texture->data);
} }
else else
model->grpatch = patch = Patch_Create(NULL, 0, NULL); model->grpatch = patch = Patch_Create(NULL, 0, NULL);
...@@ -384,33 +384,33 @@ static void md2_loadTexture(md2_t *model) ...@@ -384,33 +384,33 @@ static void md2_loadTexture(md2_t *model)
if (grPatch == NULL) if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware); grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data) if (!grPatch->texture->downloaded && !grPatch->texture->data)
{ {
int w = 0, h = 0; int w = 0, h = 0;
UINT32 size; UINT32 size;
RGBA_t *image; RGBA_t *image;
#ifdef HAVE_PNG #ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch); grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0) if (grPatch->texture->format == 0)
#endif #endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch); grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0) if (grPatch->texture->format == 0)
{ {
model->notexturefile = true; // mark it so its not searched for again repeatedly model->notexturefile = true; // mark it so its not searched for again repeatedly
return; return;
} }
grPatch->mipmap->downloaded = 0; grPatch->texture->downloaded = 0;
grPatch->mipmap->flags = 0; grPatch->texture->flags = 0;
patch->width = (INT16)w; patch->width = (INT16)w;
patch->height = (INT16)h; patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w; grPatch->texture->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h; grPatch->texture->height = (UINT16)h;
// Lactozilla: Apply colour cube // Lactozilla: Apply colour cube
image = grPatch->mipmap->data; image = grPatch->texture->data;
size = w*h; size = w*h;
while (size--) while (size--)
{ {
...@@ -418,7 +418,7 @@ static void md2_loadTexture(md2_t *model) ...@@ -418,7 +418,7 @@ static void md2_loadTexture(md2_t *model)
image++; image++;
} }
} }
HWD.pfnSetTexture(grPatch->mipmap); HWD.pfnSetTexture(grPatch->texture);
} }
// -----------------+ // -----------------+
...@@ -438,7 +438,7 @@ static void md2_loadBlendTexture(md2_t *model) ...@@ -438,7 +438,7 @@ static void md2_loadBlendTexture(md2_t *model)
patch = model->blendgrpatch; patch = model->blendgrpatch;
grPatch = (GLPatch_t *)(patch->hardware); grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch) if (grPatch)
Z_Free(grPatch->mipmap->data); Z_Free(grPatch->texture->data);
} }
else else
model->blendgrpatch = patch = Patch_Create(NULL, 0, NULL); model->blendgrpatch = patch = Patch_Create(NULL, 0, NULL);
...@@ -449,30 +449,30 @@ static void md2_loadBlendTexture(md2_t *model) ...@@ -449,30 +449,30 @@ static void md2_loadBlendTexture(md2_t *model)
if (grPatch == NULL) if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware); grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data) if (!grPatch->texture->downloaded && !grPatch->texture->data)
{ {
int w = 0, h = 0; int w = 0, h = 0;
#ifdef HAVE_PNG #ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch); grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0) if (grPatch->texture->format == 0)
#endif #endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch); grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0) if (grPatch->texture->format == 0)
{ {
model->noblendfile = true; // mark it so its not searched for again repeatedly model->noblendfile = true; // mark it so its not searched for again repeatedly
Z_Free(filename); Z_Free(filename);
return; return;
} }
grPatch->mipmap->downloaded = 0; grPatch->texture->downloaded = 0;
grPatch->mipmap->flags = 0; grPatch->texture->flags = 0;
patch->width = (INT16)w; patch->width = (INT16)w;
patch->height = (INT16)h; patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w; grPatch->texture->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h; 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); Z_Free(filename);
} }
...@@ -702,7 +702,7 @@ spritemodelfound: ...@@ -702,7 +702,7 @@ spritemodelfound:
#define SETBRIGHTNESS(brightness,r,g,b) \ #define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000)) 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 *hwrPatch = gpatch->hardware;
GLPatch_t *hwrBlendPatch = blendgpatch->hardware; GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
...@@ -718,29 +718,29 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi ...@@ -718,29 +718,29 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
memset(translation, 0, sizeof(translation)); memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff)); memset(cutoff, 0, sizeof(cutoff));
if (grMipmap->width == 0) if (hwrTexture->width == 0)
{ {
grMipmap->width = gpatch->width; hwrTexture->width = gpatch->width;
grMipmap->height = gpatch->height; hwrTexture->height = gpatch->height;
// no wrap around, no chroma key // no wrap around, no chroma key
grMipmap->flags = 0; hwrTexture->flags = 0;
// setup the texture info // setup the texture info
grMipmap->format = GL_TEXFMT_RGBA; hwrTexture->format = GPU_TEXFMT_RGBA;
} }
if (grMipmap->data) if (hwrTexture->data)
{ {
Z_Free(grMipmap->data); Z_Free(hwrTexture->data);
grMipmap->data = NULL; 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); memset(cur, 0x00, size*4);
image = hwrPatch->mipmap->data; image = hwrPatch->texture->data;
blendimage = hwrBlendPatch->mipmap->data; blendimage = hwrBlendPatch->texture->data;
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing. // TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
if (skinnum == TC_METALSONIC) if (skinnum == TC_METALSONIC)
...@@ -1084,42 +1084,42 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski ...@@ -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 // mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLPatch_t *grPatch = patch->hardware; GLPatch_t *grPatch = patch->hardware;
GLPatch_t *grBlendPatch = NULL; GLPatch_t *grBlendPatch = NULL;
GLMipmap_t *grMipmap, *newMipmap; HWRTexture_t *hwrTexture, *newTexture;
if (blendpatch == NULL || colormap == colormaps || colormap == NULL) if (blendpatch == NULL || colormap == colormaps || colormap == NULL)
{ {
// Don't do any blending // Don't do any blending
HWD.pfnSetTexture(grPatch->mipmap); HWD.pfnSetTexture(grPatch->texture);
return; 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)) && (patch->width != blendpatch->width || patch->height != blendpatch->height))
{ {
// Blend image exists, but it's bad. // Blend image exists, but it's bad.
HWD.pfnSetTexture(grPatch->mipmap); HWD.pfnSetTexture(grPatch->texture);
return; return;
} }
// search for the mipmap // search for the texture
// skip the first (no colormap translated) // skip the first (no colormap translated)
for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; ) for (hwrTexture = grPatch->texture; hwrTexture->nextcolormap; )
{ {
grMipmap = grMipmap->nextcolormap; hwrTexture = hwrTexture->nextcolormap;
if (grMipmap->colormap && grMipmap->colormap->source == colormap) 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)); M_Memcpy(hwrTexture->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendpatch, grMipmap, skinnum, color); HWR_CreateBlendedTexture(patch, blendpatch, hwrTexture, skinnum, color);
HWD.pfnUpdateTexture(grMipmap); HWD.pfnUpdateTexture(hwrTexture);
} }
else 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; return;
} }
} }
...@@ -1127,24 +1127,19 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski ...@@ -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 // If here, the blended texture has not been created
// So we create it // So we create it
newTexture = calloc(1, sizeof (*newTexture));
//BP: WARNING: don't free it manually without clearing the cache of harware renderer if (newTexture == NULL)
// (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)
I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
grMipmap->nextcolormap = newMipmap; hwrTexture->nextcolormap = newTexture;
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); newTexture->colormap = Z_Calloc(sizeof(*newTexture->colormap), PU_HWRPATCHCOLTEXTURE, NULL);
newMipmap->colormap->source = colormap; newTexture->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); 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); HWD.pfnSetTexture(newTexture);
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); Z_ChangeTag(newTexture->data, PU_HWRMODELTEXTURE_UNLOCKED);
} }
#define NORMALFOG 0x00000000 #define NORMALFOG 0x00000000
...@@ -1387,7 +1382,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) ...@@ -1387,7 +1382,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
hwrPatch = ((GLPatch_t *)gpatch->hardware); hwrPatch = ((GLPatch_t *)gpatch->hardware);
if (!gpatch || !hwrPatch if (!gpatch || !hwrPatch
|| ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) || ((!hwrPatch->texture->format || !hwrPatch->texture->downloaded) && !md2->notexturefile))
md2_loadTexture(md2); md2_loadTexture(md2);
// Load it again, because it isn't being loaded into gpatch after md2_loadtexture... // 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) ...@@ -1400,9 +1395,9 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (blendgpatch) if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); 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 && (!blendgpatch || !hwrBlendPatch
|| ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) || ((!hwrBlendPatch->texture->format || !hwrBlendPatch->texture->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2); md2_loadBlendTexture(md2);
if (md2->error) if (md2->error)
...@@ -1418,7 +1413,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) ...@@ -1418,7 +1413,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
md2_printModelInfo(md2->model); md2_printModelInfo(md2->model);
// If model uses sprite patch as texture, then // If model uses sprite patch as texture, then
// adjust texture coordinates to take power of two textures into account // 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); adjustTextureCoords(md2->model, spr->gpatch);
// note down the max_s and max_t that end up in the VBO // note down the max_s and max_t that end up in the VBO
md2->model->vbo_max_s = md2->model->max_s; md2->model->vbo_max_s = md2->model->max_s;
...@@ -1437,7 +1432,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) ...@@ -1437,7 +1432,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
finalscale = md2->scale; finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy //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; INT32 skinnum = TC_DEFAULT;
......
...@@ -58,7 +58,6 @@ PFNglGetString pglGetString; ...@@ -58,7 +58,6 @@ PFNglGetString pglGetString;
#define MAX_VIDEO_MODES 32 #define MAX_VIDEO_MODES 32
static vmode_t video_modes[MAX_VIDEO_MODES]; static vmode_t video_modes[MAX_VIDEO_MODES];
INT32 oglflags = 0;
// ************************************************************************** // **************************************************************************
// FUNCTIONS // FUNCTIONS
...@@ -239,7 +238,6 @@ int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepth ...@@ -239,7 +238,6 @@ int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepth
// -----------------+ // -----------------+
static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode) static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
{ {
LPCSTR renderer;
BOOL WantFullScreen = !(lvid->u.windowed); //(lvid->u.windowed ? 0 : CDS_FULLSCREEN); BOOL WantFullScreen = !(lvid->u.windowed); //(lvid->u.windowed ? 0 : CDS_FULLSCREEN);
UNREFERENCED_PARAMETER(pcurrentmode); UNREFERENCED_PARAMETER(pcurrentmode);
...@@ -332,40 +330,37 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode) ...@@ -332,40 +330,37 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
} }
} }
gl_extensions = pglGetString(GL_EXTENSIONS);
// Get info and extensions. // Get info and extensions.
//BP: why don't we make it earlier ? //BP: why don't we make it earlier ?
//Hurdler: we cannot do that before intialising gl context //Hurdler: we cannot do that before intialising gl context
renderer = (LPCSTR)pglGetString(GL_RENDERER); GLVersion = pglGetString(GL_VERSION);
GL_DBG_Printf("Vendor : %s\n", pglGetString(GL_VENDOR)); GLRenderer = pglGetString(GL_RENDERER);
GL_DBG_Printf("Renderer : %s\n", renderer); GLExtensions = pglGetString(GL_EXTENSIONS);
GL_DBG_Printf("Version : %s\n", pglGetString(GL_VERSION));
GL_DBG_Printf("Extensions : %s\n", gl_extensions);
// BP: disable advenced feature that don't work on somes hardware GL_DBG_Printf("OpenGL %s\n", GLVersion);
// Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04 GL_DBG_Printf("GPU: %s\n", GLRenderer);
if (strstr(renderer, "810")) oglflags |= GLF_NOZBUFREAD; GL_DBG_Printf("Vendor: %s\n", pglGetString(GL_VENDOR));
GL_DBG_Printf("oglflags : 0x%X\n", oglflags); GL_DBG_Printf("Extensions: %s\n", GLExtensions);
#ifdef USE_WGL_SWAP #ifdef USE_WGL_SWAP
if (isExtAvailable("WGL_EXT_swap_control",gl_extensions)) if (isExtAvailable("WGL_EXT_swap_control", GLExtensions))
wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT"); wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT");
else else
wglSwapIntervalEXT = NULL; wglSwapIntervalEXT = NULL;
#endif #endif
if (isExtAvailable("GL_EXT_texture_filter_anisotropic",gl_extensions)) if (isExtAvailable("GL_EXT_texture_filter_anisotropic", GLExtensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GPUMaximumAnisotropy);
else else
maximumAnisotropy = 0; GPUMaximumAnisotropy = 0;
SetupGLFunc13(); SetupGLFunc13();
screen_depth = (GLbyte)(lvid->bpp*8); GPUScreenDepth = (GLbyte)(lvid->bpp*8);
if (screen_depth > 16) if (GPUScreenDepth > 16)
textureformatGL = GL_RGBA; GPUTextureFormat = GL_RGBA;
else else
textureformatGL = GL_RGB5_A1; GPUTextureFormat = GL_RGB5_A1;
SetModelView(lvid->width, lvid->height); SetModelView(lvid->width, lvid->height);
SetStates(); SetStates();
...@@ -568,9 +563,9 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *pal) ...@@ -568,9 +563,9 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{ {
size_t palsize = (sizeof(RGBA_t) * 256); size_t palsize = (sizeof(RGBA_t) * 256);
// on a palette change, you have to reload all of the textures // 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(); Flush();
} }
} }
......
This diff is collapsed.
...@@ -117,25 +117,15 @@ static PFNglEnableClientState pglEnableClientState; ...@@ -117,25 +117,15 @@ static PFNglEnableClientState pglEnableClientState;
// GLOBAL // GLOBAL
// ========================================================================== // ==========================================================================
extern const GLubyte *gl_version; extern const GLubyte *GLVersion;
extern const GLubyte *gl_renderer; extern const GLubyte *GLRenderer;
extern const GLubyte *gl_extensions; extern const GLubyte *GLExtensions;
extern RGBA_t myPaletteData[]; extern GLint GPUTextureFormat;
extern GLint screen_width; extern RGBA_t GPUTexturePalette[256];
extern GLint screen_height; extern GLint GPUScreenWidth;
extern GLbyte screen_depth; extern GLint GPUScreenHeight;
extern GLint maximumAnisotropy; extern GLbyte GPUScreenDepth;
extern GLint GPUMaximumAnisotropy;
/** \brief OpenGL flags for video driver
*/
extern INT32 oglflags;
extern GLint textureformatGL;
typedef enum
{
GLF_NOZBUFREAD = 0x01,
GLF_NOTEXENV = 0x02,
} oglflags_t;
#endif #endif
...@@ -4134,9 +4134,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) ...@@ -4134,9 +4134,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
R_FlushTranslationColormapCache(); R_FlushTranslationColormapCache();
#ifdef HWRENDER #ifdef HWRENDER
// Free GPU textures before freeing patches.
if (vid.glstate == VID_GL_LIBRARY_LOADED) if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures(); HWR_ClearColormapCache();
#endif #endif
Patch_FreeTag(PU_PATCH_LOWPRIORITY); Patch_FreeTag(PU_PATCH_LOWPRIORITY);
...@@ -4499,7 +4498,7 @@ boolean P_AddWadFile(const char *wadfilename) ...@@ -4499,7 +4498,7 @@ boolean P_AddWadFile(const char *wadfilename)
CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces));
#ifdef HWRENDER #ifdef HWRENDER
// Free GPU textures before freeing patches. // Free all GPU textures.
if (vid.glstate == VID_GL_LIBRARY_LOADED) if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures(); HWR_ClearAllTextures();
#endif #endif
......
...@@ -79,7 +79,7 @@ typedef struct ...@@ -79,7 +79,7 @@ typedef struct
// for textures // for textures
UINT8 *picture; UINT8 *picture;
#ifdef HWRENDER #ifdef HWRENDER
void *mipmap; void *hwrTexture;
#endif #endif
} levelflat_t; } levelflat_t;
......
...@@ -141,7 +141,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) ...@@ -141,7 +141,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
if (!patch->hardware) if (!patch->hardware)
{ {
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &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); return (void *)(patch->hardware);
} }
...@@ -153,8 +153,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) ...@@ -153,8 +153,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
void *Patch_CreateGL(patch_t *patch) void *Patch_CreateGL(patch_t *patch)
{ {
GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch); GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch);
if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things if (!grPatch->texture->data) // Run HWR_MakePatch in all cases, to recalculate some things
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false); HWR_MakePatch(patch, grPatch, grPatch->texture, false);
return grPatch; return grPatch;
} }
#endif // HWRENDER #endif // HWRENDER
...@@ -89,9 +89,8 @@ void *hwSym(const char *funcName,void *handle) ...@@ -89,9 +89,8 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DeleteTexture); GETFUNC(DeleteTexture);
GETFUNC(ReadRect); GETFUNC(ReadRect);
GETFUNC(GClipRect); GETFUNC(GClipRect);
GETFUNC(ClearMipMapCache); GETFUNC(ClearTextureCache);
GETFUNC(ClearCacheList); GETFUNC(SetState);
GETFUNC(SetSpecialState);
GETFUNC(GetTextureUsed); GETFUNC(GetTextureUsed);
GETFUNC(DrawModel); GETFUNC(DrawModel);
GETFUNC(CreateModelVBOs); GETFUNC(CreateModelVBOs);
......
...@@ -1568,6 +1568,9 @@ boolean VID_CheckRenderer(void) ...@@ -1568,6 +1568,9 @@ boolean VID_CheckRenderer(void)
} }
SCR_SetDrawFuncs(); SCR_SetDrawFuncs();
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
} }
#ifdef HWRENDER #ifdef HWRENDER
else if (rendermode == render_opengl && rendererchanged) else if (rendermode == render_opengl && rendererchanged)
...@@ -1861,9 +1864,8 @@ void VID_StartupOpenGL(void) ...@@ -1861,9 +1864,8 @@ void VID_StartupOpenGL(void)
HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL); HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL); HWD.pfnReadRect = hwSym("ReadRect",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL); HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); HWD.pfnClearTextureCache= hwSym("ClearTextureCache",NULL);
HWD.pfnClearCacheList = hwSym("ClearCacheList",NULL); HWD.pfnSetState = hwSym("SetState",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
HWD.pfnSetPalette = hwSym("SetPalette",NULL); HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawModel = hwSym("DrawModel",NULL); HWD.pfnDrawModel = hwSym("DrawModel",NULL);
......