From 40dce83ace52c4639cf7ae4f65c3cb0cdd6e7d3c Mon Sep 17 00:00:00 2001 From: Disk Poppy <diskpoppy@protonmail.com> Date: Sat, 2 May 2020 13:54:42 +0200 Subject: [PATCH] reenable sprites --- src/hardware/hw_main.c | 105 ++++++++++++++++++------------- src/hardware/r_opengl/r_opengl.c | 1 + 2 files changed, 63 insertions(+), 43 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bd69f1e3a..4c614cd86 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3858,7 +3858,6 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) { GLPatch_t *gpatch; FOutVector shadowVerts[4]; - FSurfaceInfo sSurf; float fscale; float fx; float fy; float offset; extracolormap_t *colormap = NULL; UINT8 i; @@ -3946,12 +3945,14 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) colormap = thing->subsector->sector->extra_colormap; } - sSurf.TintMode = HWD_TINT_INTERPOLATE; - sSurf.BlendMode = HWD_BLEND_TRANSLUCENT; - sSurf.PolyFlags = 0; - - //HWR_Lighting(0, colormap, 255 - alpha, HWD_SHADER_SPRITE); - //HWD.pfnDrawPolygon(&sSurf, shadowVerts, 4); + //TODO: texture + levelsurfinfo_t *surf = HWR_AllocWall(shadowVerts, 0); + surf->lightlevel = 0; + surf->colormap = colormap; + surf->opacity = 255 - alpha; + surf->surfBlend = SURF_BLEND_TRANSLUCENT; + HWR_RenderWall(surf); + HWR_FreeSurf(surf); } // This is expecting a pointer to an array containing 4 wallVerts for a sprite @@ -3994,11 +3995,11 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) FOutVector wallVerts[4]; FOutVector baseWallVerts[4]; // This is what the verts should end up as GLPatch_t *gpatch; - FSurfaceInfo Surf = {}; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); extracolormap_t *colormap; UINT16 lightlevel; UINT8 opacity; + ELevelSurfaceBlending blend; float realtop, realbot, top, bot; float ttop, tbot, tmult; @@ -4097,19 +4098,17 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!cv_translucency.value) // translucency disabled { opacity = 0xFF; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; //why? - Surf.PolyFlags = PF_Occlude; + blend = SURF_BLEND_OPAQUE; + //blend = SURF_BLEND_TRANSLUCENT; } else if (spr->mobj->flags2 & MF2_SHADOW) { opacity = 0x40; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; - Surf.PolyFlags = 0; + blend = SURF_BLEND_TRANSLUCENT; } else if (spr->mobj->frame & FF_TRANSMASK) { opacity = trans2alpha[(spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT]; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; - Surf.PolyFlags = 0; + blend = SURF_BLEND_TRANSLUCENT; } else { @@ -4118,8 +4117,8 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before opacity = 0xFF; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; - Surf.PolyFlags = PF_Occlude; + blend = SURF_BLEND_OPAQUE; + //blend = SURF_BLEND_TRANSLUCENT; } // Start with the lightlevel and colormap from the top of the sprite @@ -4274,10 +4273,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) } #endif - Surf.TintMode = HWD_TINT_INTERPOLATE; - - //HWR_Lighting(lightlevel, colormap, opacity, HWD_SHADER_SPRITE); - //HWD.pfnDrawPolygon(&Surf, wallVerts, 4); + { + //TODO: texture + levelsurfinfo_t *surf = HWR_AllocWall(wallVerts, 0); + surf->lightlevel = lightlevel; + surf->colormap = colormap; + surf->opacity = opacity; + surf->surfBlend = blend; + HWR_RenderWall(surf); + HWR_FreeSurf(surf); + } top = bot; #ifdef ESLOPE @@ -4312,10 +4317,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[0].y = wallVerts[1].y = bot; #endif - Surf.TintMode = HWD_TINT_INTERPOLATE; - - //HWR_Lighting(lightlevel, colormap, opacity, HWD_SHADER_SPRITE); - //HWD.pfnDrawPolygon(&Surf, wallVerts, 4); + { + //TODO: texture + levelsurfinfo_t *surf = HWR_AllocWall(wallVerts, 0); + surf->lightlevel = lightlevel; + surf->colormap = colormap; + surf->opacity = opacity; + surf->surfBlend = blend; + HWR_RenderWall(surf); + HWR_FreeSurf(surf); + } } // -----------------+ @@ -4429,7 +4440,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; UINT16 lightlevel = 0xFF; UINT8 opacity; - boolean opaque; + ELevelSurfaceBlending blend; if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = sector->lightlevel; @@ -4437,16 +4448,16 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) if (!cv_translucency.value) // translucency disabled { opacity = 0xFF; - opaque = true; + blend = SURF_BLEND_OPAQUE; } else if (spr->mobj->flags2 & MF2_SHADOW) { opacity = 0x40; - opaque = false; + blend = SURF_BLEND_TRANSLUCENT; } else if (spr->mobj->frame & FF_TRANSMASK) { opacity = trans2alpha[(spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT]; - opaque = false; + blend = SURF_BLEND_TRANSLUCENT; } else { @@ -4455,11 +4466,17 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before opacity = 0xFF; - opaque = true; + blend = SURF_BLEND_OPAQUE; } - //HWR_Lighting(lightlevel, colormap, opacity, HWD_SHADER_SPRITE); - //HWD.pfnDrawPolygon(&Surf, wallVerts, 4); + //TODO: texture + levelsurfinfo_t *surf = HWR_AllocWall(wallVerts, 0); + surf->lightlevel = lightlevel; + surf->colormap = colormap; + surf->opacity = opacity; + surf->surfBlend = blend; + HWR_RenderWall(surf); + HWR_FreeSurf(surf); } } @@ -4469,7 +4486,6 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) { FOutVector wallVerts[4]; GLPatch_t *gpatch; // sprite patch converted to hardware - FSurfaceInfo Surf = {}; if (!spr->mobj) return; @@ -4516,6 +4532,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) extracolormap_t *colormap = sector->extra_colormap; UINT16 lightlevel = 0xFF; UINT8 opacity; + ELevelSurfaceBlending blend; if (sector->numlights) { @@ -4541,13 +4558,11 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) if (spr->mobj->flags2 & MF2_SHADOW) { opacity = 0x40; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; //why? - Surf.PolyFlags = 0; + blend = SURF_BLEND_TRANSLUCENT; } else if (spr->mobj->frame & FF_TRANSMASK) { opacity = trans2alpha[(spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT]; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; //why? - Surf.PolyFlags = 0; + blend = SURF_BLEND_TRANSLUCENT; } else { @@ -4556,14 +4571,18 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before opacity = 0xFF; - Surf.BlendMode = HWD_BLEND_TRANSLUCENT; //why? - Surf.PolyFlags = PF_Occlude; + blend = SURF_BLEND_OPAQUE; + //blend = SURF_BLEND_TRANSLUCENT; } - Surf.TintMode = HWD_TINT_INTERPOLATE; - - //HWR_Lighting(lightlevel, colormap, opacity, HWD_SHADER_SPRITE); - //HWD.pfnDrawPolygon(&Surf, wallVerts, 4); + //TODO: texture + levelsurfinfo_t *surf = HWR_AllocWall(wallVerts, 0); + surf->lightlevel = lightlevel; + surf->colormap = colormap; + surf->opacity = opacity; + surf->surfBlend = blend; + HWR_RenderWall(surf); + HWR_FreeSurf(surf); } } #endif @@ -6240,7 +6259,7 @@ void HWR_DoPostProcessor(player_t *player) Surf.BlendMode = HWD_BLEND_ADDITIVE; Surf.PolyFlags = PF_NoTexture|PF_NoDepthTest; - //HWD.pfnDrawPolygon(&Surf, v, 4); + HWD.pfnDrawDefaultSurface(&Surf, v, 4); } // Capture the screen for intermission and screen waving diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index f8c9c61a4..59584b847 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1988,6 +1988,7 @@ EXPORT void HWRAPI(DrawDefaultSurface) (FSurfaceInfo *surf, const FOutVector *pO EXPORT void HWRAPI(DrawLevelSurface) (levelsurfinfo_t *l) { + //TODO: textures if(l->surfBlend == SURF_BLEND_FOG) pglDisable(GL_TEXTURE_2D); else -- GitLab