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 (11)
  • Eidolon's avatar
    Remove MINI_GL_COMPATIBILITY. · d13968ae
    Eidolon authored
    The rationale for this is that MiniGL hasn't been relevant for 17
    years or longer. Removing it helps cleanup this horrifying section of
    the codebase.
    
    This possibly breaks upscaling in fullscreen in OpenGL mode.
    d13968ae
  • Eidolon's avatar
    Remove SHUFFLE define. · e11b3c52
    Eidolon authored
    Honestly, under no circumstances when GL is compiled into the game
    should the PostImgRedraw not be available. Removing this helps
    make the GL code slightly more readable.
    e11b3c52
  • Eidolon's avatar
    Remove KOS_GL_COMPATIBILITY. · f634a921
    Eidolon authored
    All the effort I've made to research into what exactly this is has
    been moot. Since we really only need to target GLES and GL, we should
    just worry about supporting those. Our public builds don't rely on
    this at all. This helps readability in the OpenGL code.
    f634a921
  • Eidolon's avatar
    Merge branch 'master' into cleanup-opengl · 80bde9e0
    Eidolon authored
    Synchronizing new CMake improvements with OpenGL cleanup branch for
    ease of development.
    80bde9e0
  • Eidolon's avatar
    Use vertex arrays to draw in DrawPolygon for OpenGL. · fe7d19cc
    Eidolon authored
    This should introduce a minor performance boost for slow CPUs in
    OpenGL mode. If it doesn't, it shouldn't be any slower. It also puts
    us a little closer to supporting GLES as well.
    
    This introduces several new pgl function pointers that are from
    GL 1.1. I do not check for their existence because no driver out in
    the wild in active use doesn't support 1.1.
    fe7d19cc
  • Eidolon's avatar
    Remove unused 'stride' variable in DrawPolygon. · d1d05fad
    Eidolon authored
    This is an artifact of the last commit that I was using because I had
    misunderstood the meaning of the stride argument for the array
    pointers.
    d1d05fad
  • Eidolon's avatar
    Add resizeable vertex array data structure. · 54f25c8f
    Eidolon authored
    This will be used for the vertex array buckets when building the
    render lists for each FSurfaceInfo being used by the hardware
    renderer. Generally, we will replace DrawPolygon calls with
    operations to fill these resizeable arrays, one for each
    FSurfaceInfo. After the initial BSP node draw call, we will go
    through the buckets calling DrawPolygon on each one.
    54f25c8f
  • Eidolon's avatar
    Add vertex buckets interface. · 5bf1e5b7
    Eidolon authored
    5bf1e5b7
  • Eidolon's avatar
    Merge branch 'master' into cleanup-opengl · a604624f
    Eidolon authored
    Re-synchronize with master for build system changes.
    a604624f
  • Eidolon's avatar
    Use AA trees for managing vertex array buckets. · 084cf8e6
    Eidolon authored
    Might as well leverage an existing data structure, right? AA trees
    use numbers as keys and we can iterate through them in order. I'm
    surprised this was in the codebase!
    084cf8e6
  • Eidolon's avatar
    Render most flats and sides with texture arrays. · 5c16a91f
    Eidolon authored
    This breaks stencil buffer clipping, transparent flats, the whole
    nine yards.
    
    Unfortunately, this is about as far as I will be taking this
    approach to cleaning up OpenGL. It's unfortunate, but this
    renderer is basically unsalvagable. I will have to rewrite it
    completely from scratch to get what I want out of this.
    5c16a91f
