Merge remote-tracking branch 'origin/master' into fix-linux-compile

This commit is contained in:
Rachael Alexanderson 2020-01-20 03:00:16 -05:00
commit d9563dae73
125 changed files with 1788 additions and 2608 deletions

View file

@ -35,7 +35,7 @@ private:
mpg123_handle *MPG123; mpg123_handle *MPG123;
bool Done; bool Done;
MusicIO::FileInterface* Reader; MusicIO::FileInterface* Reader = nullptr;
static off_t file_lseek(void *handle, off_t offset, int whence); static off_t file_lseek(void *handle, off_t offset, int whence);
static ssize_t file_read(void *handle, void *buffer, size_t bytes); static ssize_t file_read(void *handle, void *buffer, size_t bytes);

View file

@ -31,7 +31,7 @@ private:
SNDFILE *SndFile; SNDFILE *SndFile;
SF_INFO SndInfo; SF_INFO SndInfo;
MusicIO::FileInterface* Reader; MusicIO::FileInterface* Reader = nullptr;
static sf_count_t file_get_filelen(void *user_data); static sf_count_t file_get_filelen(void *user_data);
static sf_count_t file_seek(sf_count_t offset, int whence, void *user_data); static sf_count_t file_seek(sf_count_t offset, int whence, void *user_data);
static sf_count_t file_read(void *ptr, sf_count_t count, void *user_data); static sf_count_t file_read(void *ptr, sf_count_t count, void *user_data);

View file

@ -832,6 +832,7 @@ set (PCH_SOURCES
common/rendering/gl/system/gl_debug.cpp common/rendering/gl/system/gl_debug.cpp
common/rendering/gl/system/gl_framebuffer.cpp common/rendering/gl/system/gl_framebuffer.cpp
common/rendering/gl_load/gl_interface.cpp common/rendering/gl_load/gl_interface.cpp
common/rendering/hwrenderer/data/flatvertices.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
common/rendering/hwrenderer/utility/hw_shaderpatcher.cpp common/rendering/hwrenderer/utility/hw_shaderpatcher.cpp
@ -984,7 +985,7 @@ if( APPLE )
set_target_properties(${PROJECT_NAME} PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FRAMEWORKS}" LINK_FLAGS "${LINK_FRAMEWORKS}"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/${PROJECT_NAME}-info.plist" ) MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platform/posix/osx/${PROJECT_NAME}-info.plist" )
# Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen() # Dymanic libraries like libvulkan.dylib or libMoltenVK.dylib will be loaded by dlopen()
# if placed in the directory with the main executable # if placed in the directory with the main executable

View file

@ -3235,7 +3235,7 @@ void actKillDude(int nKillerSprite, spritetype *pSprite, DAMAGE_TYPE damageType,
gPlayer[p].fraggerId = -1; gPlayer[p].fraggerId = -1;
} }
if (pSprite->type != kDudeCultistBeast) if (pSprite->type != kDudeCultistBeast)
trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nKillerSprite); trTriggerSprite(pSprite->index, pXSprite, kCmdOff);
pSprite->flags |= 7; pSprite->flags |= 7;
if (VanillaMode()) { if (VanillaMode()) {
@ -3747,7 +3747,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in
break; break;
} }
trTriggerSprite(pSprite->index, pXSprite, kCmdOff, nSource); trTriggerSprite(pSprite->index, pXSprite, kCmdOff);
switch (pSprite->type) { switch (pSprite->type) {
case kThingObjectGib: case kThingObjectGib:
@ -4501,7 +4501,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
if (spriRangeIsFine(nHSprite) && xspriRangeIsFine(sprite[nHSprite].extra)) { if (spriRangeIsFine(nHSprite) && xspriRangeIsFine(sprite[nHSprite].extra)) {
XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra]; XSPRITE* pXHSprite = &xsprite[sprite[nHSprite].extra];
if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite))) if (pXHSprite->Touch && !pXHSprite->isTriggered && (!pXHSprite->DudeLockout || IsPlayerSprite(pSprite)))
trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch, nSprite); trTriggerSprite(nHSprite, pXHSprite, kCmdSpriteTouch);
} }
// Touch walls // Touch walls
@ -4511,7 +4511,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite)
if (wallRangeIsFine(nHWall) && xwallRangeIsFine(wall[nHWall].extra)) { if (wallRangeIsFine(nHWall) && xwallRangeIsFine(wall[nHWall].extra)) {
XWALL* pXHWall = &xwall[wall[nHWall].extra]; XWALL* pXHWall = &xwall[wall[nHWall].extra];
if (pXHWall->triggerTouch && !pXHWall->isTriggered && (!pXHWall->dudeLockout || IsPlayerSprite(pSprite))) if (pXHWall->triggerTouch && !pXHWall->isTriggered && (!pXHWall->dudeLockout || IsPlayerSprite(pSprite)))
trTriggerWall(nHWall, pXHWall, kCmdWallTouch, nSprite); trTriggerWall(nHWall, pXHWall, kCmdWallTouch);
} }
} }
@ -4798,10 +4798,10 @@ void MoveDude(spritetype *pSprite)
} }
if (!gModernMap && pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered) if (!gModernMap && pHitXSprite && pHitXSprite->Touch && !pHitXSprite->state && !pHitXSprite->isTriggered)
trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch, nSprite); trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpriteTouch);
if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXSprite && pHitXSprite->Push && !pHitXSprite->key && !pHitXSprite->DudeLockout && !pHitXSprite->state && !pHitXSprite->busy && !pPlayer)
trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush, nSprite); trTriggerSprite(nHitSprite, pHitXSprite, kCmdSpritePush);
break; break;
} }
@ -4813,7 +4813,7 @@ void MoveDude(spritetype *pSprite)
if (pHitWall->extra > 0) if (pHitWall->extra > 0)
pHitXWall = &xwall[pHitWall->extra]; pHitXWall = &xwall[pHitWall->extra];
if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXWall && pHitXWall->triggerPush && !pHitXWall->key && !pHitXWall->dudeLockout && !pHitXWall->state && !pHitXWall->busy && !pPlayer)
trTriggerWall(nHitWall, pHitXWall, kCmdWallPush, nSprite); trTriggerWall(nHitWall, pHitXWall, kCmdWallPush);
if (pHitWall->nextsector != -1) if (pHitWall->nextsector != -1)
{ {
sectortype *pHitSector = &sector[pHitWall->nextsector]; sectortype *pHitSector = &sector[pHitWall->nextsector];
@ -4821,7 +4821,7 @@ void MoveDude(spritetype *pSprite)
if (pHitSector->extra > 0) if (pHitSector->extra > 0)
pHitXSector = &xsector[pHitSector->extra]; pHitXSector = &xsector[pHitSector->extra];
if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer) if (pDudeInfo->lockOut && pHitXSector && pHitXSector->Wallpush && !pHitXSector->Key && !pHitXSector->dudeLockout && !pHitXSector->state && !pHitXSector->busy && !pPlayer)
trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush, nSprite); trTriggerSector(pHitWall->nextsector, pHitXSector, kCmdSectorPush);
if (top < pHitSector->ceilingz || bottom > pHitSector->floorz) if (top < pHitSector->ceilingz || bottom > pHitSector->floorz)
{ {
// ??? // ???
@ -4847,7 +4847,7 @@ void MoveDude(spritetype *pSprite)
else else
pXSector = NULL; pXSector = NULL;
if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout)) if (pXSector && pXSector->Exit && (pPlayer || !pXSector->dudeLockout))
trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit, nSprite); trTriggerSector(pSprite->sectnum, pXSector, kCmdSectorExit);
ChangeSpriteSect(nSprite, nSector); ChangeSpriteSect(nSprite, nSector);
nXSector = sector[nSector].extra; nXSector = sector[nSector].extra;
@ -4856,7 +4856,7 @@ void MoveDude(spritetype *pSprite)
if (sector[nSector].type == kSectorTeleport) if (sector[nSector].type == kSectorTeleport)
pXSector->data = pPlayer ? nSprite : -1; pXSector->data = pPlayer ? nSprite : -1;
trTriggerSector(nSector, pXSector, kCmdSectorEnter, nSprite); trTriggerSector(nSector, pXSector, kCmdSectorEnter);
} }
nSector = pSprite->sectnum; nSector = pSprite->sectnum;
@ -5359,7 +5359,7 @@ int MoveMissile(spritetype *pSprite)
XWALL *pXWall = &xwall[pWall->extra]; XWALL *pXWall = &xwall[pWall->extra];
if (pXWall->triggerVector) if (pXWall->triggerVector)
{ {
trTriggerWall(gHitInfo.hitwall, pXWall, kCmdWallImpact, nSprite); trTriggerWall(gHitInfo.hitwall, pXWall, kCmdWallImpact);
if (!(pWall->cstat&64)) if (!(pWall->cstat&64))
{ {
vdi = -1; vdi = -1;
@ -5428,7 +5428,7 @@ void actExplodeSprite(spritetype *pSprite)
return; return;
sfxKill3DSound(pSprite, -1, -1); sfxKill3DSound(pSprite, -1, -1);
evKill(pSprite->index, 3); evKill(pSprite->index, 3);
int nType = kExplosionStandard; int nType;
switch (pSprite->type) switch (pSprite->type)
{ {
case kMissileFireballNapam: case kMissileFireballNapam:
@ -5623,7 +5623,7 @@ void actProcessSprites(void)
if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue; if ((sprite[nAffected].flags & 32) || xsprite[sprite[nAffected].extra].health <= 0) continue;
else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) { else if (CheckProximity(&sprite[nAffected], x, y, z, sectnum, 96)) {
trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, nAffected); trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity);
break; break;
} }
} }
@ -5632,7 +5632,7 @@ void actProcessSprites(void)
for (int a = connecthead; a >= 0; a = connectpoint2[a]) { for (int a = connecthead; a >= 0; a = connectpoint2[a]) {
if (gPlayer[a].pXSprite->health > 0 && CheckProximity(gPlayer[a].pSprite, x, y, z, sectnum, 96)) { if (gPlayer[a].pXSprite->health > 0 && CheckProximity(gPlayer[a].pSprite, x, y, z, sectnum, 96)) {
trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity, gPlayer[a].pSprite->index); trTriggerSprite(index, pXProxSpr, kCmdSpriteProximity);
break; break;
} }
} }
@ -5657,7 +5657,7 @@ void actProcessSprites(void)
for (int a = connecthead; a >= 0; a = connectpoint2[a]) { for (int a = connecthead; a >= 0; a = connectpoint2[a]) {
spritetype* pPlaySprite = gPlayer[a].pSprite; spritetype* pPlaySprite = gPlayer[a].pSprite;
if (gPlayer[a].pXSprite->health > 0 && cansee(x, y, z, sectnum, pPlaySprite->x, pPlaySprite->y, pPlaySprite->z, pPlaySprite->sectnum)) { if (gPlayer[a].pXSprite->health > 0 && cansee(x, y, z, sectnum, pPlaySprite->x, pPlaySprite->y, pPlaySprite->z, pPlaySprite->sectnum)) {
trTriggerSprite(index, pXSightSpr, kCmdSpriteSight, pPlaySprite->index); trTriggerSprite(index, pXSightSpr, kCmdSpriteSight);
break; break;
} }
} }
@ -5803,7 +5803,7 @@ void actProcessSprites(void)
break; break;
} }
if (pSprite->owner == -1) actPropagateSpriteOwner(pSprite, pSprite2); if (pSprite->owner == -1) actPropagateSpriteOwner(pSprite, pSprite2);
trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity);
} }
} }
} }
@ -5879,7 +5879,7 @@ void actProcessSprites(void)
{ {
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE *pXSprite = &xsprite[nXSprite];
if (pXSprite->Impact) if (pXSprite->Impact)
trTriggerSprite(nSprite, pXSprite, kCmdOff, -1); trTriggerSprite(nSprite, pXSprite, kCmdOff);
switch (pSprite->type) { switch (pSprite->type) {
case kThingDripWater: case kThingDripWater:
case kThingDripBlood: case kThingDripBlood:
@ -5986,7 +5986,7 @@ void actProcessSprites(void)
if (nWall == -1) if (nWall == -1)
break; break;
XWALL *pXWall = &xwall[wall[nWall].extra]; XWALL *pXWall = &xwall[wall[nWall].extra];
trTriggerWall(nWall, pXWall, kCmdWallImpact, nSprite); trTriggerWall(nWall, pXWall, kCmdWallImpact);
} }
for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2]) for (int nSprite2 = headspritestat[kStatDude]; nSprite2 >= 0; nSprite2 = nextspritestat[nSprite2])
@ -6169,7 +6169,7 @@ void actProcessSprites(void)
pXIncarnation->triggerOff = false; pXIncarnation->triggerOff = false;
// trigger dude death before transform // trigger dude death before transform
trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); trTriggerSprite(nSprite, pXSprite, kCmdOff);
pSprite->type = pIncarnation->type; pSprite->type = pIncarnation->type;
pSprite->flags = pIncarnation->flags; pSprite->flags = pIncarnation->flags;
@ -6257,7 +6257,7 @@ void actProcessSprites(void)
} else { } else {
if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0; if (pXSprite->sysData1 == kGenDudeTransformStatus) pXSprite->sysData1 = 0;
// just trigger dude death // just trigger dude death
trTriggerSprite(nSprite, pXSprite, kCmdOff, pSprite->owner); trTriggerSprite(nSprite, pXSprite, kCmdOff);
} }
} }
} }
@ -6285,7 +6285,7 @@ void actProcessSprites(void)
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; XSPRITE *pXSprite2 = &xsprite[pSprite2->extra];
if ((unsigned int)pXSprite2->health > 0 && IsPlayerSprite(pSprite2)) { if ((unsigned int)pXSprite2->health > 0 && IsPlayerSprite(pSprite2)) {
if (CheckProximity(pSprite2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128)) if (CheckProximity(pSprite2, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128))
trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity, pSprite2->index); trTriggerSprite(nSprite, pXSprite, kCmdSpriteProximity);
} }
} }
} }
@ -6961,7 +6961,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
{ {
XWALL *pXWall = &xwall[nXWall]; XWALL *pXWall = &xwall[nXWall];
if (pXWall->triggerVector) if (pXWall->triggerVector)
trTriggerWall(nWall, pXWall, kCmdWallImpact, nShooter); trTriggerWall(nWall, pXWall, kCmdWallImpact);
} }
break; break;
} }
@ -6983,7 +6983,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
{ {
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE *pXSprite = &xsprite[nXSprite];
if (pXSprite->Vector) if (pXSprite->Vector)
trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact, nShooter); trTriggerSprite(nSprite, pXSprite, kCmdSpriteImpact);
} }
if (pSprite->statnum == kStatThing) if (pSprite->statnum == kStatThing)
{ {
@ -7857,8 +7857,8 @@ void debrisMove(int listIndex) {
changespritestat(nSprite, kStatThing); changespritestat(nSprite, kStatThing);
if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff, -1); if (pXDebris->state == 1) trTriggerSprite(pSprite->xvel, pXDebris, kCmdOff);
else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn, -1); else trTriggerSprite(pSprite->xvel, pXDebris, kCmdOn);
} }
} }

View file

@ -181,7 +181,7 @@ static void ThrowSeqCallback(int, int nXSprite)
if (v4) if (v4)
xsprite[pMissile->extra].Impact = 1; xsprite[pMissile->extra].Impact = 1;
else else
evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn, nSprite); evPost(pMissile->index, 3, 120*(1+Random(2)), kCmdOn);
} }
static void sub_68170(int, int nXSprite) static void sub_68170(int, int nXSprite)
@ -194,7 +194,7 @@ static void sub_68170(int, int nXSprite)
nMissile = kThingArmedTNTBundle; nMissile = kThingArmedTNTBundle;
sfxPlay3DSound(pSprite, 455, -1, 0); sfxPlay3DSound(pSprite, 455, -1, 0);
spritetype *pMissile = actFireThing(pSprite, 0, 0, gDudeSlope[nXSprite]-9460, nMissile, 0x133333); spritetype *pMissile = actFireThing(pSprite, 0, 0, gDudeSlope[nXSprite]-9460, nMissile, 0x133333);
evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn, nSprite); evPost(pMissile->index, 3, 120*(2+Random(2)), kCmdOn);
} }
static void sub_68230(int, int nXSprite) static void sub_68230(int, int nXSprite)

View file

@ -400,7 +400,7 @@ static void ThrowThing(int nXIndex, bool impact) {
if (impact == true && dist <= 7680) xsprite[pThing->extra].Impact = true; if (impact == true && dist <= 7680) xsprite[pThing->extra].Impact = true;
else { else {
xsprite[pThing->extra].Impact = false; xsprite[pThing->extra].Impact = false;
evPost(pThing->xvel, 3, 120 * Random(2) + 120, kCmdOn, pXSprite->reference); evPost(pThing->xvel, 3, 120 * Random(2) + 120, kCmdOn);
} }
} }
@ -1987,7 +1987,6 @@ bool genDudePrepare(spritetype* pSprite, int propId) {
pSprite->clipdist = ClipRange((pSprite->xrepeat + pSprite->yrepeat) >> 1, 4, 120); pSprite->clipdist = ClipRange((pSprite->xrepeat + pSprite->yrepeat) >> 1, 4, 120);
if (propId) break; if (propId) break;
break;
} }
} }

View file

@ -1223,7 +1223,6 @@ RESTART:
UpdateNetworkMenus(); UpdateNetworkMenus();
if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo) if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo)
gDemo.SetupPlayback(NULL); gDemo.SetupPlayback(NULL);
viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
gQuitGame = 0; gQuitGame = 0;
gRestartGame = 0; gRestartGame = 0;
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)

View file

@ -85,6 +85,7 @@ struct GameInterface : ::GameInterface
void faketimerhandler() override; void faketimerhandler() override;
int app_main() override; int app_main() override;
void UpdateScreenSize() override; void UpdateScreenSize() override;
bool GenerateSavePic() override;
void FreeGameData() override; void FreeGameData() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;

View file

@ -361,7 +361,7 @@ void CounterCheck(int nSector) // 12
return; return;
} else { } else {
//pXSector->waitTimeA = 0; //do not reset necessary objects counter to zero //pXSector->waitTimeA = 0; //do not reset necessary objects counter to zero
trTriggerSector(nSector, pXSector, kCmdOn, -1); trTriggerSector(nSector, pXSector, kCmdOn);
pXSector->locked = 1; //lock sector, so it can be opened again later pXSector->locked = 1; //lock sector, so it can be opened again later
} }
} }
@ -489,13 +489,13 @@ void returnFlagToBase(int nSprite) // 17
XSPRITE* pXOwner = &xsprite[pOwner->extra]; XSPRITE* pXOwner = &xsprite[pOwner->extra];
switch (pSprite->type) { switch (pSprite->type) {
case kItemFlagA: case kItemFlagA:
trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); trTriggerSprite(pOwner->index, pXOwner, kCmdOn);
sndStartSample(8003, 255, 2, 0); sndStartSample(8003, 255, 2, 0);
gBlueFlagDropped = false; gBlueFlagDropped = false;
viewSetMessage("Blue Flag returned to base."); viewSetMessage("Blue Flag returned to base.");
break; break;
case kItemFlagB: case kItemFlagB:
trTriggerSprite(pOwner->index, pXOwner, kCmdOn, pOwner->index); trTriggerSprite(pOwner->index, pXOwner, kCmdOn);
sndStartSample(8002, 255, 2, 0); sndStartSample(8002, 255, 2, 0);
gRedFlagDropped = false; gRedFlagDropped = false;
viewSetMessage("Red Flag returned to base."); viewSetMessage("Red Flag returned to base.");

View file

@ -351,10 +351,8 @@ char evGetSourceState(int nType, int nIndex)
return 0; return 0;
} }
void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy) void evSend(int nIndex, int nType, int rxId, COMMAND_ID command)
{ {
EVENT event; event.index = nIndex; event.type = nType; event.cmd = command; event.causedBy = causedBy;
switch (command) { switch (command) {
case kCmdState: case kCmdState:
command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff;
@ -366,6 +364,11 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy)
break; break;
} }
EVENT event;
event.index = nIndex;
event.type = nType;
event.cmd = command;
switch (rxId) { switch (rxId) {
case kChannelTextOver: case kChannelTextOver:
if (command >= kCmdNumberic) trTextOver(command - kCmdNumberic); if (command >= kCmdNumberic) trTextOver(command - kCmdNumberic);
@ -446,9 +449,6 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy)
if ((pPlayer = getPlayerById(i)) != NULL) if ((pPlayer = getPlayerById(i)) != NULL)
trMessageSprite(pPlayer->nSprite, event); trMessageSprite(pPlayer->nSprite, event);
} }
// send command on sprite which create the event sequence
} else if (rxId == kChannelEventCauser && spriRangeIsFine(event.causedBy)) {
trMessageSprite(event.causedBy, event);
} }
} }
@ -482,7 +482,7 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy)
} }
} }
void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy) { void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command) {
dassert(command != kCmdCallback); dassert(command != kCmdCallback);
if (command == kCmdState) command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff; if (command == kCmdState) command = evGetSourceState(nType, nIndex) ? kCmdOn : kCmdOff;
else if (command == kCmdNotState) command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn; else if (command == kCmdNotState) command = evGetSourceState(nType, nIndex) ? kCmdOff : kCmdOn;
@ -490,17 +490,15 @@ void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, shor
evn.index = nIndex; evn.index = nIndex;
evn.type = nType; evn.type = nType;
evn.cmd = command; evn.cmd = command;
evn.causedBy = causedBy;
eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn);
} }
void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy) { void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback) {
EVENT evn = {}; EVENT evn = {};
evn.index = nIndex; evn.index = nIndex;
evn.type = nType; evn.type = nType;
evn.cmd = kCmdCallback; evn.cmd = kCmdCallback;
evn.funcID = callback; evn.funcID = callback;
evn.causedBy = causedBy;
eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn);
} }

View file

@ -129,14 +129,13 @@ struct EVENT {
unsigned int type: 3; // type unsigned int type: 3; // type
unsigned int cmd: 8; // cmd unsigned int cmd: 8; // cmd
unsigned int funcID: 8; // callback unsigned int funcID: 8; // callback
signed int causedBy: 14; // by NoOne: spritenum of object which initiated this event (-1 == initiated by the game)
}; };
void evInit(void); void evInit(void);
char evGetSourceState(int nType, int nIndex); char evGetSourceState(int nType, int nIndex);
void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy); void evSend(int nIndex, int nType, int rxId, COMMAND_ID command);
void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command, short causedBy); void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command);
void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback, short causedBy = -1); void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID callback);
void evProcess(unsigned int nTime); void evProcess(unsigned int nTime);
void evKill(int a1, int a2); void evKill(int a1, int a2);
void evKill(int a1, int a2, CALLBACK_ID a3); void evKill(int a1, int a2, CALLBACK_ID a3);

View file

@ -210,7 +210,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
bool GameInterface::SaveGame(FSaveGameNode* node) bool GameInterface::SaveGame(FSaveGameNode* node)
{ {
OpenSaveGameForWrite(node->Filename);
LoadSave::hSFile = WriteSavegameChunk("snapshot.bld"); LoadSave::hSFile = WriteSavegameChunk("snapshot.bld");
try try
@ -231,7 +230,6 @@ bool GameInterface::SaveGame(FSaveGameNode* node)
Printf(TEXTCOLOR_RED "%s\n", err.what()); Printf(TEXTCOLOR_RED "%s\n", err.what());
return false; return false;
} }
G_WriteSaveHeader(node->SaveTitle);
LoadSave::hSFile = NULL; LoadSave::hSFile = NULL;
return FinishSavegameWrite(); return FinishSavegameWrite();

View file

@ -102,35 +102,6 @@ static int osdcmd_demo(osdcmdptr_t parm)
} }
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
{
if (parm->numparms != 3)
{
OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
return OSDCMD_SHOWHELP;
}
uint8_t const r = Batol(parm->parms[0]);
uint8_t const g = Batol(parm->parms[1]);
uint8_t const b = Batol(parm->parms[2]);
g_isAlterDefaultCrosshair = true;
viewSetCrosshairColor(r,g,b);
OSD_Printf("%s\n", parm->raw);
return OSDCMD_OK;
}
static int osdcmd_resetcrosshair(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
g_isAlterDefaultCrosshair = false;
viewResetCrosshairToDefault();
return OSDCMD_OK;
}
static int osdcmd_give(osdcmdptr_t parm) static int osdcmd_give(osdcmdptr_t parm)
{ {
if (numplayers != 1 || !gGameStarted || gMe->pXSprite->health == 0) if (numplayers != 1 || !gGameStarted || gMe->pXSprite->health == 0)
@ -236,8 +207,6 @@ int32_t registerosdcommands(void)
{ {
OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map); OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo); OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
OSD_RegisterFunction("crosshairreset", "crosshairreset: restores the original crosshair", osdcmd_resetcrosshair);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give); OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);

View file

