diff --git a/Srb2.dev b/Srb2.dev index fbc10139abd36c38cd0f78d6b73c79c635a606a2..983cbe98cc3a6eda1cd55bbb898ec88fc803134f 100644 --- a/Srb2.dev +++ b/Srb2.dev @@ -94,7 +94,7 @@ OverrideBuildCmd=0 BuildCmd= [Unit9] -FileName=src\hardware\hw_drv.h +FileName=src\hardware\hw_gpu.h Folder=Hw_Hardware Compile=1 CompileCpp=0 diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 966e56c97e63d18eb82588f002306b0c4d657031..fe984561ad8f627165448c1873c5fba4de01942f 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -71,7 +71,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture) } else { - HWD.pfnSetTexture(texture); + GL_SetTexture(texture); } } @@ -152,8 +152,8 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt } else { - HWD.pfnSetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target); - HWD.pfnDrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags); + GL_SetShader((shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target); + GL_DrawPolygon(pSurf, pOutVerts, iNumPts, PolyFlags); } } @@ -240,13 +240,13 @@ void HWR_RenderBatches(void) if (cv_glshaders.value && gl_shadersavailable) { - HWD.pfnSetShader(currentShader); + GL_SetShader(currentShader); } if (currentPolyFlags & PF_NoTexture) currentTexture = NULL; else - HWD.pfnSetTexture(currentTexture); + GL_SetTexture(currentTexture); while (1)// note: remember handling notexture polyflag as having texture number 0 (also in comparePolygons) { @@ -364,7 +364,7 @@ void HWR_RenderBatches(void) if (changeState || stopFlag) { // execute draw call - HWD.pfnDrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); + GL_DrawIndexedTriangles(¤tSurfaceInfo, finalVertexArray, finalIndexWritePos, currentPolyFlags, finalVertexIndexArray); // update stats ps_hw_numcalls.value.i++; ps_hw_numverts.value.i += finalIndexWritePos; @@ -382,7 +382,7 @@ void HWR_RenderBatches(void) { if (changeShader) { - HWD.pfnSetShader(nextShader); + GL_SetShader(nextShader); currentShader = nextShader; changeShader = false; @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) if (changeTexture) { // texture should be already ready for use from calls to SetTexture during batch collection - HWD.pfnSetTexture(nextTexture); + GL_SetTexture(nextTexture); currentTexture = nextTexture; changeTexture = false; diff --git a/src/hardware/hw_batching.h b/src/hardware/hw_batching.h index 4214ca410c071994bb1e16576e5f4d6c4ebfb311..c3cd37b5673d931857891c51b5a3ee246bc5d767 100644 --- a/src/hardware/hw_batching.h +++ b/src/hardware/hw_batching.h @@ -14,7 +14,7 @@ #include "hw_defs.h" #include "hw_data.h" -#include "hw_drv.h" +#include "hw_gpu.h" typedef struct { diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d402fbadcd59a259b0c7aa988e81cef7cf31856a..d5dbf16453950caa96ac21122d0157fae29b3fa7 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -14,7 +14,7 @@ #ifdef HWRENDER #include "hw_glob.h" -#include "hw_drv.h" +#include "hw_gpu.h" #include "hw_batching.h" #include "../doomstat.h" //gamemode @@ -561,7 +561,7 @@ void HWR_FreeTextureData(patch_t *patch) grPatch = patch->hardware; if (vid.glstate == VID_GL_LIBRARY_LOADED) - HWD.pfnDeleteTexture(grPatch->mipmap); + GL_DeleteTexture(grPatch->mipmap); if (grPatch->mipmap->data) Z_Free(grPatch->mipmap->data); } @@ -627,7 +627,7 @@ void HWR_FreeTextureColormaps(patch_t *patch) Z_Free(next->data); if (next->colormap) Z_Free(next->colormap); - HWD.pfnDeleteTexture(next); + GL_DeleteTexture(next); // Free the old colormap mipmap from memory. free(next); @@ -662,7 +662,7 @@ static void HWR_FreePatchCache(boolean freeall) // free all textures after each level void HWR_ClearAllTextures(void) { - HWD.pfnClearMipMapCache(); // free references to the textures + GL_ClearMipMapCache(); // free references to the textures HWR_FreePatchCache(true); } @@ -680,7 +680,7 @@ void HWR_InitMapTextures(void) static void DeleteTextureMipmap(GLMipmap_t *grMipmap, boolean delete_mipmap) { - HWD.pfnDeleteTexture(grMipmap); + GL_DeleteTexture(grMipmap); if (delete_mipmap) Z_Free(grMipmap->data); @@ -787,7 +787,7 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean chromakeyed) HWR_GenerateTexture(tex, grtex, grMipmap); if (!grMipmap->downloaded) - HWD.pfnSetTexture(grMipmap); + GL_SetTexture(grMipmap); HWR_SetCurrentTexture(grMipmap); Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); @@ -827,7 +827,7 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grmip->downloaded) - HWD.pfnSetTexture(grmip); + GL_SetTexture(grmip); HWR_SetCurrentTexture(grmip); // The system-memory data can be purged now. @@ -896,7 +896,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean chromakeyed) } if (!grMipmap->downloaded) - HWD.pfnSetTexture(grMipmap); + GL_SetTexture(grMipmap); HWR_SetCurrentTexture(grMipmap); Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED); @@ -913,7 +913,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) // If hardware does not have the texture, then call pfnSetTexture to upload it if (!grMipmap->downloaded) - HWD.pfnSetTexture(grMipmap); + GL_SetTexture(grMipmap); HWR_SetCurrentTexture(grMipmap); // The system-memory data can be purged now. @@ -931,9 +931,9 @@ static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *grMipmap) // If hardware does not have the texture, then call pfnSetTexture to upload it // If it does have the texture, then call pfnUpdateTexture to update it if (!grMipmap->downloaded) - HWD.pfnSetTexture(grMipmap); + GL_SetTexture(grMipmap); else - HWD.pfnUpdateTexture(grMipmap); + GL_UpdateTexture(grMipmap); HWR_SetCurrentTexture(grMipmap); // The system-memory data can be purged now. @@ -1124,7 +1124,7 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum) if (!grmip->downloaded && !grmip->data) HWR_CacheFadeMask(grmip, fademasklumpnum); - HWD.pfnSetTexture(grmip); + GL_SetTexture(grmip); // The system-memory data can be purged now. Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED); @@ -1158,11 +1158,11 @@ void HWR_SetPalette(RGBA_t *palette) crushed_palette[i].s.blue = (UINT8)(fblue / 31.0f * 255.0f); crushed_palette[i].s.alpha = 255; } - HWD.pfnSetScreenPalette(crushed_palette); + GL_SetScreenPalette(crushed_palette); } else { - HWD.pfnSetScreenPalette(palette); + GL_SetScreenPalette(palette); } // this part is responsible for keeping track of the palette OUTSIDE of a level. @@ -1172,7 +1172,7 @@ void HWR_SetPalette(RGBA_t *palette) else { // set the palette for the textures - HWD.pfnSetTexturePalette(palette); + GL_SetPalette(palette); // reset mapPalette so next call to HWR_SetMapPalette will update everything correctly memset(mapPalette, 0, sizeof(mapPalette)); // hardware driver will flush there own cache if cache is non paletized @@ -1204,7 +1204,7 @@ static void HWR_SetPaletteLookup(RGBA_t *palette) } } #undef STEP_SIZE - HWD.pfnSetPaletteLookup(lut); + GL_SetPaletteLookup(lut); Z_Free(lut); } @@ -1250,7 +1250,7 @@ void HWR_SetMapPalette(void) // in palette rendering mode, this means that all rgba textures now have wrong colors // and the lookup table is outdated HWR_SetPaletteLookup(mapPalette); - HWD.pfnSetTexturePalette(mapPalette); + GL_SetPalette(mapPalette); if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA) { Z_FreeTag(PU_HWRCACHE); @@ -1271,7 +1271,7 @@ UINT32 HWR_CreateLightTable(UINT8 *lighttable, RGBA_t *hw_lighttable) for (i = 0; i < 256 * 32; i++) hw_lighttable[i] = palette[lighttable[i]]; - return HWD.pfnCreateLightTable(hw_lighttable); + return GL_CreateLightTable(hw_lighttable); } // Updates a hardware lighttable of a given id from the supplied lighttable. @@ -1283,7 +1283,7 @@ void HWR_UpdateLightTable(UINT32 id, UINT8 *lighttable, RGBA_t *hw_lighttable) for (i = 0; i < 256 * 32; i++) hw_lighttable[i] = palette[lighttable[i]]; - HWD.pfnUpdateLightTable(id, hw_lighttable); + GL_UpdateLightTable(id, hw_lighttable); } // get hwr lighttable id for colormap, create it if it doesn't already exist @@ -1333,7 +1333,7 @@ void HWR_ClearLightTables(void) Z_FreeTag(PU_HWRLIGHTTABLEDATA); if (vid.glstate == VID_GL_LIBRARY_LOADED) - HWD.pfnClearLightTables(); + GL_ClearLightTables(); } #endif //HWRENDER diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 575db9286866eed148fb1e1abc3e5e971e72a68a..55c500de4f841069a1576f064a988c7098950b65 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -19,7 +19,7 @@ #ifdef HWRENDER #include "hw_main.h" #include "hw_glob.h" -#include "hw_drv.h" +#include "hw_gpu.h" #include "../m_misc.h" //FIL_WriteFile() #include "../r_draw.h" @@ -296,10 +296,10 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; Surf.PolyColor.s.alpha = opacity; flags |= PF_Modulated; - HWD.pfnDrawPolygon(&Surf, v, 4, flags); + GL_DrawPolygon(&Surf, v, 4, flags); } else - HWD.pfnDrawPolygon(NULL, v, 4, flags); + GL_DrawPolygon(NULL, v, 4, flags); } void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) @@ -587,10 +587,10 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; - HWD.pfnDrawPolygon(&Surf, v, 4, flags); + GL_DrawPolygon(&Surf, v, 4, flags); } else - HWD.pfnDrawPolygon(NULL, v, 4, flags); + GL_DrawPolygon(NULL, v, 4, flags); } // ========================================================================== @@ -666,7 +666,7 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) // needed to texture the poly HWR_GetRawFlat(flatlumpnum); - HWD.pfnDrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent); + GL_DrawPolygon(NULL, v, 4, PF_NoDepthTest); //PF_Translucent); } // -------------------------------------------------------------------------- @@ -723,10 +723,10 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) Surf.LightTableId = HWR_GetLightTableID(NULL); Surf.LightInfo.light_level = strength; - HWD.pfnMakeScreenTexture(scr_tex); - HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE)); - HWD.pfnDrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest); - HWD.pfnUnSetShader(); + GL_MakeScreenTexture(scr_tex); + GL_SetShader(HWR_GetShaderFromTarget(SHADER_UI_COLORMAP_FADE)); + GL_DrawScreenTexture(scr_tex, &Surf, PF_ColorMapped|PF_NoDepthTest); + GL_UnSetShader(); return; } @@ -745,7 +745,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) Surf.PolyColor.s.alpha = softwaretranstogl[strength]; poly_flags |= PF_Translucent; } - HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags); + GL_DrawPolygon(&Surf, v, 4, poly_flags); } // -----------------+ @@ -917,7 +917,7 @@ void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 ac Surf.PolyColor.rgba = palette[actualcolor&0xFF].rgba; Surf.PolyColor.s.alpha = softwaretranstogl[strength]; } - HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); + GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } // Draw the console background with translucency support @@ -944,7 +944,7 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height) Surf.PolyColor.rgba = UINT2RGBA(color); Surf.PolyColor.s.alpha = 0x80; - HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); + GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } // Very similar to HWR_DrawConsoleBack, except we draw from the middle(-ish) of the screen to the bottom. @@ -974,7 +974,7 @@ void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight) Surf.PolyColor.rgba = UINT2RGBA(color); Surf.PolyColor.s.alpha = (color == 0 ? 0xC0 : 0x80); // make black darker, like software - HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); + GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } // ========================================================================== @@ -999,7 +999,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) v2.x = ((float)fl->b.x-(vid.width/2.0f))*(2.0f/vid.width); v2.y = ((float)fl->b.y-(vid.height/2.0f))*(2.0f/vid.height); - HWD.pfnDraw2DLine(&v1, &v2, color_rgba); + GL_Draw2DLine(&v1, &v2, color_rgba); } // -------------------+ @@ -1165,7 +1165,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 Surf.PolyColor.rgba = UINT2RGBA(actualcolor); Surf.PolyColor.s.alpha = 0x80; - HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); + GL_DrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } // -----------------+ @@ -1269,7 +1269,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) clearColour.green = (float)rgbaColour.s.green / 255; clearColour.blue = (float)rgbaColour.s.blue / 255; clearColour.alpha = 1; - HWD.pfnClearBuffer(true, false, &clearColour); + GL_ClearBuffer(true, false, &clearColour); return; } @@ -1350,7 +1350,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; } - HWD.pfnDrawPolygon(&Surf, v, 4, + GL_DrawPolygon(&Surf, v, 4, PF_Modulated|PF_NoTexture|PF_NoDepthTest|PF_Translucent); } @@ -1433,7 +1433,7 @@ UINT8 *HWR_GetScreenshot(void) if (!buf) return NULL; // returns 24bit 888 RGB - HWD.pfnReadScreenTexture(tex, (void *)buf); + GL_ReadScreenTexture(tex, (void *)buf); return buf; } @@ -1450,7 +1450,7 @@ boolean HWR_Screenshot(const char *pathname) } // returns 24bit 888 RGB - HWD.pfnReadScreenTexture(tex, (void *)buf); + GL_ReadScreenTexture(tex, (void *)buf); #ifdef USE_PNG ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL); diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h deleted file mode 100644 index a5fdc00a47c17e6b5cbeba5d074554a66672cde7..0000000000000000000000000000000000000000 --- a/src/hardware/hw_drv.h +++ /dev/null @@ -1,140 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2024 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file hw_drv.h -/// \brief imports/exports for the 3D hardware low-level interface API - -#ifndef __HWR_DRV_H__ -#define __HWR_DRV_H__ - -// this must be here 19991024 by Kin -#include "../screen.h" -#include "hw_data.h" -#include "hw_defs.h" -#include "hw_md2.h" - -#include "hw_dll.h" - -// ========================================================================== -// STANDARD DLL EXPORTS -// ========================================================================== - -EXPORT boolean HWRAPI(Init) (void); -#ifndef HAVE_SDL -EXPORT void HWRAPI(Shutdown) (void); -#endif -EXPORT void HWRAPI(SetTexturePalette) (RGBA_t *ppal); -EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl); -EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color); -EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); -EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray); -EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky); -EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); -EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); -EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo); -EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo); -EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo); -EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data); -EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); -EXPORT void HWRAPI(ClearMipMapCache) (void); - -EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); - -//Hurdler: added for new development -EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); -EXPORT void HWRAPI(CreateModelVBOs) (model_t *model); -EXPORT void HWRAPI(SetTransform) (FTransform *ptransform); -EXPORT INT32 HWRAPI(GetTextureUsed) (void); - -EXPORT void HWRAPI(FlushScreenTextures) (void); -EXPORT void HWRAPI(DoScreenWipe) (int wipeStart, int wipeEnd, FSurfaceInfo *surf, FBITFIELD polyFlags); -EXPORT void HWRAPI(DrawScreenTexture) (int tex, FSurfaceInfo *surf, FBITFIELD polyflags); -EXPORT void HWRAPI(MakeScreenTexture) (int tex); -EXPORT void HWRAPI(DrawScreenFinalTexture) (int tex, int width, int height); - -#define SCREENVERTS 10 -EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); - -EXPORT boolean HWRAPI(InitShaders) (void); -EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage); -EXPORT boolean HWRAPI(CompileShader) (int slot); -EXPORT void HWRAPI(SetShader) (int slot); -EXPORT void HWRAPI(UnSetShader) (void); - -EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value); - -EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut); -EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable); -EXPORT void HWRAPI(UpdateLightTable)(UINT32 id, RGBA_t *hw_lighttable); -EXPORT void HWRAPI(ClearLightTables)(void); -EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette); - -// ========================================================================== -// HWR DRIVER OBJECT, FOR CLIENT PROGRAM -// ========================================================================== - -#if !defined (_CREATE_DLL_) - -struct hwdriver_s -{ - Init pfnInit; - SetTexturePalette pfnSetTexturePalette; - FinishUpdate pfnFinishUpdate; - Draw2DLine pfnDraw2DLine; - DrawPolygon pfnDrawPolygon; - DrawIndexedTriangles pfnDrawIndexedTriangles; - RenderSkyDome pfnRenderSkyDome; - SetBlend pfnSetBlend; - ClearBuffer pfnClearBuffer; - SetTexture pfnSetTexture; - UpdateTexture pfnUpdateTexture; - DeleteTexture pfnDeleteTexture; - ReadScreenTexture pfnReadScreenTexture; - GClipRect pfnGClipRect; - ClearMipMapCache pfnClearMipMapCache; - SetSpecialState pfnSetSpecialState; - DrawModel pfnDrawModel; - CreateModelVBOs pfnCreateModelVBOs; - SetTransform pfnSetTransform; - GetTextureUsed pfnGetTextureUsed; -#ifdef _WINDOWS - GetModeList pfnGetModeList; -#endif -#ifndef HAVE_SDL - Shutdown pfnShutdown; -#endif - PostImgRedraw pfnPostImgRedraw; - FlushScreenTextures pfnFlushScreenTextures; - DoScreenWipe pfnDoScreenWipe; - DrawScreenTexture pfnDrawScreenTexture; - MakeScreenTexture pfnMakeScreenTexture; - DrawScreenFinalTexture pfnDrawScreenFinalTexture; - - InitShaders pfnInitShaders; - LoadShader pfnLoadShader; - CompileShader pfnCompileShader; - SetShader pfnSetShader; - UnSetShader pfnUnSetShader; - - SetShaderInfo pfnSetShaderInfo; - - SetPaletteLookup pfnSetPaletteLookup; - CreateLightTable pfnCreateLightTable; - UpdateLightTable pfnUpdateLightTable; - ClearLightTables pfnClearLightTables; - SetScreenPalette pfnSetScreenPalette; -}; - -extern struct hwdriver_s hwdriver; - -#define HWD hwdriver - -#endif //not defined _CREATE_DLL_ - -#endif //__HWR_DRV_H__ diff --git a/src/hardware/hw_gpu.h b/src/hardware/hw_gpu.h new file mode 100644 index 0000000000000000000000000000000000000000..5dc393d2da376ebb6f350bca1f6941a5fee36b79 --- /dev/null +++ b/src/hardware/hw_gpu.h @@ -0,0 +1,70 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file hw_gpu.h +/// \brief GPU low-level interface API + +#ifndef __HWR_GPU_H__ +#define __HWR_GPU_H__ + +#include "../screen.h" + +#include "hw_data.h" +#include "hw_defs.h" +#include "hw_md2.h" + +boolean GL_Init(void); +void GL_SetPalette(RGBA_t *ppal); +void GL_FinishUpdate(INT32 waitvbl); +void GL_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color); +void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); +void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray); +void GL_RenderSkyDome(gl_sky_t *sky); +void GL_SetBlend(FBITFIELD PolyFlags); +void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); +void GL_SetTexture(GLMipmap_t *TexInfo); +void GL_UpdateTexture(GLMipmap_t *TexInfo); +void GL_DeleteTexture(GLMipmap_t *TexInfo); +void GL_ReadScreenTexture(int tex, UINT8 *dst_data); +void GL_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); +void GL_ClearMipMapCache(void); + +void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value); + +// Hurdler: added for new development +void GL_DrawModel(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); +void GL_CreateModelVBOs(model_t *model); +void GL_SetTransform(FTransform *ptransform); +INT32 GL_GetTextureUsed(void); + +void GL_FlushScreenTextures(void); +void GL_DoScreenWipe(int wipeStart, int wipeEnd, FSurfaceInfo *surf, FBITFIELD polyFlags); +void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags); +void GL_MakeScreenTexture(int tex); +void GL_DrawScreenFinalTexture(int tex, int width, int height); + +#define SCREENVERTS 10 +void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]); + +boolean GL_InitShaders(void); +void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage); +boolean GL_CompileShader(int slot); +void GL_SetShader(int slot); +void GL_UnSetShader(void); + +void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value); + +void GL_SetPaletteLookup(UINT8 *lut); +UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable); +void GL_UpdateLightTable(UINT32 id, RGBA_t *hw_lighttable); +void GL_ClearLightTables(void); +void GL_SetScreenPalette(RGBA_t *palette); + + +#endif //__HWR_GPU_H__ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index fb92d42e7413a34283847ea0ec69b7a27ca9087a..05a156ad4eec3e204547d5f30a5c36a374a59998 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -16,7 +16,7 @@ #ifdef HWRENDER #include "hw_glob.h" -#include "hw_drv.h" +#include "hw_gpu.h" #include "hw_batching.h" #include "hw_md2.h" #include "hw_clip.h" @@ -51,7 +51,6 @@ // ========================================================================== // the hardware driver object // ========================================================================== -struct hwdriver_s hwdriver; // ========================================================================== // PROTOS @@ -4165,7 +4164,7 @@ static void HWR_CreateDrawNodes(void) PS_START_TIMING(ps_hw_nodedrawtime); // Okay! Let's draw it all! Woo! - HWD.pfnSetTransform(&atransform); + GL_SetTransform(&atransform); for (i = 0; i < p; i++) { @@ -4220,7 +4219,7 @@ static void HWR_DrawSprites(void) { UINT32 i; boolean skipshadow = false; // skip shadow if it was drawn already for a linkdraw sprite encountered earlier in the list - HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_glmodellighting.value); + GL_SetSpecialState(HWD_SET_MODEL_LIGHTING, cv_glmodellighting.value); for (i = 0; i < gl_visspritecount; i++) { gl_vissprite_t *spr = gl_vsprorder[i]; @@ -4279,7 +4278,7 @@ static void HWR_DrawSprites(void) } } } - HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, 0); + GL_SetSpecialState(HWD_SET_MODEL_LIGHTING, 0); // At the end of sprite drawing, draw shapes of linkdraw sprites to z-buffer, so they // don't get drawn over by transparent surfaces. @@ -4289,7 +4288,7 @@ static void HWR_DrawSprites(void) // (Other states probably don't matter. Here I left them same as in LinkDrawHackFinish) // Without this workaround the rest of the draw calls in this frame (including UI, screen texture) // can get drawn using an incorrect glBlendFunc, resulting in a occasional black screen. - HWD.pfnSetBlend(PF_Translucent|PF_Occlude|PF_Masked); + GL_SetBlend(PF_Translucent|PF_Occlude|PF_Masked); } // -------------------------------------------------------------------------- @@ -5173,7 +5172,7 @@ static void HWR_DrawSkyBackground(player_t *player) if (HWR_IsWireframeMode()) return; - HWD.pfnSetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); + GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); HWR_GetTexture(texturetranslation[skytexture], false); @@ -5199,9 +5198,9 @@ static void HWR_DrawSkyBackground(player_t *player) } if (HWR_UseShader()) - HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_SKY)); - HWD.pfnSetTransform(&dometransform); - HWD.pfnRenderSkyDome(&gl_sky); + GL_SetShader(HWR_GetShaderFromTarget(SHADER_SKY)); + GL_SetTransform(&dometransform); + GL_RenderSkyDome(&gl_sky); } else { @@ -5281,8 +5280,8 @@ static void HWR_DrawSkyBackground(player_t *player) v[0].t = v[1].t -= ((float) angle / angleturn); } - HWD.pfnUnSetShader(); - HWD.pfnDrawPolygon(NULL, v, 4, 0); + GL_UnSetShader(); + GL_DrawPolygon(NULL, v, 4, 0); } } @@ -5299,16 +5298,16 @@ static inline void HWR_ClearView(void) /// \bug faB - enable depth mask, disable color mask - HWD.pfnGClipRect((INT32)viewwindowx, + GL_GClipRect((INT32)viewwindowx, (INT32)viewwindowy, (INT32)(viewwindowx + viewwidth), (INT32)(viewwindowy + viewheight), ZCLIP_PLANE); - HWD.pfnClearBuffer(false, true, 0); + GL_ClearBuffer(false, true, 0); //disable clip window - set to full size // rem by Hurdler - // HWD.pfnGClipRect(0, 0, vid.width, vid.height); + // GL_GClipRect(0, 0, vid.width, vid.height); } @@ -5317,7 +5316,7 @@ static inline void HWR_ClearView(void) // -----------------+ void HWR_SetViewSize(void) { - HWD.pfnFlushScreenTextures(); + GL_FlushScreenTextures(); } // Set view aiming, for the sky dome, the skybox, @@ -5349,7 +5348,7 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean // static void HWR_SetShaderState(void) { - HWD.pfnSetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); + GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } static void HWR_SetupView(player_t *player, INT32 viewnumber, float fpov, boolean skybox) @@ -5457,13 +5456,13 @@ static void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes - HWD.pfnSetTransform(&atransform); + GL_SetTransform(&atransform); // Reset the shader state. HWR_SetShaderState(); if (HWR_IsWireframeMode()) - HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 1); + GL_SetSpecialState(HWD_SET_WIREFRAME, 1); validcount++; @@ -5493,17 +5492,17 @@ static void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) } if (HWR_IsWireframeMode()) - HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 0); + GL_SetSpecialState(HWD_SET_WIREFRAME, 0); - HWD.pfnSetTransform(NULL); - HWD.pfnUnSetShader(); + GL_SetTransform(NULL); + GL_UnSetShader(); // Check for new console commands. NetUpdate(); // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane - HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); + GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); } // ========================================================================== @@ -5523,10 +5522,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) ClearColor.alpha = 1.0f; if (cv_glshaders.value) - HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. + GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. if (viewnumber == 0) // Only do it if it's the first screen being rendered - HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. + GL_ClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. PS_START_TIMING(ps_hw_skyboxtime); if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox @@ -5565,13 +5564,13 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes - HWD.pfnSetTransform(&atransform); + GL_SetTransform(&atransform); // Reset the shader state. HWR_SetShaderState(); if (HWR_IsWireframeMode()) - HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 1); + GL_SetSpecialState(HWD_SET_WIREFRAME, 1); ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; @@ -5615,10 +5614,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } if (HWR_IsWireframeMode()) - HWD.pfnSetSpecialState(HWD_SET_WIREFRAME, 0); + GL_SetSpecialState(HWD_SET_WIREFRAME, 0); - HWD.pfnSetTransform(NULL); - HWD.pfnUnSetShader(); + GL_SetTransform(NULL); + GL_UnSetShader(); HWR_DoPostProcessor(player); @@ -5627,7 +5626,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane - HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); + GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); } // Returns whether palette rendering is "actually enabled." @@ -5754,13 +5753,13 @@ consvar_t cv_glwireframe = CVAR_INIT ("gr_wireframe", "Off", "When combined with static void CV_glfiltermode_OnChange(void) { ONLY_IF_GL_LOADED - HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); + GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); } static void CV_glanisotropic_OnChange(void) { ONLY_IF_GL_LOADED - HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); + GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); } static void CV_glmodellighting_OnChange(void) @@ -5859,9 +5858,9 @@ void HWR_Startup(void) if (M_CheckParm("-msaa")) { if (M_CheckParm("-a2c")) - HWD.pfnSetSpecialState(HWD_SET_MSAA, 2); + GL_SetSpecialState(HWD_SET_MSAA, 2); else - HWD.pfnSetSpecialState(HWD_SET_MSAA, 1); + GL_SetSpecialState(HWD_SET_MSAA, 1); } } @@ -5874,8 +5873,8 @@ void HWR_Startup(void) void HWR_Switch(void) { // Set special states from CVARs - HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); - HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); + GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value); + GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value); // Load textures if (!gl_maptexturesloaded) @@ -5898,7 +5897,7 @@ void HWR_Shutdown(void) HWR_FreeExtraSubsectors(); HWR_FreePolyPool(); HWR_FreeMapTextures(); - HWD.pfnFlushScreenTextures(); + GL_FlushScreenTextures(); } void transform(float *cx, float *cy, float *cz) @@ -5989,14 +5988,14 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, INT32 HWR_GetTextureUsed(void) { - return HWD.pfnGetTextureUsed(); + return GL_GetTextureUsed(); } void HWR_DoPostProcessor(player_t *player) { postimg_t *type; - HWD.pfnUnSetShader(); + GL_UnSetShader(); if (splitscreen && player == &players[secondarydisplayplayer]) type = &postimgtype2; @@ -6025,12 +6024,12 @@ void HWR_DoPostProcessor(player_t *player) Surf.PolyColor.s.alpha = 0xc0; // match software mode - HWD.pfnDrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest); + GL_DrawPolygon(&Surf, v, 4, PF_Modulated|PF_Additive|PF_NoTexture|PF_NoDepthTest); } // Capture the screen for intermission and screen waving if(gamestate != GS_INTERMISSION) - HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); if (splitscreen) // Not supported in splitscreen - someone want to add support? return; @@ -6070,11 +6069,11 @@ void HWR_DoPostProcessor(player_t *player) v[x][y][1] = (y/((float)(SCREENVERTS-1.0f)/9.0f))-4.5f; } } - HWD.pfnPostImgRedraw(v); + GL_PostImgRedraw(v); // Capture the screen again for screen waving on the intermission if(gamestate != GS_INTERMISSION) - HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); } // Flipping of the screen isn't done here anymore } @@ -6082,18 +6081,18 @@ void HWR_DoPostProcessor(player_t *player) void HWR_StartScreenWipe(void) { //CONS_Debug(DBG_RENDER, "In HWR_StartScreenWipe()\n"); - HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); } void HWR_EndScreenWipe(void) { //CONS_Debug(DBG_RENDER, "In HWR_EndScreenWipe()\n"); - HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); } void HWR_DrawIntermissionBG(void) { - HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); } // @@ -6150,14 +6149,14 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) // polycolor alpha communicates fadein / fadeout to the shader and the backend surf.PolyColor.s.alpha = (wipestyleflags & WSF_FADEIN) ? 255 : 0; - HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_UI_TINTED_WIPE)); - HWD.pfnDoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END, + GL_SetShader(HWR_GetShaderFromTarget(SHADER_UI_TINTED_WIPE)); + GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END, &surf, polyflags); - HWD.pfnUnSetShader(); + GL_UnSetShader(); } else { - HWD.pfnDoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END, + GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END, NULL, 0); } } @@ -6165,13 +6164,13 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) void HWR_MakeScreenFinalTexture(void) { int tex = HWR_ShouldUsePaletteRendering() ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2; - HWD.pfnMakeScreenTexture(tex); + GL_MakeScreenTexture(tex); } void HWR_DrawScreenFinalTexture(int width, int height) { int tex = HWR_ShouldUsePaletteRendering() ? HWD_SCREENTEXTURE_GENERIC3 : HWD_SCREENTEXTURE_GENERIC2; - HWD.pfnDrawScreenFinalTexture(tex, width, height); + GL_DrawScreenFinalTexture(tex, width, height); } #endif // HWRENDER diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index dd36cae1395f0e2140464b67784f15a4f59b3b25..8dae00699de032fa5c2addd8aa1d2f8dfd4b6dc2 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -25,7 +25,7 @@ #include "../fastcmp.h" #ifdef HWRENDER -#include "hw_drv.h" +#include "hw_gpu.h" #include "hw_md2.h" #include "../d_main.h" #include "../r_bsp.h" @@ -425,7 +425,7 @@ static void md2_loadTexture(md2_t *model) } } } - HWD.pfnSetTexture(grPatch->mipmap); + GL_SetTexture(grPatch->mipmap); } // -----------------+ @@ -479,7 +479,7 @@ static void md2_loadBlendTexture(md2_t *model) grPatch->mipmap->width = (UINT16)w; grPatch->mipmap->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 + GL_SetTexture(grPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary Z_Free(filename); } @@ -1017,7 +1017,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski if (blendpatch == NULL || colormap == colormaps || colormap == NULL) { // Don't do any blending - HWD.pfnSetTexture(grPatch->mipmap); + GL_SetTexture(grPatch->mipmap); return; } @@ -1025,7 +1025,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski && (patch->width != blendpatch->width || patch->height != blendpatch->height)) { // Blend image exists, but it's bad. - HWD.pfnSetTexture(grPatch->mipmap); + GL_SetTexture(grPatch->mipmap); return; } @@ -1042,10 +1042,10 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski { M_Memcpy(grMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); HWR_CreateBlendedTexture(patch, blendpatch, grMipmap, skinnum, color); - HWD.pfnUpdateTexture(grMipmap); + GL_UpdateTexture(grMipmap); } else - HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture + GL_SetTexture(grMipmap); // found the colormap, set it to the correct texture Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); return; @@ -1071,7 +1071,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color); - HWD.pfnSetTexture(newMipmap); + GL_SetTexture(newMipmap); Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED); } @@ -1488,7 +1488,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // 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_t = md2->model->max_t; - HWD.pfnCreateModelVBOs(md2->model); + GL_CreateModelVBOs(md2->model); } else { @@ -1498,7 +1498,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } } - //HWD.pfnSetBlend(blend); // This seems to actually break translucency? + //GL_SetBlend(blend); // This seems to actually break translucency? //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 @@ -1674,7 +1674,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) p.mirror = atransform.mirror; if (HWR_UseShader()) - HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_MODEL)); + GL_SetShader(HWR_GetShaderFromTarget(SHADER_MODEL)); { float this_scale = FIXED_TO_FLOAT(interp.scale); @@ -1689,7 +1689,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) p.y += ox * gl_viewcos; p.z += oy; - HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf); + GL_DrawModel(md2->model, frame, durs, tics, nextFrame, &p, md2->scale * xs, md2->scale * ys, flip, hflip, &Surf); } } return true; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 7b0c8f66f33c0bcc579ce7335d800717f43cf33b..7d9c5c68e5434db3627cd287f33788904f723ed3 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -12,7 +12,7 @@ #ifdef HWRENDER #include "hw_glob.h" -#include "hw_drv.h" +#include "hw_gpu.h" #include "hw_shaders.h" #include "../z_zone.h" @@ -89,7 +89,7 @@ boolean HWR_InitShaders(void) { int i; - if (!HWD.pfnInitShaders()) + if (!GL_InitShaders()) return false; for (i = 0; i < NUMSHADERTARGETS; i++) @@ -369,16 +369,16 @@ static void HWR_CompileShader(int index) { char *preprocessed = HWR_PreprocessShader(vertex_source); if (!preprocessed) return; - HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX); + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX); } if (fragment_source) { char *preprocessed = HWR_PreprocessShader(fragment_source); if (!preprocessed) return; - HWD.pfnLoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT); + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT); } - gl_shaders[index].compiled = HWD.pfnCompileShader(index); + gl_shaders[index].compiled = GL_CompileShader(index); } // compile or recompile shaders diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 11dec6f90af3dd06cf458b6c5de4ffee01a60f84..37568bc13683ddb3a0215c7cf8463d72204d4124 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -711,7 +711,7 @@ void SetupGLFunc4(void) #endif } -EXPORT boolean HWRAPI(InitShaders) (void) +boolean GL_InitShaders (void) { #ifdef GL_SHADERS if (!pglUseProgram) @@ -732,7 +732,7 @@ EXPORT boolean HWRAPI(InitShaders) (void) #endif } -EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) +void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage) { #ifdef GL_SHADERS gl_shader_t *shader; @@ -763,7 +763,7 @@ EXPORT void HWRAPI(LoadShader) (int slot, char *code, hwdshaderstage_t stage) #endif } -EXPORT boolean HWRAPI(CompileShader) (int slot) +boolean GL_CompileShader(int slot) { #ifdef GL_SHADERS if (slot < 0 || slot >= HWR_MAXSHADERS) @@ -789,7 +789,7 @@ EXPORT boolean HWRAPI(CompileShader) (int slot) // Those are given to the uniforms. // -EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) +void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value) { #ifdef GL_SHADERS switch (info) @@ -806,12 +806,12 @@ EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value) #endif } -EXPORT void HWRAPI(SetShader) (int slot) +void GL_SetShader(int slot) { #ifdef GL_SHADERS if (slot == SHADER_NONE) { - UnSetShader(); + GL_UnSetShader(); return; } if (gl_allowshaders) @@ -840,7 +840,7 @@ EXPORT void HWRAPI(SetShader) (int slot) gl_shadersenabled = false; } -EXPORT void HWRAPI(UnSetShader) (void) +void GL_UnSetShader(void) { #ifdef GL_SHADERS if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed @@ -953,7 +953,7 @@ void SetModelView(GLint w, GLint h) // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) - FlushScreenTextures(); + GL_FlushScreenTextures(); screen_width = w; screen_height = h; @@ -1028,7 +1028,7 @@ void SetStates(void) // this set CurrentPolyFlags to the actual configuration CurrentPolyFlags = 0xffffffff; - SetBlend(0); + GL_SetBlend(0); tex_downloaded = 0; SetNoTexture(); @@ -1056,7 +1056,7 @@ void SetStates(void) // -----------------+ // DeleteTexture : Deletes a texture from the GPU and frees its data // -----------------+ -EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *pTexInfo) +void GL_DeleteTexture (GLMipmap_t *pTexInfo) { FTextureInfo *head = TexCacheHead; @@ -1154,7 +1154,7 @@ INT32 isExtAvailable(const char *extension, const GLubyte *start) // -----------------+ // Init : Initialise the OpenGL interface API // -----------------+ -EXPORT boolean HWRAPI(Init) (void) +boolean GL_Init (void) { return LoadGL(); } @@ -1163,7 +1163,7 @@ EXPORT boolean HWRAPI(Init) (void) // -----------------+ // ClearMipMapCache : Flush OpenGL textures from memory // -----------------+ -EXPORT void HWRAPI(ClearMipMapCache) (void) +void GL_ClearMipMapCache (void) { // GL_DBG_Printf ("HWR_Flush(exe)\n"); Flush(); @@ -1173,7 +1173,7 @@ EXPORT void HWRAPI(ClearMipMapCache) (void) // Writes screen texture tex into dst_data. // Pixel format is 24-bit RGB. Row order is top to bottom. // Dimensions are screen_width * screen_height. -EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data) +void GL_ReadScreenTexture(int tex, UINT8 *dst_data) { INT32 i; int dst_stride = screen_width * 3; // stride between rows of image data @@ -1186,11 +1186,11 @@ EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data) // and draw generic2 back after reading the framebuffer. // this hack is for some reason **much** faster than the simple solution of using glGetTexImage. if (tex != HWD_SCREENTEXTURE_GENERIC2) - DrawScreenTexture(tex, NULL, 0); + GL_DrawScreenTexture(tex, NULL, 0); pglPixelStorei(GL_PACK_ALIGNMENT, 1); pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, dst_data); if (tex != HWD_SCREENTEXTURE_GENERIC2) - DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); // Flip image upside down. // In other words, convert OpenGL's "bottom->top" row order into "top->bottom". for(i = 0; i < screen_height/2; i++) @@ -1205,10 +1205,26 @@ EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data) } +// -----------------+ +// SetPalette : Changes the current texture palette +// -----------------+ +void GL_SetPalette(RGBA_t *palette) +{ + INT32 i; + + for (i = 0; i < 256; i++) + { + myPaletteData[i].s = palette[i].s; + } + + Flush(); +} + + // -----------------+ // GClipRect : Defines the 2D hardware clipping window // -----------------+ -EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip) +void GL_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip) { // GL_DBG_Printf ("GClipRect(%d, %d, %d, %d)\n", minx, miny, maxx, maxy); @@ -1230,7 +1246,7 @@ EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, f // -----------------+ // ClearBuffer : Clear the color/alpha/depth buffer(s) // -----------------+ -EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, +void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat * ClearColor) { @@ -1254,7 +1270,7 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, ClearMask |= GL_DEPTH_BUFFER_BIT; } - SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude); + GL_SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude); pglClear(ClearMask); pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one @@ -1263,9 +1279,9 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, // -----------------+ -// HWRAPI Draw2DLine: Render a 2D line +// Draw2DLine: Render a 2D line // -----------------+ -EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, +void GL_Draw2DLine (F2DCoord * v1, F2DCoord * v2, RGBA_t Color) { @@ -1275,7 +1291,7 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, GLfloat angle; // BP: we should reflect the new state in our variable - //SetBlend(PF_Modulated|PF_NoTexture); + //GL_SetBlend(PF_Modulated|PF_NoTexture); pglDisable(GL_TEXTURE_2D); @@ -1394,7 +1410,7 @@ static void SetBlendMode(FBITFIELD flags) } } -EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) +void GL_SetBlend (FBITFIELD PolyFlags) { FBITFIELD Xor; Xor = CurrentPolyFlags^PolyFlags; @@ -1510,7 +1526,7 @@ static void AllocTextureBuffer(GLMipmap_t *pTexInfo) // -----------------+ // UpdateTexture : Updates texture data. // -----------------+ -EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) +void GL_UpdateTexture (GLMipmap_t *pTexInfo) { // Upload a texture GLuint num = pTexInfo->downloaded; @@ -1711,7 +1727,7 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo) // -----------------+ // SetTexture : The mipmap becomes the current texture source // -----------------+ -EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo) + void GL_SetTexture (GLMipmap_t *pTexInfo) { if (!pTexInfo) { @@ -1730,7 +1746,7 @@ EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo) { FTextureInfo *newTex = calloc(1, sizeof (*newTex)); - UpdateTexture(pTexInfo); + GL_UpdateTexture(pTexInfo); newTex->texture = pTexInfo; newTex->downloaded = (UINT32)pTexInfo->downloaded; @@ -1988,7 +2004,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD if ((PolyFlags & PF_Corona) && (oglflags & GLF_NOZBUFREAD)) PolyFlags &= ~(PF_NoDepthTest|PF_Corona); - SetBlend(PolyFlags); //TODO: inline (#pragma..) + GL_SetBlend(PolyFlags); //TODO: inline (#pragma..) if (pSurf) { @@ -2097,7 +2113,7 @@ static void PreparePolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FBITFIELD // -----------------+ // DrawPolygon : Render a polygon, set the texture, set render mode // -----------------+ -EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) +void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) { PreparePolygon(pSurf, pOutVerts, PolyFlags); @@ -2115,7 +2131,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI Clamp2D(GL_TEXTURE_WRAP_T); } -EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray) +void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray) { PreparePolygon(pSurf, pOutVerts, PolyFlags); @@ -2133,7 +2149,7 @@ static const boolean gl_ext_arb_vertex_buffer_object = true; #define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &sky->data[0].u) #define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &sky->data[0].r) -EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky) +void GL_RenderSkyDome(gl_sky_t *sky) { int i, j; @@ -2217,7 +2233,7 @@ EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky) pglDisableClientState(GL_COLOR_ARRAY); } -EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) + void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) { switch (IdState) { @@ -2460,7 +2476,7 @@ static void CreateModelVBOTiny(mesh_t *mesh, tinyframe_t *frame) pglBindBuffer(GL_ARRAY_BUFFER, 0); } -EXPORT void HWRAPI(CreateModelVBOs) (model_t *model) + void GL_CreateModelVBOs(model_t *model) { int i; for (i = 0; i < model->numMeshes; i++) @@ -2602,7 +2618,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float lt_downloaded = Surface->LightTableId; } - SetBlend(flags); + GL_SetBlend(flags); Shader_SetUniforms(Surface, &poly, &tint, &fade); pglEnable(GL_CULL_FACE); @@ -2788,9 +2804,9 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float } // -----------------+ -// HWRAPI DrawModel : Draw a model +// DrawModel : Draw a model // -----------------+ -EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) + void GL_DrawModel (model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) { DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); } @@ -2798,7 +2814,7 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, float duration, // -----------------+ // SetTransform : // -----------------+ -EXPORT void HWRAPI(SetTransform) (FTransform *stransform) + void GL_SetTransform (FTransform *stransform) { static boolean special_splitscreen; boolean shearing = false; @@ -2859,7 +2875,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) } -EXPORT INT32 HWRAPI(GetTextureUsed) (void) +INT32 GL_GetTextureUsed(void) { FTextureInfo *tmp = TexCacheHead; INT32 res = 0; @@ -2884,7 +2900,7 @@ EXPORT INT32 HWRAPI(GetTextureUsed) (void) return res; } -EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) +void GL_PostImgRedraw (float points[SCREENVERTS][SCREENVERTS][2]) { INT32 x, y; float float_x, float_y, float_nextx, float_nexty; @@ -2974,7 +2990,7 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) // Sryder: This needs to be called whenever the screen changes resolution in order to reset the screen textures to use // a new size -EXPORT void HWRAPI(FlushScreenTextures) (void) +void GL_FlushScreenTextures(void) { int i; pglDeleteTextures(NUMSCREENTEXTURES, screenTextures); @@ -2982,7 +2998,7 @@ EXPORT void HWRAPI(FlushScreenTextures) (void) screenTextures[i] = 0; } -EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) +void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) { float xfix, yfix; @@ -3030,7 +3046,7 @@ EXPORT void HWRAPI(DrawScreenTexture)(int tex, FSurfaceInfo *surf, FBITFIELD pol } // Do screen fades! -EXPORT void HWRAPI(DoScreenWipe)(int wipeStart, int wipeEnd, FSurfaceInfo *surf, +void GL_DoScreenWipe(int wipeStart, int wipeEnd, FSurfaceInfo *surf, FBITFIELD polyFlags) { float xfix, yfix; @@ -3082,7 +3098,7 @@ EXPORT void HWRAPI(DoScreenWipe)(int wipeStart, int wipeEnd, FSurfaceInfo *surf, pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - SetBlend(PF_Modulated|PF_NoDepthTest); + GL_SetBlend(PF_Modulated|PF_NoDepthTest); pglEnable(GL_TEXTURE_2D); pglBindTexture(GL_TEXTURE_2D, screenTextures[firstScreen]); @@ -3103,7 +3119,7 @@ EXPORT void HWRAPI(DoScreenWipe)(int wipeStart, int wipeEnd, FSurfaceInfo *surf, } else // Blend wipeEnd into screen with the fade mask { - SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); + GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); // Draw the end screen that fades in pglActiveTexture(GL_TEXTURE0); @@ -3137,7 +3153,7 @@ EXPORT void HWRAPI(DoScreenWipe)(int wipeStart, int wipeEnd, FSurfaceInfo *surf, } // Create a texture from the screen. -EXPORT void HWRAPI(MakeScreenTexture) (int tex) +void GL_MakeScreenTexture(int tex) { boolean firstTime = (screenTextures[tex] == 0); @@ -3164,7 +3180,7 @@ EXPORT void HWRAPI(MakeScreenTexture) (int tex) tex_downloaded = screenTextures[tex]; } -EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) +void GL_DrawScreenFinalTexture(int tex, int width, int height) { float xfix, yfix; float origaspect, newaspect; @@ -3222,8 +3238,8 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) clearColour.red = clearColour.green = clearColour.blue = 0; clearColour.alpha = 1; - ClearBuffer(true, false, &clearColour); - SetBlend(PF_NoDepthTest); + GL_ClearBuffer(true, false, &clearColour); + GL_SetBlend(PF_NoDepthTest); pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); pglColor4ubv(white); @@ -3235,7 +3251,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, int width, int height) tex_downloaded = screenTextures[tex]; } -EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut) + void GL_SetPaletteLookup(UINT8 *lut) { GLenum internalFormat; if (gl_version[0] == '1' || gl_version[0] == '2') @@ -3261,7 +3277,7 @@ EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut) pglActiveTexture(GL_TEXTURE0); } -EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable) + UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable) { LTListItem *item = malloc(sizeof(LTListItem)); if (!LightTablesTail) @@ -3286,7 +3302,7 @@ EXPORT UINT32 HWRAPI(CreateLightTable)(RGBA_t *hw_lighttable) return item->id; } -EXPORT void HWRAPI(UpdateLightTable)(UINT32 id, RGBA_t *hw_lighttable) + void GL_UpdateLightTable(UINT32 id, RGBA_t *hw_lighttable) { LTListItem *item = LightTablesHead; while (item && item->id != id) @@ -3305,7 +3321,7 @@ EXPORT void HWRAPI(UpdateLightTable)(UINT32 id, RGBA_t *hw_lighttable) } // Delete light table textures, ids given before become invalid and must not be used. -EXPORT void HWRAPI(ClearLightTables)(void) +void GL_ClearLightTables(void) { while (LightTablesHead) { @@ -3322,7 +3338,7 @@ EXPORT void HWRAPI(ClearLightTables)(void) } // This palette is used for the palette rendering postprocessing step. -EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette) + void GL_SetScreenPalette(RGBA_t *palette) { if (memcmp(screenPalette, palette, sizeof(screenPalette))) { diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 197f75ea8931735b3e10b80e68a6ae47a5a736f5..74560546f38c65fc0c67c12bc96a06c8d976637c 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -44,7 +44,8 @@ #define _CREATE_DLL_ // necessary for Unix AND Windows #include "../../doomdef.h" -#include "../hw_drv.h" +#include "../hw_gpu.h" +#include "../hw_dll.h" #include "../../z_zone.h" // ========================================================================== diff --git a/src/r_things.c b/src/r_things.c index cab3d2b302695afc83a0a249f55ab71813d053cd..55be384ce97ec80cc25568eb6eadfcd95ce64aa2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -40,7 +40,7 @@ #ifdef HWRENDER #include "hardware/hw_md2.h" #include "hardware/hw_glob.h" -#include "hardware/hw_drv.h" +#include "hardware/hw_gpu.h" #endif #define MINZ (FRACUNIT*4) diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index 2a25f33031adee58358a423e0251937995e5471c..7b5c7ca1266851314a0a281c0eab7fd83441b89b 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -310,7 +310,7 @@ <ClInclude Include="..\hardware\hw_data.h" /> <ClInclude Include="..\hardware\hw_defs.h" /> <ClInclude Include="..\hardware\hw_dll.h" /> - <ClInclude Include="..\hardware\hw_drv.h" /> + <ClInclude Include="..\hardware\hw_gpu.h" /> <ClInclude Include="..\hardware\hw_glob.h" /> <ClInclude Include="..\hardware\hw_light.h" /> <ClInclude Include="..\hardware\hw_main.h" /> diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index 8daaa7773f091d5dfbf6bac965b58160380bb50c..6caba352ba4a862cbc734d039c37716acdf424fa 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -231,7 +231,7 @@ <ClInclude Include="..\hardware\hw_dll.h"> <Filter>Hw_Hardware</Filter> </ClInclude> - <ClInclude Include="..\hardware\hw_drv.h"> + <ClInclude Include="..\hardware\hw_gpu.h"> <Filter>Hw_Hardware</Filter> </ClInclude> <ClInclude Include="..\hardware\hw_glob.h"> diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index f561266017dd9fcf20b467b3c5e9323be7f5dbe2..baea55a578ef7352837dbbda7bcedb6c25c6a079 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -44,7 +44,7 @@ #define _CREATE_DLL_ // necessary for Unix AND Windows #ifdef HWRENDER -#include "../hardware/hw_drv.h" +#include "../hardware/hw_gpu.h" #include "ogl_sdl.h" #ifdef STATIC_OPENGL #include "../hardware/r_opengl/r_opengl.h" @@ -73,82 +73,17 @@ void *hwSym(const char *funcName,void *handle) { void *funcPointer = NULL; -#ifdef HWRENDER - if (0 == strcmp("SetTexturePalette", funcName)) - funcPointer = &OglSdlSetPalette; - - GETFUNC(Init); - GETFUNC(Draw2DLine); - GETFUNC(DrawPolygon); - GETFUNC(DrawIndexedTriangles); - GETFUNC(RenderSkyDome); - GETFUNC(SetBlend); - GETFUNC(ClearBuffer); - GETFUNC(SetTexture); - GETFUNC(UpdateTexture); - GETFUNC(DeleteTexture); - GETFUNC(ReadScreenTexture); - GETFUNC(GClipRect); - GETFUNC(ClearMipMapCache); - GETFUNC(SetSpecialState); - GETFUNC(GetTextureUsed); - GETFUNC(DrawModel); - GETFUNC(CreateModelVBOs); - GETFUNC(SetTransform); - GETFUNC(PostImgRedraw); - GETFUNC(FlushScreenTextures); - GETFUNC(DoScreenWipe); - GETFUNC(DrawScreenTexture); - GETFUNC(MakeScreenTexture); - GETFUNC(DrawScreenFinalTexture); - - GETFUNC(InitShaders); - GETFUNC(LoadShader); - GETFUNC(CompileShader); - GETFUNC(SetShader); - GETFUNC(UnSetShader); - - GETFUNC(SetShaderInfo); - - GETFUNC(SetPaletteLookup); - GETFUNC(CreateLightTable); - GETFUNC(UpdateLightTable); - GETFUNC(ClearLightTables); - GETFUNC(SetScreenPalette); - -#else //HWRENDER - if (0 == strcmp("FinishUpdate", funcName)) - return funcPointer; //&FinishUpdate; -#endif //!HWRENDER -#ifdef STATIC3DS - GETFUNC(Startup); - GETFUNC(AddSfx); - GETFUNC(AddSource); - GETFUNC(StartSource); - GETFUNC(StopSource); - GETFUNC(GetHW3DSVersion); - GETFUNC(BeginFrameUpdate); - GETFUNC(EndFrameUpdate); - GETFUNC(IsPlaying); - GETFUNC(UpdateListener); - GETFUNC(UpdateSourceParms); - GETFUNC(SetGlobalSfxVolume); - GETFUNC(SetCone); - GETFUNC(Update3DSource); - GETFUNC(ReloadSource); - GETFUNC(KillSource); - GETFUNC(Shutdown); - GETFUNC(GetHW3DSTitle); -#endif + if (0) ; #ifdef NOLOADSO else funcPointer = handle; #else else if (handle) - funcPointer = SDL_LoadFunction(handle,funcName); + funcPointer = SDL_LoadFunction(handle, funcName); #endif if (!funcPointer) I_OutputMsg("hwSym for %s: %s\n", funcName, SDL_GetError()); + return funcPointer; } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index d315984ef8e3f492ade12a2321d065c0ccf07f3b..8364a33d82a499033f6465863fb4ad1f2bf7abb4 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -82,7 +82,7 @@ #ifdef HWRENDER #include "../hardware/hw_main.h" -#include "../hardware/hw_drv.h" +#include "../hardware/hw_gpu.h" #include "hwsym_sdl.h" #include "ogl_sdl.h" #endif @@ -1084,10 +1084,10 @@ void I_FinishUpdate(void) // Final postprocess step of palette rendering, after everything else has been drawn. if (HWR_ShouldUsePaletteRendering()) { - HWD.pfnMakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); - HWD.pfnSetShader(HWR_GetShaderFromTarget(SHADER_PALETTE_POSTPROCESS)); - HWD.pfnDrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); - HWD.pfnUnSetShader(); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); + GL_SetShader(HWR_GetShaderFromTarget(SHADER_PALETTE_POSTPROCESS)); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); + GL_UnSetShader(); } OglSdlFinishUpdate(cv_vidwait.value); } @@ -1490,47 +1490,7 @@ static void Impl_InitOpenGL(void) if (vid.glstate == VID_GL_LIBRARY_LOADED) return; - HWD.pfnInit = hwSym("Init",NULL); - HWD.pfnFinishUpdate = NULL; - HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL); - HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL); - HWD.pfnDrawIndexedTriangles = hwSym("DrawIndexedTriangles",NULL); - HWD.pfnRenderSkyDome = hwSym("RenderSkyDome",NULL); - HWD.pfnSetBlend = hwSym("SetBlend",NULL); - HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL); - HWD.pfnSetTexture = hwSym("SetTexture",NULL); - HWD.pfnUpdateTexture = hwSym("UpdateTexture",NULL); - HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL); - HWD.pfnReadScreenTexture= hwSym("ReadScreenTexture",NULL); - HWD.pfnGClipRect = hwSym("GClipRect",NULL); - HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); - HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); - HWD.pfnSetTexturePalette= hwSym("SetTexturePalette",NULL); - HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); - HWD.pfnDrawModel = hwSym("DrawModel",NULL); - HWD.pfnCreateModelVBOs = hwSym("CreateModelVBOs",NULL); - HWD.pfnSetTransform = hwSym("SetTransform",NULL); - HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); - HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); - HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); - HWD.pfnDrawScreenTexture= hwSym("DrawScreenTexture",NULL); - HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); - HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL); - - HWD.pfnInitShaders = hwSym("InitShaders",NULL); - HWD.pfnLoadShader = hwSym("LoadShader",NULL); - HWD.pfnCompileShader = hwSym("CompileShader",NULL); - HWD.pfnSetShader = hwSym("SetShader",NULL); - HWD.pfnUnSetShader = hwSym("UnSetShader",NULL); - - HWD.pfnSetShaderInfo = hwSym("SetShaderInfo",NULL); - - HWD.pfnSetPaletteLookup = hwSym("SetPaletteLookup",NULL); - HWD.pfnCreateLightTable = hwSym("CreateLightTable",NULL); - HWD.pfnClearLightTables = hwSym("ClearLightTables",NULL); - HWD.pfnSetScreenPalette = hwSym("SetScreenPalette",NULL); - - if (HWD.pfnInit()) + if (GL_Init()) vid.glstate = VID_GL_LIBRARY_LOADED; else { diff --git a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj index 40f580be12967abc4e049372810215e89005ce8f..a2fd1daad156a25ebaac0eb2cf3331ff53d5b61d 100644 --- a/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.pbproj/project.pbxproj @@ -1060,8 +1060,8 @@ 8417773A085A106C000C01D8 = { fileEncoding = 30; isa = PBXFileReference; - name = hw_drv.h; - path = ../../hardware/hw_drv.h; + name = hw_gpu.h; + path = ../../hardware/hw_gpu.h; refType = 2; }; 8417773C085A106C000C01D8 = { diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index 04f8ecc0aaea916da6795d9841caa8451bd3397c..7403b53bfc14609851285ff382f0de5f99196cbe 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -179,7 +179,7 @@ 1E44AE630B67CC2B00BAD059 /* hw3sound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw3sound.c; path = ../../hardware/hw3sound.c; sourceTree = SOURCE_ROOT; }; 1E44AE640B67CC2B00BAD059 /* hw_cache.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_cache.c; path = ../../hardware/hw_cache.c; sourceTree = SOURCE_ROOT; }; 1E44AE650B67CC2B00BAD059 /* hw_dll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_dll.h; path = ../../hardware/hw_dll.h; sourceTree = SOURCE_ROOT; }; - 1E44AE660B67CC2B00BAD059 /* hw_drv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_drv.h; path = ../../hardware/hw_drv.h; sourceTree = SOURCE_ROOT; }; + 1E44AE660B67CC2B00BAD059 /* hw_gpu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_gpu.h; path = ../../hardware/hw_gpu.h; sourceTree = SOURCE_ROOT; }; 1E44AE680B67CC2B00BAD059 /* hw_light.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_light.c; path = ../../hardware/hw_light.c; sourceTree = SOURCE_ROOT; }; 1E44AE690B67CC2B00BAD059 /* hw_light.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_light.h; path = ../../hardware/hw_light.h; sourceTree = SOURCE_ROOT; }; 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3sound.h; path = ../../hardware/hw3sound.h; sourceTree = SOURCE_ROOT; }; @@ -531,7 +531,7 @@ 1E44AE630B67CC2B00BAD059 /* hw3sound.c */, 1E44AE640B67CC2B00BAD059 /* hw_cache.c */, 1E44AE650B67CC2B00BAD059 /* hw_dll.h */, - 1E44AE660B67CC2B00BAD059 /* hw_drv.h */, + 1E44AE660B67CC2B00BAD059 /* hw_gpu.h */, 1E44AE680B67CC2B00BAD059 /* hw_light.c */, 1E44AE690B67CC2B00BAD059 /* hw_light.h */, 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */, diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index ea02279958ddac3e39c07caa8185ae8ae84880ba..23f2d365460bdcf9a1ab1519b4fd7fa390cd3071 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -189,25 +189,15 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(sdlw, sdlh); SDL_GL_SwapWindow(window); - GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); + GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE); // Sryder: We need to draw the final screen texture again into the other buffer in the original position so that // effects that want to take the old screen can do so after this // Generic2 has the screen image without palette rendering brightness adjustments. // Using that here will prevent brightness adjustments being applied twice. - DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); } -EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette) -{ - size_t palsize = (sizeof(RGBA_t) * 256); - // on a palette change, you have to reload all of the textures - if (memcmp(&myPaletteData, palette, palsize)) - { - memcpy(&myPaletteData, palette, palsize); - Flush(); - } -} #endif //HWRENDER #endif //SDL diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 87df5e5e6115334dd8705658d70f9f6e5b6706f8..7b47025e545982d9c3d26267ccae0a4e9efd95bc 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -26,8 +26,4 @@ void OglSdlFinishUpdate(boolean vidwait); extern SDL_Renderer *renderer; extern SDL_GLContext sdlglcontext; extern Uint16 realwidth; -extern Uint16 realheight; - -#ifdef _CREATE_DLL_ -EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette); -#endif +extern Uint16 realheight; \ No newline at end of file