Showing
with 449 additions and 426 deletions
......@@ -351,6 +351,8 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_trick.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertarray.c
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertbuckets.c
)
set (SRB2_HWRENDER_HEADERS
......@@ -363,6 +365,8 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertarray.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_vertbuckets.h
)
set(SRB2_R_OPENGL_SOURCES
......
......@@ -472,11 +472,6 @@ extern const char *compdate, *comptime, *comprevision;
/// Most modifications should probably enable this.
//#define SAVEGAME_OTHERVERSIONS
#if !defined (_NDS) && !defined (_PSP)
/// Shuffle's incomplete OpenGL sorting code.
#define SHUFFLE // This has nothing to do with sorting, why was it disabled?
#endif
#if !defined (_NDS) && !defined (_PSP)
/// Allow the use of the SOC RESETINFO command.
/// \note Builds that are tight on memory should disable this.
......
......@@ -1105,4 +1105,9 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
}
int HWR_GetNumCacheTextures(void)
{
return gr_numtextures;
}
#endif //HWRENDER
......@@ -159,6 +159,12 @@ enum EPolyFlags
PF_Debug = 0x80000000 // print debug message in driver :)
};
enum EPolygonPrimitive
{
PP_TriangleFan = 0,
PP_Triangles
};
enum ESurfFlags
{
......
......@@ -132,7 +132,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
flags |= PF_ForceWrapY;
// clip it since it is used for bunny scroll in doom I
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, PP_TriangleFan);
}
void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, const UINT8 *colormap)
......@@ -229,10 +229,10 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
HWD.pfnDrawPolygon(&Surf, v, 4, flags, PP_TriangleFan);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, PP_TriangleFan);
}
void HWR_DrawCroppedPatch(GLPatch_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)
......@@ -305,10 +305,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value];
else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel];
flags |= PF_Modulated;
HWD.pfnDrawPolygon(&Surf, v, 4, flags);
HWD.pfnDrawPolygon(&Surf, v, 4, flags, PP_TriangleFan);
}
else
HWD.pfnDrawPolygon(NULL, v, 4, flags);
HWD.pfnDrawPolygon(NULL, v, 4, flags, PP_TriangleFan);
}
void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
......@@ -343,7 +343,7 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
// But then, the question is: why not 0 instead of PF_Masked ?
// or maybe PF_Environment ??? (like what I said above)
// BP: PF_Environment don't change anything ! and 0 is undifined
HWD.pfnDrawPolygon(NULL, v, 4, BLENDMODE | PF_NoDepthTest | PF_Clip | PF_NoZClip);
HWD.pfnDrawPolygon(NULL, v, 4, BLENDMODE | PF_NoDepthTest | PF_Clip | PF_NoZClip, PP_TriangleFan);
}
// ==========================================================================
......@@ -419,7 +419,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
// BTW, I see we put 0 for PFs, and If I'm right, that
// means we take the previous PFs as default
// how can we be sure they are ok?
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent);
HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest, PP_TriangleFan); //PF_Translucent);
}
......@@ -452,7 +452,7 @@ void HWR_FadeScreenMenuBack(UINT32 color, INT32 height)
Surf.FlatColor.rgba = UINT2RGBA(color);
Surf.FlatColor.s.alpha = (UINT8)((0xff/2) * ((float)height / vid.height)); //calum: varies console alpha
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, PP_TriangleFan);
}
// Draw the console background with translucency support
......@@ -479,7 +479,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
Surf.FlatColor.rgba = UINT2RGBA(color);
Surf.FlatColor.s.alpha = 0x80;
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest, PP_TriangleFan);
}
......@@ -678,7 +678,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
Surf.FlatColor = V_GetColor(color);
HWD.pfnDrawPolygon(&Surf, v, 4,
PF_Modulated|PF_NoTexture|PF_NoDepthTest);
PF_Modulated|PF_NoTexture|PF_NoDepthTest, PP_TriangleFan);
}
#ifdef HAVE_PNG
......
......@@ -53,7 +53,7 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal, RGBA_t *pgamma);
#endif
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(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int PrimitiveType);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
......@@ -75,10 +75,8 @@ EXPORT INT32 HWRAPI(GetRenderVersion) (void);
// metzgermeister: added for Voodoo detection
EXPORT char *HWRAPI(GetRenderer) (void);
#endif
#ifdef SHUFFLE
#define SCREENVERTS 10
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
#endif
EXPORT void HWRAPI(StartScreenWipe) (void);
EXPORT void HWRAPI(EndScreenWipe) (void);
EXPORT void HWRAPI(DoScreenWipe) (float alpha);
......@@ -121,9 +119,7 @@ struct hwdriver_s
#ifndef HAVE_SDL
Shutdown pfnShutdown;
#endif
#ifdef SHUFFLE
PostImgRedraw pfnPostImgRedraw;
#endif
StartScreenWipe pfnStartScreenWipe;
EndScreenWipe pfnEndScreenWipe;
DoScreenWipe pfnDoScreenWipe;
......
......@@ -108,6 +108,9 @@ GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
/** */
int HWR_GetNumCacheTextures(void);
// --------
// hw_draw.c
// --------
......
......@@ -768,7 +768,7 @@ void HWR_WallLighting(FOutVector *wlVerts)
if (dynlights->mo[j]->state->nextstate == S_NULL)
Surf.FlatColor.s.alpha = (UINT8)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
HWD.pfnDrawPolygon (&Surf, wlVerts, 4, LIGHTMAPFLAGS);
HWD.pfnDrawPolygon (&Surf, wlVerts, 4, LIGHTMAPFLAGS, PP_TriangleFan);
} // end for (j = 0; j < dynlights->nb; j++)
}
......@@ -831,7 +831,7 @@ void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts)
if ((dynlights->mo[j]->state->nextstate == S_NULL))
Surf.FlatColor.s.alpha = (unsigned char)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha);
HWD.pfnDrawPolygon (&Surf, clVerts, nrClipVerts, LIGHTMAPFLAGS);
HWD.pfnDrawPolygon (&Surf, clVerts, nrClipVerts, LIGHTMAPFLAGS, PP_TriangleFan);
} // end for (j = 0; j < dynlights->nb; j++)
}
......@@ -928,7 +928,7 @@ void HWR_DoCoronasLighting(FOutVector *outVerts, gr_vissprite_t *spr)
HWR_GetPic(coronalumpnum); /// \todo use different coronas
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_Corona | PF_NoDepthTest);
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_Corona | PF_NoDepthTest, PP_TriangleFan);
}
}
#endif
......@@ -1008,7 +1008,7 @@ void HWR_DrawCoronas(void)
light[3].y = cy+size*1.33f;
light[3].sow = 0.0f; light[3].tow = 1.0f;
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_NoDepthTest | PF_Corona);
HWD.pfnDrawPolygon (&Surf, light, 4, PF_Modulated | PF_Additive | PF_Clip | PF_NoDepthTest | PF_Corona, PP_TriangleFan);
}
}
#endif
......
......@@ -24,6 +24,7 @@
#include "hw_glob.h"
#include "hw_light.h"
#include "hw_drv.h"
#include "hw_vertbuckets.h"
#include "../i_video.h" // for rendermode == render_glide
#include "../v_video.h"
......@@ -758,7 +759,8 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, fixed_t fi
else
PolyFlags |= PF_Masked|PF_Modulated|PF_Clip;
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags);
//HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags);
HWR_InsertVertexArray(HWR_GetVertexArrayForFlat(lumpnum), nrPlaneVerts, planeVerts);
#ifdef ALAM_LIGHTING
// add here code for dynamic lighting on planes
......@@ -807,7 +809,7 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight)
}
HWD.pfnDrawPolygon(NULL, planeVerts, nrPlaneVerts,
PF_Clip|PF_Invisible|PF_NoTexture|PF_Occlude);
PF_Clip|PF_Invisible|PF_NoTexture|PF_Occlude, PP_TriangleFan);
}
#endif //polysky
......@@ -897,7 +899,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
break;
}
HWD.pfnDrawPolygon(&pSurf2, trVerts, 4, i|PF_Modulated|PF_Clip|PF_Decal);
HWD.pfnDrawPolygon(&pSurf2, trVerts, 4, i|PF_Modulated|PF_Clip|PF_Decal, PP_TriangleFan);
}
}
#endif
......@@ -942,7 +944,7 @@ static void HWR_AddTransparentWall(wallVert3D *wallVerts, FSurfaceInfo * pSurf,
*/
static void HWR_ProjectWall(wallVert3D * wallVerts,
FSurfaceInfo * pSurf,
FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap)
FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap, int texnum)
{
FOutVector trVerts[4];
FOutVector *wv;
......@@ -988,7 +990,14 @@ static void HWR_ProjectWall(wallVert3D * wallVerts,
pSurf->FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false);
}
HWD.pfnDrawPolygon(pSurf, trVerts, 4, blendmode|PF_Modulated|PF_Occlude|PF_Clip);
if (texnum == -1)
{
//HWD.pfnDrawPolygon(pSurf, trVerts, 4, blendmode|PF_Modulated|PF_Occlude|PF_Clip, PP_TriangleFan);
}
else
{
HWR_InsertVertexArray(HWR_GetVertexArrayForTexture(texnum), 4, trVerts);
}
#ifdef WALLSPLATS
if (gr_curline->linedef->splats && cv_splats.value)
......@@ -1144,7 +1153,7 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum,
else if (glTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap, texnum);
if (solid)
top = bheight;
......@@ -1181,7 +1190,7 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum,
else if (glTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, Surf, texnum, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap, texnum);
}
//
......@@ -1301,7 +1310,7 @@ static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t b
// set top/bottom coords
wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(top); // No real way to find the correct height of this
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(bottom); // worldlow/bottom because it needs to cover up the lower thok barrier wall
HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_Clip|PF_NoTexture, 255, NULL);
HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_Clip|PF_NoTexture, 255, NULL, -1);
// PF_Invisible so it's not drawn into the colour buffer
// PF_NoTexture for no texture
// PF_Occlude is set in HWR_ProjectWall to draw into the depth buffer
......@@ -1448,7 +1457,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, texturetranslation[gr_sidedef->toptexture], PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texturetranslation[gr_sidedef->toptexture]);
}
// check BOTTOM TEXTURE
......@@ -1486,7 +1495,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, texturetranslation[gr_sidedef->bottomtexture], PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texturetranslation[gr_sidedef->bottomtexture]);
}
gr_midtexture = texturetranslation[gr_sidedef->midtexture];
if (gr_midtexture)
......@@ -1686,7 +1695,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
else if (!(blendmode & PF_Masked))
HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap, gr_midtexture);
// If there is a colormap change, remove it.
/* if (!(Surf.FlatColor.s.red + Surf.FlatColor.s.green + Surf.FlatColor.s.blue == Surf.FlatColor.s.red/3)
......@@ -1810,7 +1819,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (grTex->mipmap.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, gr_midtexture);
}
}
......@@ -1936,7 +1945,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texnum);
}
}
}
......@@ -2042,7 +2051,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (blendmode != PF_Masked)
HWR_AddTransparentWall(wallVerts, &Surf, texnum, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap, texnum);
}
}
}
......@@ -2785,7 +2794,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, fixed_t fixedheight
else
blendmode |= PF_Masked|PF_Modulated|PF_Clip;
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode);
HWD.pfnDrawPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, PP_TriangleFan);
}
static void HWR_AddPolyObjectPlanes(void)
......@@ -2979,6 +2988,7 @@ static void HWR_Subsector(size_t num)
{
if (sub->validcount != validcount)
{
HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum);
HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], locFloorHeight, PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, NULL, 255, false, floorcolormap);
}
......@@ -3814,7 +3824,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
if (sSurf.FlatColor.s.alpha > floorheight/4)
{
sSurf.FlatColor.s.alpha = (UINT8)(sSurf.FlatColor.s.alpha - floorheight/4);
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated|PF_Clip);
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated|PF_Clip, PP_TriangleFan);
}
}
}
......@@ -3886,7 +3896,7 @@ noshadow:
blend = PF_Translucent|PF_Occlude;
}
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip);
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, PP_TriangleFan);
}
}
......@@ -3986,7 +3996,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
blend = PF_Translucent|PF_Occlude;
}
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip);
HWD.pfnDrawPolygon(&Surf, wallVerts, 4, blend|PF_Modulated|PF_Clip, PP_TriangleFan);
}
#endif
......@@ -4883,7 +4893,7 @@ static void HWR_DrawSkyBackground(player_t *player)
v[0].tow = v[1].tow -= ((float) angle / angleturn);
}
HWD.pfnDrawPolygon(NULL, v, 4, 0);
HWD.pfnDrawPolygon(NULL, v, 4, 0, PP_TriangleFan);
}
......@@ -5075,7 +5085,9 @@ if (0)
validcount++;
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1);
HWR_DrawVertexBuckets();
// Make a viewangle int so we can render things based on mouselook
if (player == &players[consoleplayer])
......@@ -5088,18 +5100,27 @@ if (0)
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //left
HWR_DrawVertexBuckets();
dup_viewangle += ANGLE_90;
if (((INT32)aimingangle > ANGLE_45 || (INT32)aimingangle<-ANGLE_45))
{
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //back
HWR_DrawVertexBuckets();
}
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //right
HWR_DrawVertexBuckets();
dup_viewangle += ANGLE_90;
}
......@@ -5305,7 +5326,9 @@ if (0)
validcount++;
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1);
HWR_DrawVertexBuckets();
// Make a viewangle int so we can render things based on mouselook
if (player == &players[consoleplayer])
......@@ -5318,18 +5341,27 @@ if (0)
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //left
HWR_DrawVertexBuckets();
dup_viewangle += ANGLE_90;
if (((INT32)aimingangle > ANGLE_45 || (INT32)aimingangle<-ANGLE_45))
{
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //back
HWR_DrawVertexBuckets();
}
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
HWR_ResetVertexBuckets();
HWR_RenderBSPNode((INT32)numnodes-1); //right
HWR_DrawVertexBuckets();
dup_viewangle += ANGLE_90;
}
......@@ -5774,9 +5806,9 @@ static void HWR_RenderWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, FBITFIE
pSurf->FlatColor.s.alpha = alpha; // put the alpha back after lighting
if (blend & PF_Environment)
HWD.pfnDrawPolygon(pSurf, trVerts, 4, blend|PF_Modulated|PF_Clip|PF_Occlude); // PF_Occlude must be used for solid objects
HWD.pfnDrawPolygon(pSurf, trVerts, 4, blend|PF_Modulated|PF_Clip|PF_Occlude, PP_TriangleFan); // PF_Occlude must be used for solid objects
else
HWD.pfnDrawPolygon(pSurf, trVerts, 4, blend|PF_Modulated|PF_Clip); // No PF_Occlude means overlapping (incorrect) transparency
HWD.pfnDrawPolygon(pSurf, trVerts, 4, blend|PF_Modulated|PF_Clip, PP_TriangleFan); // No PF_Occlude means overlapping (incorrect) transparency
#ifdef WALLSPLATS
if (gr_curline->linedef->splats && cv_splats.value)
......@@ -5830,7 +5862,7 @@ void HWR_DoPostProcessor(player_t *player)
Surf.FlatColor.s.alpha = 0xc0; // match software mode
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest|PF_Clip|PF_NoZClip);
HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest|PF_Clip|PF_NoZClip, PP_TriangleFan);
}
// Capture the screen for intermission and screen waving
......@@ -5840,7 +5872,6 @@ void HWR_DoPostProcessor(player_t *player)
if (splitscreen) // Not supported in splitscreen - someone want to add support?
return;
#ifdef SHUFFLE
// Drunken vision! WooOOooo~
if (*type == postimg_water || *type == postimg_heat)
{
......@@ -5883,7 +5914,6 @@ void HWR_DoPostProcessor(player_t *player)
HWD.pfnMakeScreenTexture();
}
// Flipping of the screen isn't done here anymore
#endif // SHUFFLE
}
void HWR_StartScreenWipe(void)
......
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Resizeable vertex array implementation
#include "hw_vertarray.h"
#include "../z_zone.h"
#define RESIZE_FACTOR 2
void HWR_InitVertexArray(FVertexArray * varray, unsigned int initialSize)
{
varray->size = initialSize;
varray->used = 0;
varray->buffer = (FOutVector *) Z_Malloc(varray->size * sizeof(FOutVector), PU_STATIC, varray);
}
void HWR_FreeVertexArray(FVertexArray * varray)
{
Z_Free(varray->buffer);
}
void HWR_InsertVertexArray(FVertexArray * varray, int numElements, FOutVector * elements)
{
int i = 0;
FOutVector * actualElements = NULL;
int numActualElements = numElements;
// Expand array from fan to triangles
// Not optimal... but the overhead will make up for it significantly
{
int j = 0;
int k = 0;
numActualElements -= 3;
numActualElements *= 3;
numActualElements += 3;
actualElements = (FOutVector *) Z_Malloc(numActualElements * sizeof(FOutVector), PU_STATIC, NULL);
for (j = 2; j < numElements; j++)
{
actualElements[k] = elements[0];
actualElements[k+1] = elements[j-1];
actualElements[k+2] = elements[j];
k += 3;
}
}
while (varray->used + numActualElements >= varray->size)
{
varray->buffer = (FOutVector *) Z_Realloc(varray->buffer, varray->size * RESIZE_FACTOR * sizeof(FOutVector), PU_STATIC, varray);
varray->size *= RESIZE_FACTOR;
}
for (i = 0; i < numActualElements; i++)
{
varray->buffer[i + varray->used] = actualElements[i];
}
varray->used += numActualElements;
Z_Free(actualElements);
}
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Resizeable vertex array
#ifndef __HWR_VERTARRAY_H__
#define __HWR_VERTARRAY_H__
#include "hw_defs.h"
typedef struct
{
FOutVector * buffer;
unsigned int used;
unsigned int size;
} FVertexArray;
void HWR_InitVertexArray(FVertexArray * varray, unsigned int initialSize);
void HWR_FreeVertexArray(FVertexArray * varray);
void HWR_InsertVertexArray(FVertexArray * varray, int numElements, FOutVector * elements);
#endif // __HWR_VERTARRAY_H__
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Vertex buckets mapping based on texture binding, implementation
#include "hw_vertbuckets.h"
#include "hw_glob.h"
#include "hw_drv.h"
#include "../z_zone.h"
// 6 because we assume at least a quad per texture.
#define INITIAL_BUCKET_SIZE 6
static FVertexArray * buckets = NULL;
static int numTextureBuckets = 0;
static int bucketsHaveBeenInitialized = 0;
static aatree_t * flatArrays;
static aatree_t * textureArrays;
static UINT8 arraysInitialized = 0;
typedef enum
{
RMODE_FLAT,
RMODE_TEXTURE
} EMode;
static EMode rmode;
static void FreeArraysFunc(INT32 key, void * value)
{
FVertexArray * varray = (FVertexArray *) value;
HWR_FreeVertexArray(varray);
Z_Free(varray);
}
static void DrawArraysFunc(INT32 key, void * value)
{
FVertexArray * varray = (FVertexArray *) value;
FSurfaceInfo surf;
if (varray->used == 0)
{
return;
}
surf.FlatColor.rgba = 0xFFFFFFFF;
if (rmode == RMODE_FLAT)
{
HWR_GetFlat(key);
}
else if (rmode == RMODE_TEXTURE)
{
HWR_GetTexture(key);
}
// TODO support flags, translucency, etc
HWD.pfnDrawPolygon(&surf, varray->buffer, varray->used, PF_Occlude, PP_Triangles);
}
static FVertexArray * GetVArray(aatree_t * tree, int index)
{
FVertexArray * varray = (FVertexArray *) M_AATreeGet(tree, index);
if (!varray)
{
// no varray for this flat yet, create it
varray = (FVertexArray *) Z_Calloc(sizeof(FVertexArray), PU_STATIC, NULL);
HWR_InitVertexArray(varray, INITIAL_BUCKET_SIZE);
M_AATreeSet(tree, index, (void *) varray);
}
return varray;
}
void HWR_ResetVertexBuckets(void)
{
if (arraysInitialized)
{
M_AATreeIterate(flatArrays, FreeArraysFunc);
M_AATreeIterate(textureArrays, FreeArraysFunc);
M_AATreeFree(flatArrays);
M_AATreeFree(textureArrays);
}
flatArrays = M_AATreeAlloc(0);
textureArrays = M_AATreeAlloc(0);
}
FVertexArray * HWR_GetVertexArrayForTexture(int texNum)
{
return GetVArray(textureArrays, texNum);
}
FVertexArray * HWR_GetVertexArrayForFlat(lumpnum_t lump)
{
return GetVArray(flatArrays, lump);
}
void HWR_DrawVertexBuckets(void)
{
rmode = RMODE_TEXTURE;
M_AATreeIterate(textureArrays, DrawArraysFunc);
rmode = RMODE_FLAT;
M_AATreeIterate(flatArrays, DrawArraysFunc);
}
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2015 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Vertex buckets mapping based on texture binding
#ifndef __HW_VERTBUCKETS_H__
#define __HW_VERTBUCKETS_H__
#include "hw_vertarray.h"
/* The vertex buckets are a mapping of runtime texture number to FVertexArray.
* BSP traversal, instead of sending DrawPolygon calls to the driver directly,
* will add vertices to these buckets based on the texture used. After BSP
* traversal, you should call HWR_DrawVertexBuckets in order to send DrawPolygon
* calls for each texture in the buckets.
*/
/** Empty the vertex buckets to prepare for another BSP traversal. This function
* should be called before rendering any BSP node. */
void HWR_ResetVertexBuckets(void);
FVertexArray * HWR_GetVertexArrayForFlat(lumpnum_t lumpnum);
/** Get a pointer to the vertex array used for a given texture number. */
FVertexArray * HWR_GetVertexArrayForTexture(int texNum);
/** Send draw commands to the hardware driver to draw each of the buckets. */
void HWR_DrawVertexBuckets(void);
#endif //__HW_VERTBUCKETS_H__
......@@ -18,7 +18,6 @@
/// \brief OpenGL API for Sonic Robo Blast 2
#if defined (_WIN32)
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#endif
......@@ -29,11 +28,6 @@
#include <stdarg.h>
#include <math.h>
#ifndef SHUFFLE
#ifndef KOS_GL_COMPATIBILITY
#define SHUFFLE
#endif
#endif
#include "r_opengl.h"
#if defined (HWRENDER) && !defined (NOROPENGL)
......@@ -83,9 +77,7 @@ GLint screen_height = 0;
GLbyte screen_depth = 0;
GLint textureformatGL = 0;
GLint maximumAnisotropy = 0;
#ifndef KOS_GL_COMPATIBILITY
static GLboolean MipMap = GL_FALSE;
#endif
static GLint min_filter = GL_LINEAR;
static GLint mag_filter = GL_LINEAR;
static GLint anisotropic_filter = 0;
......@@ -94,11 +86,9 @@ static FTransform md2_transform;
const GLubyte *gl_extensions = NULL;
//Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-)
#ifndef MINI_GL_COMPATIBILITY
static GLdouble modelMatrix[16];
static GLdouble projMatrix[16];
static GLint viewport[4];
#endif
#ifdef USE_PALETTED_TEXTURE
......@@ -158,9 +148,7 @@ float byteasfloat(UINT8 fbyte)
static I_Error_t I_Error_GL = NULL;
#ifndef MINI_GL_COMPATIBILITY
static boolean gl13 = false; // whether we can use opengl 1.3 functions
#endif
// -----------------+
......@@ -197,15 +185,13 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglPolygonOffset glPolygonOffset
#define pglScissor glScissor
#define pglEnable glEnable
#define pglEnableClientState glEnableClientState
#define pglDisable glDisable
#ifndef MINI_GL_COMPATIBILITY
#define pglDisableClientState glDisableClientState
#define pglGetDoublev glGetDoublev
#endif
//glGetIntegerv
//glGetString
#ifdef KOS_GL_COMPATIBILITY
#define pglHint glHint
#endif
/* Depth Buffer */
#define pglClearDepth glClearDepth
......@@ -219,11 +205,8 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglPushMatrix glPushMatrix
#define pglPopMatrix glPopMatrix
#define pglLoadIdentity glLoadIdentity
#ifdef MINI_GL_COMPATIBILITY
#define pglMultMatrixf glMultMatrixf
#else
#define pglMultMatrixd glMultMatrixd
#endif
#define pglRotatef glRotatef
#define pglScalef glScalef
#define pglTranslatef glTranslatef
......@@ -237,6 +220,16 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglColor4fv glColor4fv
#define pglTexCoord2f glTexCoord2f
/* Drawing Functions (arrays) */
#define pglVertexPointer glVertexPointer
#define pglNormalPointer glNormalPointer
#define pglColorPointer glColorPointer
#define pglIndexPointer glIndexPointer
#define pglTexCoordPointer glTexCoordPointer
#define pglEdgeFlagPointer glEdgeFlagPointer
#define pglDrawArrays glDrawArrays
#define pglDrawElements glDrawElements
/* Lighting */
#define pglShadeModel glShadeModel
#define pglLightfv glLightfv
......@@ -260,17 +253,13 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglDeleteTextures glDeleteTextures
#define pglBindTexture glBindTexture
/* texture mapping */ //GL_EXT_copy_texture
#ifndef KOS_GL_COMPATIBILITY
#define pglCopyTexImage2D glCopyTexImage2D
/* GLU functions */
#define pgluBuild2DMipmaps gluBuild2DMipmaps
#endif
#ifndef MINI_GL_COMPATIBILITY
/* 1.3 functions for multitexturing */
#define pglActiveTexture glActiveTexture
#define pglMultiTexCoord2f glMultiTexCoord2f
#endif
#else //!STATIC_OPENGL
/* 1.0 functions */
......@@ -294,12 +283,14 @@ typedef void (APIENTRY * PFNglScissor) (GLint x, GLint y, GLsizei width, GLsizei
static PFNglScissor pglScissor;
typedef void (APIENTRY * PFNglEnable) (GLenum cap);
static PFNglEnable pglEnable;
typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap);
static PFNglEnableClientState pglEnableClientState;
typedef void (APIENTRY * PFNglDisable) (GLenum cap);
static PFNglDisable pglDisable;
#ifndef MINI_GL_COMPATIBILITY
typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap);
static PFNglDisableClientState pglDisableClientState;
typedef void (APIENTRY * PFNglGetDoublev) (GLenum pname, GLdouble *params);
static PFNglGetDoublev pglGetDoublev;
#endif
//glGetIntegerv
//glGetString
......@@ -324,13 +315,10 @@ typedef void (APIENTRY * PFNglPopMatrix) (void);
static PFNglPopMatrix pglPopMatrix;
typedef void (APIENTRY * PFNglLoadIdentity) (void);
static PFNglLoadIdentity pglLoadIdentity;
#ifdef MINI_GL_COMPATIBILITY
typedef void (APIENTRY * PFNglMultMatrixf) (const GLfloat *m);
static PFNglMultMatrixf pglMultMatrixf;
#else
typedef void (APIENTRY * PFNglMultMatrixd) (const GLdouble *m);
static PFNglMultMatrixd pglMultMatrixd;
#endif
typedef void (APIENTRY * PFNglRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
static PFNglRotatef pglRotatef;
typedef void (APIENTRY * PFNglScalef) (GLfloat x, GLfloat y, GLfloat z);
......@@ -354,6 +342,24 @@ static PFNglColor4fv pglColor4fv;
typedef void (APIENTRY * PFNglTexCoord2f) (GLfloat s, GLfloat t);
static PFNglTexCoord2f pglTexCoord2f;
/* Drawing Functions (arrays) */
typedef void (APIENTRY * PFNglVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
static PFNglVertexPointer pglVertexPointer;
typedef void (APIENTRY * PFNglNormalPointer) (GLenum type, GLsizei stride, const GLvoid * pointer);
static PFNglNormalPointer pglNormalPointer;
typedef void (APIENTRY * PFNglColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
static PFNglColorPointer pglColorPointer;
typedef void (APIENTRY * PFNglIndexPointer) (GLenum type, GLsizei stride, const GLvoid * pointer);
static PFNglIndexPointer pglIndexPointer;
typedef void (APIENTRY * PFNglTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
static PFNglTexCoordPointer pglTexCoordPointer;
typedef void (APIENTRY * PFNglEdgeFlagPointer) (GLsizei stride, const GLvoid * pointer);
static PFNglEdgeFlagPointer pglEdgeFlagPointer;
typedef void (APIENTRY * PFNglDrawArrays) (GLenum mode, GLint first, GLsizei count);
static PFNglDrawArrays pglDrawArrays;
typedef void (APIENTRY * PFNglDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
static PFNglDrawElements pglDrawElements;
/* Lighting */
typedef void (APIENTRY * PFNglShadeModel) (GLenum mode);
static PFNglShadeModel pglShadeModel;
......@@ -396,16 +402,13 @@ static PFNglCopyTexImage2D pglCopyTexImage2D;
typedef GLint (APIENTRY * PFNgluBuild2DMipmaps) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
static PFNgluBuild2DMipmaps pgluBuild2DMipmaps;
#ifndef MINI_GL_COMPATIBILITY
/* 1.3 functions for multitexturing */
typedef void (APIENTRY *PFNglActiveTexture) (GLenum);
static PFNglActiveTexture pglActiveTexture;
typedef void (APIENTRY *PFNglMultiTexCoord2f) (GLenum, GLfloat, GLfloat);
static PFNglMultiTexCoord2f pglMultiTexCoord2f;
#endif
#endif
#ifndef MINI_GL_COMPATIBILITY
/* 1.2 Parms */
/* GL_CLAMP_TO_EDGE_EXT */
#ifndef GL_CLAMP_TO_EDGE
......@@ -426,14 +429,6 @@ static PFNglMultiTexCoord2f pglMultiTexCoord2f;
#define GL_TEXTURE1 0x84C1
#endif
#endif
#ifdef MINI_GL_COMPATIBILITY
#undef GL_CLAMP_TO_EDGE
#undef GL_TEXTURE_MIN_LOD
#undef GL_TEXTURE_MAX_LOD
#endif
boolean SetupGLfunc(void)
{
#ifndef STATIC_OPENGL
......@@ -455,10 +450,10 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglPolygonOffset , glPolygonOffset)
GETOPENGLFUNC(pglScissor , glScissor)
GETOPENGLFUNC(pglEnable , glEnable)
GETOPENGLFUNC(pglEnableClientState, glEnableClientState);
GETOPENGLFUNC(pglDisable , glDisable)
#ifndef MINI_GL_COMPATIBILITY
GETOPENGLFUNC(pglDisableClientState, glDisableClientState);
GETOPENGLFUNC(pglGetDoublev , glGetDoublev)
#endif
GETOPENGLFUNC(pglGetIntegerv , glGetIntegerv)
GETOPENGLFUNC(pglGetString , glGetString)
......@@ -472,11 +467,8 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglPushMatrix , glPushMatrix)
GETOPENGLFUNC(pglPopMatrix , glPopMatrix)
GETOPENGLFUNC(pglLoadIdentity , glLoadIdentity)
#ifdef MINI_GL_COMPATIBILITY
GETOPENGLFUNC(pglMultMatrixf , glMultMatrixf)
#else
GETOPENGLFUNC(pglMultMatrixd , glMultMatrixd)
#endif
GETOPENGLFUNC(pglRotatef , glRotatef)
GETOPENGLFUNC(pglScalef , glScalef)
GETOPENGLFUNC(pglTranslatef , glTranslatef)
......@@ -488,6 +480,14 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglColor4f , glColor4f)
GETOPENGLFUNC(pglColor4fv , glColor4fv)
GETOPENGLFUNC(pglTexCoord2f , glTexCoord2f)
GETOPENGLFUNC(pglVertexPointer, glVertexPointer)
GETOPENGLFUNC(pglNormalPointer, glNormalPointer)
GETOPENGLFUNC(pglColorPointer, glColorPointer)
GETOPENGLFUNC(pglTexCoordPointer, glTexCoordPointer)
GETOPENGLFUNC(pglEdgeFlagPointer, glEdgeFlagPointer)
GETOPENGLFUNC(pglDrawArrays, glDrawArrays)
GETOPENGLFUNC(pglDrawElements, glDrawElements)
GETOPENGLFUNC(pglShadeModel , glShadeModel)
GETOPENGLFUNC(pglLightfv, glLightfv)
......@@ -523,9 +523,6 @@ boolean SetupGLFunc13(void)
int glmajor, glminor;
gl13 = false;
#ifdef MINI_GL_COMPATIBILITY
return false;
#else
#ifdef STATIC_OPENGL
gl13 = true;
#else
......@@ -572,7 +569,6 @@ boolean SetupGLFunc13(void)
#endif
return true;
#endif
}
// -----------------+
......@@ -590,11 +586,7 @@ static void SetNoTexture(void)
static void GLPerspective(GLdouble fovy, GLdouble aspect)
{
#ifdef MINI_GL_COMPATIBILITY
GLfloat m[4][4] =
#else
GLdouble m[4][4] =
#endif
{
{ 1.0f, 0.0f, 0.0f, 0.0f},
{ 0.0f, 1.0f, 0.0f, 0.0f},
......@@ -617,14 +609,9 @@ static void GLPerspective(GLdouble fovy, GLdouble aspect)
m[1][1] = cotangent;
m[2][2] = -(zFar + zNear) / deltaZ;
m[3][2] = -2.0f * zNear * zFar / deltaZ;
#ifdef MINI_GL_COMPATIBILITY
pglMultMatrixf(&m[0][0]);
#else
pglMultMatrixd(&m[0][0]);
#endif
}
#ifndef MINI_GL_COMPATIBILITY
static void GLProject(GLdouble objX, GLdouble objY, GLdouble objZ,
GLdouble* winX, GLdouble* winY, GLdouble* winZ)
{
......@@ -664,7 +651,6 @@ static void GLProject(GLdouble objX, GLdouble objY, GLdouble objZ,
*winY=in[1];
*winZ=in[2];
}
#endif
// -----------------+
// SetModelView :
......@@ -691,10 +677,8 @@ void SetModelView(GLint w, GLint h)
//pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gr_scalefrustum (ORIGINAL_ASPECT)
// added for new coronas' code (without depth buffer)
#ifndef MINI_GL_COMPATIBILITY
pglGetIntegerv(GL_VIEWPORT, viewport);
pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
#endif
}
......@@ -719,17 +703,13 @@ void SetStates(void)
//pglShadeModel(GL_FLAT);
pglEnable(GL_TEXTURE_2D); // two-dimensional texturing
#ifndef KOS_GL_COMPATIBILITY
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
pglAlphaFunc(GL_NOTEQUAL, 0.0f);
#endif
//pglBlendFunc(GL_ONE, GL_ZERO); // copy pixel to frame buffer (opaque)
pglEnable(GL_BLEND); // enable color blending
#ifndef KOS_GL_COMPATIBILITY
pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
#endif
//pglDisable(GL_DITHER); // faB: ??? (undocumented in OpenGL 1.1)
// Hurdler: yes, it is!
......@@ -754,9 +734,7 @@ void SetStates(void)
//tex_downloaded = NOTEXTURE_NUM;
//pglTexImage2D(GL_TEXTURE_2D, 0, 4, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
#ifndef KOS_GL_COMPATIBILITY
pglPolygonOffset(-1.0f, -1.0f);
#endif
//pglEnable(GL_CULL_FACE);
//pglCullFace(GL_FRONT);
......@@ -777,9 +755,7 @@ void SetStates(void)
// bp : when no t&l :)
pglLoadIdentity();
pglScalef(1.0f, 1.0f, -1.0f);
#ifndef MINI_GL_COMPATIBILITY
pglGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer)
#endif
}
......@@ -882,14 +858,6 @@ EXPORT void HWRAPI(ClearMipMapCache) (void)
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
INT32 dst_stride, UINT16 * dst_data)
{
#ifdef KOS_GL_COMPATIBILITY
(void)x;
(void)y;
(void)width;
(void)height;
(void)dst_stride;
(void)dst_data;
#else
INT32 i;
// DBG_Printf ("ReadRect()\n");
if (dst_stride == width*3)
......@@ -927,7 +895,6 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
}
free(image);
}
#endif
}
......@@ -948,10 +915,8 @@ EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, f
pglMatrixMode(GL_MODELVIEW);
// added for new coronas' code (without depth buffer)
#ifndef MINI_GL_COMPATIBILITY
pglGetIntegerv(GL_VIEWPORT, viewport);
pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
#endif
}
......@@ -998,12 +963,6 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
GLRGBAFloat c;
// DBG_Printf ("DrawLine() (%f %f %f) %d\n", v1->x, -v1->y, -v1->z, v1->argb);
#ifdef MINI_GL_COMPATIBILITY
GLfloat px1, px2, px3, px4;
GLfloat py1, py2, py3, py4;
GLfloat dx, dy;
GLfloat angle;
#endif
// BP: we should reflect the new state in our variable
//SetBlend(PF_Modulated|PF_NoTexture);
......@@ -1015,33 +974,11 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
c.blue = byte2float[Color.s.blue];
c.alpha = byte2float[Color.s.alpha];
#ifndef MINI_GL_COMPATIBILITY
pglColor4fv(&c.red); // is in RGBA float format
pglBegin(GL_LINES);
pglVertex3f(v1->x, -v1->y, 1.0f);
pglVertex3f(v2->x, -v2->y, 1.0f);
pglEnd();
#else
if (v2->x != v1->x)
angle = (float)atan((v2->y-v1->y)/(v2->x-v1->x));
else
angle = N_PI_DEMI;
dx = (float)sin(angle) / (float)screen_width;
dy = (float)cos(angle) / (float)screen_height;
px1 = v1->x - dx; py1 = v1->y + dy;
px2 = v2->x - dx; py2 = v2->y + dy;
px3 = v2->x + dx; py3 = v2->y - dy;
px4 = v1->x + dx; py4 = v1->y - dy;
pglColor4f(c.red, c.green, c.blue, c.alpha);
pglBegin(GL_TRIANGLE_FAN);
pglVertex3f(px1, -py1, 1);
pglVertex3f(px2, -py2, 1);
pglVertex3f(px3, -py3, 1);
pglVertex3f(px4, -py4, 1);
pglEnd();
#endif
pglEnable(GL_TEXTURE_2D);
}
......@@ -1078,11 +1015,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture
break;
case PF_Additive & PF_Blending:
#ifdef ATI_RAGE_PRO_COMPATIBILITY
pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency
#else
pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest
#endif
break;
case PF_Environment & PF_Blending:
pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
......@@ -1098,7 +1031,6 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
break;
}
}
#ifndef KOS_GL_COMPATIBILITY
if (Xor & PF_NoAlphaTest)
{
if (PolyFlags & PF_NoAlphaTest)
......@@ -1114,7 +1046,6 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
else
pglDisable(GL_POLYGON_OFFSET_FILL);
}
#endif
if (Xor&PF_NoDepthTest)
{
if (PolyFlags & PF_NoDepthTest)
......@@ -1141,10 +1072,6 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
#ifdef KOS_GL_COMPATIBILITY
if (Xor&PF_Modulated && !(PolyFlags & PF_Modulated))
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
#else
if (Xor&PF_Modulated)
{
#if defined (__unix__) || defined (UNIXCOMMON)
......@@ -1164,7 +1091,6 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
}
#endif
if (Xor & PF_Occlude) // depth test but (no) depth write
{
......@@ -1218,11 +1144,7 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
else
{
// Download a mipmap
#ifdef KOS_GL_COMPATIBILITY
static GLushort tex[2048*2048];
#else
static RGBA_t tex[2048*2048];
#endif
const GLvoid *ptex = tex;
INT32 w, h;
......@@ -1241,102 +1163,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
}
else
#endif
#ifdef KOS_GL_COMPATIBILITY
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) ||
(pTexInfo->grInfo.format == GR_TEXFMT_AP_88))
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
for (i = 0; i < w; i++)
{
if ((*pImgData == HWR_PATCHES_CHROMAKEY_COLORINDEX) &&
(pTexInfo->flags & TF_CHROMAKEYED))
{
tex[w*j+i] = 0;
}
else
{
if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88 && !(pTexInfo->flags & TF_CHROMAKEYED))
tex[w*j+i] = 0;
else
tex[w*j+i] = (myPaletteData[*pImgData].s.alpha>>4)<<12;
tex[w*j+i] |= (myPaletteData[*pImgData].s.red >>4)<<8;
tex[w*j+i] |= (myPaletteData[*pImgData].s.green>>4)<<4;
tex[w*j+i] |= (myPaletteData[*pImgData].s.blue >>4);
}
pImgData++;
if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)
{
if (!(pTexInfo->flags & TF_CHROMAKEYED))
tex[w*j+i] |= ((*pImgData)>>4)<<12;
pImgData++;
}
}
}
}
else if (pTexInfo->grInfo.format == GR_RGBA)
{
// corona test : passed as ARGB 8888, which is not in glide formats
// Hurdler: not used for coronas anymore, just for dynamic lighting
const RGBA_t *pImgData = (const RGBA_t *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
for (i = 0; i < w; i++)
{
tex[w*j+i] = (pImgData->s.alpha>>4)<<12;
tex[w*j+i] |= (pImgData->s.red >>4)<<8;
tex[w*j+i] |= (pImgData->s.green>>4)<<4;
tex[w*j+i] |= (pImgData->s.blue >>4);
pImgData++;
}
}
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88)
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
for (i = 0; i < w; i++)
{
const GLubyte sID = (*pImgData)>>4;
tex[w*j+i] = sID<<8 | sID<<4 | sID;
pImgData++;
tex[w*j+i] |= ((*pImgData)>>4)<<12;
pImgData++;
}
}
}
else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks
{
const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data;
INT32 i, j;
for (j = 0; j < h; j++)
{
for (i = 0; i < w; i++)
{
tex[w*j+i] = (pImgData>>4)<<12;
tex[w*j+i] |= (255>>4)<<8;
tex[w*j+i] |= (255>>4)<<4;
tex[w*j+i] |= (255>>4);
pImgData++;
}
}
}
else
DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
#else
if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) ||
(pTexInfo->grInfo.format == GR_TEXFMT_AP_88))
{
......@@ -1418,7 +1244,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
}
else
DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
#endif
pTexInfo->downloaded = NextTexAvail++;
tex_downloaded = pTexInfo->downloaded;
......@@ -1427,18 +1252,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
#ifdef KOS_GL_COMPATIBILITY
pglTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB4444, w, h, 0, GL_ARGB4444, GL_UNSIGNED_BYTE, ptex);
#else
#ifdef MINI_GL_COMPATIBILITY
//if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88)
//pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
//else
if (MipMap)
pgluBuild2DMipmaps(GL_TEXTURE_2D, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
else
pglTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
#else
#ifdef USE_PALETTED_TEXTURE
//Hurdler: not really supported and not tested recently
if (glColorTableEXT &&
......@@ -1489,8 +1302,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
else
pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex);
}
#endif
#endif
if (pTexInfo->flags & TF_WRAPX)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
......@@ -1514,19 +1325,6 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
else // initialisation de la liste
gr_cachetail = gr_cachehead = pTexInfo;
}
#ifdef MINI_GL_COMPATIBILITY
switch (pTexInfo->flags)
{
case 0 :
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
break;
default:
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
break;
}
#endif
}
......@@ -1537,21 +1335,15 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
//FTextureInfo *pTexInfo,
FOutVector *pOutVerts,
FUINT iNumPts,
FBITFIELD PolyFlags)
FBITFIELD PolyFlags,
int PrimitiveType)
{
FUINT i;
#ifndef MINI_GL_COMPATIBILITY
FUINT j;
#endif
GLRGBAFloat c = {0,0,0,0};
#ifdef MINI_GL_COMPATIBILITY
if (PolyFlags & PF_Corona)
PolyFlags &= ~PF_NoDepthTest;
#else
if ((PolyFlags & PF_Corona) && (oglflags & GLF_NOZBUFREAD))
PolyFlags &= ~(PF_NoDepthTest|PF_Corona);
#endif
SetBlend(PolyFlags); //TODO: inline (#pragma..)
......@@ -1573,16 +1365,11 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
c.alpha = byte2float[pSurf->FlatColor.s.alpha];
}
#ifdef MINI_GL_COMPATIBILITY
pglColor4f(c.red, c.green, c.blue, c.alpha);
#else
pglColor4fv(&c.red); // is in RGBA float format
#endif
}
// this test is added for new coronas' code (without depth buffer)
// I think I should do a separate function for drawing coronas, so it will be a little faster
#ifndef MINI_GL_COMPATIBILITY
if (PolyFlags & PF_Corona) // check to see if we need to draw the corona
{
//rem: all 8 (or 8.0f) values are hard coded: it can be changed to a higher value
......@@ -1629,19 +1416,27 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
c.alpha *= scalef; // change the alpha value (it seems better than changing the size of the corona)
pglColor4fv(&c.red);
}
#endif
if (PolyFlags & PF_MD2)
return;
pglBegin(GL_TRIANGLE_FAN);
for (i = 0; i < iNumPts; i++)
pglEnableClientState(GL_VERTEX_ARRAY);
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x);
pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].sow);
switch (PrimitiveType)
{
pglTexCoord2f(pOutVerts[i].sow, pOutVerts[i].tow);
//Hurdler: test code: -pOutVerts[i].z => pOutVerts[i].z
pglVertex3f(pOutVerts[i].x, pOutVerts[i].y, pOutVerts[i].z);
//pglVertex3f(pOutVerts[i].x, pOutVerts[i].y, -pOutVerts[i].z);
case PP_TriangleFan:
pglDrawArrays(GL_TRIANGLE_FAN, 0, iNumPts);
break;
case PP_Triangles:
pglDrawArrays(GL_TRIANGLES, 0, iNumPts);
break;
default:
break;
}
pglEnd();
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
pglDisableClientState(GL_VERTEX_ARRAY);
if (PolyFlags & PF_RemoveYWrap)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
......@@ -1723,41 +1518,15 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
break;
case HWD_SET_POLYGON_SMOOTH:
#ifdef KOS_GL_COMPATIBILITY // GL_POLYGON_SMOOTH_HINT
if (Value)
pglHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
else
pglHint(GL_POLYGON_SMOOTH_HINT,GL_FASTEST);
#else
if (Value)
pglEnable(GL_POLYGON_SMOOTH);
else
pglDisable(GL_POLYGON_SMOOTH);
#endif
break;
case HWD_SET_TEXTUREFILTERMODE:
switch (Value)
{
#ifdef KOS_GL_COMPATIBILITY
case HWD_SET_TEXTUREFILTER_TRILINEAR:
case HWD_SET_TEXTUREFILTER_BILINEAR:
min_filter = mag_filter = GL_FILTER_BILINEAR;
break;
case HWD_SET_TEXTUREFILTER_POINTSAMPLED:
min_filter = mag_filter = GL_FILTER_NONE;
case HWD_SET_TEXTUREFILTER_MIXED1:
min_filter = GL_FILTER_NONE;
mag_filter = GL_LINEAR;
case HWD_SET_TEXTUREFILTER_MIXED2:
min_filter = GL_LINEAR;
mag_filter = GL_FILTER_NONE;
break;
case HWD_SET_TEXTUREFILTER_MIXED3:
min_filter = GL_FILTER_BILINEAR;
mag_filter = GL_FILTER_NONE;
break;
#elif !defined (MINI_GL_COMPATIBILITY)
case HWD_SET_TEXTUREFILTER_TRILINEAR:
min_filter = GL_LINEAR_MIPMAP_LINEAR;
mag_filter = GL_LINEAR;
......@@ -1786,14 +1555,9 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
mag_filter = GL_NEAREST;
MipMap = GL_TRUE;
break;
#endif
default:
#ifdef KOS_GL_COMPATIBILITY
min_filter = mag_filter = GL_FILTER_NONE;
#else
mag_filter = GL_LINEAR;
min_filter = GL_NEAREST;
#endif
}
#ifndef STATIC_OPENGL
if (!pgluBuild2DMipmaps)
......@@ -1831,9 +1595,7 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d
float scalex = scale, scaley = scale, scalez = scale;
// Because Otherwise, scaling the screen negatively vertically breaks the lighting
#ifndef KOS_GL_COMPATIBILITY
GLfloat LightPos[] = {0.0f, 1.0f, 0.0f, 0.0f};
#endif
if (duration == 0)
duration = 1;
......@@ -1885,9 +1647,7 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d
pglCullFace(GL_BACK);
}
#ifndef KOS_GL_COMPATIBILITY
pglLightfv(GL_LIGHT0, GL_POSITION, LightPos);
#endif
pglShadeModel(GL_SMOOTH);
if (color)
......@@ -1899,7 +1659,7 @@ EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 d
#endif
}
DrawPolygon(NULL, NULL, 0, PF_Masked|PF_Modulated|PF_Occlude|PF_Clip);
DrawPolygon(NULL, NULL, 0, PF_Masked|PF_Modulated|PF_Occlude|PF_Clip, PP_TriangleFan);
pglPushMatrix(); // should be the same as glLoadIdentity
//Hurdler: now it seems to work
......@@ -2013,9 +1773,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5)
else
GLPerspective(stransform->fovxangle, ASPECT_RATIO);
#ifndef MINI_GL_COMPATIBILITY
pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer)
#endif
pglMatrixMode(GL_MODELVIEW);
}
else
......@@ -2029,15 +1787,11 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
else
//Hurdler: is "fov" correct?
GLPerspective(fov, ASPECT_RATIO);
#ifndef MINI_GL_COMPATIBILITY
pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer)
#endif
pglMatrixMode(GL_MODELVIEW);
}
#ifndef MINI_GL_COMPATIBILITY
pglGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer)
#endif
}
EXPORT INT32 HWRAPI(GetTextureUsed) (void)
......@@ -2058,7 +1812,6 @@ EXPORT INT32 HWRAPI(GetRenderVersion) (void)
return VERSION;
}
#ifdef SHUFFLE
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
{
INT32 x, y;
......@@ -2118,7 +1871,6 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
pglEnable(GL_DEPTH_TEST);
pglEnable(GL_BLEND);
}
#endif //SHUFFLE
// Create Screen to fade from
EXPORT void HWRAPI(StartScreenWipe) (void)
......@@ -2133,18 +1885,11 @@ EXPORT void HWRAPI(StartScreenWipe) (void)
// Create screen texture
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
#ifdef KOS_GL_COMPATIBILITY
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_FILTER_NONE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_FILTER_NONE);
#else
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
#ifndef KOS_GL_COMPATIBILITY
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0);
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
......@@ -2162,18 +1907,11 @@ EXPORT void HWRAPI(EndScreenWipe)(void)
// Create screen texture
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
#ifdef KOS_GL_COMPATIBILITY
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_FILTER_NONE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_FILTER_NONE);
#else
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
#ifndef KOS_GL_COMPATIBILITY
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0);
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
......@@ -2226,9 +1964,7 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
INT32 texsize = 2048;
float xfix, yfix;
#ifndef MINI_GL_COMPATIBILITY
INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set
#endif
// Use a power of two texture, dammit
if(screen_width <= 1024)
......@@ -2268,7 +2004,6 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest|PF_Clip|PF_NoZClip);
#ifndef MINI_GL_COMPATIBILITY
if (gl13)
{
// Draw the end screen that fades in
......@@ -2311,31 +2046,28 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
}
else
{
#endif
// Draw the end screen that fades in
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
pglBegin(GL_QUADS);
pglColor4f(1.0f, 1.0f, 1.0f, alpha);
// Draw the end screen that fades in
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
pglBegin(GL_QUADS);
pglColor4f(1.0f, 1.0f, 1.0f, alpha);
// Bottom left
pglTexCoord2f(0.0f, 0.0f);
pglVertex3f(-1.0f, -1.0f, 1.0f);
// Bottom left
pglTexCoord2f(0.0f, 0.0f);
pglVertex3f(-1.0f, -1.0f, 1.0f);
// Top left
pglTexCoord2f(0.0f, yfix);
pglVertex3f(-1.0f, 1.0f, 1.0f);
// Top left
pglTexCoord2f(0.0f, yfix);
pglVertex3f(-1.0f, 1.0f, 1.0f);
// Top right
pglTexCoord2f(xfix, yfix);
pglVertex3f(1.0f, 1.0f, 1.0f);
// Top right
pglTexCoord2f(xfix, yfix);
pglVertex3f(1.0f, 1.0f, 1.0f);
// Bottom right
pglTexCoord2f(xfix, 0.0f);
pglVertex3f(1.0f, -1.0f, 1.0f);
pglEnd();
#ifndef MINI_GL_COMPATIBILITY
// Bottom right
pglTexCoord2f(xfix, 0.0f);
pglVertex3f(1.0f, -1.0f, 1.0f);
pglEnd();
}
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
......@@ -2354,18 +2086,11 @@ EXPORT void HWRAPI(MakeScreenTexture) (void)
// Create screen texture
pglBindTexture(GL_TEXTURE_2D, screentexture);
#ifdef KOS_GL_COMPATIBILITY
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_FILTER_NONE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_FILTER_NONE);
#else
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
#ifndef KOS_GL_COMPATIBILITY
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0);
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
}
......@@ -2382,18 +2107,11 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
// Create screen texture
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
#ifdef KOS_GL_COMPATIBILITY
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_FILTER_NONE);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_FILTER_NONE);
#else
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
#endif
Clamp2D(GL_TEXTURE_WRAP_S);
Clamp2D(GL_TEXTURE_WRAP_T);
#ifndef KOS_GL_COMPATIBILITY
pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, texsize, texsize, 0);
#endif
tex_downloaded = 0; // 0 so it knows it doesn't have any of the cached patches downloaded right now
......
......@@ -36,13 +36,11 @@
#include <GL/gl.h>
#include <GL/glu.h>
#ifndef MINI_GL_COMPATIBILITY
#ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static
#define GL_GLEXT_PROTOTYPES
#include <GL/glext.h>
#endif
#endif
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows
#include "../../doomdef.h"
......
......@@ -97,9 +97,7 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DrawMD2i);
GETFUNC(SetTransform);
GETFUNC(GetRenderVersion);
#ifdef SHUFFLE
GETFUNC(PostImgRedraw);
#endif //SHUFFLE
GETFUNC(StartScreenWipe);
GETFUNC(EndScreenWipe);
GETFUNC(DoScreenWipe);
......
......@@ -1752,9 +1752,7 @@ void I_StartupGraphics(void)
HWD.pfnDrawMD2i = hwSym("DrawMD2i",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
#ifdef SHUFFLE
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);
#endif
HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL);
HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL);
HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL);
......
......@@ -97,9 +97,7 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DrawMD2i);
GETFUNC(SetTransform);
GETFUNC(GetRenderVersion);
#ifdef SHUFFLE
GETFUNC(PostImgRedraw);
#endif //SHUFFLE
GETFUNC(StartScreenWipe);
GETFUNC(EndScreenWipe);
GETFUNC(DoScreenWipe);
......
......@@ -1969,9 +1969,7 @@ void I_StartupGraphics(void)
HWD.pfnDrawMD2i = hwSym("DrawMD2i",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
#ifdef SHUFFLE
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);
#endif
HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL);
HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL);
HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL);
......
......@@ -230,11 +230,9 @@ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
glXSwapIntervalSGIEXT = NULL;
#endif
#ifndef KOS_GL_COMPATIBILITY
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
else
#endif
maximumAnisotropy = 0;
SetupGLFunc13();
......@@ -246,11 +244,7 @@ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
HWR_Startup();
#ifdef KOS_GL_COMPATIBILITY
textureformatGL = GL_ARGB4444;
#else
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
#endif
return true;
}
......