@ -991,7 +991,7 @@ void playerResetPosture(PLAYER* pPlayer) {
void playerResetQavScene(PLAYER* pPlayer) { void playerResetQavScene(PLAYER* pPlayer) {
QAVSCENE* pQavScene = &gPlayerCtrl[pPlayer->nPlayer].qavScene; QAVSCENE* pQavScene = &gPlayerCtrl[pPlayer->nPlayer].qavScene;
pQavScene->index = pQavScene->causedBy = pPlayer->sceneQav = -1; pQavScene->index = pQavScene->dummy = pPlayer->sceneQav = -1;
pQavScene->qavResrc = NULL; pQavScene->qavResrc = NULL;
} }
@ -1062,7 +1062,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) { if ((pPlayer->hasFlag & 1) == 0 && pXItem->state) {
pPlayer->hasFlag |= 1; pPlayer->hasFlag |= 1;
pPlayer->used2[0] = pItem->index; pPlayer->used2[0] = pItem->index;
trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); trTriggerSprite(pItem->index, pXItem, kCmdOff);
sprintf(buffer, "%s stole Blue Flag", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s stole Blue Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8007, 255, 2, 0); sndStartSample(8007, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1074,7 +1074,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) { if ((pPlayer->hasFlag & 1) != 0 && !pXItem->state) {
pPlayer->hasFlag &= ~1; pPlayer->hasFlag &= ~1;
pPlayer->used2[0] = -1; pPlayer->used2[0] = -1;
trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); trTriggerSprite(pItem->index, pXItem, kCmdOn);
sprintf(buffer, "%s returned Blue Flag", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s returned Blue Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8003, 255, 2, 0); sndStartSample(8003, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1085,7 +1085,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
pPlayer->used2[1] = -1; pPlayer->used2[1] = -1;
dword_21EFB0[pPlayer->teamId] += 10; dword_21EFB0[pPlayer->teamId] += 10;
dword_21EFD0[pPlayer->teamId] += 240; dword_21EFD0[pPlayer->teamId] += 240;
evSend(0, 0, 81, kCmdOn, pPlayer->nSprite); evSend(0, 0, 81, kCmdOn);
sprintf(buffer, "%s captured Red Flag!", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s captured Red Flag!", gProfile[pPlayer->nPlayer].name);
sndStartSample(8001, 255, 2, 0); sndStartSample(8001, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1106,7 +1106,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) { if ((pPlayer->hasFlag & 2) == 0 && pXItem->state) {
pPlayer->hasFlag |= 2; pPlayer->hasFlag |= 2;
pPlayer->used2[1] = pItem->index; pPlayer->used2[1] = pItem->index;
trTriggerSprite(pItem->index, pXItem, kCmdOff, pPlayer->nSprite); trTriggerSprite(pItem->index, pXItem, kCmdOff);
sprintf(buffer, "%s stole Red Flag", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s stole Red Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8006, 255, 2, 0); sndStartSample(8006, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1118,7 +1118,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
{ {
pPlayer->hasFlag &= ~2; pPlayer->hasFlag &= ~2;
pPlayer->used2[1] = -1; pPlayer->used2[1] = -1;
trTriggerSprite(pItem->index, pXItem, kCmdOn, pPlayer->nSprite); trTriggerSprite(pItem->index, pXItem, kCmdOn);
sprintf(buffer, "%s returned Red Flag", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s returned Red Flag", gProfile[pPlayer->nPlayer].name);
sndStartSample(8002, 255, 2, 0); sndStartSample(8002, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1129,7 +1129,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
pPlayer->used2[0] = -1; pPlayer->used2[0] = -1;
dword_21EFB0[pPlayer->teamId] += 10; dword_21EFB0[pPlayer->teamId] += 10;
dword_21EFD0[pPlayer->teamId] += 240; dword_21EFD0[pPlayer->teamId] += 240;
evSend(0, 0, 80, kCmdOn, pPlayer->nSprite); evSend(0, 0, 80, kCmdOn);
sprintf(buffer, "%s captured Blue Flag!", gProfile[pPlayer->nPlayer].name); sprintf(buffer, "%s captured Blue Flag!", gProfile[pPlayer->nPlayer].name);
sndStartSample(8000, 255, 2, 0); sndStartSample(8000, 255, 2, 0);
viewSetMessage(buffer); viewSetMessage(buffer);
@ -1305,7 +1305,7 @@ void PickUp(PLAYER *pPlayer, spritetype *pSprite)
else if (pSprite->extra > 0) { else if (pSprite->extra > 0) {
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE *pXSprite = &xsprite[pSprite->extra];
if (pXSprite->Pickup) if (pXSprite->Pickup)
trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup, pPlayer->nSprite); trTriggerSprite(pSprite->index, pXSprite, kCmdSpritePickup);
} }
if (!actCheckRespawn(pSprite)) if (!actCheckRespawn(pSprite))
@ -1400,7 +1400,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
zvel[*a2] += mulscale16(z, t2); zvel[*a2] += mulscale16(z, t2);
} }
if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered) if (pXSprite->Push && !pXSprite->state && !pXSprite->isTriggered)
trTriggerSprite(*a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); trTriggerSprite(*a2, pXSprite, kCmdSpritePush);
} }
break; break;
case 0: case 0:
@ -1578,7 +1578,9 @@ void ProcessInput(PLAYER *pPlayer)
break; break;
default: default:
if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) { if (!pPlayer->cantJump && pInput->buttonFlags.jump && pXSprite->height == 0) {
if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0)
sfxPlay3DSound(pSprite, 700, 0, 0); sfxPlay3DSound(pSprite, 700, 0, 0);
if (packItemActive(pPlayer, 4)) zvel[nSprite] = pPosture->pwupJumpZ; //-0x175555; if (packItemActive(pPlayer, 4)) zvel[nSprite] = pPosture->pwupJumpZ; //-0x175555;
else zvel[nSprite] = pPosture->normalJumpZ; //-0xbaaaa; else zvel[nSprite] = pPosture->normalJumpZ; //-0xbaaaa;
pPlayer->cantJump = 1; pPlayer->cantJump = 1;
@ -1605,7 +1607,7 @@ void ProcessInput(PLAYER *pPlayer)
sndStartSample(3062, 255, 2, 0); sndStartSample(3062, 255, 2, 0);
} }
if (!key || pPlayer->hasKey[key]) if (!key || pPlayer->hasKey[key])
trTriggerSector(a2, pXSector, kCmdSpritePush, nSprite); trTriggerSector(a2, pXSector, kCmdSpritePush);
else if (pPlayer == gMe) else if (pPlayer == gMe)
{ {
viewSetMessage(GStrings("TXTB_KEY")); viewSetMessage(GStrings("TXTB_KEY"));
@ -1623,7 +1625,7 @@ void ProcessInput(PLAYER *pPlayer)
sndStartSample(3062, 255, 2, 0); sndStartSample(3062, 255, 2, 0);
} }
if (!key || pPlayer->hasKey[key]) if (!key || pPlayer->hasKey[key])
trTriggerWall(a2, pXWall, kCmdWallPush, pPlayer->nSprite); trTriggerWall(a2, pXWall, kCmdWallPush);
else if (pPlayer == gMe) else if (pPlayer == gMe)
{ {
viewSetMessage(GStrings("TXTB_KEY")); viewSetMessage(GStrings("TXTB_KEY"));
@ -1638,7 +1640,7 @@ void ProcessInput(PLAYER *pPlayer)
if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg) if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg)
trTextOver(pXSprite->lockMsg); trTextOver(pXSprite->lockMsg);
if (!key || pPlayer->hasKey[key]) if (!key || pPlayer->hasKey[key])
trTriggerSprite(a2, pXSprite, kCmdSpritePush, pPlayer->nSprite); trTriggerSprite(a2, pXSprite, kCmdSpritePush);
else if (pPlayer == gMe) else if (pPlayer == gMe)
{ {
viewSetMessage(GStrings("TXTB_KEY")); viewSetMessage(GStrings("TXTB_KEY"));
@ -2010,16 +2012,16 @@ void FragPlayer(PLAYER *pPlayer, int nSprite)
if (nTeam1 == 0) if (nTeam1 == 0)
{ {
if (nTeam1 != nTeam2) if (nTeam1 != nTeam2)
evSend(0, 0, 15, kCmdToggle, pKiller->nSprite); evSend(0, 0, 15, kCmdToggle);
else else
evSend(0, 0, 16, kCmdToggle, pKiller->nSprite); evSend(0, 0, 16, kCmdToggle);
} }
else else
{ {
if (nTeam1 == nTeam2) if (nTeam1 == nTeam2)
evSend(0, 0, 16, kCmdToggle, pKiller->nSprite); evSend(0, 0, 16, kCmdToggle);
else else
evSend(0, 0, 15, kCmdToggle, pKiller->nSprite); evSend(0, 0, 15, kCmdToggle);
} }
} }
} }
@ -2201,7 +2203,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in
{ {
powerupClear(pPlayer); powerupClear(pPlayer);
if (nXSector > 0 && xsector[nXSector].Exit) if (nXSector > 0 && xsector[nXSector].Exit)
trTriggerSector(pSprite->sectnum, &xsector[nXSector], kCmdSectorExit, nSprite); trTriggerSector(pSprite->sectnum, &xsector[nXSector], kCmdSectorExit);
pSprite->flags |= 7; pSprite->flags |= 7;
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
@ -2209,7 +2211,7 @@ int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, in
gPlayer[p].fraggerId = -1; gPlayer[p].fraggerId = -1;
} }
FragPlayer(pPlayer, nSource); FragPlayer(pPlayer, nSource);
trTriggerSprite(nSprite, pXSprite, kCmdOff, nSource); trTriggerSprite(nSprite, pXSprite, kCmdOff);
} }
dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL); dassert(gSysRes.Lookup(pDudeInfo->seqStartID + nDeathSeqID, "SEQ") != NULL);
seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer); seqSpawn(pDudeInfo->seqStartID+nDeathSeqID, 3, nXSprite, nKneelingPlayer);

View file

@ -202,8 +202,6 @@ struct PLAYER
POSTURE pPosture[kModeMax][kPostureMax]; POSTURE pPosture[kModeMax][kPostureMax];
}; };
struct PROFILE struct PROFILE
{ {
int nAutoAim; int nAutoAim;
@ -226,21 +224,15 @@ struct POWERUPINFO
int maxTime; int maxTime;
}; };
#define kQavSceneStackSize 16
// by NoOne: this one stores qavs anims that can be played by trigger // by NoOne: this one stores qavs anims that can be played by trigger
struct QAVSCENE struct QAVSCENE {
{
short index = -1; // index of sprite which triggered qav scene short index = -1; // index of sprite which triggered qav scene
QAV * qavResrc = NULL; QAV * qavResrc = NULL;
short causedBy = -1; short dummy = -1;
// TO-DO: Stack of animations which allows to pop and push (restoring previous animation instead of weapon once current animation is played)
}; };
// by NoOne: this one for controlling the player using triggers (movement speed, jumps and other stuff) // by NoOne: this one for controlling the player using triggers (movement speed, jumps and other stuff)
struct TRPLAYERCTRL struct TRPLAYERCTRL {
{
QAVSCENE qavScene; QAVSCENE qavScene;
}; };

File diff suppressed because it is too large Load diff

View file

@ -35,11 +35,11 @@ BEGIN_BLD_NS
#define kPlayerCtrlSigStart "<<<<TRPLAYERCTRL{" // save game TRPLAYERCTRL block start #define kPlayerCtrlSigStart "<<<<TRPLAYERCTRL{" // save game TRPLAYERCTRL block start
#define kPlayerCtrlSigEnd "}TRPLAYERCTRL>>>>" // save game TRPLAYERCTRL block end #define kPlayerCtrlSigEnd "}TRPLAYERCTRL>>>>" // save game TRPLAYERCTRL block end
void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command, short causedBy); void trTriggerSector(unsigned int nSector, XSECTOR *pXSector, int command);
void trMessageSector(unsigned int nSector, EVENT event); void trMessageSector(unsigned int nSector, EVENT event);
void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command, short causedBy); void trTriggerWall(unsigned int nWall, XWALL *pXWall, int command);
void trMessageWall(unsigned int nWall, EVENT event); void trMessageWall(unsigned int nWall, EVENT event);
void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command, short causedBy); void trTriggerSprite(unsigned int nSprite, XSPRITE *pXSprite, int command);
void trMessageSprite(unsigned int nSprite, EVENT event); void trMessageSprite(unsigned int nSprite, EVENT event);
void trProcessBusy(void); void trProcessBusy(void);
void trInit(void); void trInit(void);
@ -69,7 +69,7 @@ void freeTargets(int nSprite);
void freeAllTargets(XSPRITE* pXSource); void freeAllTargets(XSPRITE* pXSource);
bool affectedByTargetChg(XSPRITE* pXDude); bool affectedByTargetChg(XSPRITE* pXDude);
int getDataFieldOfObject(int objType, int objIndex, int dataIndex); int getDataFieldOfObject(int objType, int objIndex, int dataIndex);
bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value, int causedBy); bool setDataValueOfObject(int objType, int objIndex, int dataIndex, int value);
bool goalValueIsReached(XSPRITE* pXSprite); bool goalValueIsReached(XSPRITE* pXSprite);
bool getDudesForTargetChg(XSPRITE* pXSprite); bool getDudesForTargetChg(XSPRITE* pXSprite);
void stopWindOnSectors(XSPRITE* pXSource); void stopWindOnSectors(XSPRITE* pXSource);
@ -84,7 +84,7 @@ void TeleFrag(int nKiller, int nSector);
bool valueIsBetween(int val, int min, int max); bool valueIsBetween(int val, int min, int max);
void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer); void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer);
void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer, int causedBy); void trPlayerCtrlStartScene(XSPRITE* pXSource, PLAYER* pPlayer);
void trPlayerCtrlStopScene(XSPRITE* pXSource, PLAYER* pPlayer); void trPlayerCtrlStopScene(XSPRITE* pXSource, PLAYER* pPlayer);
// ------------------------------------------------------- // -------------------------------------------------------

View file

@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "menu/menu.h" #include "menu/menu.h"
#include "gstrings.h" #include "gstrings.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "v_video.h"
CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups") CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE|CVAR_FRONTEND_BLOOD, "enable/disable displaying the remaining seconds for power-ups")
@ -1856,7 +1857,6 @@ void viewResizeView(int size)
} }
videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1); videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1);
gGameMessageMgr.SetCoordinates(gViewX0S + 1, gViewY0S + 1); gGameMessageMgr.SetCoordinates(gViewX0S + 1, gViewY0S + 1);
viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
viewUpdatePages(); viewUpdatePages();
} }
@ -2337,7 +2337,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
break; break;
#endif #endif
// Can be overridden by def script // Can be overridden by def script
if (r_voxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1) if (r_voxels && gDetail >= 4 && videoGetRenderMode() != REND_POLYMER && tiletovox[pTSprite->picnum] == -1 && voxelIndex[pTSprite->picnum] != -1 && !(spriteext[nSprite].flags&SPREXT_NOTMD))
{ {
if ((pTSprite->flags&kHitagRespawn) == 0) if ((pTSprite->flags&kHitagRespawn) == 0)
{ {
@ -2362,7 +2362,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
nAnim--; nAnim--;
} }
if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER) if ((pTSprite->cstat&48) != 48 && r_voxels && videoGetRenderMode() != REND_POLYMER && !(spriteext[nSprite].flags&SPREXT_NOTMD))
{ {
int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner); int nAnimTile = pTSprite->picnum + animateoffs_replace(pTSprite->picnum, 32768+pTSprite->owner);
@ -2877,29 +2877,29 @@ void UpdateDacs(int nPalette, bool bNoTint)
{ {
case 0: case 0:
default: default:
tint->r = 255; tint->tint.r = 255;
tint->g = 255; tint->tint.g = 255;
tint->b = 255; tint->tint.b = 255;
break; break;
case 1: case 1:
tint->r = 132; tint->tint.r = 132;
tint->g = 164; tint->tint.g = 164;
tint->b = 255; tint->tint.b = 255;
break; break;
case 2: case 2:
tint->r = 255; tint->tint.r = 255;
tint->g = 126; tint->tint.g = 126;
tint->b = 105; tint->tint.b = 105;
break; break;
case 3: case 3:
tint->r = 162; tint->tint.r = 162;
tint->g = 186; tint->tint.g = 186;
tint->b = 15; tint->tint.b = 15;
break; break;
case 4: case 4:
tint->r = 255; tint->tint.r = 255;
tint->g = 255; tint->tint.g = 255;
tint->b = 255; tint->tint.b = 255;
break; break;
} }
if (!bNoTint) if (!bNoTint)
@ -3063,7 +3063,7 @@ int gLastPal = 0;
int32_t g_frameRate; int32_t g_frameRate;
void viewDrawScreen(void) void viewDrawScreen(bool sceneonly)
{ {
int nPalette = 0; int nPalette = 0;
static ClockTicks lastUpdate; static ClockTicks lastUpdate;
@ -3226,6 +3226,7 @@ void viewDrawScreen(void)
} }
else if (v4 && gNetPlayers > 1) else if (v4 && gNetPlayers > 1)
{ {
int tmp = ((int)totalclock / 240) % (gNetPlayers - 1); int tmp = ((int)totalclock / 240) % (gNetPlayers - 1);
int i = connecthead; int i = connecthead;
while (1) while (1)
@ -3245,6 +3246,7 @@ void viewDrawScreen(void)
} }
renderSetTarget(4079, 128, 128); renderSetTarget(4079, 128, 128);
renderSetAspect(65536, 78643); renderSetAspect(65536, 78643);
screen->BeginScene();
int vd8 = pOther->pSprite->x; int vd8 = pOther->pSprite->x;
int vd4 = pOther->pSprite->y; int vd4 = pOther->pSprite->y;
int vd0 = pOther->zView; int vd0 = pOther->zView;
@ -3307,6 +3309,7 @@ void viewDrawScreen(void)
memcpy(gotpic + 510, bakMirrorGotpic, 2); memcpy(gotpic + 510, bakMirrorGotpic, 2);
viewProcessSprites(vd8, vd4, vd0, v50, gInterpolate); viewProcessSprites(vd8, vd4, vd0, v50, gInterpolate);
renderDrawMasks(); renderDrawMasks();
screen->FinishScene();
renderRestoreTarget(); renderRestoreTarget();
} }
else else
@ -3347,6 +3350,7 @@ void viewDrawScreen(void)
} }
nSprite = nextspritestat[nSprite]; nSprite = nextspritestat[nSprite];
} }
screen->BeginScene();
g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip));
cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff; cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff;
int vfc, vf8; int vfc, vf8;
@ -3400,6 +3404,8 @@ void viewDrawScreen(void)
sub_557C4(cX, cY, gInterpolate); sub_557C4(cX, cY, gInterpolate);
renderDrawMasks(); renderDrawMasks();
gView->pSprite->cstat = bakCstat; gView->pSprite->cstat = bakCstat;
screen->FinishScene();
if (sceneonly) return;
if (v78 || bDelirium) if (v78 || bDelirium)
{ {
@ -3477,7 +3483,7 @@ void viewDrawScreen(void)
{ {
if (cl_crosshair) if (cl_crosshair)
{ {
rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, g_isAlterDefaultCrosshair ? CROSSHAIR_PAL : 0, 2, gViewX0, gViewY0, gViewX1, gViewY1); rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, 0, 2, gViewX0, gViewY0, gViewX1, gViewY1);
} }
cX = (v4c >> 8) + 160; cX = (v4c >> 8) + 160;
cY = (v48 >> 8) + 220 + (zDelta >> 7); cY = (v48 >> 8) + 220 + (zDelta >> 7);
@ -3587,6 +3593,14 @@ void viewDrawScreen(void)
UpdateDacs(nPalette); UpdateDacs(nPalette);
} }
bool GameInterface::GenerateSavePic()
{
viewDrawScreen(true);
return true;
}
int nLoadingScreenTile; int nLoadingScreenTile;
char pzLoadingScreenText1[256], pzLoadingScreenText2[256], pzLoadingScreenText3[256]; char pzLoadingScreenText1[256], pzLoadingScreenText2[256], pzLoadingScreenText3[256];
@ -3674,55 +3688,6 @@ void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const c
viewLoadingScreenUpdate(NULL, -1); viewLoadingScreenUpdate(NULL, -1);
} }
palette_t CrosshairColors = { 255, 255, 255, 0 };
bool g_isAlterDefaultCrosshair = false;
void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b)
{
if (!g_isAlterDefaultCrosshair)
return;
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
auto ptr = TileFiles.tileMakeWritable(kCrosshairTile);
if (!ptr) return;
int32_t ii = tilesiz[kCrosshairTile].x * tilesiz[kCrosshairTile].y;
dassert(ii > 0);
int32_t i = (videoGetRenderMode() == REND_CLASSIC)
? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b)
: paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
if (*ptr != 255)
*ptr = i;
ptr++;
} while (--ii);
paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL];
crosshairtint.r = CrosshairColors.r;
crosshairtint.g = CrosshairColors.g;
crosshairtint.b = CrosshairColors.b;
crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE;
#endif
tileInvalidate(kCrosshairTile, -1, -1);
}
void viewResetCrosshairToDefault(void)
{
paletteFreeLookupTable(CROSSHAIR_PAL);
tileLoad(kCrosshairTile);
}
#define COLOR_RED redcol #define COLOR_RED redcol
#define COLOR_WHITE whitecol #define COLOR_WHITE whitecol

View file

@ -63,7 +63,6 @@ enum INTERPOLATE_TYPE {
INTERPOLATE_TYPE_SHORT, INTERPOLATE_TYPE_SHORT,
}; };
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
#define kCrosshairTile 2319 #define kCrosshairTile 2319
#define kLoadScreen 2049 #define kLoadScreen 2049
#define kLoadScreenCRC -2051908571 #define kLoadScreenCRC -2051908571
@ -98,8 +97,6 @@ extern CGameMessageMgr gGameMessageMgr;
extern int gViewXCenter, gViewYCenter; extern int gViewXCenter, gViewYCenter;
extern int gViewX0, gViewY0, gViewX1, gViewY1; extern int gViewX0, gViewY0, gViewX1, gViewY1;
extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S; extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S;
extern palette_t CrosshairColors;
extern bool g_isAlterDefaultCrosshair;
extern int gLastPal; extern int gLastPal;
@ -144,14 +141,12 @@ void viewDisplayMessage(void);
void viewSetErrorMessage(const char *pMessage); void viewSetErrorMessage(const char *pMessage);
void DoLensEffect(void); void DoLensEffect(void);
void UpdateDacs(int nPalette, bool bNoTint = false); void UpdateDacs(int nPalette, bool bNoTint = false);
void viewDrawScreen(void); void viewDrawScreen(bool sceneonly = false);
void viewLoadingScreenWide(void); void viewLoadingScreenWide(void);
void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1); void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1);
void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3); void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3);
void viewUpdateDelirium(void); void viewUpdateDelirium(void);
void viewUpdateShake(void); void viewUpdateShake(void);
void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b);
void viewResetCrosshairToDefault(void);
void viewSetSystemMessage(const char* pMessage, ...); void viewSetSystemMessage(const char* pMessage, ...);
void viewPrecacheTiles(void); void viewPrecacheTiles(void);

View file

@ -1005,7 +1005,7 @@ void ThrowCan(int, PLAYER *pPlayer)
if (pSprite) if (pSprite)
{ {
sfxPlay3DSound(pSprite, 441, 0, 0); sfxPlay3DSound(pSprite, 441, 0, 0);
evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn);
int nXSprite = pSprite->extra; int nXSprite = pSprite->extra;
XSPRITE *pXSprite = &xsprite[nXSprite]; XSPRITE *pXSprite = &xsprite[nXSprite];
pXSprite->Impact = 1; pXSprite->Impact = 1;
@ -1020,7 +1020,7 @@ void DropCan(int, PLAYER *pPlayer)
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0);
if (pSprite) if (pSprite)
{ {
evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
} }
} }
@ -1029,7 +1029,7 @@ void ExplodeCan(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, -1, 441); sfxKill3DSound(pPlayer->pSprite, -1, 441);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0);
evPost(pSprite->index, 3, 0, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, 0, kCmdOn);
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
StartQAV(pPlayer, 15, -1); StartQAV(pPlayer, 15, -1);
pPlayer->curWeapon = 0; pPlayer->curWeapon = 0;
@ -1047,7 +1047,7 @@ void ThrowBundle(int, PLAYER *pPlayer)
if (pPlayer->fuseTime < 0) if (pPlayer->fuseTime < 0)
pXSprite->Impact = 1; pXSprite->Impact = 1;
else else
evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 5, 1); UseAmmo(pPlayer, 5, 1);
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
} }
@ -1056,7 +1056,7 @@ void DropBundle(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, 16, -1); sfxKill3DSound(pPlayer->pSprite, 16, -1);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0);
evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 5, 1); UseAmmo(pPlayer, 5, 1);
} }
@ -1064,7 +1064,7 @@ void ExplodeBundle(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, 16, -1); sfxKill3DSound(pPlayer->pSprite, 16, -1);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0);
evPost(pSprite->index, 3, 0, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, 0, kCmdOn);
UseAmmo(pPlayer, 5, 1); UseAmmo(pPlayer, 5, 1);
StartQAV(pPlayer, 24, -1, 0); StartQAV(pPlayer, 24, -1, 0);
pPlayer->curWeapon = 0; pPlayer->curWeapon = 0;
@ -1076,7 +1076,7 @@ void ThrowProx(int, PLAYER *pPlayer)
int nSpeed = mulscale16(pPlayer->throwPower, 0x177777)+0x66666; int nSpeed = mulscale16(pPlayer->throwPower, 0x177777)+0x66666;
sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed); spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed);
evPost(pSprite->index, 3, 240, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, 240, kCmdOn);
UseAmmo(pPlayer, 10, 1); UseAmmo(pPlayer, 10, 1);
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
} }
@ -1084,7 +1084,7 @@ void ThrowProx(int, PLAYER *pPlayer)
void DropProx(int, PLAYER *pPlayer) void DropProx(int, PLAYER *pPlayer)
{ {
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedProxBomb, 0); spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedProxBomb, 0);
evPost(pSprite->index, 3, 240, kCmdOn, pPlayer->nSprite); evPost(pSprite->index, 3, 240, kCmdOn);
UseAmmo(pPlayer, 10, 1); UseAmmo(pPlayer, 10, 1);
} }
@ -1111,7 +1111,7 @@ void DropRemote(int, PLAYER *pPlayer)
void FireRemote(int, PLAYER *pPlayer) void FireRemote(int, PLAYER *pPlayer)
{ {
evSend(0, 0, 90+(pPlayer->pSprite->type-kDudePlayer1), kCmdOn, pPlayer->nSprite); evSend(0, 0, 90+(pPlayer->pSprite->type-kDudePlayer1), kCmdOn);
} }
#define kMaxShotgunBarrels 4 #define kMaxShotgunBarrels 4
@ -1946,9 +1946,9 @@ void WeaponProcess(PLAYER *pPlayer) {
XSPRITE* pXSprite = &xsprite[sprite[nIndex].extra]; XSPRITE* pXSprite = &xsprite[sprite[nIndex].extra];
if (pXSprite->waitTime > 0 && --pXSprite->sysData1 <= 0) { if (pXSprite->waitTime > 0 && --pXSprite->sysData1 <= 0) {
if (pXSprite->txID > 0) if (pXSprite->txID > 0)
evSend(nIndex, 3, pXSprite->txID, (COMMAND_ID) pXSprite->command, pQavScene->causedBy); evSend(nIndex, 3, pXSprite->txID, (COMMAND_ID) pXSprite->command);
if (pXSprite->locked) trPlayerCtrlStopScene(pXSprite, pPlayer); if (pXSprite->locked) trPlayerCtrlStopScene(pXSprite, pPlayer);
else evPost(nIndex, 3, 0, (COMMAND_ID) (kCmdNumberic + 4), pQavScene->causedBy); else evPost(nIndex, 3, 0, (COMMAND_ID) (kCmdNumberic + 4));
} else { } else {
qavScenePlay(pPlayer); qavScenePlay(pPlayer);
pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= 4, 0); pPlayer->weaponTimer = ClipLow(pPlayer->weaponTimer -= 4, 0);

View file

@ -99,6 +99,7 @@ enum EMenuSounds : int;
struct GameInterface struct GameInterface
{ {
virtual ~GameInterface() {} virtual ~GameInterface() {}
virtual bool GenerateSavePic() { return false; }
virtual void faketimerhandler() {} // This is a remnant of older versions, but Blood backend has not updated yet. virtual void faketimerhandler() {} // This is a remnant of older versions, but Blood backend has not updated yet.
virtual int app_main() = 0; virtual int app_main() = 0;
virtual void UpdateScreenSize() {} virtual void UpdateScreenSize() {}

View file

@ -329,10 +329,11 @@ typedef struct {
uint32_t mdanimtims; uint32_t mdanimtims;
int16_t mdanimcur; int16_t mdanimcur;
int16_t angoff, pitch, roll; int16_t angoff, pitch, roll;
vec3_t offset; vec3_t pivot_offset, position_offset;
uint8_t flags; uint8_t flags;
uint8_t xpanning, ypanning; uint8_t xpanning, ypanning; // EDuke script hacks.
uint8_t filler; uint8_t filler;
uint32_t filler2;
float alpha; float alpha;
// NOTE: keep 'tspr' on an 8-byte boundary: // NOTE: keep 'tspr' on an 8-byte boundary:
tspriteptr_t tspr; tspriteptr_t tspr;
@ -1110,7 +1111,6 @@ enum {
TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR
}; };
extern int32_t glprojectionhacks;
extern int32_t gltexmaxsize; extern int32_t gltexmaxsize;
void gltexapplyprops (void); void gltexapplyprops (void);
void texcache_invalidate(void); void texcache_invalidate(void);

View file

@ -1,21 +1,16 @@
#ifndef HIGHTILE_PRIV_H #ifndef HIGHTILE_PRIV_H
#define HIGHTILE_PRIV_H #define HIGHTILE_PRIV_H
#include "palentry.h"
typedef struct { typedef struct {
polytintflags_t f; polytintflags_t f;
uint8_t r, g, b; PalEntry tint;
uint8_t sr, sg, sb; PalEntry shade;
} polytint_t; } polytint_t;
extern polytint_t hictinting[MAXPALOOKUPS]; extern polytint_t hictinting[MAXPALOOKUPS];
static inline void globaltinting_apply(float *color)
{
color[0] *= (float)globalr * (1.f/255.f);
color[1] *= (float)globalg * (1.f/255.f);
color[2] *= (float)globalb * (1.f/255.f);
}
// replacement flags // replacement flags
enum enum
@ -39,11 +34,8 @@ enum
HICTINT_BLEND_HARDLIGHT = 3<<6, HICTINT_BLEND_HARDLIGHT = 3<<6,
HICTINT_BLENDMASK = 64|128, HICTINT_BLENDMASK = 64|128,
HICTINT_ALWAYSUSEART = 256,
HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK, HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK,
HICTINT_IN_MEMORY = HICTINT_PRECOMPUTED | HICTINT_GRAYSCALE | HICTINT_INVERT,
HICTINT_MEMORY_COMBINATIONS = 1<<5,
}; };
#endif #endif

View file

@ -51,7 +51,7 @@ typedef struct {
} rgb24_t; } rgb24_t;
extern palette_t curpalette[256], curpalettefaded[256], palfadergb; extern palette_t curpalette[256], curpalettefaded[256], palfadergb;
extern char palfadedelta; extern unsigned char palfadedelta;
void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false); void paletteSetColorTable(int32_t id, uint8_t const *table, bool transient = false);
void paletteFreeColorTable(int32_t id); void paletteFreeColorTable(int32_t id);

View file

@ -10,6 +10,9 @@
#include "matrix.h" #include "matrix.h"
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
#include "textures.h"
#include "bitmap.h"
#include "v_draw.h"
#undef UNUSED #undef UNUSED
#define VPX_CODEC_DISABLE_COMPAT 1 #define VPX_CODEC_DISABLE_COMPAT 1
@ -17,6 +20,74 @@
#include <vpx/vp8dx.h> #include <vpx/vp8dx.h>
#include "animvpx.h" #include "animvpx.h"
class VPXTexture : public FTexture
{
public:
VPXTexture();
void SetFrame(const void* data, int width, int height);
virtual FBitmap GetBgraBitmap(const PalEntry* remap, int* trans) override;
protected:
const void* data;
public:
};
//==========================================================================
//
//
//
//==========================================================================
VPXTexture::VPXTexture() {}
void VPXTexture::SetFrame(const void *data_, int width, int height)
{
Size.x = width;
Size.y = height;
data = data_;
DeleteHardwareTextures();
}
//===========================================================================
//
// FPNGTexture::CopyPixels
//
//===========================================================================
FBitmap VPXTexture::GetBgraBitmap(const PalEntry* remap, int* trans)
{
FBitmap bmp;
bmp.Create(Size.x, Size.y);
auto spix = (uint8_t*)data;
auto dpix = bmp.GetPixels();
for (int i = 0; i < Size.x * Size.y; i++)
{
int p = i * 4;
float y = spix[p] * (1/255.f);
float u = spix[p+1] * (1 / 255.f) - 0.5f;
float v = spix[p+2] * (1 / 255.f) - 0.5f;
y = 1.1643f * (y - 0.0625f);
float r = y + 1.5958f * v;
float g = y - 0.39173f * u - 0.81290f * v;
float b = y + 2.017f * u;
dpix[p + 0] = (uint8_t)(clamp(b, 0, 1.f) * 255);
dpix[p + 1] = (uint8_t)(clamp(g, 0, 1.f) * 255);
dpix[p + 2] = (uint8_t)(clamp(r, 0, 1.f) * 255);
dpix[p + 3] = 255;
}
return bmp;
}
const char *animvpx_read_ivf_header_errmsg[] = { const char *animvpx_read_ivf_header_errmsg[] = {
"All OK", "All OK",
"couldn't read 32-byte IVF header", "couldn't read 32-byte IVF header",
@ -339,28 +410,13 @@ read_ivf_frame:
/////////////// DRAWING! /////////////// /////////////// DRAWING! ///////////////
static FHardwareTexture* texture;
static int sampler; static int sampler;
static int32_t texuploaded; static VPXTexture* vpxtex;
void animvpx_setup_glstate(int32_t animvpx_flags) void animvpx_setup_glstate(int32_t animvpx_flags)
{ {
static char logbuf[512];
GLInterface.SetVPXShader();
////////// GL STATE ////////// ////////// GL STATE //////////
vpxtex = new VPXTexture;
//Force fullscreen (glox1=-1 forces it to restore afterwards)
GLInterface.SetViewport(0,0,xdim,ydim); glox1 = -1;
GLInterface.EnableAlphaTest(false);
GLInterface.EnableDepthTest(false);
GLInterface.EnableBlend(false);
GLInterface.SetCull(Cull_None);
texture = GLInterface.NewTexture();
if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && hw_texfilter == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER || if ((animvpx_flags & CUTSCENE_TEXTUREFILTER && hw_texfilter == TEXFILTER_ON) || animvpx_flags & CUTSCENE_FORCEFILTER ||
(!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs (!(animvpx_flags & CUTSCENE_TEXTUREFILTER) && !(animvpx_flags & CUTSCENE_FORCENOFILTER))) // if no flags, then use filter for IVFs
@ -372,18 +428,14 @@ void animvpx_setup_glstate(int32_t animvpx_flags)
sampler = SamplerNoFilterClampXY; sampler = SamplerNoFilterClampXY;
} }
texuploaded = 0;
////////////////////
GLInterface.ClearScreen(0, true); GLInterface.ClearScreen(0, true);
} }
void animvpx_restore_glstate(void) void animvpx_restore_glstate(void)
{ {
GLInterface.SetPolymostShader(); delete vpxtex;
delete texture; vpxtex = nullptr;
texture = nullptr;
texuploaded = 0;
} }
int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect)
@ -396,13 +448,7 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect)
if (codec->pic == NULL) if (codec->pic == NULL)
return 2; // shouldn't happen return 2; // shouldn't happen
if (!texuploaded) vpxtex->SetFrame(codec->pic, codec->width, codec->height);
{
texture->CreateTexture(codec->width, codec->height, FHardwareTexture::TrueColor, false);
texuploaded = 1;
}
texture->LoadTexture(codec->pic);
GLInterface.BindTexture(0, texture, sampler);
float vid_wbyh = ((float)codec->width)/codec->height; float vid_wbyh = ((float)codec->width)/codec->height;
if (animvpx_aspect > 0) if (animvpx_aspect > 0)
@ -422,22 +468,9 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect)
} }
#endif #endif
auto data = GLInterface.AllocVertices(4); x *= screen->GetWidth() / 2;
auto vt = data.second; y *= screen->GetHeight() / 2;
DrawTexture(twod, vpxtex, screen->GetWidth() / 2 - int(x), screen->GetHeight()/2 - int(y), DTA_DestWidth, 2*int(x), DTA_DestHeight, 2*int(y), DTA_Masked, false, DTA_KeepRatio, true, TAG_DONE);
vt[0].SetTexCoord(0.0,1.0);
vt[0].SetVertex(-x, -y, 0.0);
vt[1].SetTexCoord(0.0,0.0);
vt[1].SetVertex(-x, y, 0.0);
vt[2].SetTexCoord(1.0,0.0);
vt[2].SetVertex(x, y, 0.0);
vt[3].SetTexCoord(1.0,1.0);
vt[3].SetVertex(x, -y, 0.0);
GLInterface.Draw(DT_TRIANGLE_FAN, data.first, 4);
t = timerGetTicks()-t; t = timerGetTicks()-t;
codec->sumtimes[2] += t; codec->sumtimes[2] += t;

View file

@ -6108,13 +6108,17 @@ draw_as_face_sprite:
} }
} }
x = tspr->x + spriteext[spritenum].position_offset.x;
y = tspr->y + spriteext[spritenum].position_offset.y;
z = tspr->z + spriteext[spritenum].position_offset.z;
i = (int32_t)tspr->ang+1536; i = (int32_t)tspr->ang+1536;
i += spriteext[spritenum].angoff; i += spriteext[spritenum].angoff;
const int32_t ceilingz = (sec->ceilingstat&3) == 0 ? sec->ceilingz : INT32_MIN; const int32_t ceilingz = (sec->ceilingstat&3) == 0 ? sec->ceilingz : INT32_MIN;
const int32_t floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX; const int32_t floorz = (sec->floorstat&3) == 0 ? sec->floorz : INT32_MAX;
classicDrawVoxel(tspr->x,tspr->y,tspr->z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum, classicDrawVoxel(x,y,z,i,daxrepeat,(int32_t)tspr->yrepeat,vtilenum,
tspr->shade,tspr->pal,lwall.Data(),swall.Data(),tspr->cstat,(tspr->cstat&48)!=48,floorz,ceilingz); tspr->shade,tspr->pal,lwall.Data(),swall.Data(),tspr->cstat,(tspr->cstat&48)!=48,floorz,ceilingz);
} }
@ -10783,5 +10787,3 @@ void renderSetRollAngle(int32_t rolla)
gtang = (float)rolla * (fPI * (1.f/1024.f)); gtang = (float)rolla * (fPI * (1.f/1024.f));
} }
#endif #endif

View file

@ -10,6 +10,7 @@
#include "baselayer.h" #include "baselayer.h"
#include "build.h" #include "build.h"
#include "tarray.h" #include "tarray.h"
#include "flatvertices.h"
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
static TArray<uint8_t> buffer; static TArray<uint8_t> buffer;
@ -75,13 +76,5 @@ void glsurface_blitBuffer()
bufferTexture->LoadTexture(buffer.Data()); bufferTexture->LoadTexture(buffer.Data());
GLInterface.BindTexture(0, bufferTexture, SamplerNoFilterClampXY); GLInterface.BindTexture(0, bufferTexture, SamplerNoFilterClampXY);
GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
auto data = GLInterface.AllocVertices(4);
auto vt = data.second;
vt[0].Set(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f); //top-left
vt[1].Set(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f); //bottom-left
vt[2].Set(1.0f, 1.0f, 0.0f, 1.0f, 0.0f); //top-right
vt[3].Set(1.0f, -1.0f, 0.0f, 1.0f, 1.0f); //bottom-right
GLInterface.Draw(DT_TRIANGLE_STRIP, data.first, 4);
} }

View file

@ -24,7 +24,7 @@ void hicinit(void)
for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100% for (i=0; i<MAXPALOOKUPS; i++) // all tints should be 100%
{ {
polytint_t & tint = hictinting[i]; polytint_t & tint = hictinting[i];
tint.r = tint.g = tint.b = 0xff; tint.tint = 0xffffff;
tint.f = 0; tint.f = 0;
} }
} }
@ -41,12 +41,12 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg,
if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return; if ((uint32_t)palnum >= (uint32_t)MAXPALOOKUPS) return;
polytint_t & tint = hictinting[palnum]; polytint_t & tint = hictinting[palnum];
tint.r = r; tint.tint.r = r;
tint.g = g; tint.tint.g = g;
tint.b = b; tint.tint.b = b;
tint.sr = sr; tint.shade.r = sr;
tint.sg = sg; tint.shade.g = sg;
tint.sb = sb; tint.shade.b = sb;
tint.f = effect; tint.f = effect;
} }

View file

@ -15,6 +15,8 @@
#include "palette.h" #include "palette.h"
#include "textures.h" #include "textures.h"
#include "bitmap.h" #include "bitmap.h"
#include "v_video.h"
#include "flatvertices.h"
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
static int32_t curextra=MAXTILES; static int32_t curextra=MAXTILES;
@ -1425,23 +1427,26 @@ int md3postload_polymer(md3model_t *m)
void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]) void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16])
{ {
float g;
float k0, k1, k2, k3, k4, k5, k6, k7; float k0, k1, k2, k3, k4, k5, k6, k7;
k0 = ((float)(tspr->x-globalposx))*f*(1.f/1024.f); k0 = ((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))*f*(1.f/1024.f);
k1 = ((float)(tspr->y-globalposy))*f*(1.f/1024.f); k1 = ((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy))*f*(1.f/1024.f);
f = gcosang2*gshang/gvrcorrection;
g = gsinang2*gshang/gvrcorrection;
k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f); k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f);
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f); k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f);
k2 = k0*(1-k4)+k1*k5; k2 = k0*(1-k4)+k1*k5;
k3 = k1*(1-k4)-k0*k5; k3 = k1*(1-k4)-k0*k5;
k6 = f*gstang - gsinang*gctang; k7 = g*gstang + gcosang*gctang; k6 = - gsinang;
mat[0] = k4*k6 + k5*k7; mat[4] = gchang*gstang; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7; k7 = gcosang;
k6 = f*gctang + gsinang*gstang; k7 = g*gctang - gcosang*gstang; mat[0] = k4*k6 + k5*k7; mat[4] = 0; mat[ 8] = k4*k7 - k5*k6; mat[12] = k2*k6 + k3*k7;
mat[1] = k4*k6 + k5*k7; mat[5] = gchang*gctang; mat[ 9] = k4*k7 - k5*k6; mat[13] = k2*k6 + k3*k7;
k6 = gcosang2*gchang; k7 = gsinang2*gchang; mat[1] = 0; mat[5] = 1; mat[ 9] = 0; mat[13] = 0;
mat[2] = k4*k6 + k5*k7; mat[6] =-gshang*gvrcorrection; mat[10] = k4*k7 - k5*k6; mat[14] = k2*k6 + k3*k7;
k6 = gcosang2;
k7 = gsinang2;
mat[2] = k4*k6 + k5*k7;
mat[6] =0;
mat[10] = k4*k7 - k5*k6;
mat[14] = k2*k6 + k3*k7;
mat[12] = (mat[12] + a0->y*mat[0]) + (a0->z*mat[4] + a0->x*mat[ 8]); mat[12] = (mat[12] + a0->y*mat[0]) + (a0->z*mat[4] + a0->x*mat[ 8]);
mat[13] = (mat[13] + a0->y*mat[1]) + (a0->z*mat[5] + a0->x*mat[ 9]); mat[13] = (mat[13] + a0->y*mat[1]) + (a0->z*mat[5] + a0->x*mat[ 9]);
@ -1454,8 +1459,8 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle,
int32_t i; int32_t i;
auto data = GLInterface.AllocVertices(s->numtris * 3); auto data = screen->mVertexData->AllocVertices(s->numtris * 3);
auto vt = data.second; auto vt = data.first;
for (i=s->numtris-1; i>=0; i--) for (i=s->numtris-1; i>=0; i--)
{ {
uint16_t tri = M ? M->indexes[i] : i; uint16_t tri = M ? M->indexes[i] : i;
@ -1470,7 +1475,7 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle,
vt->SetVertex(vertlist[k].x, vertlist[k].y); vt->SetVertex(vertlist[k].x, vertlist[k].y);
} }
} }
GLInterface.Draw(DT_TRIANGLES, data.first, s->numtris *3); GLInterface.Draw(DT_TRIANGLES, data.second, s->numtris *3);
#ifndef USE_GLEXT #ifndef USE_GLEXT
UNREFERENCED_PARAMETER(texunits); UNREFERENCED_PARAMETER(texunits);
@ -1521,7 +1526,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
a0.z = m->zadd * m->scale; a0.z = m->zadd * m->scale;
// Parkar: Moved up to be able to use k0 for the y-flipping code // Parkar: Moved up to be able to use k0 for the y-flipping code
k0 = (float)tspr->z; k0 = (float)tspr->z+spriteext[tspr->owner].position_offset.z;
if ((globalorientation&128) && !((globalorientation&48)==32)) if ((globalorientation&128) && !((globalorientation&48)==32))
k0 += (float)(sizyrep<<1); k0 += (float)(sizyrep<<1);
@ -1544,7 +1549,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
m0.z *= f; m1.z *= f; a0.z *= f; m0.z *= f; m1.z *= f; a0.z *= f;
// floor aligned // floor aligned
k1 = (float)tspr->y; k1 = (float)tspr->y+spriteext[tspr->owner].position_offset.y;
if ((globalorientation&48)==32) if ((globalorientation&48)==32)
{ {
m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z; m0.z = -m0.z; m1.z = -m1.z; a0.z = -a0.z;
@ -1557,7 +1562,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
// calculations below again, but are needed for the base offsets. // calculations below again, but are needed for the base offsets.
f = (65536.f*512.f)/(fxdimen*fviewingrange); f = (65536.f*512.f)/(fxdimen*fviewingrange);
g = 32.f/(fxdimen*gxyaspect); g = 32.f/(fxdimen*gxyaspect);
m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x-globalposx))* (1.f/1024.f) + a0.y)*f; m0.y *= f; m1.y *= f; a0.y = (((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))* (1.f/1024.f) + a0.y)*f;
m0.x *=-f; m1.x *=-f; a0.x = ((k1 -fglobalposy) * -(1.f/1024.f) + a0.x)*-f; m0.x *=-f; m1.x *=-f; a0.x = ((k1 -fglobalposy) * -(1.f/1024.f) + a0.x)*-f;
m0.z *= g; m1.z *= g; a0.z = ((k0 -fglobalposz) * -(1.f/16384.f) + a0.z)*g; m0.z *= g; m1.z *= g; a0.z = ((k0 -fglobalposz) * -(1.f/16384.f) + a0.z)*g;
@ -1591,8 +1596,6 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
// tinting // tinting
pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades;
auto h = hictinting[globalpal];
GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b));
pc[3] = (tspr->cstat&2) ? glblend[tspr->blend].def[!!(tspr->cstat&512)].alpha : 1.0f; pc[3] = (tspr->cstat&2) ? glblend[tspr->blend].def[!!(tspr->cstat&512)].alpha : 1.0f;
pc[3] *= 1.0f - sext->alpha; pc[3] *= 1.0f - sext->alpha;
@ -1625,14 +1628,14 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
float f = 1.f/(fxdimen * fviewingrange) * (256.f/(65536.f*128.f)) * (m0.x+m1.x); float f = 1.f/(fxdimen * fviewingrange) * (256.f/(65536.f*128.f)) * (m0.x+m1.x);
Bmemset(&a0, 0, sizeof(a0)); Bmemset(&a0, 0, sizeof(a0));
if (sext->offset.x) if (sext->pivot_offset.x)
a0.x = (float) sext->offset.x * f; a0.x = (float) sext->pivot_offset.x * f;
if (sext->offset.y) // Compare with SCREEN_FACTORS above if (sext->pivot_offset.y) // Compare with SCREEN_FACTORS above
a0.y = (float) sext->offset.y * f; a0.y = (float) sext->pivot_offset.y * f;
if ((sext->offset.z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above if ((sext->pivot_offset.z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above
a0.z = (float)sext->offset.z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.z+m1.z)); a0.z = (float)sext->pivot_offset.z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.z+m1.z));
k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f); k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f);
k1 = (float)sintable[sext->pitch&2047] * (1.f/16384.f); k1 = (float)sintable[sext->pitch&2047] * (1.f/16384.f);
@ -1640,11 +1643,9 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
k3 = (float)sintable[sext->roll&2047] * (1.f/16384.f); k3 = (float)sintable[sext->roll&2047] * (1.f/16384.f);
} }
float const xpanning = (float)sext->xpanning * (1.f/256.f);
float const ypanning = (float)sext->ypanning * (1.f/256.f);
int prevClamp = GLInterface.GetClamp(); int prevClamp = GLInterface.GetClamp();
GLInterface.SetClamp(0); GLInterface.SetClamp(0);
auto matrixindex = GLInterface.SetIdentityMatrix(Matrix_Model);
for (surfi=0; surfi<m->head.numsurfs; surfi++) for (surfi=0; surfi<m->head.numsurfs; surfi++)
{ {
@ -1699,7 +1700,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
//Let OpenGL (and perhaps hardware :) handle the matrix rotation //Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;
GLInterface.SetMatrix(Matrix_ModelView, mat); GLInterface.SetMatrix(Matrix_Model, mat);
// PLAG: End // PLAG: End
bool exact = false; bool exact = false;
@ -1722,10 +1723,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
} }
glow = hw_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0; glow = hw_glowmapping ? mdloadskin((md2model_t *) m, tile2model[Ptile2tile(tspr->picnum, lpal)].skinnum, GLOWPAL, surfi, nullptr) : 0;
} }
GLInterface.SetModelTexture(tex, globalpal, xpanning, ypanning, det, detscale, glow); GLInterface.SetModelTexture(tex, globalpal, det, detscale, glow);
VSMatrix texmat(0);
texmat.translate(xpanning, ypanning, 1.0f);
if (tspr->clipdist & TSPR_FLAGS_MDHACK) if (tspr->clipdist & TSPR_FLAGS_MDHACK)
{ {
@ -1792,9 +1790,9 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
GLInterface.SetCull(Cull_None); GLInterface.SetCull(Cull_None);
VSMatrix identity(0); VSMatrix identity(0);
GLInterface.SetIdentityMatrix(Matrix_ModelView); GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
GLInterface.SetClamp(prevClamp); GLInterface.SetClamp(prevClamp);
globalnoeffect=0; globalnoeffect=0;

View file

@ -46,9 +46,12 @@ int32_t engineLoadMHK(const char *filename)
T_NOANIM, T_NOANIM,
T_PITCH, T_PITCH,
T_ROLL, T_ROLL,
T_MDXOFF, T_MDPIVOTXOFF,
T_MDYOFF, T_MDPIVOTYOFF,
T_MDZOFF, T_MDPIVOTZOFF,
T_MDPOSITIONXOFF,
T_MDPOSITIONYOFF,
T_MDPOSITIONZOFF,
T_AWAY1, T_AWAY1,
T_AWAY2, T_AWAY2,
T_LIGHT, T_LIGHT,
@ -67,9 +70,21 @@ int32_t engineLoadMHK(const char *filename)
{ "nomdanim", T_NOANIM }, { "nomdanim", T_NOANIM },
{ "pitch", T_PITCH }, { "pitch", T_PITCH },
{ "roll", T_ROLL }, { "roll", T_ROLL },
{ "mdxoff", T_MDXOFF }, { "mdxoff", T_MDPIVOTXOFF },
{ "mdyoff", T_MDYOFF }, { "mdyoff", T_MDPIVOTYOFF },
{ "mdzoff", T_MDZOFF }, { "mdzoff", T_MDPIVOTZOFF },
{ "mdpivxoff", T_MDPIVOTXOFF },
{ "mdpivyoff", T_MDPIVOTYOFF },
{ "mdpivzoff", T_MDPIVOTZOFF },
{ "mdpivotxoff", T_MDPIVOTXOFF },
{ "mdpivotyoff", T_MDPIVOTYOFF },
{ "mdpivotzoff", T_MDPIVOTZOFF },
{ "mdposxoff", T_MDPOSITIONXOFF },
{ "mdposyoff", T_MDPOSITIONYOFF },
{ "mdposzoff", T_MDPOSITIONZOFF },
{ "mdpositionxoff", T_MDPOSITIONXOFF },
{ "mdpositionyoff", T_MDPOSITIONYOFF },
{ "mdpositionzoff", T_MDPOSITIONZOFF },
{ "away1", T_AWAY1 }, { "away1", T_AWAY1 },
{ "away2", T_AWAY2 }, { "away2", T_AWAY2 },
{ "light", T_LIGHT }, { "light", T_LIGHT },
@ -197,7 +212,7 @@ int32_t engineLoadMHK(const char *filename)
spriteext[whichsprite].roll = (int16_t) roll; spriteext[whichsprite].roll = (int16_t) roll;
} }
break; break;
case T_MDXOFF: // mdxoff <xx> case T_MDPIVOTXOFF: // mdpivxoff <xx>
{ {
int32_t i; int32_t i;
if (scriptfile_getnumber(script, &i)) break; if (scriptfile_getnumber(script, &i)) break;
@ -205,14 +220,14 @@ int32_t engineLoadMHK(const char *filename)
if (whichsprite < 0) if (whichsprite < 0)
{ {
// no sprite directive preceeding // no sprite directive preceeding
initprintf("Ignoring mdxoff directive because of absent/invalid sprite number on line %s:%d\n", initprintf("Ignoring mdxoff/mdpivxoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr)); script->filename, scriptfile_getlinum(script, cmdtokptr));
break; break;
} }
spriteext[whichsprite].offset.x = i; spriteext[whichsprite].pivot_offset.x = i;
} }
break; break;
case T_MDYOFF: // mdyoff <xx> case T_MDPIVOTYOFF: // mdpivyoff <xx>
{ {
int32_t i; int32_t i;
if (scriptfile_getnumber(script, &i)) break; if (scriptfile_getnumber(script, &i)) break;
@ -220,14 +235,14 @@ int32_t engineLoadMHK(const char *filename)
if (whichsprite < 0) if (whichsprite < 0)
{ {
// no sprite directive preceeding // no sprite directive preceeding
initprintf("Ignoring mdyoff directive because of absent/invalid sprite number on line %s:%d\n", initprintf("Ignoring mdyoff/mdpivyoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr)); script->filename, scriptfile_getlinum(script, cmdtokptr));
break; break;
} }
spriteext[whichsprite].offset.y = i; spriteext[whichsprite].pivot_offset.y = i;
} }
break; break;
case T_MDZOFF: // mdzoff <xx> case T_MDPIVOTZOFF: // mdpivzoff <xx>
{ {
int32_t i; int32_t i;
if (scriptfile_getnumber(script, &i)) break; if (scriptfile_getnumber(script, &i)) break;
@ -235,11 +250,56 @@ int32_t engineLoadMHK(const char *filename)
if (whichsprite < 0) if (whichsprite < 0)
{ {
// no sprite directive preceeding // no sprite directive preceeding
initprintf("Ignoring mdzoff directive because of absent/invalid sprite number on line %s:%d\n", initprintf("Ignoring mdzoff/mdpivzoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr)); script->filename, scriptfile_getlinum(script, cmdtokptr));
break; break;
} }
spriteext[whichsprite].offset.z = i; spriteext[whichsprite].pivot_offset.z = i;
}
break;
case T_MDPOSITIONXOFF: // mdposxoff <xx>
{
int32_t i;
if (scriptfile_getnumber(script, &i)) break;
if (whichsprite < 0)
{
// no sprite directive preceeding
initprintf("Ignoring mdposxoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr));
break;
}
spriteext[whichsprite].position_offset.x = i;
}
break;
case T_MDPOSITIONYOFF: // mdposyoff <xx>
{
int32_t i;
if (scriptfile_getnumber(script, &i)) break;
if (whichsprite < 0)
{
// no sprite directive preceeding
initprintf("Ignoring mdposyoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr));
break;
}
spriteext[whichsprite].position_offset.y = i;
}
break;
case T_MDPOSITIONZOFF: // mdposzoff <xx>
{
int32_t i;
if (scriptfile_getnumber(script, &i)) break;
if (whichsprite < 0)
{
// no sprite directive preceeding
initprintf("Ignoring mdposzoff directive because of absent/invalid sprite number on line %s:%d\n",
script->filename, scriptfile_getlinum(script, cmdtokptr));
break;
}
spriteext[whichsprite].position_offset.z = i;
} }
break; break;
case T_AWAY1: // away1 case T_AWAY1: // away1

View file

@ -27,7 +27,7 @@ uint32_t g_lastpalettesum = 0;
palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint
palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card) palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card)
palette_t palfadergb = { 0, 0, 0, 0 }; palette_t palfadergb = { 0, 0, 0, 0 };
char palfadedelta = 0; unsigned char palfadedelta = 0;
int32_t realmaxshade; int32_t realmaxshade;
float frealmaxshade; float frealmaxshade;

View file

@ -16,6 +16,8 @@ Ken Silverman's official web site: http://www.advsys.net/ken
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "gamecvars.h" #include "gamecvars.h"
#include "v_video.h"
#include "flatvertices.h"
CVAR(Bool, hw_detailmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, hw_detailmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, hw_glowmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Bool, hw_glowmapping, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -24,7 +26,6 @@ CVARD(Bool, hw_animsmoothing, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/di
CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering") CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering")
CVARD(Bool, hw_models, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering") CVARD(Bool, hw_models, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable model rendering")
CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky") CVARD(Bool, hw_parallaxskypanning, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable parallaxed floor/ceiling panning when drawing a parallaxing sky")
//{ "r_projectionhack", "enable/disable projection hack", (void*)&glprojectionhacks, CVAR_INT, 0, 2 }, What is this?
CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable shade interpolation") CVARD(Bool, hw_shadeinterpolate, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable shade interpolation")
CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading") CVARD(Float, hw_shadescale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "multiplier for shading")
CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering") CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable indexed color texture rendering")
@ -100,8 +101,9 @@ static float ghorizcorrect;
double gxyaspect; double gxyaspect;
float gyxscale, ghalfx, grhalfxdown10, grhalfxdown10x, ghalfy; float gyxscale, ghalfx, grhalfxdown10, grhalfxdown10x, ghalfy;
float gcosang, gsinang, gcosang2, gsinang2; float gcosang, gsinang, gcosang2, gsinang2;
float gchang, gshang, gctang, gstang;
float gtang = 0.f; float gtang = 0.f;
float gchang = 0, gshang = 0, gctang = 0, gstang = 0;
float gvrcorrection = 1.f; float gvrcorrection = 1.f;
static vec3d_t xtex, ytex, otex, xtex2, ytex2, otex2; static vec3d_t xtex, ytex, otex, xtex2, ytex2, otex2;
@ -117,7 +119,6 @@ static int32_t drawpoly_srepeat = 0, drawpoly_trepeat = 0;
static int32_t lastglpolygonmode = 0; //FUK static int32_t lastglpolygonmode = 0; //FUK
int32_t glprojectionhacks = 2;
static FHardwareTexture *polymosttext = 0; static FHardwareTexture *polymosttext = 0;
int32_t glrendmode = REND_POLYMOST; int32_t glrendmode = REND_POLYMOST;
@ -254,26 +255,6 @@ void polymost_glinit()
} }
static float get_projhack_ratio(void)
{
if ((glprojectionhacks == 1) && !r_yshearing)
{
// calculates the extend of the zenith glitch
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
float verticalfov = atanf(verticalfovtan) * (2.f / fPI);
static constexpr float const maxhorizangle = 0.6361136f; // horiz of 199 in degrees
float zenglitch = verticalfov + maxhorizangle - 0.95f; // less than 1 because the zenith glitch extends a bit
if (zenglitch <= 0.f)
return 1.f;
float const zenglitchtan = tanf((verticalfov - zenglitch) * (fPI / 2.f));
static constexpr float const maxcoshoriz = 0.54097117f; // 128/sqrt(128^2+199^2) = cos of an horiz diff of 199
return 1.f + (((verticalfovtan / zenglitchtan) - 1.f) * ((1.f - Bfabsf(gchang)) / maxcoshoriz ));
}
// No projection hacks (legacy or new-aspect)
return 1.f;
}
static void resizeglcheck(void) static void resizeglcheck(void)
{ {
//FUK //FUK
@ -290,7 +271,7 @@ static void resizeglcheck(void)
if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale) || (glohoriz2 != ghoriz2) || (glohorizcorrect != ghorizcorrect) || (glotang != gtang)) if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale) || (glohoriz2 != ghoriz2) || (glohorizcorrect != ghorizcorrect) || (glotang != gtang))
{ {
const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1); const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1);
float ratio = get_projhack_ratio(); float ratio = 1;
const int32_t fovcorrect = (int32_t)(ourxdimen*ratio - ourxdimen); const int32_t fovcorrect = (int32_t)(ourxdimen*ratio - ourxdimen);
ratio = 1.f/ratio; ratio = 1.f/ratio;
@ -321,8 +302,7 @@ static void resizeglcheck(void)
m[2][3] = 1.f; m[2][3] = 1.f;
m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip); m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip);
GLInterface.SetMatrix(Matrix_Projection, &m[0][0]); GLInterface.SetMatrix(Matrix_Projection, &m[0][0]);
VSMatrix identity(0); GLInterface.SetIdentityMatrix(Matrix_Model);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
} }
} }
@ -393,17 +373,8 @@ int32_t polymost_spriteHasTranslucency(tspritetype const * const tspr)
static void polymost_updaterotmat(void) static void polymost_updaterotmat(void)
{ {
if (1)
{
float matrix[16] = {
1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
0.f, 0.f, 1.f, 0.f,
0.f, 0.f, 0.f, 1.f,
};
#if !SOFTROTMAT
//Up/down rotation //Up/down rotation
float udmatrix[16] = { float matrix[16] = {
1.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f,
0.f, gchang, -gshang*gvrcorrection, 0.f, 0.f, gchang, -gshang*gvrcorrection, 0.f,
0.f, gshang/gvrcorrection, gchang, 0.f, 0.f, gshang/gvrcorrection, gchang, 0.f,
@ -416,16 +387,8 @@ static void polymost_updaterotmat(void)
0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f, 0.f,
0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 1.f,
}; };
multiplyMatrix4f(matrix, udmatrix);
multiplyMatrix4f(matrix, tiltmatrix); multiplyMatrix4f(matrix, tiltmatrix);
#endif
GLInterface.SetMatrix(Matrix_View, matrix); GLInterface.SetMatrix(Matrix_View, matrix);
}
}
static void polymost_identityrotmat(void)
{
GLInterface.SetIdentityMatrix(Matrix_View);
} }
static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz);
@ -474,34 +437,9 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
int j = 0; int j = 0;
float px[8], py[8], dd[8], uu[8], vv[8]; float px[8], py[8], dd[8], uu[8], vv[8];
#if SOFTROTMAT
float const ozgs = (ghalfx / gvrcorrection) * gshang,
ozgc = (ghalfx / gvrcorrection) * gchang;
#endif
for (bssize_t i=0; i<n; ++i) for (bssize_t i=0; i<n; ++i)
{ {
#if SOFTROTMAT
//Up/down rotation
vec3f_t const orot = { dpxy[i].x - ghalfx,
(dpxy[i].y - ghoriz) * gchang - ozgs,
(dpxy[i].y - ghoriz) * gshang + ozgc };
// Tilt rotation
float const r = (ghalfx / gvrcorrection) / orot.z;
px[j] = ghalfx + (((orot.x * gctang) - (orot.y * gstang)) * r);
py[j] = ghoriz + (((orot.x * gstang) + (orot.y * gctang)) * r);
dd[j] = (dpxy[i].x * xtex.d + dpxy[i].y * ytex.d + otex.d) * r;
if (dd[j] <= 0.f) // invalid polygon
return;
uu[j] = (dpxy[i].x * xtex.u + dpxy[i].y * ytex.u + otex.u) * r;
vv[j] = (dpxy[i].x * xtex.v + dpxy[i].y * ytex.v + otex.v) * r;
if ((!j) || (px[j] != px[j-1]) || (py[j] != py[j-1]))
j++;
#else
px[j] = dpxy[i].x; px[j] = dpxy[i].x;
py[j] = dpxy[i].y; py[j] = dpxy[i].y;
@ -511,7 +449,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
uu[j] = (dpxy[i].x * xtex.u + dpxy[i].y * ytex.u + otex.u); uu[j] = (dpxy[i].x * xtex.u + dpxy[i].y * ytex.u + otex.u);
vv[j] = (dpxy[i].x * xtex.v + dpxy[i].y * ytex.v + otex.v); vv[j] = (dpxy[i].x * xtex.v + dpxy[i].y * ytex.v + otex.v);
j++; j++;
#endif
} }
while ((j >= 3) && (px[j-1] == px[0]) && (py[j-1] == py[0])) j--; while ((j >= 3) && (px[j-1] == px[0]) && (py[j-1] == py[0])) j--;
@ -532,7 +469,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
else if (drawpoly_trepeat) sampleroverride = SamplerClampX; else if (drawpoly_trepeat) sampleroverride = SamplerClampX;
else sampleroverride = SamplerClampXY; else sampleroverride = SamplerClampXY;
bool success = GLInterface.SetTexture(globalpicnum, TileFiles.tiles[globalpicnum], globalpal, method, sampleroverride); bool success = GLInterface.SetTexture(globalpicnum, TileFiles.tiles[globalpicnum], globalpal, method, sampleroverride);
if (!success) if (!success)
{ {
@ -560,16 +496,6 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
GLInterface.SetNpotEmulation(false, 1.f, 0.f); GLInterface.SetNpotEmulation(false, 1.f, 0.f);
} }
vec2f_t hacksc = { 1.f, 1.f };
#if 0
if (pth->flags & PTH_HIGHTILE)
{
hacksc = pth->scale;
tsiz = pth->siz;
}
#endif
vec2_t tsiz2 = tsiz; vec2_t tsiz2 = tsiz;
@ -580,30 +506,20 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
float pc[4]; float pc[4];
polytint_t const& tint = hictinting[globalpal]; // The shade rgb from the tint is ignored here.
// This makes no sense. pc[0] = (float)globalr * (1.f / 255.f);
pc[0] = 1.f;// (1.f - (tint.sr * (1.f / 255.f))) + (tint.sr * (1.f / 255.f)); pc[1] = (float)globalg * (1.f / 255.f);
pc[1] = 1.f;// (1.f - (tint.sg * (1.f / 255.f))) + (tint.sg * (1.f / 255.f)); pc[2] = (float)globalb * (1.f / 255.f);
pc[2] = 1.f;// (1.f - (tint.sb * (1.f / 255.f))) + (tint.sb * (1.f / 255.f));
// spriteext full alpha control
pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha); pc[3] = float_trans(method & DAMETH_MASKPROPS, drawpoly_blend) * (1.f - drawpoly_alpha);
// tinting
auto& h = hictinting[globalpal];
GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b));
globaltinting_apply(pc);
if (skyzbufferhack_pass) if (skyzbufferhack_pass)
pc[3] = 0.01f; pc[3] = 0.01f;
GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]); GLInterface.SetColor(pc[0], pc[1], pc[2], pc[3]);
vec2f_t const scale = { 1.f / tsiz2.x * hacksc.x, 1.f / tsiz2.y * hacksc.y }; vec2f_t const scale = { 1.f / tsiz2.x, 1.f / tsiz2.y };
auto data = GLInterface.AllocVertices(npoints); auto data = screen->mVertexData->AllocVertices(npoints);
auto vt = data.second; auto vt = data.first;
for (bssize_t i = 0; i < npoints; ++i, vt++) for (bssize_t i = 0; i < npoints; ++i, vt++)
{ {
float const r = 1.f / dd[i]; float const r = 1.f / dd[i];
@ -620,9 +536,9 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
r * (1.f / 1024.f)); r * (1.f / 1024.f));
} }
GLInterface.Draw(DT_TRIANGLE_FAN, data.first, npoints); GLInterface.Draw(DT_TRIANGLE_FAN, data.second, npoints);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
GLInterface.UseDetailMapping(false); GLInterface.UseDetailMapping(false);
GLInterface.UseGlowMapping(false); GLInterface.UseGlowMapping(false);
GLInterface.SetNpotEmulation(false, 1.f, 0.f); GLInterface.SetNpotEmulation(false, 1.f, 0.f);
@ -3237,7 +3153,7 @@ void polymost_drawrooms()
// This is a global setting for the entire scene, so let's do it here, right at the start. // This is a global setting for the entire scene, so let's do it here, right at the start.
auto& hh = hictinting[MAXPALOOKUPS - 1]; auto& hh = hictinting[MAXPALOOKUPS - 1];
// This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.) // This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.)
GLInterface.SetBasepalTint(PalEntry(hh.r, hh.g, hh.b)); GLInterface.SetBasepalTint(hh.tint);
polymost_outputGLDebugMessage(3, "polymost_drawrooms()"); polymost_outputGLDebugMessage(3, "polymost_drawrooms()");
@ -3259,7 +3175,7 @@ void polymost_drawrooms()
GLInterface.SetBrightness(r_scenebrightness); GLInterface.SetBrightness(r_scenebrightness);
gvrcorrection = viewingrange*(1.f/65536.f); gvrcorrection = viewingrange*(1.f/65536.f);
if (glprojectionhacks == 2) //if (glprojectionhacks == 2)
{ {
// calculates the extend of the zenith glitch // calculates the extend of the zenith glitch
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f); float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
@ -3305,13 +3221,13 @@ void polymost_drawrooms()
ghoriz = (float)(ydimen>>1); ghoriz = (float)(ydimen>>1);
resizeglcheck(); resizeglcheck();
float const ratio = 1.f/get_projhack_ratio(); float const ratio = 1.f;
//global cos/sin tilt angle //global cos/sin tilt angle
gctang = cosf(gtang); gctang = cosf(gtang);
gstang = sinf(gtang); gstang = sinf(gtang);
if (Bfabsf(gstang) < .001f) // This hack avoids nasty precision bugs in domost() if (Bfabsf(gstang) < .001f) // This avoids nasty precision bugs in domost()
{ {
gstang = 0.f; gstang = 0.f;
gctang = (gctang > 0.f) ? 1.f : -1.f; gctang = (gctang > 0.f) ? 1.f : -1.f;
@ -3336,10 +3252,9 @@ void polymost_drawrooms()
v = { o2.x, o2.y * gchang + o2.z * gshang, o2.z * gchang - o2.y * gshang }; v = { o2.x, o2.y * gchang + o2.z * gshang, o2.z * gchang - o2.y * gshang };
} }
#if !SOFTROTMAT
if (inpreparemirror) if (inpreparemirror)
gstang = -gstang; gstang = -gstang;
#endif polymost_updaterotmat();
//Clip to SCISDIST plane //Clip to SCISDIST plane
int n = 0; int n = 0;
@ -3433,8 +3348,6 @@ void polymost_drawrooms()
//else if (!g_nodraw) { videoEndDrawing(); return; } //else if (!g_nodraw) { videoEndDrawing(); return; }
#endif #endif
polymost_updaterotmat();
numscans = numbunches = 0; numscans = numbunches = 0;
// MASKWALL_BAD_ACCESS // MASKWALL_BAD_ACCESS
@ -3497,7 +3410,6 @@ void polymost_drawrooms()
} }
GLInterface.SetDepthFunc(Depth_LessEqual); GLInterface.SetDepthFunc(Depth_LessEqual);
polymost_identityrotmat();
videoEndDrawing(); videoEndDrawing();
} }
@ -3705,9 +3617,7 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex)
pow2xsplit = 0; pow2xsplit = 0;
skyclamphack = 0; skyclamphack = 0;
polymost_updaterotmat();
polymost_drawpoly(dpxy, n, method, tilesiz[globalpicnum]); polymost_drawpoly(dpxy, n, method, tilesiz[globalpicnum]);
polymost_identityrotmat();
} }
void polymost_drawmaskwall(int32_t damaskwallcnt) void polymost_drawmaskwall(int32_t damaskwallcnt)
@ -3722,7 +3632,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang
//POGO: prepare necessary globals for drawing, as we intend to call this outside of drawrooms //POGO: prepare necessary globals for drawing, as we intend to call this outside of drawrooms
gvrcorrection = viewingrange*(1.f/65536.f); gvrcorrection = viewingrange*(1.f/65536.f);
if (glprojectionhacks == 2) //if (glprojectionhacks == 2)
{ {
// calculates the extend of the zenith glitch // calculates the extend of the zenith glitch
float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f); float verticalfovtan = (fviewingrange * (windowxy2.y-windowxy1.y) * 5.f) / ((float)yxaspect * (windowxy2.x-windowxy1.x) * 4.f);
@ -3771,6 +3681,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fix16_t daang
gstang = 0.f; gstang = 0.f;
gctang = (gctang > 0.f) ? 1.f : -1.f; gctang = (gctang > 0.f) ? 1.f : -1.f;
} }
polymost_updaterotmat();
grhalfxdown10x = grhalfxdown10; grhalfxdown10x = grhalfxdown10;
//POGO: write the mirror region to the stencil buffer to allow showing mirrors & skyboxes at the same time //POGO: write the mirror region to the stencil buffer to allow showing mirrors & skyboxes at the same time
@ -3978,8 +3889,6 @@ void polymost_drawsprite(int32_t snum)
if (tsiz.x <= 0 || tsiz.y <= 0) if (tsiz.x <= 0 || tsiz.y <= 0)
return; return;
polymost_updaterotmat();
vec2f_t const ftsiz = { (float) tsiz.x, (float) tsiz.y }; vec2f_t const ftsiz = { (float) tsiz.x, (float) tsiz.y };
switch ((globalorientation >> 4) & 3) switch ((globalorientation >> 4) & 3)
@ -4500,7 +4409,7 @@ void polymost_drawsprite(int32_t snum)
show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; show2dsprite[spritenum>>3] |= pow2char[spritenum&7];
_drawsprite_return: _drawsprite_return:
polymost_identityrotmat(); ;
} }
EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED); EDUKE32_STATIC_ASSERT((int)RS_YFLIP == (int)HUDFLAG_FLIPPED);
@ -4541,18 +4450,19 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
polymost_outputGLDebugMessage(3, "polymost_dorotatespritemodel(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, uniqid:%d)", polymost_outputGLDebugMessage(3, "polymost_dorotatespritemodel(sx:%d, sy:%d, z:%d, a:%hd, picnum:%hd, dashade:%hhd, dapalnum:%hhu, dastat:%d, daalpha:%hhu, dablend:%hhu, uniqid:%d)",
sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, uniqid); sx, sy, z, a, picnum, dashade, dapalnum, dastat, daalpha, dablend, uniqid);
float const ogchang = gchang; gchang = 1.f; gchang = 1.f;
float const ogshang = gshang; gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f)); gshang = 0.f; d = (float) z*(1.0f/(65536.f*16384.f));
float const ogctang = gctang; gctang = (float) sintable[(a+512)&2047]*d; gctang = (float) sintable[(a+512)&2047]*d;
float const ogstang = gstang; gstang = (float) sintable[a&2047]*d; gstang = (float) sintable[a&2047]*d;
gvrcorrection = 1.f;
polymost_updaterotmat();
int const ogshade = globalshade; globalshade = dashade; int const ogshade = globalshade; globalshade = dashade;
int const ogpal = globalpal; globalpal = (int32_t) ((uint8_t) dapalnum); int const ogpal = globalpal; globalpal = (int32_t) ((uint8_t) dapalnum);
double const ogxyaspect = gxyaspect; gxyaspect = 1.f; double const ogxyaspect = gxyaspect; gxyaspect = 1.f;
int const oldviewingrange = viewingrange; viewingrange = 65536; int const oldviewingrange = viewingrange; viewingrange = 65536;
float const oldfviewingrange = fviewingrange; fviewingrange = 65536.f; float const oldfviewingrange = fviewingrange; fviewingrange = 65536.f;
float const ogvrcorrection = gvrcorrection; gvrcorrection = 1.f;
polymost_updaterotmat();
vec1 = hud->add; vec1 = hud->add;
@ -4651,7 +4561,6 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
GLInterface.SetMatrix(Matrix_Projection, &m[0][0]); GLInterface.SetMatrix(Matrix_Projection, &m[0][0]);
VSMatrix identity(0); VSMatrix identity(0);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
} }
if (hud->flags & HUDFLAG_NODEPTH) if (hud->flags & HUDFLAG_NODEPTH)
@ -4675,17 +4584,11 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
if (videoGetRenderMode() == REND_POLYMOST) if (videoGetRenderMode() == REND_POLYMOST)
polymost_mddraw(&tspr); polymost_mddraw(&tspr);
gvrcorrection = ogvrcorrection;
viewingrange = oldviewingrange; viewingrange = oldviewingrange;
fviewingrange = oldfviewingrange; fviewingrange = oldfviewingrange;
gxyaspect = ogxyaspect; gxyaspect = ogxyaspect;
globalshade = ogshade; globalshade = ogshade;
globalpal = ogpal; globalpal = ogpal;
gchang = ogchang;
gshang = ogshang;
gctang = ogctang;
gstang = ogstang;
polymost_identityrotmat();
} }

View file

@ -1,45 +1,16 @@
// SDL interface layer for the Build Engine // SDL interface layer for the Build Engine
// Use SDL 1.2 or 2.0 from http://www.libsdl.org // Use SDL 1.2 or 2.0 from http://www.libsdl.org
#ifdef _WIN32
#include <Windows.h>
#include <CommCtrl.h>
#endif
#include <signal.h>
#include <string>
#include <stdexcept>
# include "gl_load.h"
#include "a.h" #include "a.h"
#include "build.h" #include "build.h"
#include "common.h" #include "common.h"
#include "compat.h" #include "compat.h"
#include "engine_priv.h" #include "engine_priv.h"
#include "osd.h"
#include "palette.h" #include "palette.h"
#include "baselayer.h" #include "baselayer.h"
#include "m_argv.h"
#include "mmulti.h" #include "mmulti.h"
#include "scriptfile.h" #include "glsurface.h"
#include "zstring.h"
#include "gameconfigfile.h"
#include "gamecontrol.h"
#include "resourcefile.h"
#include "sc_man.h"
#include "i_specialpaths.h"
#include "inputstate.h"
#include "c_cvars.h"
#include "i_time.h"
#include "c_dispatch.h"
#include "d_gui.h"
#include "menu.h"
#include "utf8.h"
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
# include "glsurface.h"
double g_beforeSwapTime; double g_beforeSwapTime;
@ -66,47 +37,6 @@ int32_t lockcount=0;
char modechange=1; char modechange=1;
char offscreenrendering=0; char offscreenrendering=0;
#define MAX_ERRORTEXT 4096
//==========================================================================
//
// I_Error
//
// Throw an error that will send us to the console if we are far enough
// along in the startup process.
//
//==========================================================================
void I_Error(const char *error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
#ifdef _WIN32
OutputDebugStringA(errortext);
#endif
throw std::runtime_error(errortext);
}
void I_FatalError(const char* error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
#ifdef _WIN32
OutputDebugStringA(errortext);
#endif
throw std::runtime_error(errortext);
}
// Calculate ylookup[] and call setvlinebpl() // Calculate ylookup[] and call setvlinebpl()
void calc_ylookup(int32_t bpl, int32_t lastyidx) void calc_ylookup(int32_t bpl, int32_t lastyidx)
@ -223,35 +153,5 @@ void videoEndDrawing(void)
lockcount = 0; lockcount = 0;
} }
//
//
// ---------------------------------------
//
// Miscellany
//
// ---------------------------------------
//
//
auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries.
//
// debugprintf() -- sends a debug string to the debugger
//
void debugprintf(const char* f, ...)
{
va_list va;
va_start(va, f);
#ifdef _WIN32
if (!IsDebuggerPresent()) return;
char buf[1024];
vsnprintf(buf, 1024, f, va);
va_end(va);
OutputDebugStringA(buf);
#else
vprintf(f, va);
#endif
}

View file

@ -10,6 +10,8 @@
#include "hightile.h" #include "hightile.h"
#include "polymost.h" #include "polymost.h"
#include "mdsprite.h" #include "mdsprite.h"
#include "v_video.h"
#include "flatvertices.h"
#include "palette.h" #include "palette.h"
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
@ -1035,7 +1037,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
f = (float) tspr->yrepeat * k0; f = (float) tspr->yrepeat * k0;
m0.z *= f; a0.z *= f; m0.z *= f; a0.z *= f;
k0 = (float) tspr->z; k0 = (float) (tspr->z+spriteext[tspr->owner].position_offset.z);
f = ((globalorientation&8) && (sprite[tspr->owner].cstat&48)!=0) ? -4.f : 4.f; f = ((globalorientation&8) && (sprite[tspr->owner].cstat&48)!=0) ? -4.f : 4.f;
k0 -= (tspr->yoffset*tspr->yrepeat)*f*m->bscale; k0 -= (tspr->yoffset*tspr->yrepeat)*f*m->bscale;
zoff = m->siz.z*.5f; zoff = m->siz.z*.5f;
@ -1053,8 +1055,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
int const shadowHack = !!(tspr->clipdist & TSPR_FLAGS_MDHACK); int const shadowHack = !!(tspr->clipdist & TSPR_FLAGS_MDHACK);
m0.y *= f; a0.y = (((float)(tspr->x-globalposx)) * (1.f/1024.f) + a0.y) * f; m0.y *= f; a0.y = (((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx)) * (1.f/1024.f) + a0.y) * f;
m0.x *=-f; a0.x = (((float)(tspr->y-globalposy)) * -(1.f/1024.f) + a0.x) * -f; m0.x *=-f; a0.x = (((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy)) * -(1.f/1024.f) + a0.x) * -f;
m0.z *= g; a0.z = (((float)(k0 -globalposz - shadowHack)) * -(1.f/16384.f) + a0.z) * g; m0.z *= g; a0.z = (((float)(k0 -globalposz - shadowHack)) * -(1.f/16384.f) + a0.z) * g;
float mat[16]; float mat[16];
@ -1083,7 +1085,10 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades; pc[0] = pc[1] = pc[2] = ((float)numshades - min(max((globalshade * hw_shadescale) + m->shadeoff, 0.f), (float)numshades)) / (float)numshades;
auto& h = hictinting[globalpal]; auto& h = hictinting[globalpal];
GLInterface.SetTinting(h.f, PalEntry(h.sr, h.sg, h.sb), PalEntry(h.r, h.g, h.b)); if (h.f & (HICTINT_USEONART|HICTINT_ALWAYSUSEART))
GLInterface.SetTinting(h.f, h.tint, h.tint);
else
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
if (!shadowHack) if (!shadowHack)
{ {
@ -1115,7 +1120,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
//Let OpenGL (and perhaps hardware :) handle the matrix rotation //Let OpenGL (and perhaps hardware :) handle the matrix rotation
mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f; mat[3] = mat[7] = mat[11] = 0.f; mat[15] = 1.f;
GLInterface.SetMatrix(Matrix_ModelView, mat); int matrixindex = GLInterface.SetMatrix(Matrix_Model, mat);
const float ru = 1.f/((float)m->mytexx); const float ru = 1.f/((float)m->mytexx);
const float rv = 1.f/((float)m->mytexy); const float rv = 1.f/((float)m->mytexy);
@ -1137,10 +1142,10 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
GLInterface.UseDetailMapping(false); GLInterface.UseDetailMapping(false);
#endif #endif
auto data = GLInterface.AllocVertices(m->qcnt * 6); auto data = screen->mVertexData->AllocVertices(m->qcnt * 6);
auto vt = data.second; auto vt = data.first;
int qstart = 0; int qstart = data.second;
int qdone = 0; int qdone = 0;
for (bssize_t i=0, fi=0; i<m->qcnt; i++) for (bssize_t i=0, fi=0; i<m->qcnt; i++)
{ {
@ -1172,9 +1177,10 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
#else #else
vt->SetTexCoord(((float)vptr[j].u)*ru, ((float)vptr[j].v)*rv); vt->SetTexCoord(((float)vptr[j].u)*ru, ((float)vptr[j].v)*rv);
#endif #endif
vt->x = ((float)vptr[j].x) - phack[xx>vptr[j].x*2] + phack[xx<vptr[j].x*2]; vt->SetVertex(
vt->y = ((float)vptr[j].y) - phack[yy>vptr[j].y*2] + phack[yy<vptr[j].y*2]; ((float)vptr[j].x) - phack[xx > vptr[j].x * 2] + phack[xx < vptr[j].x * 2],
vt->z = ((float)vptr[j].z) - phack[zz>vptr[j].z*2] + phack[zz<vptr[j].z*2]; ((float)vptr[j].y) - phack[yy > vptr[j].y * 2] + phack[yy < vptr[j].y * 2],
((float)vptr[j].z) - phack[zz > vptr[j].z * 2] + phack[zz < vptr[j].z * 2]);
} }
qdone++; qdone++;
} }
@ -1189,9 +1195,9 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
GLInterface.SetDepthFunc(Depth_Less); GLInterface.SetDepthFunc(Depth_Less);
} }
VSMatrix identity(0); VSMatrix identity(0);
GLInterface.SetIdentityMatrix(Matrix_ModelView); GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
GLInterface.SetFadeDisable(false); GLInterface.SetFadeDisable(false);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255)); GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
return 1; return 1;
} }
#endif #endif

View file

@ -14,7 +14,7 @@ struct F2DPolygons
TArray<FVector4> vertices; TArray<FVector4> vertices;
TArray<int> indices; TArray<int> indices;
unsigned AllocVertices(int num) // Allocates a triangle fan. There's no code that needs a triangle strip. unsigned AllocVertices(int num)
{ {
auto vindex = vertices.Reserve(num); auto vindex = vertices.Reserve(num);
indices.Push(num); indices.Push(num);

View file

@ -655,14 +655,16 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
parms->style = STYLE_Stencil; parms->style = STYLE_Stencil;
} }
} }
else if (parms->Alpha < 1.f) else //if (parms->Alpha < 1.f)
{ {
parms->style = STYLE_Translucent; parms->style = STYLE_Translucent;
} }
/*
else else
{ {
parms->style = STYLE_Normal; parms->style = STYLE_Normal;
} }
*/
} }
return true; return true;
} }

View file

@ -37,6 +37,8 @@
#include "compositesaveame.h" #include "compositesaveame.h"
#include "file_zip.h" #include "file_zip.h"
#include "resourcefile.h" #include "resourcefile.h"
#include "m_png.h"
#include "gamecontrol.h"
bool WriteZip(const char *filename, TArray<FString> &filenames, TArray<FCompressedBuffer> &content); bool WriteZip(const char *filename, TArray<FString> &filenames, TArray<FCompressedBuffer> &content);

View file

@ -78,7 +78,7 @@ class FDirectory : public FResourceFile
void AddEntry(const char *fullpath, int size); void AddEntry(const char *fullpath, int size);
public: public:
FDirectory(const char * dirname, bool nosubdirflag); FDirectory(const char * dirname, bool nosubdirflag = false);
bool Open(bool quiet); bool Open(bool quiet);
virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; } virtual FResourceLump *GetLump(int no) { return ((unsigned)no < NumLumps)? &Lumps[no] : NULL; }
}; };

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#include <stdexcept>
#include "gamecontrol.h" #include "gamecontrol.h"
#include "tarray.h" #include "tarray.h"
#include "zstring.h" #include "zstring.h"
@ -807,3 +808,57 @@ void S_SetSoundPaused(int state)
} }
#endif #endif
} }
#define MAX_ERRORTEXT 4096
//==========================================================================
//
// I_Error
//
// Throw an error that will send us to the console if we are far enough
// along in the startup process.
//
//==========================================================================
void I_Error(const char* error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
#ifdef _WIN32
OutputDebugStringA(errortext);
#endif
throw std::runtime_error(errortext);
}
void I_FatalError(const char* error, ...)
{
va_list argptr;
char errortext[MAX_ERRORTEXT];
va_start(argptr, error);
vsnprintf(errortext, MAX_ERRORTEXT, error, argptr);
va_end(argptr);
#ifdef _WIN32
OutputDebugStringA(errortext);
#endif
throw std::runtime_error(errortext);
}
//
// debugprintf() -- sends a debug string to the debugger
//
void debugprintf(const char* f, ...)
{
va_list va;
va_start(va, f);
FString out;
out.VFormat(f, va);
I_DebugPrint(out);
}

View file

@ -466,6 +466,16 @@ bool M_SetMenu(FName menu, int param, FName caller)
case NAME_SkillMenu: case NAME_SkillMenu:
GameStartupInfo.Skill = param; GameStartupInfo.Skill = param;
break; break;
case NAME_EngineCredits:
case NAME_EngineCredits2:
{
auto m = DMenu::CurrentMenu;
DMenu::CurrentMenu = m->mParentMenu;
m->mParentMenu = nullptr;
toDelete.Push(m);
break;
}
} }
switch (menu) switch (menu)

View file

@ -67,7 +67,7 @@ public:
bool Activate(FName caller) override bool Activate(FName caller) override
{ {
M_MenuSound(CursorSound); M_MenuSound(CursorSound);
M_SetMenu(mAction, mParam); M_SetMenu(mAction, mParam, static_cast<DOptionMenu*>(DMenu::CurrentMenu)->GetDescriptor()->mMenuName);
return true; return true;
} }
}; };

View file

@ -64,13 +64,15 @@ void FSavegameManager::LoadGame(FSaveGameNode* node)
void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq) void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq)
{ {
if (OpenSaveGameForWrite(node->Filename, node->SaveTitle))
{
if (gi->SaveGame(node)) if (gi->SaveGame(node))
{ {
FString fn = node->Filename; FString fn = node->Filename;
FString desc = node->SaveTitle; FString desc = node->SaveTitle;
NotifyNewSave(fn, desc, ok4q, forceq); NotifyNewSave(fn, desc, ok4q, forceq);
} }
}
} }
//============================================================================= //=============================================================================
@ -146,8 +148,9 @@ int FSavegameManager::InsertSaveNode(FSaveGameNode *node)
} }
else else
{ // Add node at top of list { // Add node at top of list
unsigned int i; unsigned int i = 0;
for (i = 0; i < SaveGames.Size(); i++) if (SaveGames[0] == &NewSaveNode) i++; // To not insert above the "new savegame" dummy entry.
for (; i < SaveGames.Size(); i++)
{ {
if (SaveGames[i]->bOldVersion || node->SaveTitle.CompareNoCase(SaveGames[i]->SaveTitle) <= 0) if (SaveGames[i]->bOldVersion || node->SaveTitle.CompareNoCase(SaveGames[i]->SaveTitle) <= 0)
{ {
@ -379,8 +382,8 @@ unsigned FSavegameManager::ExtractSaveData(int index)
FString comment = sjson_get_string(root, "Creation Time", ""); FString comment = sjson_get_string(root, "Creation Time", "");
FString fcomment = sjson_get_string(root, "Map Label", ""); FString fcomment = sjson_get_string(root, "Map Label", "");
FString ncomment = sjson_get_string(root, "Map Name", ""); FString ncomment = sjson_get_string(root, "Map Name", "");
FStringf pcomment("%s - %s\n", fcomment.GetChars(), ncomment.GetChars()); FString mtime = sjson_get_string(root, "Map Time", "");
comment += pcomment; comment.AppendFormat("\n%s - %s\n%s", fcomment.GetChars(), ncomment.GetChars(), mtime.GetChars());
SaveCommentString = comment; SaveCommentString = comment;
// Extract pic (todo: let the renderer write a proper PNG file instead of a raw canvas dunp of the software renderer - and make it work for all games.) // Extract pic (todo: let the renderer write a proper PNG file instead of a raw canvas dunp of the software renderer - and make it work for all games.)
@ -400,7 +403,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
PNGHandle *png = M_VerifyPNG(picreader); PNGHandle *png = M_VerifyPNG(picreader);
if (png != nullptr) if (png != nullptr)
{ {
SavePic = nullptr; // not yet implemented: PNGTexture_CreateFromFile(png, node->Filename); SavePic = PNGTexture_CreateFromFile(png, node->Filename);
delete png; delete png;
if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1) if (SavePic && SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1)
{ {

View file

@ -32,8 +32,9 @@
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
#include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
//#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "r_videoscale.h" #include "r_videoscale.h"
#include "v_video.h"
extern bool vid_hdr_active; extern bool vid_hdr_active;
@ -45,23 +46,9 @@ namespace OpenGLRenderer
void FGLRenderer::RenderScreenQuad() void FGLRenderer::RenderScreenQuad()
{ {
// The buffer here needs to be enabled later again, of course.
#if 0
auto buffer = static_cast<GLVertexBuffer *>(screen->mVertexData->GetBufferObjects().first); auto buffer = static_cast<GLVertexBuffer *>(screen->mVertexData->GetBufferObjects().first);
buffer->Bind(nullptr); buffer->Bind(nullptr);
glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
#else
glBegin(GL_TRIANGLE_STRIP);
glVertexAttrib2f(1, 0, 0);
glVertexAttrib2f(0, -1, -1);
glVertexAttrib2f(1, 0, 1);
glVertexAttrib2f(0, -1, 1);
glVertexAttrib2f(1, 1, 0);
glVertexAttrib2f(0, 1, -1);
glVertexAttrib2f(1, 1, 1);
glVertexAttrib2f(0, 1,1);
glEnd();
#endif
} }
void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D) void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D)

View file

@ -44,8 +44,9 @@ namespace OpenGLRenderer
// //
//========================================================================== //==========================================================================
FGLRenderBuffers::FGLRenderBuffers() FGLRenderBuffers::FGLRenderBuffers(int ms)
{ {
gl_multisample = ms;
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
} }

View file

@ -101,8 +101,9 @@ private:
class FGLRenderBuffers class FGLRenderBuffers
{ {
int gl_multisample = 0; // intentionally overload the global CVAR
public: public:
FGLRenderBuffers(); FGLRenderBuffers(int ms);
~FGLRenderBuffers(); ~FGLRenderBuffers();
void Setup(int width, int height, int sceneWidth, int sceneHeight); void Setup(int width, int height, int sceneWidth, int sceneHeight);

View file

@ -39,6 +39,7 @@
#include "filesystem.h" #include "filesystem.h"
#include "i_time.h" #include "i_time.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "m_png.h"
//#include "swrenderer/r_swscene.h" //#include "swrenderer/r_swscene.h"
//#include "hwrenderer/utility/hw_clock.h" //#include "hwrenderer/utility/hw_clock.h"
@ -58,14 +59,14 @@
//#include "r_data/models/models.h" //#include "r_data/models/models.h"
#include "gl/renderer/gl_postprocessstate.h" #include "gl/renderer/gl_postprocessstate.h"
#include "gl/system/gl_buffers.h" #include "gl/system/gl_buffers.h"
#include "../glbackend/gl_hwtexture.h"
#include "build.h"
EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Bool, cl_capfps) EXTERN_CVAR(Bool, cl_capfps)
extern bool NoInterpolateView; extern bool NoInterpolateView;
void DoWriteSavePic(FileWriter *file, ESSType ssformat, uint8_t *scr, int width, int height, sector_t *viewsector, bool upsidedown);
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
@ -88,8 +89,8 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
void FGLRenderer::Initialize(int width, int height) void FGLRenderer::Initialize(int width, int height)
{ {
mScreenBuffers = new FGLRenderBuffers(); mScreenBuffers = new FGLRenderBuffers(gl_multisample);
mSaveBuffers = new FGLRenderBuffers(); mSaveBuffers = new FGLRenderBuffers(0);
mBuffers = mScreenBuffers; mBuffers = mScreenBuffers;
mPresentShader = new FPresentShader(); mPresentShader = new FPresentShader();
mPresent3dCheckerShader = new FPresent3DCheckerShader(); mPresent3dCheckerShader = new FPresent3DCheckerShader();
@ -168,20 +169,17 @@ void FGLRenderer::EndOffscreen()
// //
//=========================================================================== //===========================================================================
void FGLRenderer::BindToFrameBuffer(FMaterial *mat) void FGLRenderer::BindToFrameBuffer(FTexture *mat)
{ {
#if 0 auto pBaseLayer = mat->GetHardwareTexture(0);
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0, 0)); auto BaseLayer = pBaseLayer ? *pBaseLayer : nullptr;
if (BaseLayer == nullptr) if (BaseLayer == nullptr)
{ {
// must create the hardware texture first // must create the hardware texture first
BaseLayer->BindOrCreate(mat->sourcetex, 0, 0, 0, 0); BaseLayer->CreateTexture(mat->GetWidth(), mat->GetHeight(), FHardwareTexture::TrueColor, false);
FHardwareTexture::Unbind(0);
gl_RenderState.ClearLastMaterial();
} }
BaseLayer->BindToFrameBuffer(mat->GetWidth(), mat->GetHeight()); BaseLayer->BindToFrameBuffer(mat->GetWidth(), mat->GetHeight());
#endif
} }
//=========================================================================== //===========================================================================
@ -190,8 +188,7 @@ void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
// //
//=========================================================================== //===========================================================================
#if 0 void FGLRenderer::WriteSavePic ( FileWriter *file, int width, int height)
void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
{ {
IntRect bounds; IntRect bounds;
bounds.left = 0; bounds.left = 0;
@ -204,35 +201,53 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
// Switch to render buffers dimensioned for the savepic // Switch to render buffers dimensioned for the savepic
mBuffers = mSaveBuffers; mBuffers = mSaveBuffers;
mBuffers->BindSceneFB(false);
screen->SetViewportRects(&bounds);
hw_ClearFakeFlat();
gl_RenderState.SetVertexBuffer(screen->mVertexData);
screen->mVertexData->Reset();
screen->mLights->Clear();
screen->mViewpoints->Clear();
// This shouldn't overwrite the global viewpoint even for a short time. int oldx = xdim;
FRenderViewpoint savevp; int oldy = ydim;
sector_t *viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false); auto oldwindowxy1 = windowxy1;
glDisable(GL_STENCIL_TEST); auto oldwindowxy2 = windowxy2;
gl_RenderState.SetNoSoftLightLevel();
xdim = width;
ydim = height;
videoSetViewableArea(0, 0, width - 1, height - 1);
renderSetAspect(65536, 65536);
calc_ylookup(width, height);
bool didit = gi->GenerateSavePic();
xdim = oldx;
ydim = oldy;
videoSetViewableArea(oldwindowxy1.x, oldwindowxy1.y, oldwindowxy2.x, oldwindowxy2.y);
calc_ylookup(bytesperline, ydim);
modechange = 1;
// The 2D drawers can contain some garbage from the dirty render setup. Get rid of that first.
twodgen.Clear();
twodpsp.Clear();
CopyToBackbuffer(&bounds, false); CopyToBackbuffer(&bounds, false);
// strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers // strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers
glFinish(); glFinish();
if (didit)
{
int numpixels = width * height; int numpixels = width * height;
uint8_t * scr = (uint8_t *)M_Malloc(numpixels * 3); uint8_t* scr = (uint8_t*)Xmalloc(numpixels * 3);
glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, scr);
M_CreatePNG(file, scr + ((height - 1) * width * 3), nullptr, SS_RGB, width, height, -width * 3, vid_gamma);
DoWriteSavePic(file, SS_RGB, scr, width, height, viewsector, true); M_FinishPNG(file);
M_Free(scr); Xfree(scr);
}
// Switch back the screen render buffers // Switch back the screen render buffers
screen->SetViewportRects(nullptr); screen->SetViewportRects(nullptr);
mBuffers = mScreenBuffers; mBuffers = mScreenBuffers;
bool useSSAO = (gl_ssao != 0);
mBuffers->BindSceneFB(useSSAO);
} }
#endif
//=========================================================================== //===========================================================================
// //
@ -243,7 +258,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
void FGLRenderer::BeginFrame() void FGLRenderer::BeginFrame()
{ {
mScreenBuffers->Setup(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height); mScreenBuffers->Setup(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
//mSaveBuffers->Setup(SAVEPICWIDTH, SAVEPICHEIGHT, SAVEPICWIDTH, SAVEPICHEIGHT); mSaveBuffers->Setup(240, 180, 240, 180);
} }
} }

View file

@ -81,29 +81,19 @@ public:
void DrawPresentTexture(const IntRect &box, bool applyGamma); void DrawPresentTexture(const IntRect &box, bool applyGamma);
void Flush(); void Flush();
//void Draw2D(F2DDrawer *data); //void Draw2D(F2DDrawer *data);
#if 0 void WriteSavePic(FileWriter *file, int width, int height);
void WriteSavePic(player_t *player, FileWriter *file, int width, int height);
#endif
void BeginFrame(); void BeginFrame();
bool StartOffscreen(); bool StartOffscreen();
void EndOffscreen(); void EndOffscreen();
void BindToFrameBuffer(FMaterial *mat); void BindToFrameBuffer(FTexture* tex);
private: private:
void DrawScene(HWDrawInfo *di, int drawmode); void DrawScene(HWDrawInfo *di, int drawmode);
bool QuadStereoCheckInitialRenderContextState();
void PresentAnaglyph(bool r, bool g, bool b);
void PresentSideBySide();
void PresentTopBottom();
void prepareInterleavedPresent(FPresentShaderBase& shader);
void PresentColumnInterleaved();
void PresentRowInterleaved();
void PresentCheckerInterleaved();
void PresentQuadStereo();
}; };

View file

@ -45,6 +45,7 @@
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "hwrenderer/data/flatvertices.h"
/* /*
#include "gl/textures/gl_samplers.h" #include "gl/textures/gl_samplers.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
@ -105,8 +106,8 @@ OpenGLFrameBuffer::~OpenGLFrameBuffer()
{ {
PPResource::ResetAll(); PPResource::ResetAll();
#ifdef IMPLEMENT_IT
if (mVertexData != nullptr) delete mVertexData; if (mVertexData != nullptr) delete mVertexData;
#ifdef IMPLEMENT_IT
if (mSkyData != nullptr) delete mSkyData; if (mSkyData != nullptr) delete mSkyData;
if (mViewpoints != nullptr) delete mViewpoints; if (mViewpoints != nullptr) delete mViewpoints;
if (mLights != nullptr) delete mLights; if (mLights != nullptr) delete mLights;
@ -171,8 +172,8 @@ void OpenGLFrameBuffer::InitializeState()
SetViewportRects(nullptr); SetViewportRects(nullptr);
#ifdef IMPLEMENT_IT
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight()); mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
#ifdef IMPLEMENT_IT
mSkyData = new FSkyVertexBuffer; mSkyData = new FSkyVertexBuffer;
mViewpoints = new HWViewpointBuffer; mViewpoints = new HWViewpointBuffer;
mLights = new FLightBuffer(); mLights = new FLightBuffer();
@ -206,6 +207,18 @@ void OpenGLFrameBuffer::Update()
Swap(); Swap();
Super::Update(); Super::Update();
screen->mVertexData->Reset();
}
//===========================================================================
//
// Render the view to a savegame picture
//
//===========================================================================
void OpenGLFrameBuffer::WriteSavePic(FileWriter *file, int width, int height)
{
GLRenderer->WriteSavePic(file, width, height);
} }
@ -305,6 +318,7 @@ FModelRenderer *OpenGLFrameBuffer::CreateModelRenderer(int mli)
{ {
return new FHWModelRenderer(nullptr, gl_RenderState, mli); return new FHWModelRenderer(nullptr, gl_RenderState, mli);
} }
#endif
IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer() IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer()
{ {
@ -315,7 +329,6 @@ IIndexBuffer *OpenGLFrameBuffer::CreateIndexBuffer()
{ {
return new GLIndexBuffer; return new GLIndexBuffer;
} }
#endif
IDataBuffer *OpenGLFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) IDataBuffer *OpenGLFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize)
{ {
@ -467,4 +480,3 @@ void videoShowFrame(int32_t w)
twodgen.Clear(); twodgen.Clear();
GLInterface.ResetFrame(); GLInterface.ResetFrame();
} }

View file

@ -8,7 +8,6 @@
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
class FHardwareTexture;
class FGLDebug; class FGLDebug;
class OpenGLFrameBuffer : public SystemGLFrameBuffer class OpenGLFrameBuffer : public SystemGLFrameBuffer
@ -27,6 +26,7 @@ public:
void CleanForRestart() override; void CleanForRestart() override;
const char* DeviceName() const override; const char* DeviceName() const override;
void WriteSavePic(FileWriter* file, int width, int height);
#ifdef IMPLEMENT_IT #ifdef IMPLEMENT_IT
void SetTextureFilterMode() override; void SetTextureFilterMode() override;
IHardwareTexture *CreateHardwareTexture() override; IHardwareTexture *CreateHardwareTexture() override;
@ -37,10 +37,8 @@ public:
void BeginFrame() override; void BeginFrame() override;
//void SetViewportRects(IntRect *bounds) override; //void SetViewportRects(IntRect *bounds) override;
void BlurScene(float amount) override; void BlurScene(float amount) override;
#ifdef IMPLEMENT_IT
IVertexBuffer *CreateVertexBuffer() override; IVertexBuffer *CreateVertexBuffer() override;
IIndexBuffer *CreateIndexBuffer() override; IIndexBuffer *CreateIndexBuffer() override;
#endif
IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) override; IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) override;
// Retrieves a buffer containing image data for a screenshot. // Retrieves a buffer containing image data for a screenshot.

View file

@ -0,0 +1,158 @@
/*
** hw_flatvertices.cpp
** Creates flat vertex data for hardware rendering.
**
**---------------------------------------------------------------------------
** Copyright 2010-2020 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "c_cvars.h"
#include "flatvertices.h"
#include "v_video.h"
#include "cmdlib.h"
#include "printf.h"
#include "hwrenderer/data/buffers.h"
//==========================================================================
//
//
//
//==========================================================================
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
{
vbo_shadowdata.Resize(NUM_RESERVED);
// the first quad is reserved for handling coordinates through uniforms.
vbo_shadowdata[0].Set(0, 0, 0, 0, 0);
vbo_shadowdata[1].Set(1, 0, 0, 0, 0);
vbo_shadowdata[2].Set(2, 0, 0, 0, 0);
vbo_shadowdata[3].Set(3, 0, 0, 0, 0);
// and the second one for the fullscreen quad used for blend overlays.
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1);
vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0);
vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1);
// and this is for the postprocessing copy operation
vbo_shadowdata[8].Set(-1.0f, -1.0f, 0, 0.0f, 0.0f);
vbo_shadowdata[9].Set(-1.0f, 1.0f, 0, 0.0f, 1.f);
vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f);
vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f);
// The next two are the stencil caps.
vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
mVertexBuffer = screen->CreateVertexBuffer();
mIndexBuffer = screen->CreateIndexBuffer();
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
mVertexBuffer->SetData(bytesize, nullptr, false);
static const FVertexBufferAttribute format[] = {
{ 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) },
{ 0, VATTR_TEXCOORD, VFmt_Float2, (int)myoffsetof(FFlatVertex, u) }
};
mVertexBuffer->SetFormat(1, 2, sizeof(FFlatVertex), format);
mIndex = mCurIndex = NUM_RESERVED;
mNumReserved = NUM_RESERVED;
Copy(0, NUM_RESERVED);
}
//==========================================================================
//
//
//
//==========================================================================
FFlatVertexBuffer::~FFlatVertexBuffer()
{
delete mIndexBuffer;
delete mVertexBuffer;
mIndexBuffer = nullptr;
mVertexBuffer = nullptr;
}
//==========================================================================
//
//
//
//==========================================================================
void FFlatVertexBuffer::OutputResized(int width, int height)
{
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1);
vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0);
vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1);
Copy(4, 4);
}
//==========================================================================
//
//
//
//==========================================================================
std::pair<FFlatVertex *, unsigned int> FFlatVertexBuffer::AllocVertices(unsigned int count)
{
FFlatVertex *p = GetBuffer();
auto index = mCurIndex.fetch_add(count);
auto offset = index;
if (index + count >= BUFFER_SIZE_TO_USE)
{
// If a single scene needs 2'000'000 vertices there must be something very wrong.
I_FatalError("Out of vertex memory. Tried to allocate more than %u vertices for a single frame", index + count);
}
return std::make_pair(p, index);
}
//==========================================================================
//
//
//
//==========================================================================
void FFlatVertexBuffer::Copy(int start, int count)
{
Map();
memcpy(GetBuffer(start), &vbo_shadowdata[0], count * sizeof(FFlatVertex));
Unmap();
}

View file

@ -0,0 +1,112 @@
#ifndef _HW__VERTEXBUFFER_H
#define _HW__VERTEXBUFFER_H
#include "tarray.h"
#include "hwrenderer/data/buffers.h"
#include <atomic>
#include <mutex>
class FRenderState;
struct secplane_t;
struct subsector_t;
struct FFlatVertex
{
float x, z, y; // world position
float u, v; // texture coordinates
void Set(float xx, float zz, float yy, float uu, float vv)
{
x = xx;
z = zz;
y = yy;
u = uu;
v = vv;
}
void SetVertex(float _x, float _y, float _z = 0)
{
x = _x;
z = _y;
y = _z;
}
void SetTexCoord(float _u = 0, float _v = 0)
{
u = _u;
v = _v;
}
};
class FFlatVertexBuffer
{
TArray<FFlatVertex> vbo_shadowdata;
TArray<uint32_t> ibo_data;
IVertexBuffer *mVertexBuffer;
IIndexBuffer *mIndexBuffer;
unsigned int mIndex;
std::atomic<unsigned int> mCurIndex;
unsigned int mNumReserved;
static const unsigned int BUFFER_SIZE = 2000000;
static const unsigned int BUFFER_SIZE_TO_USE = 1999500;
public:
enum
{
QUAD_INDEX = 0,
FULLSCREEN_INDEX = 4,
PRESENT_INDEX = 8,
STENCILTOP_INDEX = 12,
STENCILBOTTOM_INDEX = 16,
NUM_RESERVED = 20
};
FFlatVertexBuffer(int width, int height);
~FFlatVertexBuffer();
void OutputResized(int width, int height);
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
{
return std::make_pair(mVertexBuffer, mIndexBuffer);
}
void Copy(int start, int count);
FFlatVertex *GetBuffer(int index) const
{
FFlatVertex *ff = (FFlatVertex*)mVertexBuffer->Memory();
return &ff[index];
}
FFlatVertex *GetBuffer() const
{
return GetBuffer(mCurIndex);
}
std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count);
void Reset()
{
mCurIndex = mIndex;
}
void Map()
{
mVertexBuffer->Map();
}
void Unmap()
{
mVertexBuffer->Unmap();
}
};
#endif

View file

@ -46,11 +46,12 @@
#include "i_time.h" #include "i_time.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "build.h" #include "build.h"
#include "../glbackend/glbackend.h"
/* /*
#include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/scene/hw_portal.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/data/flatvertices.h"
*/ */
#include "hwrenderer/data/flatvertices.h"
#include <chrono> #include <chrono>
#include <thread> #include <thread>
@ -189,7 +190,7 @@ void DFrameBuffer::Update()
{ {
SetVirtualSize(clientWidth, clientHeight); SetVirtualSize(clientWidth, clientHeight);
V_OutputResized(clientWidth, clientHeight); V_OutputResized(clientWidth, clientHeight);
//mVertexData->OutputResized(clientWidth, clientHeight); mVertexData->OutputResized(clientWidth, clientHeight);
} }
} }
@ -234,6 +235,16 @@ FTexture *DFrameBuffer::WipeEndScreen()
return nullptr; return nullptr;
} }
//==========================================================================
//
//
//
//==========================================================================
void DFrameBuffer::WriteSavePic(FileWriter *file, int width, int height)
{
}
//========================================================================== //==========================================================================
// //
// Calculates the viewport values needed for 2D and 3D operations // Calculates the viewport values needed for 2D and 3D operations
@ -364,3 +375,24 @@ void DFrameBuffer::FPSLimit()
} }
#endif #endif
} }
void DFrameBuffer::BeginScene()
{
if (videoGetRenderMode() < REND_POLYMOST) return;
assert(BufferLock >= 0);
if (BufferLock++ == 0)
{
mVertexData->Map();
}
}
void DFrameBuffer::FinishScene()
{
if (videoGetRenderMode() < REND_POLYMOST) return;
assert(BufferLock > 0);
if (--BufferLock == 0)
{
mVertexData->Unmap();
GLInterface.DoDraw();
}
}

View file

@ -178,6 +178,7 @@ class FFont;
struct FRemapTable; struct FRemapTable;
class player_t; class player_t;
typedef uint32_t angle_t; typedef uint32_t angle_t;
struct RenderScene;
// //
@ -219,6 +220,7 @@ protected:
private: private:
int Width = 0; int Width = 0;
int Height = 0; int Height = 0;
int BufferLock = 0;
protected: protected:
int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1; int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1;
@ -233,7 +235,7 @@ public:
const char *vendorstring; // We have to account for some issues with particular vendors. const char *vendorstring; // We have to account for some issues with particular vendors.
//FPortalSceneState *mPortalState; // global portal state. //FPortalSceneState *mPortalState; // global portal state.
//FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer //FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer
//FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data
//HWViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data. //HWViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data.
//FLightBuffer *mLights = nullptr; // Dynamic lights //FLightBuffer *mLights = nullptr; // Dynamic lights
//IShadowMap mShadowMap; //IShadowMap mShadowMap;
@ -313,6 +315,9 @@ public:
void Begin2D() { isIn2D = true; } void Begin2D() { isIn2D = true; }
void End2D() { isIn2D = false; } void End2D() { isIn2D = false; }
void BeginScene();
void FinishScene();
void End2DAndUpdate() void End2DAndUpdate()
{ {
DrawRateStuff(); DrawRateStuff();
@ -334,6 +339,7 @@ public:
virtual int Backend() { return 0; } virtual int Backend() { return 0; }
virtual const char* DeviceName() const { return "Unknown"; } virtual const char* DeviceName() const { return "Unknown"; }
virtual void Draw2D() {} virtual void Draw2D() {}
virtual void WriteSavePic(FileWriter *file, int width, int height);
// Screen wiping // Screen wiping
virtual FTexture *WipeStartScreen(); virtual FTexture *WipeStartScreen();

View file

@ -46,6 +46,7 @@
#include "s_music.h" #include "s_music.h"
#include "quotemgr.h" #include "quotemgr.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "v_video.h"
static CompositeSavegameWriter savewriter; static CompositeSavegameWriter savewriter;
static FResourceFile *savereader; static FResourceFile *savereader;
@ -64,12 +65,6 @@ static FResourceFile *savereader;
//============================================================================= //=============================================================================
void OpenSaveGameForWrite(const char *name)
{
savewriter.Clear();
savewriter.SetFileName(name);
}
bool OpenSaveGameForRead(const char *name) bool OpenSaveGameForRead(const char *name)
{ {
if (savereader) delete savereader; if (savereader) delete savereader;
@ -126,16 +121,20 @@ void FinishSavegameRead()
//============================================================================= //=============================================================================
// //
// Writes the header which is used to display the savegame in the menu. // Creates the savegame and writes all cross-game content.
// //
//============================================================================= //=============================================================================
void G_WriteSaveHeader(const char *name) bool OpenSaveGameForWrite(const char* filename, const char *name)
{ {
savewriter.Clear();
savewriter.SetFileName(filename);
sjson_context* ctx = sjson_create_context(0, 0, NULL); sjson_context* ctx = sjson_create_context(0, 0, NULL);
if (!ctx) if (!ctx)
{ {
return; savewriter.Clear();
return false;
} }
sjson_node* root = sjson_mkobject(ctx); sjson_node* root = sjson_mkobject(ctx);
auto savesig = gi->GetSaveSig(); auto savesig = gi->GetSaveSig();
@ -143,9 +142,13 @@ void G_WriteSaveHeader(const char *name)
sjson_put_string(ctx, root, "Engine", savesig.savesig); sjson_put_string(ctx, root, "Engine", savesig.savesig);
sjson_put_string(ctx, root, "Game Resource", fileSystem.GetResourceFileName(1)); sjson_put_string(ctx, root, "Game Resource", fileSystem.GetResourceFileName(1));
sjson_put_string(ctx, root, "Map Name", currentLevel->DisplayName()); sjson_put_string(ctx, root, "Map Name", currentLevel->DisplayName());
sjson_put_string(ctx, root, "Creation Time", myasctime());
sjson_put_string(ctx, root, "Title", name); sjson_put_string(ctx, root, "Title", name);
sjson_put_string(ctx, root, "Map File", currentLevel->fileName); sjson_put_string(ctx, root, "Map File", currentLevel->fileName);
sjson_put_string(ctx, root, "Map Label", currentLevel->labelName); sjson_put_string(ctx, root, "Map Label", currentLevel->labelName);
auto gs = gi->getStats();
FStringf timeStr("%02d:%02d", gs.timesecnd / 60, gs.timesecnd % 60);
sjson_put_string(ctx, root, "Map Time", timeStr);
const char *fn = currentLevel->fileName; const char *fn = currentLevel->fileName;
if (*fn == '/') fn++; if (*fn == '/') fn++;
if (strncmp(fn, "file://", 7) != 0) // this only has meaning for non-usermaps if (strncmp(fn, "file://", 7) != 0) // this only has meaning for non-usermaps
@ -154,7 +157,11 @@ void G_WriteSaveHeader(const char *name)
auto mapfile = fileSystem.GetFileContainer(fileno); auto mapfile = fileSystem.GetFileContainer(fileno);
auto mapcname = fileSystem.GetResourceFileName(mapfile); auto mapcname = fileSystem.GetResourceFileName(mapfile);
if (mapcname) sjson_put_string(ctx, root, "Map Resource", mapcname); if (mapcname) sjson_put_string(ctx, root, "Map Resource", mapcname);
else return; // this should never happen. Saving on a map that isn't present is impossible. else
{
savewriter.Clear();
return false; // this should never happen. Saving on a map that isn't present is impossible.
}
} }
char* encoded = sjson_stringify(ctx, root, " "); char* encoded = sjson_stringify(ctx, root, " ");
@ -163,7 +170,8 @@ void G_WriteSaveHeader(const char *name)
if (!fil) if (!fil)
{ {
sjson_destroy_context(ctx); sjson_destroy_context(ctx);
return; savewriter.Clear();
return false;
} }
fil->Write(encoded, strlen(encoded)); fil->Write(encoded, strlen(encoded));
@ -176,6 +184,9 @@ void G_WriteSaveHeader(const char *name)
SECRET_Save(); SECRET_Save();
MUS_Save(); MUS_Save();
quoteMgr.WriteToSavegame(); quoteMgr.WriteToSavegame();
auto picfile = WriteSavegameChunk("savepic.png");
screen->WriteSavePic(picfile, 240, 180);
return true;
} }
//============================================================================= //=============================================================================

View file

@ -2,7 +2,7 @@
#include "filesystem/resourcefile.h" #include "filesystem/resourcefile.h"
void OpenSaveGameForWrite(const char *name); bool OpenSaveGameForWrite(const char *fname, const char *name);
bool OpenSaveGameForRead(const char *name); bool OpenSaveGameForRead(const char *name);
FileWriter *WriteSavegameChunk(const char *name); FileWriter *WriteSavegameChunk(const char *name);
@ -16,7 +16,6 @@ class FileReader;
FString G_BuildSaveName (const char *prefix); FString G_BuildSaveName (const char *prefix);
int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu); int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu);
void G_WriteSaveHeader(const char* name);
#define SAVEGAME_EXT ".dsave" #define SAVEGAME_EXT ".dsave"

View file

@ -358,7 +358,7 @@ public:
{ {
return id == 0 ? "" : S_sfx[id].name.GetChars(); return id == 0 ? "" : S_sfx[id].name.GetChars();
} }
TArray<sfxinfo_t> &GetSounds() //Thio should only be used for constructing the sound list or for diagnostics code prinring information about the sound list. TArray<sfxinfo_t> &GetSounds() //Thio should only be used for constructing the sound list or for diagnostics code printing information about the sound list.
{ {
return S_sfx; return S_sfx;
} }

View file

@ -511,3 +511,129 @@ int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion)
} }
//==========================================================================
//
// A savegame picture
// This is essentially a stripped down version of the PNG texture
// only supporting the features actually present in a savegame
// that does not use an image source, because image sources are not
// meant to be transient data like the savegame picture.
//
//==========================================================================
class FPNGFileTexture : public FTexture
{
public:
FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype);
virtual FBitmap GetBgraBitmap(const PalEntry *remap, int *trans) override;
protected:
FileReader fr;
uint8_t ColorType;
int PaletteSize;
};
//==========================================================================
//
//
//
//==========================================================================
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{
if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
{
return nullptr;
}
// Savegame images can only be either 8 bit paletted or 24 bit RGB
auto &data = png->File;
int width = data.ReadInt32BE();
int height = data.ReadInt32BE();
uint8_t bitdepth = data.ReadUInt8();
uint8_t colortype = data.ReadUInt8();
uint8_t compression = data.ReadUInt8();
uint8_t filter = data.ReadUInt8();
uint8_t interlace = data.ReadUInt8();
// Reject anything that cannot be put into a savegame picture by GZDoom itself.
if (compression != 0 || filter != 0 || interlace > 0 || bitdepth != 8 || (colortype != 2 && colortype != 3)) return nullptr;
else return new FPNGFileTexture (png->File, width, height, colortype);
}
//==========================================================================
//
//
//
//==========================================================================
FPNGFileTexture::FPNGFileTexture (FileReader &lump, int width, int height, uint8_t colortype)
: ColorType(colortype)
{
Size.x = width;
Size.y = height;
fr = std::move(lump);
}
//===========================================================================
//
// FPNGTexture::CopyPixels
//
//===========================================================================
FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans)
{
FBitmap bmp;
// Parse pre-IDAT chunks. I skip the CRCs. Is that bad?
PalEntry pe[256];
uint32_t len, id;
int pixwidth = Size.x * (ColorType == 2? 3:1);
FileReader *lump = &fr;
bmp.Create(Size.x, Size.y);
lump->Seek(33, FileReader::SeekSet);
lump->Read(&len, 4);
lump->Read(&id, 4);
while (id != MAKE_ID('I','D','A','T') && id != MAKE_ID('I','E','N','D'))
{
len = BigLong((unsigned int)len);
if (id != MAKE_ID('P','L','T','E'))
lump->Seek (len, FileReader::SeekCur);
else
{
PaletteSize = std::min<int> (len / 3, 256);
for(int i = 0; i < PaletteSize; i++)
{
pe[i].r = lump->ReadUInt8();
pe[i].g = lump->ReadUInt8();
pe[i].b = lump->ReadUInt8();
pe[i].a = 255;
}
}
lump->Seek(4, FileReader::SeekCur); // Skip CRC
lump->Read(&len, 4);
id = MAKE_ID('I','E','N','D');
lump->Read(&id, 4);
}
auto StartOfIDAT = (uint32_t)lump->Tell() - 8;
TArray<uint8_t> Pixels(pixwidth * Size.y);
lump->Seek (StartOfIDAT, FileReader::SeekSet);
lump->Read(&len, 4);
lump->Read(&id, 4);
M_ReadIDAT (*lump, Pixels.Data(), Size.x, Size.y, pixwidth, 8, ColorType, 0, BigLong((unsigned int)len));
if (ColorType == 3)
{
bmp.CopyPixelData(0, 0, Pixels.Data(), Size.x, Size.y, 1, Size.x, 0, pe);
}
else
{
bmp.CopyPixelDataRGB(0, 0, Pixels.Data(), Size.x, Size.y, 3, pixwidth, 0, CF_RGB);
}
return bmp;
}

View file

@ -139,7 +139,6 @@ class FSerializer;
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
class FGLRenderState; class FGLRenderState;
class FHardwareTexture;
} }
union FContentIdBuilder union FContentIdBuilder

View file

@ -50,4 +50,6 @@ xx(Alresamplers)
xx(AdvSoundOptions) xx(AdvSoundOptions)
xx(JoystickConfigMenu) xx(JoystickConfigMenu)
xx(JoystickOptions) xx(JoystickOptions)
xx(EngineCredits)
xx(EngineCredits2)

View file

@ -66,7 +66,6 @@ set( PCH_SOURCES
src/gameexec.cpp src/gameexec.cpp
src/gamevars.cpp src/gamevars.cpp
src/global.cpp src/global.cpp
src/menus.cpp
src/namesdyn.cpp src/namesdyn.cpp
src/network.cpp src/network.cpp
src/osdcmds.cpp src/osdcmds.cpp

View file

@ -315,9 +315,13 @@ typedef struct netactor_s
ext_pitch, ext_pitch,
ext_roll, ext_roll,
ext_offset_x, ext_pivot_offset_x,
ext_offset_y, ext_pivot_offset_y,
ext_offset_z, ext_pivot_offset_z,
ext_position_offset_x,
ext_position_offset_y,
ext_position_offset_z,
ext_flags, ext_flags,
ext_xpanning, ext_xpanning,

View file

@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "cmdlib.h" #include "cmdlib.h"
#include "compat.h" #include "compat.h"
#include "build.h" #include "build.h"
#include "v_2ddrawer.h"
#include "../glbackend/glbackend.h" #include "../glbackend/glbackend.h"
@ -303,6 +304,7 @@ int32_t Anim_Play(const char *fn)
// OSD_Printf("msecs per frame: %d\n", msecsperframe); // OSD_Printf("msecs per frame: %d\n", msecsperframe);
GLInterface.EnableNonTransparent255(true); GLInterface.EnableNonTransparent255(true);
do do
{ {
nextframetime += msecsperframe; nextframetime += msecsperframe;
@ -325,7 +327,7 @@ int32_t Anim_Play(const char *fn)
VM_OnEventWithReturn(EVENT_PRECUTSCENE, g_player[screenpeek].ps->i, screenpeek, framenum); VM_OnEventWithReturn(EVENT_PRECUTSCENE, g_player[screenpeek].ps->i, screenpeek, framenum);
videoClearScreen(0); twod->ClearScreen();
ototalclock = totalclock + 1; // pause game like ANMs ototalclock = totalclock + 1; // pause game like ANMs
@ -376,12 +378,7 @@ int32_t Anim_Play(const char *fn)
} }
} }
// this and showframe() instead of nextpage() are so that videoNextPage();
// nobody tramples on our carefully set up GL state!
palfadedelta = 0;
videoShowFrame(0);
// inputState.ClearAllInput();
do do
{ {
@ -395,8 +392,9 @@ int32_t Anim_Play(const char *fn)
} while (timerGetTicks() < nextframetime); } while (timerGetTicks() < nextframetime);
} while (running); } while (running);
GLInterface.EnableNonTransparent255(false); GLInterface.EnableNonTransparent255(false);
#ifdef DEBUGGINGAIDS
animvpx_print_stats(&codec); animvpx_print_stats(&codec);
#endif
// //
animvpx_restore_glstate(); animvpx_restore_glstate();

View file

@ -172,7 +172,7 @@ void G_OpenDemoWrite(void)
if (g_demo_filePtr == NULL) if (g_demo_filePtr == NULL)
return; return;
i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1); i=sv_saveandmakesnapshot(*g_demo_filePtr, -1);
if (i) if (i)
{ {
delete g_demo_filePtr; delete g_demo_filePtr;

View file

@ -145,6 +145,7 @@ struct GameInterface : ::GameInterface
int app_main() override; int app_main() override;
void UpdateScreenSize() override; void UpdateScreenSize() override;
void FreeGameData() override; void FreeGameData() override;
bool GenerateSavePic() override;
bool validate_hud(int) override; bool validate_hud(int) override;
void set_hud_layout(int size) override; void set_hud_layout(int size) override;
void set_hud_scale(int size) override; void set_hud_scale(int size) override;

View file

@ -725,6 +725,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
"other values are reserved.\n"); "other values are reserved.\n");
#endif #endif
screen->BeginScene();
#ifdef LEGACY_ROR #ifdef LEGACY_ROR
G_SE40(smoothRatio); G_SE40(smoothRatio);
#endif #endif
@ -737,6 +738,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
yax_drawrooms(G_DoSpriteAnimations, pSprite->sectnum, 0, smoothRatio); yax_drawrooms(G_DoSpriteAnimations, pSprite->sectnum, 0, smoothRatio);
G_DoSpriteAnimations(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, fix16_to_int(CAMERA(q16ang)), smoothRatio); G_DoSpriteAnimations(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, fix16_to_int(CAMERA(q16ang)), smoothRatio);
renderDrawMasks(); renderDrawMasks();
screen->FinishScene();
} }
} }
else else
@ -760,14 +762,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
else else
renderSetAspect(mulscale16(vr, viewingrange), yxaspect); renderSetAspect(mulscale16(vr, viewingrange), yxaspect);
if (g_screenCapture) if (screenTilting)
{
TileFiles.tileCreate(TILE_SAVESHOT, 200, 320);
//if (videoGetRenderMode() == REND_CLASSIC)
renderSetTarget(TILE_SAVESHOT, 200, 320);
}
else if (screenTilting)
{ {
int32_t oviewingrange = viewingrange; // save it from renderSetAspect() int32_t oviewingrange = viewingrange; // save it from renderSetAspect()
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0; const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
@ -848,23 +843,15 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
} }
else if (videoGetRenderMode() >= REND_POLYMOST) else if (videoGetRenderMode() >= REND_POLYMOST)
{ {
if (ud.screen_tilting if (ud.screen_tilting)
#ifdef SPLITSCREEN_MOD_HACKS
&& !g_fakeMultiMode
#endif
)
{ {
#ifdef USE_OPENGL
renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio)); renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio));
#endif
pPlayer->orotscrnang = pPlayer->rotscrnang; pPlayer->orotscrnang = pPlayer->rotscrnang;
} }
#ifdef USE_OPENGL
else else
{ {
renderSetRollAngle(0); renderSetRollAngle(0);
} }
#endif
} }
if (pPlayer->newowner < 0) if (pPlayer->newowner < 0)
@ -981,6 +968,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMS return value must be 0 or 1, " OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMS return value must be 0 or 1, "
"other values are reserved.\n"); "other values are reserved.\n");
#endif #endif
screen->BeginScene();
G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio); G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(q16ang), CAMERA(q16horiz), smoothRatio);
G_ClearGotMirror(); G_ClearGotMirror();
@ -1010,24 +998,10 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
#endif #endif
renderDrawMasks(); renderDrawMasks();
#endif #endif
screen->FinishScene();
} }
if (g_screenCapture) if (screenTilting)
{
g_screenCapture = 0;
tileInvalidate(TILE_SAVESHOT, 0, 255);
//if (videoGetRenderMode() == REND_CLASSIC)
{
renderRestoreTarget();
}
#ifdef USE_OPENGL
//else
// G_ReadGLFrame();
#endif
}
else if (screenTilting)
{ {
const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0; const int16_t tang = (ud.screen_tilting) ? pPlayer->rotscrnang : 0;
@ -1111,6 +1085,14 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
VM_OnEvent(EVENT_DISPLAYROOMSEND, g_player[screenpeek].ps->i, screenpeek); VM_OnEvent(EVENT_DISPLAYROOMSEND, g_player[screenpeek].ps->i, screenpeek);
} }
bool GameInterface::GenerateSavePic()
{
G_DrawRooms(myconnectindex, 65536);
return true;
}
void G_DumpDebugInfo(void) void G_DumpDebugInfo(void)
{ {
static char const s_WEAPON[] = "WEAPON"; static char const s_WEAPON[] = "WEAPON";
@ -5898,12 +5880,6 @@ MAIN_LOOP_RESTART:
} }
if (g_networkMode != NET_DEDICATED_SERVER)
{
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
}
if (ud.warp_on == 1) if (ud.warp_on == 1)
{ {
G_NewGame_EnterLevel(); G_NewGame_EnterLevel();

View file

@ -236,11 +236,6 @@ extern int32_t voting;
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen; //extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
extern palette_t CrosshairColors;
extern palette_t DefaultCrosshairColors;
int32_t A_CheckInventorySprite(spritetype *s); int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr, int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss); uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
@ -282,12 +277,10 @@ void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_GameExit(const char *msg) ATTRIBUTE((noreturn)); void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
void G_GameQuit(void); void G_GameQuit(void);
void G_GetCrosshairColor(void);
void G_HandleLocalKeys(void); void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void); void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(int32_t snum); void G_PrintGameQuotes(int32_t snum);
//void G_SE40(int32_t smoothratio); //void G_SE40(int32_t smoothratio);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_Shutdown(void); void G_Shutdown(void);
void G_UpdatePlayerFromMenu(void); void G_UpdatePlayerFromMenu(void);
void P_DoQuote(int32_t q,DukePlayer_t *p); void P_DoQuote(int32_t q,DukePlayer_t *p);

View file

@ -737,9 +737,12 @@ enum ActorLabel_t
ACTOR_ANGOFF = ACTOR_SPRITEEXT_BEGIN, ACTOR_ANGOFF = ACTOR_SPRITEEXT_BEGIN,
ACTOR_PITCH, ACTOR_PITCH,
ACTOR_ROLL, ACTOR_ROLL,
ACTOR_MDXOFF, ACTOR_MDPIVOTXOFF,
ACTOR_MDYOFF, ACTOR_MDPIVOTYOFF,
ACTOR_MDZOFF, ACTOR_MDPIVOTZOFF,
ACTOR_MDPOSITIONXOFF,
ACTOR_MDPOSITIONYOFF,
ACTOR_MDPOSITIONZOFF,
ACTOR_MDFLAGS, ACTOR_MDFLAGS,
ACTOR_XPANNING, ACTOR_XPANNING,
ACTOR_YPANNING, ACTOR_YPANNING,

View file

@ -42,6 +42,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "quotemgr.h" #include "quotemgr.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "version.h" #include "version.h"
#include "v_video.h"
#include "debugbreak.h" #include "debugbreak.h"
@ -1214,6 +1215,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int sect, i
renderSetAspect(viewingRange, yxAspect); renderSetAspect(viewingRange, yxAspect);
int const smoothratio = calc_smoothratio(totalclock, ototalclock); int const smoothratio = calc_smoothratio(totalclock, ototalclock);
G_DoInterpolations(smoothratio); G_DoInterpolations(smoothratio);
screen->BeginScene();
if (!display_mirror) if (!display_mirror)
G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio); G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio);
#ifdef POLYMER #ifdef POLYMER
@ -1228,6 +1230,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int sect, i
G_DoSpriteAnimations(vec.x, vec.y, vec.z, fix16_to_int(a), smoothratio); G_DoSpriteAnimations(vec.x, vec.y, vec.z, fix16_to_int(a), smoothratio);
display_mirror = 0; display_mirror = 0;
renderDrawMasks(); renderDrawMasks();
screen->FinishScene();
G_RestoreInterpolations(); G_RestoreInterpolations();
G_UpdateScreenArea(); G_UpdateScreenArea();
renderSetAspect(viewingRange, yxAspect); renderSetAspect(viewingRange, yxAspect);

View file

@ -305,9 +305,12 @@ const memberlabel_t ActorLabels[]=
LABEL_SETUP(spriteext, pitch, ACTOR_PITCH), LABEL_SETUP(spriteext, pitch, ACTOR_PITCH),
LABEL_SETUP(spriteext, roll, ACTOR_ROLL), LABEL_SETUP(spriteext, roll, ACTOR_ROLL),
LABEL_SETUP_UNMATCHED(spriteext, offset.x, "mdxoff", ACTOR_MDXOFF), LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.x, "mdxoff", ACTOR_MDPIVOTXOFF),
LABEL_SETUP_UNMATCHED(spriteext, offset.y, "mdyoff", ACTOR_MDYOFF), LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.y, "mdyoff", ACTOR_MDPIVOTYOFF),
LABEL_SETUP_UNMATCHED(spriteext, offset.z, "mdzoff", ACTOR_MDZOFF), LABEL_SETUP_UNMATCHED(spriteext, pivot_offset.z, "mdzoff", ACTOR_MDPIVOTZOFF),
LABEL_SETUP_UNMATCHED(spriteext, position_offset.x, "mdposxoff", ACTOR_MDPOSITIONXOFF),
LABEL_SETUP_UNMATCHED(spriteext, position_offset.y, "mdposyoff", ACTOR_MDPOSITIONYOFF),
LABEL_SETUP_UNMATCHED(spriteext, position_offset.z, "mdposzoff", ACTOR_MDPOSITIONZOFF),
LABEL_SETUP_UNMATCHED(spriteext, flags, "mdflags", ACTOR_MDFLAGS), LABEL_SETUP_UNMATCHED(spriteext, flags, "mdflags", ACTOR_MDFLAGS),
LABEL_SETUP(spriteext, xpanning, ACTOR_XPANNING), LABEL_SETUP(spriteext, xpanning, ACTOR_XPANNING),

View file

@ -147,7 +147,6 @@ G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
G_EXTERN int32_t g_noEnemies; G_EXTERN int32_t g_noEnemies;
G_EXTERN int32_t g_restorePalette; G_EXTERN int32_t g_restorePalette;
G_EXTERN int32_t g_screenCapture;
G_EXTERN projectile_t SpriteProjectile[MAXSPRITES]; G_EXTERN projectile_t SpriteProjectile[MAXSPRITES];
G_EXTERN uint32_t everyothertime; G_EXTERN uint32_t everyothertime;
G_EXTERN uint32_t g_moveThingsCount; G_EXTERN uint32_t g_moveThingsCount;

View file

@ -1,225 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2016 EDuke32 developers and contributors
This file is part of EDuke32.
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "cheats.h"
#include "compat.h"
#include "demo.h"
#include "duke3d.h"
#include "menus.h"
#include "osdcmds.h"
#include "savegame.h"
#include "superfasthash.h"
#include "gamecvars.h"
#include "gamecontrol.h"
#include "c_bind.h"
#include "../../glbackend/glbackend.h"
bool ShowOptionMenu();
namespace ImGui
{
void ShowDemoWindow(bool*);
}
BEGIN_DUKE_NS
#if 0
void Menu_Init(void)
{
int32_t i, j, k;
if (FURY)
// prepare shareware
if (VOLUMEONE)
{
// blue out episodes beyond the first
for (i = 1; i < g_volumeCnt; ++i)
{
if (MEL_EPISODE[i])
{
ME_EPISODE[i].entry = &MEO_EPISODE_SHAREWARE;
ME_EPISODE[i].flags |= MEF_LookDisabled;
}
}
M_EPISODE.numEntries = g_volumeCnt; // remove User Map (and spacer)
MEOS_NETOPTIONS_EPISODE.numOptions = 1;
MenuEntry_DisableOnCondition(&ME_NETOPTIONS_EPISODE, 1);
}
}
static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
{
int32_t i, j, l = 0;
switch (cm)
{
case MENU_CREDITS4: // JBF 20031220
{
#define MENU_YOFFSET 40
#define MENU_INCREMENT(x) (oy += ((x) << 16)) // maybe this should have been MENU_EXCREMENT instead
int32_t oy = origin.y;
mgametextcenter(origin.x, MENU_INCREMENT(MENU_YOFFSET), "Developers");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Richard \"TerminX\" Gobeille", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Evan \"Hendricks266\" Ramos", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Alex \"pogokeen\" Dawson", 8);
mgametextcenter(origin.x, MENU_INCREMENT(11), "Retired developers");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Pierre-Loup \"Plagman\" Griffais", 8);
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(7), "Philipp \"Helixhorned\" Kutin", 8);
mgametextcenter(origin.x, MENU_INCREMENT(11), "Special thanks to");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Jonathon \"JonoF\" Fowler", 8);
mgametextcenter(origin.x, MENU_INCREMENT(11), "Uses BUILD Engine technology by");
creditsminitext(origin.x + (160 << 16), MENU_INCREMENT(11), "Ken \"Awesoken\" Silverman", 8);
#undef MENU_INCREMENT
#undef MENU_YOFFSET
}
break;
case MENU_CREDITS5:
l = 7;
mgametextcenter(origin.x, origin.y + ((38-l)<<16), "License and Other Contributors");
{
static const char *header[] =
{
"This program is distributed under the terms of the",
"GNU General Public License version 2 as published by the",
"Free Software Foundation. See gpl-2.0.txt for details.",
"BUILD engine technology available under license. See buildlic.txt.",
nullptr,
"The EDuke32 team thanks the following people for their contributions:",
nullptr,
};
static const char *body[] =
{
"Alexey Skrybykin", // Nuke.YKT - Polymost fixes
"Bioman", // GTK work, APT repository and package upkeep
"Brandon Bergren", // "Bdragon" - tiles.cfg
"Charlie Honig", // "CONAN" - showview command
"Dan Gaskill", // "DeeperThought" - testing
"David Koenig", // "Bargle" - Merged a couple of things from duke3d_w32
"Ed Coolidge", // Mapster32 improvements
"Emile Belanger", // original Android work
"Fox", // various patches
"Hunter_rus", // tons of stuff
"James Bentler", // Mapster32 improvements
"Jasper Foreman", // netcode contributions
"Javier Martinez", // "Malone3D" - EDuke 2.1.1 components
"Jeff Hart", // website graphics
"Jonathan Strander", // "Mblackwell" - testing and feature speccing
"Jordon Moss", // "Striker" - various patches, OldMP work
"Jose del Castillo", // "Renegado" - EDuke 2.1.1 components
"Lachlan McDonald", // official EDuke32 icon
"LSDNinja", // OS X help and testing
"Marcus Herbert", // "rhoenie" - OS X compatibility work
"Matthew Palmer", // "Usurper" - testing and eduke32.com domain
"Matt Saettler", // original DOS EDuke/WW2GI enhancements
"NY00123", // Linux / SDL usability patches
"Ozkan Sezer", // SDL/GTK version checking improvements
"Peter Green", // "Plugwash" - dynamic remapping, custom gametypes
"Peter Veenstra", // "Qbix" - port to 64-bit
"Robin Green", // CON array support
"Ryan Gordon", // "icculus" - icculus.org Duke3D port sound code
"Stephen Anthony", // early 64-bit porting work
"tueidj", // Wii port
};
EDUKE32_STATIC_ASSERT(ARRAY_SIZE(body) % 3 == 0);
static const char *footer[] =
{
nullptr,
"Visit eduke32.com for news and updates",
};
static constexpr int header_numlines = ARRAY_SIZE(header);
static constexpr int body_numlines = ARRAY_SIZE(body);
static constexpr int footer_numlines = ARRAY_SIZE(footer);
static constexpr int CCOLUMNS = 3;
static constexpr int CCOLXBUF = 20;
int c;
i = 0;
for (c = 0; c < header_numlines; c++)
if (header[c])
creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)-l)<<16), header[c], 8);
i += c;
for (c = 0; c < body_numlines; c++)
if (body[c])
creditsminitext(origin.x + ((CCOLXBUF+((320-CCOLXBUF*2)/(CCOLUMNS*2)) +((320-CCOLXBUF*2)/CCOLUMNS)*(c/(body_numlines/CCOLUMNS)))<<16), origin.y + ((17+10+10+8+4+((c%(body_numlines/CCOLUMNS))*7)+(i*7)-l)<<16), body[c], 8);
i += c/CCOLUMNS;
for (c = 0; c < footer_numlines; c++)
if (footer[c])
creditsminitext(origin.x + (160<<16), origin.y + ((17+10+10+8+4+(c*7)+(i*7)-l)<<16), footer[c], 8);
}
break;
default:
break;
}
}
/*
Functions where a "newValue" or similar is passed are run *before* the linked variable is actually changed.
That way you can compare the new and old values and potentially block the change.
*/
static void Menu_EntryLinkActivate(MenuEntry_t *entry)
{
else if (entry == &ME_NETHOST_LAUNCH)
{
// master does whatever it wants
if (g_netServer)
{
Net_FillNewGame(&pendingnewgame, 1);
Net_StartNewGame();
Net_SendNewGame(1, NULL);
}
else if (voting == -1)
{
Net_SendMapVoteInitiate();
Menu_Change(MENU_NETWAITVOTES);
}
}
}
#endif
END_DUKE_NS

View file

@ -57,91 +57,6 @@ inline int G_CheckPlayerColor(int color)
} }
#if 0
enum MenuIndex_t {
MENU_NULL = INT32_MIN, // sentinel for "do nothing"
MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu"
MENU_PREVIOUS = -1, // sentinel for "go to previous menu"
MENU_MAIN = 0, // done
MENU_MAIN_INGAME = 50, // done
MENU_EPISODE = 100, // done
MENU_USERMAP = 101,
MENU_NEWGAMECUSTOM = 102, // done
MENU_NEWGAMECUSTOMSUB = 103,// done
MENU_SKILL = 110, // done
MENU_OPTIONS = 202,
MENU_GAMESETUP = 200,
MENU_CHEATS = 800, // IF script hacked
MENU_CHEATENTRY = 801, // IF script hacked
MENU_CHEAT_WARP = 802,
MENU_CHEAT_SKILL = 803,
MENU_DISPLAYSETUP = 234,
MENU_SCREENSETUP = 233, // HUD
MENU_COLCORR = 231, // color correction
MENU_COLCORR_INGAME = 232, // almost the same for ingame - not needed
MENU_VIDEOSETUP = 203,
MENU_POLYMOST = 230,
MENU_POLYMER = 240, // Who needs a renderer that's folding performance-wise with a single light?
MENU_SOUND = 700,
MENU_SOUND_INGAME = 701, // Just the same with different exit logic.
MENU_ADVSOUND = 702, // Only needed for space reasons. Fold into main sound menu.
MENU_PLAYER = 20002,
MENU_MACROS = 20004,
MENU_CONTROLS = 220,
MENU_KEYBOARDSETUP = 204,
MENU_KEYBOARDKEYS = 209,
MENU_MOUSESETUP = 205,
MENU_MOUSEBTNS = 210, // folded with keyboard
MENU_MOUSEADVANCED = 212,
MENU_JOYSTICKSETUP = 206,
MENU_JOYSTICKBTNS = 207,
MENU_JOYSTICKAXES = 208,
MENU_JOYSTICKAXIS = 213,
MENU_LOAD = 300,
MENU_SAVE = 350,
MENU_STORY = 400,
MENU_F1HELP = 401,
MENU_CREDITS = 990,
MENU_CREDITS2 = 991,
MENU_CREDITS3 = 992,
MENU_CREDITS4 = 993,
MENU_CREDITS5 = 994,
MENU_QUIT = 500,
MENU_QUITTOTITLE = 501,
MENU_QUIT_INGAME = 502,
MENU_SAVESETUP = 750,
MENU_SAVECLEANVERIFY = 751,
MENU_LOADVERIFY = 1000,
MENU_LOADDELVERIFY = 1100,
MENU_NEWVERIFY = 1500,
MENU_SAVEVERIFY = 2000,
MENU_SAVEDELVERIFY = 2100,
MENU_COLCORRRESETVERIFY = 2200,
MENU_KEYSRESETVERIFY = 2201,
MENU_KEYSCLASSICVERIFY = 2202,
MENU_JOYSTANDARDVERIFY = 2203,
MENU_JOYPROVERIFY = 2204,
MENU_JOYCLEARVERIFY = 2205,
MENU_ADULTPASSWORD = 10001,
MENU_RESETPLAYER = 15000,
MENU_BUYDUKE = 20000,
MENU_NETSETUP = 600,
MENU_NETWAITMASTER = 601,
MENU_NETWAITVOTES = 603,
MENU_NETWORK = 20001,
MENU_NETHOST = 20010,
MENU_NETOPTIONS = 20011,
MENU_NETUSERMAP = 20012,
MENU_NETJOIN = 20020,
};
#endif
END_DUKE_NS END_DUKE_NS
#endif #endif

View file

@ -402,9 +402,13 @@ static netField_t ActorFields[] =
{ ACTF(ext_pitch), 16 }, { ACTF(ext_pitch), 16 },
{ ACTF(ext_roll), 16 }, { ACTF(ext_roll), 16 },
{ ACTF(ext_offset_x), 32 }, { ACTF(ext_pivot_offset_x), 32 },
{ ACTF(ext_offset_y), 32 }, { ACTF(ext_pivot_offset_y), 32 },
{ ACTF(ext_offset_z), 32 }, { ACTF(ext_pivot_offset_z), 32 },
{ ACTF(ext_position_offset_x), 32 },
{ ACTF(ext_position_offset_y), 32 },
{ ACTF(ext_position_offset_z), 32 },
{ ACTF(ext_flags), 8 }, { ACTF(ext_flags), 8 },
{ ACTF(ext_xpanning), 8 }, { ACTF(ext_xpanning), 8 },
@ -453,12 +457,12 @@ static uint32_t g_cl_InterpolatedRevision = 0;
static netmapstate_t g_mapStartState; static netmapstate_t g_mapStartState;
static netmapstate_t g_cl_InterpolatedMapStateHistory[NET_REVISIONS]; static TArray<netmapstate_t> g_cl_InterpolatedMapStateHistory;
// note that the map state number is not an index into here, // note that the map state number is not an index into here,
// to get the index into this array out of a map state number, do <Map state number> % NET_REVISONS // to get the index into this array out of a map state number, do <Map state number> % NET_REVISONS
static netmapstate_t g_mapStateHistory[NET_REVISIONS]; static TArray<netmapstate_t> g_mapStateHistory;
static uint8_t tempnetbuf[MAX_WORLDBUFFER]; static TArray<uint8_t> tempnetbuf;
// Remember that this constant needs to be one bit longer than a struct index, so it can't be mistaken for a valid wall, sprite, or sector index // Remember that this constant needs to be one bit longer than a struct index, so it can't be mistaken for a valid wall, sprite, or sector index
static const int32_t cSTOP_PARSING_CODE = ((1 << NETINDEX_BITS) - 1); static const int32_t cSTOP_PARSING_CODE = ((1 << NETINDEX_BITS) - 1);
@ -1020,9 +1024,13 @@ static void Net_CopySpriteExtFromNet(const netactor_t* netActor, spriteext_t* ga
gameSprExt->pitch = netActor->ext_pitch; gameSprExt->pitch = netActor->ext_pitch;
gameSprExt->roll = netActor->ext_roll; gameSprExt->roll = netActor->ext_roll;
gameSprExt->offset.x = netActor->ext_offset_x; gameSprExt->pivot_offset.x = netActor->ext_pivot_offset_x;
gameSprExt->offset.y = netActor->ext_offset_y; gameSprExt->pivot_offset.y = netActor->ext_pivot_offset_y;
gameSprExt->offset.z = netActor->ext_offset_z; gameSprExt->pivot_offset.z = netActor->ext_pivot_offset_z;
gameSprExt->position_offset.x = netActor->ext_position_offset_x;
gameSprExt->position_offset.y = netActor->ext_position_offset_y;
gameSprExt->position_offset.z = netActor->ext_position_offset_z;
gameSprExt->flags = netActor->ext_flags; gameSprExt->flags = netActor->ext_flags;
gameSprExt->xpanning = netActor->ext_xpanning; gameSprExt->xpanning = netActor->ext_xpanning;
@ -1375,9 +1383,13 @@ static void Net_CopySpriteExtToNet(const spriteext_t* gameSpriteExt, netactor_t*
netActor->ext_pitch = gameSpriteExt->pitch; netActor->ext_pitch = gameSpriteExt->pitch;
netActor->ext_roll = gameSpriteExt->roll; netActor->ext_roll = gameSpriteExt->roll;
netActor->ext_offset_x = gameSpriteExt->offset.x; netActor->ext_pivot_offset_x = gameSpriteExt->pivot_offset.x;
netActor->ext_offset_y = gameSpriteExt->offset.y; netActor->ext_pivot_offset_y = gameSpriteExt->pivot_offset.y;
netActor->ext_offset_z = gameSpriteExt->offset.z; netActor->ext_pivot_offset_z = gameSpriteExt->pivot_offset.z;
netActor->ext_position_offset_x = gameSpriteExt->position_offset.x;
netActor->ext_position_offset_y = gameSpriteExt->position_offset.y;
netActor->ext_position_offset_z = gameSpriteExt->position_offset.z;
netActor->ext_flags = gameSpriteExt->flags; netActor->ext_flags = gameSpriteExt->flags;
netActor->ext_xpanning = gameSpriteExt->xpanning; netActor->ext_xpanning = gameSpriteExt->xpanning;
@ -4199,8 +4211,8 @@ static void Net_SendWorldUpdate(uint32_t fromRevisionNumber, uint32_t toRevision
return; return;
} }
Bassert(MAX_WORLDBUFFER == ARRAY_SIZE(tempnetbuf)); //Bassert(MAX_WORLDBUFFER == ARRAY_SIZE(tempnetbuf));
Bassert(NET_REVISIONS == ARRAY_SIZE(g_mapStateHistory)); //Bassert(NET_REVISIONS == ARRAY_SIZE(g_mapStateHistory));
uint32_t playerRevisionIsTooOld = (toRevisionNumber - fromRevisionNumber) > NET_REVISIONS; uint32_t playerRevisionIsTooOld = (toRevisionNumber - fromRevisionNumber) > NET_REVISIONS;
@ -4938,7 +4950,7 @@ void Net_SendServerUpdates(void)
serverupdate.pause_on = ud.pause_on; serverupdate.pause_on = ud.pause_on;
serverupdate.numplayers = 0; serverupdate.numplayers = 0;
updatebuf = tempnetbuf + sizeof(serverupdate_t); updatebuf = tempnetbuf.Data() + sizeof(serverupdate_t);
for (TRAVERSE_CONNECT(i)) for (TRAVERSE_CONNECT(i))
{ {
@ -4976,7 +4988,7 @@ void Net_SendServerUpdates(void)
return; return;
} }
Bmemcpy(tempnetbuf, &serverupdate, sizeof(serverupdate_t)); Bmemcpy(tempnetbuf.Data(), &serverupdate, sizeof(serverupdate_t));
enet_host_broadcast( enet_host_broadcast(
g_netServer, CHAN_MOVE, g_netServer, CHAN_MOVE,
@ -5143,6 +5155,9 @@ void Net_InitMapStateHistory()
void Net_StartNewGame() void Net_StartNewGame()
{ {
g_mapStateHistory.Resize(NET_REVISIONS);
g_cl_InterpolatedMapStateHistory.Resize(NET_REVISIONS);
tempnetbuf.Resize(MAX_WORLDBUFFER);
Net_ResetPlayers(); Net_ResetPlayers();
Net_ExtractNewGame(&pendingnewgame, 0); Net_ExtractNewGame(&pendingnewgame, 0);

View file

@ -370,27 +370,6 @@ static int osdcmd_setactorvar(osdcmdptr_t parm)
} }
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
{
if (parm->numparms != 3)
{
OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
return OSDCMD_SHOWHELP;
}
uint8_t const r = Batol(parm->parms[0]);
uint8_t const g = Batol(parm->parms[1]);
uint8_t const b = Batol(parm->parms[2]);
G_SetCrosshairColor(r,g,b);
OSD_Printf("%s\n", parm->raw);
return OSDCMD_OK;
}
static int osdcmd_give(osdcmdptr_t parm) static int osdcmd_give(osdcmdptr_t parm)
{ {
int32_t i; int32_t i;
@ -739,8 +718,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo); OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
} }
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give); OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat); OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);

View file

@ -534,9 +534,6 @@ void G_UpdateScreenArea(void)
videoSetViewableArea(v1.x, v1.y, v2.x-1, v2.y-1); videoSetViewableArea(v1.x, v1.y, v2.x-1, v2.y-1);
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
pub = NUMPAGES; pub = NUMPAGES;
pus = NUMPAGES; pus = NUMPAGES;
} }

View file

@ -27,7 +27,6 @@ BEGIN_DUKE_NS
extern int32_t g_levelTextTime; extern int32_t g_levelTextTime;
extern int32_t voting,vote_map,vote_episode; extern int32_t voting,vote_map,vote_episode;
extern palette_t CrosshairColors;
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName); void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName);
int G_EnterLevel(int gameMode); int G_EnterLevel(int gameMode);
int G_FindLevelByFile(const char *fileName); int G_FindLevelByFile(const char *fileName);
@ -35,7 +34,6 @@ void G_CacheMapData(void);
void G_FreeMapState(int levelNum); void G_FreeMapState(int levelNum);
void G_NewGame(int volumeNum, int levelNum, int skillNum); void G_NewGame(int volumeNum, int levelNum, int skillNum);
void G_ResetTimers(bool saveMoveCnt); void G_ResetTimers(bool saveMoveCnt);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_UpdateScreenArea(void); void G_UpdateScreenArea(void);
void P_MoveToRandomSpawnPoint(int playerNum); void P_MoveToRandomSpawnPoint(int playerNum);
void P_ResetInventory(int playerNum); void P_ResetInventory(int playerNum);

View file

@ -536,10 +536,6 @@ static void G_RestoreTimers(void)
bool G_SavePlayer(FSaveGameNode *sv) bool G_SavePlayer(FSaveGameNode *sv)
{ {
#ifdef __ANDROID__
G_SavePalette();
#endif
G_SaveTimers(); G_SaveTimers();
Net_WaitForServer(); Net_WaitForServer();
@ -550,7 +546,6 @@ bool G_SavePlayer(FSaveGameNode *sv)
errno = 0; errno = 0;
FileWriter *fil; FileWriter *fil;
OpenSaveGameForWrite(sv->Filename);
fil = WriteSavegameChunk("snapshot.dat"); fil = WriteSavegameChunk("snapshot.dat");
// The above call cannot fail. // The above call cannot fail.
{ {
@ -564,7 +559,7 @@ bool G_SavePlayer(FSaveGameNode *sv)
portableBackupSave(sv->Filename, sv->SaveTitle, ud.last_stateless_volume, ud.last_stateless_level); portableBackupSave(sv->Filename, sv->SaveTitle, ud.last_stateless_volume, ud.last_stateless_level);
// SAVE! // SAVE!
sv_saveandmakesnapshot(fw, sv->SaveTitle, 0); sv_saveandmakesnapshot(fw, 0);
fw.Close(); fw.Close();
@ -620,10 +615,6 @@ bool GameInterface::SaveGame(FSaveGameNode* sv)
else else
{ {
videoNextPage(); // no idea if this is needed here. videoNextPage(); // no idea if this is needed here.
g_screenCapture = 1;
//G_DrawRooms(myconnectindex, 65536);
g_screenCapture = 0;
return G_SavePlayer(sv); return G_SavePlayer(sv);
} }
} }
@ -1361,7 +1352,7 @@ static void SV_AllocSnap(int32_t allocinit)
} }
// make snapshot only if spot < 0 (demo) // make snapshot only if spot < 0 (demo)
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot) int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot)
{ {
savehead_t h; savehead_t h;
@ -1400,8 +1391,6 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot)
// savegame // savegame
auto fw = WriteSavegameChunk("header.dat"); auto fw = WriteSavegameChunk("header.dat");
fw->Write(&h, sizeof(savehead_t)); fw->Write(&h, sizeof(savehead_t));
G_WriteSaveHeader(name);
} }
else else
{ {

View file

@ -68,7 +68,7 @@ int32_t sv_readdiff(FileReader& fil);
uint32_t sv_writediff(FileWriter *fil); uint32_t sv_writediff(FileWriter *fil);
int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h); int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h);
int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h); int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h);
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot); int32_t sv_saveandmakesnapshot(FileWriter &fil, int8_t spot);
void sv_freemem(); void sv_freemem();
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh); int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh);
void ReadSaveGameHeaders(void); void ReadSaveGameHeaders(void);

View file

@ -43,8 +43,6 @@ BEGIN_DUKE_NS
#define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11) #define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11)
palette_t CrosshairColors = { 255, 255, 255, 0 };
palette_t DefaultCrosshairColors = { 0, 0, 0, 0 };
int32_t g_crosshairSum = -1; int32_t g_crosshairSum = -1;
// yxaspect and viewingrange just before the 'main' drawrooms call // yxaspect and viewingrange just before the 'main' drawrooms call
int32_t dr_yxaspect, dr_viewingrange; int32_t dr_yxaspect, dr_viewingrange;
@ -93,86 +91,6 @@ void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set)
videoSetPalette(0, palid, set); videoSetPalette(0, palid, set);
} }
void G_GetCrosshairColor(void)
{
if (FURY)
return;
if (DefaultCrosshairColors.f)
return;
tileLoad(CROSSHAIR);
auto ptr = tilePtr(CROSSHAIR);
if (!ptr) return;
// find the brightest color in the original 8-bit tile
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
int32_t bri = 0, j = 0, i;
Bassert(ii > 0);
do
{
if (*ptr != 255)
{
i = curpalette[(int32_t) *ptr].r+curpalette[(int32_t) *ptr].g+curpalette[(int32_t) *ptr].b;
if (i > j) { j = i; bri = *ptr; }
}
ptr++;
} while (--ii);
Bmemcpy(&CrosshairColors, &curpalette[bri], sizeof(palette_t));
Bmemcpy(&DefaultCrosshairColors, &curpalette[bri], sizeof(palette_t));
DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected
}
void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
{
if (FURY)
return;
if (g_crosshairSum == r+(g<<8)+(b<<16))
return;
auto ptr = TileFiles.tileMakeWritable(CROSSHAIR);
if (!ptr) return;
if (!DefaultCrosshairColors.f)
G_GetCrosshairColor();
g_crosshairSum = r+(g<<8)+(b<<16);
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
Bassert(ii > 0);
int32_t i = (videoGetRenderMode() == REND_CLASSIC)
? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b)
: paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
if (*ptr != 255)
*ptr = i;
ptr++;
} while (--ii);
paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL];
crosshairtint.r = CrosshairColors.r;
crosshairtint.g = CrosshairColors.g;
crosshairtint.b = CrosshairColors.b;
crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE;
#endif
tileInvalidate(CROSSHAIR, -1, -1);
}
#define SCORESHEETOFFSET -20 #define SCORESHEETOFFSET -20
static void G_ShowScores(void) static void G_ShowScores(void)
@ -761,23 +679,23 @@ void G_DisplayRest(int32_t smoothratio)
if (pp->palette == WATERPAL) if (pp->palette == WATERPAL)
{ {
fstint.r = 224; fstint.tint.r = 224;
fstint.g = 192; fstint.tint.g = 192;
fstint.b = 255; fstint.tint.b = 255;
fstint.f = 0; fstint.f = 0;
} }
else if (pp->palette == SLIMEPAL) else if (pp->palette == SLIMEPAL)
{ {
fstint.r = 208; fstint.tint.r = 208;
fstint.g = 255; fstint.tint.g = 255;
fstint.b = 192; fstint.tint.b = 192;
fstint.f = 0; fstint.f = 0;
} }
else else
{ {
fstint.r = 255; fstint.tint.r = 255;
fstint.g = 255; fstint.tint.g = 255;
fstint.b = 255; fstint.tint.b = 255;
fstint.f = 0; fstint.f = 0;
} }
} }
@ -956,7 +874,6 @@ void G_DisplayRest(int32_t smoothratio)
if ((unsigned) a < MAXTILES) if ((unsigned) a < MAXTILES)
{ {
vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] }; vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] };
uint8_t crosshair_pal = CROSSHAIR_PAL;
uint32_t crosshair_o = 1|2; uint32_t crosshair_o = 1|2;
uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100); uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100);
@ -966,12 +883,11 @@ void G_DisplayRest(int32_t smoothratio)
crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15); crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15);
crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15); crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15);
crosshair_scale = scale(crosshair_scale, ydim << 2, xdim * 3) >> 1; crosshair_scale = scale(crosshair_scale, ydim << 2, xdim * 3) >> 1;
crosshair_pal = 0;
crosshair_o |= 1024; crosshair_o |= 1024;
renderSetAspect(viewingrange, 65536); renderSetAspect(viewingrange, 65536);
} }
rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o); rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, 0, crosshair_o);
if (FURY) if (FURY)
renderSetAspect(viewingrange, oyxaspect); renderSetAspect(viewingrange, oyxaspect);

View file

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "printf.h" #include "printf.h"
#include "secrets.h" #include "secrets.h"
#include "v_video.h"
BEGIN_DUKE_NS BEGIN_DUKE_NS
@ -399,6 +400,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio)
OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMSCAMERATILE return value must be 0 or 1, " OSD_Printf(OSD_ERROR "ERROR: EVENT_DISPLAYROOMSCAMERATILE return value must be 0 or 1, "
"other values are reserved.\n"); "other values are reserved.\n");
#endif #endif
screen->BeginScene();
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum));
@ -408,6 +410,7 @@ static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio)
G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio); G_DoSpriteAnimations(camera.x, camera.y, camera.z, SA(spriteNum), smoothRatio);
display_mirror = saveMirror; display_mirror = saveMirror;
renderDrawMasks(); renderDrawMasks();
screen->FinishScene();
finishTileSetup: finishTileSetup:
renderRestoreTarget(); renderRestoreTarget();

View file

@ -114,6 +114,7 @@ float S_ConvertPitch(int lpitch)
int S_GetUserFlags(int num) int S_GetUserFlags(int num)
{ {
if (!soundEngine->isValidSoundId(num+1)) return 0;
auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1); auto const* snd = (sound_t*)soundEngine->GetUserData(num + 1);
if (!snd) return 0; if (!snd) return 0;
return snd->flags; return snd->flags;

View file

@ -275,6 +275,7 @@ struct GameInterface : ::GameInterface
{ {
int app_main() override; int app_main() override;
void UpdateScreenSize() override; void UpdateScreenSize() override;
bool GenerateSavePic() override;
bool validate_hud(int) override { return true; } bool validate_hud(int) override { return true; }
void set_hud_layout(int size) override {} void set_hud_layout(int size) override {}
void set_hud_scale(int size) override {} void set_hud_scale(int size) override {}

View file

@ -105,7 +105,6 @@ int32_t registerosdcommands(void)
//} //}
//OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); //OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
//OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
//OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give); //OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);

View file

@ -40,10 +40,6 @@ static TArray<SavegameHelper*> sghelpers(TArray<SavegameHelper*>::NoInit);
bool GameInterface::SaveGame(FSaveGameNode* sv) bool GameInterface::SaveGame(FSaveGameNode* sv)
{ {
OpenSaveGameForWrite(sv->Filename);
// workaround until the level info here has been transitioned.
G_WriteSaveHeader(sv->SaveTitle);
auto fw = WriteSavegameChunk("engine"); auto fw = WriteSavegameChunk("engine");
fw->Write(&numsectors, sizeof(numsectors)); fw->Write(&numsectors, sizeof(numsectors));
fw->Write(sector, sizeof(sectortype) * numsectors); fw->Write(sector, sizeof(sectortype) * numsectors);

View file

@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "engine.h" #include "engine.h"
#include "trigdat.h" #include "trigdat.h"
#include "runlist.h" #include "runlist.h"
#include "v_video.h"
#include <string.h> #include <string.h>
BEGIN_PS_NS BEGIN_PS_NS
@ -356,7 +357,7 @@ static inline fix16_t q16angle_interpolate16(fix16_t a, fix16_t b, int smooth)
return a + mulscale16(((b+F16(1024)-a)&0x7FFFFFF)-F16(1024), smooth); return a + mulscale16(((b+F16(1024)-a)&0x7FFFFFF)-F16(1024), smooth);
} }
void DrawView(int smoothRatio) void DrawView(int smoothRatio, bool sceneonly)
{ {
int playerX; int playerX;
int playerY; int playerY;
@ -365,28 +366,15 @@ void DrawView(int smoothRatio)
fix16_t nAngle; fix16_t nAngle;
fix16_t pan; fix16_t pan;
#if 0
if (bgpages <= 0) if (!sceneonly)
{
if (textpages > 0)
{
textpages--;
FlushMessageLine();
}
}
else
{ {
RefreshBackground(); RefreshBackground();
bgpages--;
}
#else
//FlushMessageLine();
RefreshBackground();
#endif
if (!bFullScreen) { if (!bFullScreen) {
MaskStatus(); MaskStatus();
} }
}
zbob = Sin(2 * bobangle) >> 3; zbob = Sin(2 * bobangle) >> 3;
@ -394,7 +382,7 @@ void DrawView(int smoothRatio)
int nPlayerOldCstat = sprite[nPlayerSprite].cstat; int nPlayerOldCstat = sprite[nPlayerSprite].cstat;
int nDoppleOldCstat = sprite[nDoppleSprite[nLocalPlayer]].cstat; int nDoppleOldCstat = sprite[nDoppleSprite[nLocalPlayer]].cstat;
if (nSnakeCam >= 0) if (nSnakeCam >= 0 && !sceneonly)
{ {
int nSprite = SnakeList[nSnakeCam].nSprites[0]; int nSprite = SnakeList[nSnakeCam].nSprites[0];
@ -437,9 +425,9 @@ void DrawView(int smoothRatio)
nCameraa = nAngle; nCameraa = nAngle;
if (!bCamera || nFreeze) if (!bCamera || nFreeze || sceneonly)
{ {
if (nSnakeCam >= 0) if (nSnakeCam >= 0 && !sceneonly)
{ {
pan = F16(92); pan = F16(92);
viewz = playerZ; viewz = playerZ;
@ -530,9 +518,11 @@ void DrawView(int smoothRatio)
} }
} }
screen->BeginScene();
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa, nCamerapan, nSector);
analyzesprites(); analyzesprites();
renderDrawMasks(); renderDrawMasks();
screen->FinishScene();
if (HavePLURemap()) if (HavePLURemap())
{ {
@ -599,7 +589,7 @@ void DrawView(int smoothRatio)
} }
} }
} }
else else if (!sceneonly)
{ {
if (nSnakeCam < 0) if (nSnakeCam < 0)
{ {
@ -634,6 +624,14 @@ void DrawView(int smoothRatio)
flash = 0; flash = 0;
} }
bool GameInterface::GenerateSavePic()
{
DrawView(65536, true);
return true;
}
void NoClip() void NoClip()
{ {
videoSetViewableArea(0, 0, xdim - 1, ydim - 1); videoSetViewableArea(0, 0, xdim - 1, ydim - 1);

View file

@ -35,7 +35,7 @@ extern short bCamera;
void InitView(); void InitView();
void SetView1(); void SetView1();
void RefreshBackground(); void RefreshBackground();
void DrawView(int smoothRatio); void DrawView(int smoothRatio, bool sceneonly = false);
void MySetView(int x1, int y1, int x2, int y2); void MySetView(int x1, int y1, int x2, int y2);
void ResetView(); void ResetView();
void NoClip(); void NoClip();

View file

@ -39,6 +39,7 @@
#include "bitmap.h" #include "bitmap.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "printf.h" #include "printf.h"
#include "gl_interface.h"
//#include "compat.h" //#include "compat.h"
// Workaround to avoid including the dirty 'compat.h' header. This will hopefully not be needed anymore once the texture format uses something better. // Workaround to avoid including the dirty 'compat.h' header. This will hopefully not be needed anymore once the texture format uses something better.
@ -145,6 +146,7 @@ FHardwareTexture::~FHardwareTexture()
{ {
alltexturesize -= allocated; alltexturesize -= allocated;
if (glTexID != 0) glDeleteTextures(1, &glTexID); if (glTexID != 0) glDeleteTextures(1, &glTexID);
if (glBufferID != 0) glDeleteBuffers(1, &glBufferID);
} }
@ -153,4 +155,44 @@ unsigned int FHardwareTexture::GetTextureHandle()
return glTexID; return glTexID;
} }
static int GetTexDimension(int value)
{
if (value > gl.max_texturesize) return gl.max_texturesize;
return value;
}
//===========================================================================
//
// Creates a depth buffer for this texture
//
//===========================================================================
int FHardwareTexture::GetDepthBuffer(int width, int height)
{
if (glDepthID == 0)
{
glGenRenderbuffers(1, &glDepthID);
glBindRenderbuffer(GL_RENDERBUFFER, glDepthID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
return glDepthID;
}
//===========================================================================
//
// Binds this texture's surfaces to the current framrbuffer
//
//===========================================================================
void FHardwareTexture::BindToFrameBuffer(int width, int height)
{
width = GetTexDimension(width);
height = GetTexDimension(height);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height));
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height));
}

View file

@ -1,7 +1,4 @@
#pragma once
#ifndef __GLTEXTURE_H
#define __GLTEXTURE_H
class FBitmap; class FBitmap;
class FTexture; class FTexture;
@ -22,12 +19,16 @@ private:
int mSampler = 0; int mSampler = 0;
unsigned int glTexID = 0; unsigned int glTexID = 0;
unsigned int glDepthID = 0; // only used by camera textures
unsigned int glBufferID = 0;
int internalType = TrueColor; int internalType = TrueColor;
bool mipmapped = true; bool mipmapped = true;
int mWidth = 0, mHeight = 0; int mWidth = 0, mHeight = 0;
int colorId = 0; int colorId = 0;
uint32_t allocated = 0; uint32_t allocated = 0;
int GetDepthBuffer(int w, int h);
public: public:
~FHardwareTexture(); ~FHardwareTexture();
@ -43,9 +44,9 @@ public:
int GetSampler() { return mSampler; } int GetSampler() { return mSampler; }
void SetSampler(int sampler) { mSampler = sampler; } void SetSampler(int sampler) { mSampler = sampler; }
bool isIndexed() const { return internalType == Indexed; } bool isIndexed() const { return internalType == Indexed; }
void BindToFrameBuffer(int w, int h);
friend class FGameTexture; friend class FGameTexture;
}; };
#endif

View file

@ -10,7 +10,7 @@ enum EMatrixType
{ {
Matrix_View, Matrix_View,
Matrix_Projection, Matrix_Projection,
Matrix_ModelView, Matrix_Model,
Matrix_Detail, Matrix_Detail,
Matrix_Texture, Matrix_Texture,
// These are the only ones being used. // These are the only ones being used.
@ -35,6 +35,7 @@ enum PRSFlags
RF_HICTINT_BLEND_Overlay = 0x100000, RF_HICTINT_BLEND_Overlay = 0x100000,
RF_HICTINT_BLEND_Hardlight = 0x200000, RF_HICTINT_BLEND_Hardlight = 0x200000,
RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight, RF_HICTINT_BLENDMASK = RF_HICTINT_BLEND_Screen | RF_HICTINT_BLEND_Overlay | RF_HICTINT_BLEND_Hardlight,
RF_HICTINT_MASK = 0x3f0000,
STF_BLEND = 1, STF_BLEND = 1,
STF_COLORMASK = 2, STF_COLORMASK = 2,
@ -49,13 +50,14 @@ enum PRSFlags
STF_CLEARCOLOR = 1024, STF_CLEARCOLOR = 1024,
STF_CLEARDEPTH = 2048, STF_CLEARDEPTH = 2048,
STF_VIEWPORTSET = 4096, STF_VIEWPORTSET = 4096,
STF_SCISSORSET = 4096, STF_SCISSORSET = 8192,
}; };
struct PolymostRenderState struct PolymostRenderState
{ {
int vindex, vcount, primtype;
float Shade; float Shade;
float NumShades = 64.f; float NumShades = 64.f;
float ShadeDiv = 62.f; float ShadeDiv = 62.f;
@ -67,7 +69,9 @@ struct PolymostRenderState
float AlphaThreshold = 0.5f; float AlphaThreshold = 0.5f;
bool AlphaTest = true; bool AlphaTest = true;
float Color[4] = { 1,1,1,1 }; float Color[4] = { 1,1,1,1 };
short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 }; short matrixIndex[NUMMATRICES] = { 0,0,0,0,0 };
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
int hictint_flags = -1;
int StateFlags = STF_COLORMASK|STF_DEPTHMASK; int StateFlags = STF_COLORMASK|STF_DEPTHMASK;
FRenderStyle Style{}; FRenderStyle Style{};
@ -79,9 +83,5 @@ struct PolymostRenderState
PalEntry FogColor; PalEntry FogColor;
IVertexBuffer* VertexBuffer = nullptr;
int VB_Offset[2] = {};
IIndexBuffer* IndexBuffer = nullptr;
void Apply(PolymostShader *shader, GLState &oldstate); void Apply(PolymostShader *shader, GLState &oldstate);
}; };

View file

@ -144,6 +144,9 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
Brightness.Init(hShader, "u_brightness"); Brightness.Init(hShader, "u_brightness");
FogColor.Init(hShader, "u_fogColor"); FogColor.Init(hShader, "u_fogColor");
AlphaThreshold.Init(hShader, "u_alphaThreshold"); AlphaThreshold.Init(hShader, "u_alphaThreshold");
TintModulate.Init(hShader, "u_tintModulate");
TintOverlay.Init(hShader, "u_tintOverlay");
TintFlags.Init(hShader, "u_tintFlags");
RotMatrix.Init(hShader, "u_rotMatrix"); RotMatrix.Init(hShader, "u_rotMatrix");
ModelMatrix.Init(hShader, "u_modelMatrix"); ModelMatrix.Init(hShader, "u_modelMatrix");

View file

@ -45,6 +45,10 @@ public:
FBufferedUniform1f Brightness; FBufferedUniform1f Brightness;
FBufferedUniform1f AlphaThreshold; FBufferedUniform1f AlphaThreshold;
FBufferedUniformPalEntry FogColor; FBufferedUniformPalEntry FogColor;
FBufferedUniformPalEntry TintModulate;
FBufferedUniformPalEntry TintOverlay;
FBufferedUniform1i TintFlags;
FUniformMatrix4f RotMatrix; FUniformMatrix4f RotMatrix;
FUniformMatrix4f ModelMatrix; FUniformMatrix4f ModelMatrix;

View file

@ -150,7 +150,7 @@ FHardwareTexture* GLInstance::LoadTexture(FTexture* tex, int textype, int palid)
// //
//=========================================================================== //===========================================================================
bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow) bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int method, int sampleroverride, FTexture *det, float detscale, FTexture *glow)
{ {
if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false; if (tex->GetWidth() <= 0 || tex->GetHeight() <= 0) return false;
int usepalette = fixpalette >= 1 ? fixpalette - 1 : curbasepal; int usepalette = fixpalette >= 1 ? fixpalette - 1 : curbasepal;
@ -158,30 +158,44 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
GLInterface.SetPalette(usepalette); GLInterface.SetPalette(usepalette);
GLInterface.SetPalswap(usepalswap); GLInterface.SetPalswap(usepalswap);
bool texbound[3] = {}; bool texbound[3] = {};
int MatrixChange = 0;
TextureType = hw_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR; TextureType = hw_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR;
int lookuppal = 0; int lookuppal = 0;
VSMatrix texmat; VSMatrix texmat;
auto rep = hw_hightile? tex->FindReplacement(palette) : nullptr; auto& h = hictinting[palette];
bool applytint = false;
auto rep = (hw_hightile && !(h.f & HICTINT_ALWAYSUSEART)) ? tex->FindReplacement(palette) : nullptr;
if (rep) if (rep)
{ {
// Hightile replacements have only one texture representation and it is always the base. // Hightile replacements have only one texture representation and it is always the base.
tex = rep->faces[0]; tex = rep->faces[0];
TextureType = TT_HICREPLACE; TextureType = TT_HICREPLACE;
if (rep->palnum != palette || (h.f & HICTINT_APPLYOVERALTPAL)) applytint = true;
} }
else else
{ {
// Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.) // Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.)
if (TextureType == TT_TRUECOLOR) if (TextureType == TT_TRUECOLOR)
{ {
/*lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true); // Tinting is not used on indexed textures
if (lookuppal< 0)*/ lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255); if (h.f & (HICTINT_ALWAYSUSEART | HICTINT_USEONART))
{
applytint = true;
if (!(h.f & HICTINT_APPLYOVERPALSWAP)) usepalswap = 0;
}
lookuppal = palmanager.LookupPalette(usepalette, usepalswap, false, g_nontransparent255);
} }
} }
// This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.
if (applytint) GLInterface.SetTinting(h.f, h.tint, h.tint);
else GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
// Load the main texture // Load the main texture
auto mtex = LoadTexture(tex, TextureType, lookuppal); auto mtex = LoadTexture(tex, TextureType, lookuppal);
if (mtex) if (mtex)
@ -196,13 +210,12 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
UseBrightmaps(false); UseBrightmaps(false);
BindTexture(0, mtex, sampler); BindTexture(0, mtex, sampler);
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f || xpanning != 0 || ypanning != 0)) // Needs a) testing and b) verification for correctness. This doesn't look like it makes sense.
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f))
{ {
texmat.loadIdentity(); //texmat.loadIdentity();
texmat.translate(xpanning, ypanning, 0); //texmat.scale(rep->scale.x, rep->scale.y, 1.0f);
texmat.scale(rep->scale.x, rep->scale.y, 1.0f); //GLInterface.SetMatrix(Matrix_Texture, &texmat);
GLInterface.SetMatrix(Matrix_Texture, &texmat);
MatrixChange |= 1;
} }
// Also load additional layers needed for this texture. // Also load additional layers needed for this texture.
@ -226,16 +239,17 @@ bool GLInstance::SetTextureInternal(int picnum, FTexture* tex, int palette, int
BindTexture(3, htex, SamplerRepeat); BindTexture(3, htex, SamplerRepeat);
texbound[0] = true; texbound[0] = true;
// Q: Pass the scale factor as a separate uniform to get rid of the additional matrix?
/* todo: instead of a matrix, just pass a two-component uniform. Using a full matrix here is problematic.
if (MatrixChange & 1) MatrixChange |= 2; if (MatrixChange & 1) MatrixChange |= 2;
else texmat.loadIdentity(); else texmat.loadIdentity();
if ((detscalex != 1.0f) || (detscaley != 1.0f)) if ((detscalex != 1.0f) || (detscaley != 1.0f))
{ {
texmat.scale(detscalex, detscaley, 1.0f); texmat.scale(detscalex, detscaley, 1.0f);
MatrixChange |= 2; MatrixChange |= 2;
} }
if (MatrixChange & 2) GLInterface.SetMatrix(Matrix_Detail, &texmat); if (MatrixChange & 2) GLInterface.SetMatrix(Matrix_Detail, &texmat);
*/
} }
} }
if (hw_glowmapping && hw_hightile) if (hw_glowmapping && hw_hightile)

View file

@ -47,6 +47,7 @@
#include "gl_interface.h" #include "gl_interface.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "v_video.h" #include "v_video.h"
#include "flatvertices.h"
#include "gl_renderer.h" #include "gl_renderer.h"
float shadediv[MAXPALOOKUPS]; float shadediv[MAXPALOOKUPS];
@ -55,7 +56,7 @@ static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALP
static int renderops[] = { GL_FUNC_ADD, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT }; static int renderops[] = { GL_FUNC_ADD, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT };
int depthf[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL }; int depthf[] = { GL_ALWAYS, GL_LESS, GL_EQUAL, GL_LEQUAL };
static TArray<VSMatrix> matrixArray; TArray<VSMatrix> matrixArray;
FileReader GetResource(const char* fn) FileReader GetResource(const char* fn)
{ {
@ -72,7 +73,8 @@ GLInstance GLInterface;
GLInstance::GLInstance() GLInstance::GLInstance()
:palmanager(this) :palmanager(this)
{ {
VSMatrix mat(0);
matrixArray.Push(mat);
} }
void ImGui_Init_Backend(); void ImGui_Init_Backend();
@ -91,7 +93,6 @@ void GLInstance::Init(int ydim)
new(&renderState) PolymostRenderState; // reset to defaults. new(&renderState) PolymostRenderState; // reset to defaults.
LoadSurfaceShader(); LoadSurfaceShader();
LoadVPXShader();
LoadPolymostShader(); LoadPolymostShader();
#if 0 #if 0
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
@ -127,19 +128,6 @@ void GLInstance::LoadPolymostShader()
SetPolymostShader(); SetPolymostShader();
} }
void GLInstance::LoadVPXShader()
{
auto fr1 = GetResource("engine/shaders/glsl/animvpx.vp");
TArray<uint8_t> Vert = fr1.Read();
fr1 = GetResource("engine/shaders/glsl/animvpx.fp");
TArray<uint8_t> Frag = fr1.Read();
// Zero-terminate both strings.
Vert.Push(0);
Frag.Push(0);
vpxShader = new FShader();
vpxShader->Load("VPXShader", (const char*)Vert.Data(), (const char*)Frag.Data());
}
void GLInstance::LoadSurfaceShader() void GLInstance::LoadSurfaceShader()
{ {
auto fr1 = GetResource("engine/shaders/glsl/glsurface.vp"); auto fr1 = GetResource("engine/shaders/glsl/glsurface.vp");
@ -174,6 +162,7 @@ void GLInstance::InitGLState(int fogmode, int multisample)
screen->BeginFrame(); screen->BeginFrame();
bool useSSAO = (gl_ssao != 0); bool useSSAO = (gl_ssao != 0);
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(useSSAO); OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(useSSAO);
ClearBufferState();
} }
void GLInstance::Deinit() void GLInstance::Deinit()
@ -192,8 +181,6 @@ void GLInstance::Deinit()
polymostShader = nullptr; polymostShader = nullptr;
if (surfaceShader) delete surfaceShader; if (surfaceShader) delete surfaceShader;
surfaceShader = nullptr; surfaceShader = nullptr;
if (vpxShader) delete vpxShader;
vpxShader = nullptr;
activeShader = nullptr; activeShader = nullptr;
palmanager.DeleteAllTextures(); palmanager.DeleteAllTextures();
lastPalswapIndex = -1; lastPalswapIndex = -1;
@ -212,13 +199,25 @@ void GLInstance::ResetFrame()
} }
void GLInstance::SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2)
std::pair<size_t, BaseVertex *> GLInstance::AllocVertices(size_t num)
{ {
Buffer.resize(num); int o[] = { offset1, offset2 };
return std::make_pair((size_t)0, Buffer.data()); static_cast<OpenGLRenderer::GLVertexBuffer*>(vb)->Bind(o);
} }
void GLInstance::SetIndexBuffer(IIndexBuffer* vb)
{
if (vb) static_cast<OpenGLRenderer::GLIndexBuffer*>(vb)->Bind();
else glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GLInstance::ClearBufferState()
{
SetVertexBuffer(screen->mVertexData->GetBufferObjects().first, 0, 0);
SetIndexBuffer(nullptr);
}
static GLint primtypes[] = static GLint primtypes[] =
{ {
GL_TRIANGLES, GL_TRIANGLES,
@ -227,49 +226,27 @@ static GLint primtypes[] =
GL_LINES GL_LINES
}; };
void GLInstance::Draw(EDrawType type, size_t start, size_t count) void GLInstance::Draw(EDrawType type, size_t start, size_t count)
{ {
// Todo: Based on the current tinting flags and the texture type (indexed texture and APPLYOVERPALSWAP not set) this may have to reset the palette for the draw call / texture creation. renderState.vindex = start;
bool applied = false; renderState.vcount = count;
renderState.primtype = type;
rendercommands.Push(renderState);
SetIdentityMatrix(Matrix_Texture);
SetIdentityMatrix(Matrix_Detail);
renderState.StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
}
void GLInstance::DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState &renderState)
{
if (activeShader == polymostShader) if (activeShader == polymostShader)
{ {
glVertexAttrib4fv(2, renderState.Color); glVertexAttrib4fv(2, renderState.Color);
if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all. if (renderState.Color[3] != 1.f) renderState.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
renderState.Apply(polymostShader, lastState); renderState.Apply(polymostShader, lastState);
if (renderState.VertexBuffer != LastVertexBuffer || LastVB_Offset[0] != renderState.VB_Offset[0] || LastVB_Offset[1] != renderState.VB_Offset[1])
{
if (renderState.VertexBuffer)
{
static_cast<OpenGLRenderer::GLVertexBuffer*>(renderState.VertexBuffer)->Bind(renderState.VB_Offset);
} }
else glBindBuffer(GL_ARRAY_BUFFER, 0); if (type != DT_LINES)
LastVertexBuffer = renderState.VertexBuffer;
LastVB_Offset[0] = renderState.VB_Offset[0];
LastVB_Offset[1] = renderState.VB_Offset[1];
}
if (renderState.IndexBuffer != LastIndexBuffer)
{
if (renderState.IndexBuffer)
{
static_cast<OpenGLRenderer::GLIndexBuffer*>(renderState.IndexBuffer)->Bind();
}
else glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
LastIndexBuffer = renderState.IndexBuffer;
}
}
if (!LastVertexBuffer)
{
glBegin(primtypes[type]);
auto p = &Buffer[start];
for (size_t i = 0; i < count; i++, p++)
{
glVertexAttrib2f(1, p->u, p->v);
glVertexAttrib3f(0, p->x, p->y, p->z);
}
glEnd();
}
else if (type != DT_LINES)
{ {
glDrawElements(primtypes[type], count, GL_UNSIGNED_INT, (void*)(intptr_t)(start * sizeof(uint32_t))); glDrawElements(primtypes[type], count, GL_UNSIGNED_INT, (void*)(intptr_t)(start * sizeof(uint32_t)));
} }
@ -277,21 +254,29 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
{ {
glDrawArrays(primtypes[type], start, count); glDrawArrays(primtypes[type], start, count);
} }
if (MatrixChange) }
void GLInstance::DoDraw()
{
for (auto& rs : rendercommands)
{ {
if (MatrixChange & 1) SetIdentityMatrix(Matrix_Texture); glVertexAttrib4fv(2, rs.Color);
if (MatrixChange & 2) SetIdentityMatrix(Matrix_Detail); if (rs.Color[3] != 1.f) rs.Flags &= ~RF_Brightmapping; // The way the colormaps are set up means that brightmaps cannot be used on translucent content at all.
MatrixChange = 0; rs.Apply(polymostShader, lastState);
glDrawArrays(primtypes[rs.primtype], rs.vindex, rs.vcount);
} }
rendercommands.Clear();
matrixArray.Resize(1); matrixArray.Resize(1);
} }
void GLInstance::SetMatrix(int num, const VSMatrix *mat) int GLInstance::SetMatrix(int num, const VSMatrix *mat)
{ {
int r = renderState.matrixIndex[num];
if (num == Matrix_Projection) mProjectionM5 = mat->get()[5]; if (num == Matrix_Projection) mProjectionM5 = mat->get()[5];
renderState.matrixIndex[num] = matrixArray.Size(); renderState.matrixIndex[num] = matrixArray.Size();
matrixArray.Push(*mat); matrixArray.Push(*mat);
return r;
} }
void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer) void GLInstance::ReadPixels(int xdim, int ydim, uint8_t* buffer)
@ -317,15 +302,6 @@ void GLInstance::SetSurfaceShader()
} }
} }
void GLInstance::SetVPXShader()
{
if (activeShader != vpxShader)
{
vpxShader->Bind();
activeShader = vpxShader;
}
}
void GLInstance::SetPalette(int index) void GLInstance::SetPalette(int index)
{ {
palmanager.BindPalette(index); palmanager.BindPalette(index);
@ -481,12 +457,15 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f); shader->AlphaThreshold.Set(AlphaTest ? AlphaThreshold : -1.f);
shader->Brightness.Set(Brightness); shader->Brightness.Set(Brightness);
shader->FogColor.Set(FogColor); shader->FogColor.Set(FogColor);
shader->TintFlags.Set(hictint_flags);
shader->TintModulate.Set(hictint);
shader->TintOverlay.Set(hictint_overlay);
if (matrixIndex[Matrix_View] != -1) if (matrixIndex[Matrix_View] != -1)
shader->RotMatrix.Set(matrixArray[matrixIndex[Matrix_View]].get()); shader->RotMatrix.Set(matrixArray[matrixIndex[Matrix_View]].get());
if (matrixIndex[Matrix_Projection] != -1) if (matrixIndex[Matrix_Projection] != -1)
shader->ProjectionMatrix.Set(matrixArray[matrixIndex[Matrix_Projection]].get()); shader->ProjectionMatrix.Set(matrixArray[matrixIndex[Matrix_Projection]].get());
if (matrixIndex[Matrix_ModelView] != -1) if (matrixIndex[Matrix_Model] != -1)
shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_ModelView]].get()); shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_Model]].get());
if (matrixIndex[Matrix_Detail] != -1) if (matrixIndex[Matrix_Detail] != -1)
shader->DetailMatrix.Set(matrixArray[matrixIndex[Matrix_Detail]].get()); shader->DetailMatrix.Set(matrixArray[matrixIndex[Matrix_Detail]].get());
if (matrixIndex[Matrix_Texture] != -1) if (matrixIndex[Matrix_Texture] != -1)

View file

@ -95,34 +95,6 @@ struct glinfo_t {
float maxanisotropy; float maxanisotropy;
}; };
struct BaseVertex
{
float x, y, z;
float u, v;
void SetVertex(float _x, float _y, float _z = 0)
{
x = _x;
y = _y;
z = _z;
}
void SetTexCoord(float _u = 0, float _v = 0)
{
u = _u;
v = _v;
}
void Set(float _x, float _y, float _z = 0, float _u = 0, float _v = 0)
{
x = _x;
y = _y;
z = _z;
u = _u;
v = _v;
}
};
enum EDrawType enum EDrawType
{ {
DT_TRIANGLES, DT_TRIANGLES,
@ -180,7 +152,7 @@ struct GLState
class GLInstance class GLInstance
{ {
std::vector<BaseVertex> Buffer; // cheap-ass implementation. The primary purpose is to get the GL accesses out of polymost.cpp, not writing something performant right away. TArray<PolymostRenderState> rendercommands;
int maxTextureSize; int maxTextureSize;
PaletteManager palmanager; PaletteManager palmanager;
int lastPalswapIndex = -1; int lastPalswapIndex = -1;
@ -193,16 +165,11 @@ class GLInstance
// Cached GL state. // Cached GL state.
GLState lastState; GLState lastState;
IVertexBuffer* LastVertexBuffer = nullptr;
int LastVB_Offset[2] = {};
IIndexBuffer* LastIndexBuffer = nullptr;
float mProjectionM5 = 1.0f; // needed by ssao float mProjectionM5 = 1.0f; // needed by ssao
PolymostRenderState renderState; PolymostRenderState renderState;
FShader* activeShader; FShader* activeShader;
PolymostShader* polymostShader; PolymostShader* polymostShader;
SurfaceShader* surfaceShader; SurfaceShader* surfaceShader;
FShader* vpxShader;
public: public:
@ -213,7 +180,6 @@ public:
void InitGLState(int fogmode, int multisample); void InitGLState(int fogmode, int multisample);
void LoadPolymostShader(); void LoadPolymostShader();
void LoadSurfaceShader(); void LoadSurfaceShader();
void LoadVPXShader();
void Draw2D(F2DDrawer* drawer); void Draw2D(F2DDrawer* drawer);
void DrawImGui(ImDrawData*); void DrawImGui(ImDrawData*);
void ResetFrame(); void ResetFrame();
@ -227,8 +193,9 @@ public:
} }
GLInstance(); GLInstance();
std::pair<size_t, BaseVertex *> AllocVertices(size_t num);
void Draw(EDrawType type, size_t start, size_t count); void Draw(EDrawType type, size_t start, size_t count);
void DoDraw();
void DrawElement(EDrawType type, size_t start, size_t count, PolymostRenderState& renderState);
FHardwareTexture* NewTexture(); FHardwareTexture* NewTexture();
void EnableNonTransparent255(bool on) void EnableNonTransparent255(bool on)
@ -236,39 +203,29 @@ public:
g_nontransparent255 = on; g_nontransparent255 = on;
} }
void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2) void SetVertexBuffer(IVertexBuffer* vb, int offset1, int offset2);
{ void SetIndexBuffer(IIndexBuffer* vb);
renderState.VertexBuffer = vb; void ClearBufferState();
renderState.VB_Offset[0] = offset1;
renderState.VB_Offset[1] = offset2;
}
void SetIndexBuffer(IIndexBuffer* vb)
{
renderState.IndexBuffer = vb;
}
void ClearBufferState()
{
SetVertexBuffer(nullptr, 0, 0);
SetIndexBuffer(nullptr);
// Invalidate the pointers as well to make sure that if another buffer with the same address is used it actually gets bound.
LastVertexBuffer = (IVertexBuffer*)~intptr_t(0);
LastIndexBuffer = (IIndexBuffer*)~intptr_t(0);
}
float GetProjectionM5() { return mProjectionM5; } float GetProjectionM5() { return mProjectionM5; }
void SetMatrix(int num, const VSMatrix *mat ); int SetMatrix(int num, const VSMatrix *mat );
void SetMatrix(int num, const float *mat) int SetMatrix(int num, const float *mat)
{ {
SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat)); return SetMatrix(num, reinterpret_cast<const VSMatrix*>(mat));
} }
void SetIdentityMatrix(int num) int SetIdentityMatrix(int num)
{ {
auto r = renderState.matrixIndex[num];
renderState.matrixIndex[num] = 0; renderState.matrixIndex[num] = 0;
return r;
}
void RestoreMatrix(int num, int index)
{
renderState.matrixIndex[num] = index;
} }
void SetPolymostShader(); void SetPolymostShader();
void SetSurfaceShader(); void SetSurfaceShader();
void SetVPXShader();
void SetPalette(int palette); void SetPalette(int palette);
void ReadPixels(int w, int h, uint8_t* buffer); void ReadPixels(int w, int h, uint8_t* buffer);
@ -520,14 +477,16 @@ public:
renderState.Brightness = 8.f / (brightness + 8.f); renderState.Brightness = 8.f / (brightness + 8.f);
} }
void SetTinting(int flags, PalEntry color, PalEntry modulateColor) void SetTinting(int flags, PalEntry color, PalEntry overlayColor)
{ {
// not yet implemented. renderState.hictint = color;
renderState.hictint_overlay = overlayColor;
renderState.hictint_flags = flags;
} }
void SetBasepalTint(PalEntry color) void SetBasepalTint(PalEntry color)
{ {
// not yet implemented - only relevant for hires replacements. renderState.fullscreenTint = color;
} }
int GetPaletteIndex(PalEntry* palette) int GetPaletteIndex(PalEntry* palette)
@ -549,18 +508,18 @@ public:
FHardwareTexture* CreateIndexedTexture(FTexture* tex); FHardwareTexture* CreateIndexedTexture(FTexture* tex);
FHardwareTexture* CreateTrueColorTexture(FTexture* tex, int palid, bool checkfulltransparency = false, bool rgb8bit = false); FHardwareTexture* CreateTrueColorTexture(FTexture* tex, int palid, bool checkfulltransparency = false, bool rgb8bit = false);
FHardwareTexture *LoadTexture(FTexture* tex, int texturetype, int palid); FHardwareTexture *LoadTexture(FTexture* tex, int texturetype, int palid);
bool SetTextureInternal(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow); bool SetTextureInternal(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride, FTexture *det, float detscale, FTexture *glow);
bool SetNamedTexture(FTexture* tex, int palette, int sampleroverride); bool SetNamedTexture(FTexture* tex, int palette, int sampleroverride);
bool SetTexture(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride) bool SetTexture(int globalpicnum, FTexture* tex, int palette, int method, int sampleroverride)
{ {
return SetTextureInternal(globalpicnum, tex, palette, method, sampleroverride, 0, 0, nullptr, 1, nullptr); return SetTextureInternal(globalpicnum, tex, palette, method, sampleroverride, nullptr, 1, nullptr);
} }
bool SetModelTexture(FTexture *tex, int palette, float xpanning, float ypanning, FTexture *det, float detscale, FTexture *glow) bool SetModelTexture(FTexture *tex, int palette, FTexture *det, float detscale, FTexture *glow)
{ {
return SetTextureInternal(-1, tex, palette, 8/*DAMETH_MODEL*/, -1, xpanning, ypanning, det, detscale, glow); return SetTextureInternal(-1, tex, palette, 8/*DAMETH_MODEL*/, -1, det, detscale, glow);
} }
}; };

View file

@ -40,8 +40,11 @@
#include "glbackend.h" #include "glbackend.h"
#include "v_draw.h" #include "v_draw.h"
#include "palette.h" #include "palette.h"
#include "flatvertices.h"
extern int16_t numshades; extern int16_t numshades;
extern TArray<VSMatrix> matrixArray;
//=========================================================================== //===========================================================================
// //
// Vertex buffer for 2D drawer // Vertex buffer for 2D drawer
@ -96,9 +99,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
void GLInstance::Draw2D(F2DDrawer *drawer) void GLInstance::Draw2D(F2DDrawer *drawer)
{ {
VSMatrix mat(0); VSMatrix mat(0);
SetMatrix(Matrix_View, mat.get()); SetIdentityMatrix(Matrix_View);
SetMatrix(Matrix_ModelView, mat.get()); SetIdentityMatrix(Matrix_Model);
SetMatrix(Matrix_Detail, mat.get()); SetIdentityMatrix(Matrix_Detail);
mat.ortho(0, xdim, ydim, 0, -1, 1); mat.ortho(0, xdim, ydim, 0, -1, 1);
SetMatrix(Matrix_Projection, mat.get()); SetMatrix(Matrix_Projection, mat.get());
SetViewport(0, 0, xdim, ydim); SetViewport(0, 0, xdim, ydim);
@ -164,21 +167,21 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
if (cmd.mTexture != nullptr) if (cmd.mTexture != nullptr)
{ {
auto tex = cmd.mTexture; auto tex = cmd.mTexture;
if (cmd.mType == F2DDrawer::DrawTypeRotateSprite) if (cmd.mType == F2DDrawer::DrawTypeRotateSprite)
{ {
// todo: Set up hictinting. (broken as the feature is...) // todo: Set up hictinting. (broken as the feature is...)
SetShade(cmd.mRemapIndex >> 16, numshades); SetShade(cmd.mRemapIndex >> 16, numshades);
SetFadeDisable(false); SetFadeDisable(false);
SetTexture(0, tex, cmd.mRemapIndex & 0xffff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); SetTexture(0, tex, cmd.mRemapIndex & 0xffff, 4/*DAMETH_CLAMPED*/, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY);
EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1));
} }
else else
{ {
SetFadeDisable(true); SetFadeDisable(true);
SetShade(0, numshades); SetShade(0, numshades);
SetNamedTexture(cmd.mTexture, cmd.mRemapIndex, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); SetNamedTexture(cmd.mTexture, cmd.mRemapIndex, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY);
EnableBlend(true);
} }
EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1));
UseColorOnly(false); UseColorOnly(false);
} }
else else
@ -190,11 +193,11 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
{ {
case F2DDrawer::DrawTypeTriangles: case F2DDrawer::DrawTypeTriangles:
case F2DDrawer::DrawTypeRotateSprite: case F2DDrawer::DrawTypeRotateSprite:
Draw(DT_TRIANGLES, cmd.mIndexIndex, cmd.mIndexCount); DrawElement(DT_TRIANGLES, cmd.mIndexIndex, cmd.mIndexCount, renderState);
break; break;
case F2DDrawer::DrawTypeLines: case F2DDrawer::DrawTypeLines:
Draw(DT_LINES, cmd.mVertIndex, cmd.mVertCount); DrawElement(DT_LINES, cmd.mVertIndex, cmd.mVertCount, renderState);
break; break;
case F2DDrawer::DrawTypePoints: case F2DDrawer::DrawTypePoints:
@ -225,75 +228,50 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
//drawer->mIsFirstPass = false; //drawer->mIsFirstPass = false;
EnableBlend(true); EnableBlend(true);
EnableMultisampling(true); EnableMultisampling(true);
SetIdentityMatrix(Matrix_Projection);
matrixArray.Resize(1);
} }
void fullscreen_tint_gl(PalEntry pe)
{
// Todo: reroute to the 2D drawer
GLInterface.SetIdentityMatrix(Matrix_Projection);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
GLInterface.EnableDepthTest(false);
GLInterface.EnableAlphaTest(false);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
GLInterface.EnableBlend(true);
GLInterface.SetColorub (pe.r, pe.g, pe.b, pe.a);
GLInterface.UseColorOnly(true);
auto data = GLInterface.AllocVertices(3);
auto vt = data.second;
vt[0].Set(-2.5f, 1.f);
vt[1].Set(2.5f, 1.f);
vt[2].Set(.0f, -2.5f);
GLInterface.Draw(DT_TRIANGLES, data.first, 3);
GLInterface.UseColorOnly(false);
}
void fullscreen_tint_gl_blood(int tint_blood_r, int tint_blood_g, int tint_blood_b)
{
if (!(tint_blood_r | tint_blood_g | tint_blood_b))
return;
GLInterface.SetIdentityMatrix(Matrix_Projection);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
GLInterface.EnableDepthTest(false);
GLInterface.EnableAlphaTest(false);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Add]);
GLInterface.EnableBlend(true);
GLInterface.UseColorOnly(true);
GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255);
auto data = GLInterface.AllocVertices(3);
auto vt = data.second;
vt[0].Set(-2.5f, 1.f);
vt[1].Set(2.5f, 1.f);
vt[2].Set(.0f, -2.5f);
GLInterface.Draw(DT_TRIANGLES, data.first, 3);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Subtract]);
GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255);
data = GLInterface.AllocVertices(3);
vt = data.second;
vt[0].Set(-2.5f, 1.f);
vt[1].Set(2.5f, 1.f);
vt[2].Set(.0f, -2.5f);
GLInterface.Draw(DT_TRIANGLES, data.first, 3);
GLInterface.SetColorub(255, 255, 255, 255);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
GLInterface.UseColorOnly(false);
}
static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0; static int32_t tint_blood_r = 0, tint_blood_g = 0, tint_blood_b = 0;
extern palette_t palfadergb; extern palette_t palfadergb;
extern char palfadedelta ; extern unsigned char palfadedelta ;
void DrawFullscreenBlends() void DrawFullscreenBlends()
{ {
if (palfadedelta) fullscreen_tint_gl(PalEntry(palfadedelta, palfadergb.r, palfadergb.g, palfadergb.b)); GLInterface.SetIdentityMatrix(Matrix_Projection);
fullscreen_tint_gl_blood(tint_blood_r, tint_blood_g, tint_blood_b); GLInterface.SetIdentityMatrix(Matrix_Model);
GLInterface.SetIdentityMatrix(Matrix_View);
GLInterface.EnableDepthTest(false);
GLInterface.EnableAlphaTest(false);
GLInterface.EnableBlend(true);
GLInterface.UseColorOnly(true);
if (palfadedelta > 0)
{
// Todo: reroute to the 2D drawer
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
GLInterface.SetColorub(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
}
if (tint_blood_r | tint_blood_g | tint_blood_b)
{
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Add]);
GLInterface.SetColorub(max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0), 255);
GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Subtract]);
GLInterface.SetColorub(max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0), 255);
GLInterface.Draw(DT_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
GLInterface.SetColorub(255, 255, 255, 255);
GLInterface.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]);
}
GLInterface.DoDraw();
GLInterface.UseColorOnly(false);
} }

View file

@ -9,11 +9,11 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>zdoom.icns</string> <string>zdoom.icns</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.drdteam.gzdoom</string> <string>org.drdteam.raze</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>GZDoom</string> <string>Raze</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
@ -28,19 +28,16 @@
<array> <array>
<dict> <dict>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>Doom Resource File</string> <string>Build Engine Resource File</string>
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Viewer</string> <string>Viewer</string>
<key>CFBundleTypeExtensions</key> <key>CFBundleTypeExtensions</key>
<array> <array>
<string>wad</string> <string>grp</string>
<string>pk3</string> <string>pk3</string>
<string>zip</string> <string>zip</string>
<string>pk7</string> <string>pk7</string>
<string>7z</string> <string>7z</string>
<string>iwad</string>
<string>ipk3</string>
<string>ipk7</string>
</array> </array>
</dict> </dict>
</array> </array>

View file

@ -405,7 +405,7 @@ bool Win32GLVideo::InitHardware(HWND Window, int multisample)
int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
const char *version = Args->CheckValue("-glversion"); const char *version = Args->CheckValue("-glversion");
prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // At the moment the renderer still needs the compatibility profile. //prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // At the moment the renderer still needs the compatibility profile.
for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) for (; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++)
{ {

View file

@ -62,7 +62,6 @@ set( PCH_SOURCES
src/gamedef.cpp src/gamedef.cpp
src/gameexec.cpp src/gameexec.cpp
src/global.cpp src/global.cpp
src/menus.cpp
src/namesdyn.cpp src/namesdyn.cpp
src/net.cpp src/net.cpp
src/osdcmds.cpp src/osdcmds.cpp

View file

@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "animlib.h" #include "animlib.h"
#include "compat.h" #include "compat.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "v_2ddrawer.h"
#include "../glbackend/glbackend.h" #include "../glbackend/glbackend.h"
@ -359,7 +360,7 @@ int32_t Anim_Play(const char *fn)
if (!pic) if (!pic)
break; // no more pics! break; // no more pics!
videoClearScreen(0); twod->ClearScreen();
ototalclock = totalclock + 1; // pause game like ANMs ototalclock = totalclock + 1; // pause game like ANMs
@ -408,13 +409,7 @@ int32_t Anim_Play(const char *fn)
} }
} }
// this and showframe() instead of nextpage() are so that videoNextPage();
// nobody tramples on our carefully set up GL state!
palfadedelta = 0;
videoShowFrame(0);
// inputState.ClearAllInput();
do do
{ {
G_HandleAsync(); G_HandleAsync();
@ -428,7 +423,9 @@ int32_t Anim_Play(const char *fn)
} while (running); } while (running);
GLInterface.EnableNonTransparent255(false); GLInterface.EnableNonTransparent255(false);
#ifdef DEBUGGINGAIDS
animvpx_print_stats(&codec); animvpx_print_stats(&codec);
#endif
// //
animvpx_restore_glstate(); animvpx_restore_glstate();

View file

@ -172,7 +172,7 @@ void G_OpenDemoWrite(void)
if (g_demo_filePtr == NULL) if (g_demo_filePtr == NULL)
return; return;
i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1, (demorec_seeds_cvar<<1)); i=sv_saveandmakesnapshot(*g_demo_filePtr, -1, (demorec_seeds_cvar<<1));
if (i) if (i)
{ {
delete g_demo_filePtr; delete g_demo_filePtr;

Some files were not shown because too many files have changed in this diff Show more