Skip to content

Commit

Permalink
Merge pull request #389 from avaraline/render-refactor
Browse files Browse the repository at this point in the history
Second pass at render refactor
  • Loading branch information
rherriman authored Feb 5, 2024
2 parents 0cd09ea + b705aec commit 0026ace
Show file tree
Hide file tree
Showing 30 changed files with 357 additions and 469 deletions.
18 changes: 8 additions & 10 deletions Avara.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
9465BFD32B30C2A00050681C /* AssetManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9465BFD12B30C2A00050681C /* AssetManager.cpp */; };
9465BFD72B30EF680050681C /* PackageManifest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9465BFD52B30EF680050681C /* PackageManifest.cpp */; };
9465BFD82B30EF680050681C /* PackageManifest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9465BFD52B30EF680050681C /* PackageManifest.cpp */; };
946EF8D22B6D9CB2000EF17E /* AbstractRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 946EF8D12B6D9CB2000EF17E /* AbstractRenderer.cpp */; };
946EF8D32B6D9CB2000EF17E /* AbstractRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 946EF8D12B6D9CB2000EF17E /* AbstractRenderer.cpp */; };
947F5C652B576B9F00F41689 /* ModernOpenGLRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 947F5C642B576B9F00F41689 /* ModernOpenGLRenderer.cpp */; };
947F5C662B576B9F00F41689 /* ModernOpenGLRenderer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 947F5C642B576B9F00F41689 /* ModernOpenGLRenderer.cpp */; };
948128B02B53A1C7002A3459 /* RenderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 948128AF2B53A1C7002A3459 /* RenderManager.cpp */; };
948128B12B53A1C7002A3459 /* RenderManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 948128AF2B53A1C7002A3459 /* RenderManager.cpp */; };
948CBF142B335A1400147E80 /* BaseAssetStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 948CBF132B335A1400147E80 /* BaseAssetStorage.cpp */; };
948CBF152B335A1400147E80 /* BaseAssetStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 948CBF132B335A1400147E80 /* BaseAssetStorage.cpp */; };
94924EAF2B3A894900197378 /* OggFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94924EAE2B3A894900197378 /* OggFile.cpp */; };
Expand Down Expand Up @@ -387,12 +387,11 @@
9465BFD12B30C2A00050681C /* AssetManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AssetManager.cpp; sourceTree = "<group>"; };
9465BFD52B30EF680050681C /* PackageManifest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PackageManifest.cpp; sourceTree = "<group>"; };
9465BFD92B30EFB40050681C /* PackageManifest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PackageManifest.h; sourceTree = "<group>"; };
947F5C622B57693300F41689 /* Renderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Renderer.h; sourceTree = "<group>"; };
946EF8D12B6D9CB2000EF17E /* AbstractRenderer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractRenderer.cpp; sourceTree = "<group>"; };
947F5C622B57693300F41689 /* AbstractRenderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AbstractRenderer.h; sourceTree = "<group>"; };
947F5C632B576ACD00F41689 /* ModernOpenGLRenderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ModernOpenGLRenderer.h; sourceTree = "<group>"; };
947F5C642B576B9F00F41689 /* ModernOpenGLRenderer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ModernOpenGLRenderer.cpp; sourceTree = "<group>"; };
947F5C672B57A30100F41689 /* NullRenderer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NullRenderer.h; sourceTree = "<group>"; };
948128AE2B539B6C002A3459 /* RenderManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderManager.h; sourceTree = "<group>"; };
948128AF2B53A1C7002A3459 /* RenderManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderManager.cpp; sourceTree = "<group>"; };
948CBF112B33581D00147E80 /* AssetStorage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AssetStorage.h; sourceTree = "<group>"; };
948CBF122B3359D700147E80 /* BaseAssetStorage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseAssetStorage.h; sourceTree = "<group>"; };
948CBF132B335A1400147E80 /* BaseAssetStorage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BaseAssetStorage.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1073,9 +1072,8 @@
940541EB2B58744500E32241 /* OpenGLShader.h */,
941D878E2B5A213200E5577C /* OpenGLVertices.cpp */,
941D878D2B5A206A00E5577C /* OpenGLVertices.h */,
947F5C622B57693300F41689 /* Renderer.h */,
948128AF2B53A1C7002A3459 /* RenderManager.cpp */,
948128AE2B539B6C002A3459 /* RenderManager.h */,
946EF8D12B6D9CB2000EF17E /* AbstractRenderer.cpp */,
947F5C622B57693300F41689 /* AbstractRenderer.h */,
941D878C2B5A1EEC00E5577C /* VertexData.h */,
);
path = render;
Expand Down Expand Up @@ -2095,7 +2093,6 @@
E517F064299713DB0036B206 /* Resource.cpp in Sources */,
E517F065299713DB0036B206 /* System.cpp in Sources */,
E517F066299713DB0036B206 /* KeyFuncs.cpp in Sources */,
948128B12B53A1C7002A3459 /* RenderManager.cpp in Sources */,
E517F067299713DB0036B206 /* CAbstractActor.cpp in Sources */,
E517F068299713DB0036B206 /* CAbstractMissile.cpp in Sources */,
E517F069299713DB0036B206 /* CAbstractMovers.cpp in Sources */,
Expand Down Expand Up @@ -2123,6 +2120,7 @@
E517F07F299713DB0036B206 /* CLogic.cpp in Sources */,
E517F080299713DB0036B206 /* CLogicAnd.cpp in Sources */,
E517F081299713DB0036B206 /* CLogicBase.cpp in Sources */,
946EF8D32B6D9CB2000EF17E /* AbstractRenderer.cpp in Sources */,
E517F082299713DB0036B206 /* CLogicCounter.cpp in Sources */,
E517F083299713DB0036B206 /* CLogicDelay.cpp in Sources */,
E517F084299713DB0036B206 /* CLogicDistributor.cpp in Sources */,
Expand Down Expand Up @@ -2265,7 +2263,6 @@
E5890D1529895118007A875D /* CDirectObject.cpp in Sources */,
E5890CAC29895118007A875D /* CHandlePipe.cpp in Sources */,
E5890CC729895118007A875D /* LinkLoose.cpp in Sources */,
948128B02B53A1C7002A3459 /* RenderManager.cpp in Sources */,
E5890F0329895124007A875D /* textbox.cpp in Sources */,
E5253ED92996DD2200F8C1E8 /* PascalStrings.cpp in Sources */,
E5890CE129895118007A875D /* CAbstractMovers.cpp in Sources */,
Expand Down Expand Up @@ -2293,6 +2290,7 @@
E5890CF429895118007A875D /* CSolidActor.cpp in Sources */,
E5890EFE29895124007A875D /* combobox.cpp in Sources */,
E5890D0B29895118007A875D /* CWindow.cpp in Sources */,
946EF8D22B6D9CB2000EF17E /* AbstractRenderer.cpp in Sources */,
E5890CA829895118007A875D /* Beeper.cpp in Sources */,
E5890CDE29895118007A875D /* CYonBox.cpp in Sources */,
E5890EF429895124007A875D /* tabheader.cpp in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/CBSPPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

#include "CBSPPart.h"

#include "AbstractRenderer.h"
#include "AssetManager.h"
#include "AvaraDefines.h"
#include "CViewParameters.h"
#include "Memory.h"
#include "RenderManager.h"

#include <fstream>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/CBSPWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "CBSPWorld.h"

#include "AbstractRenderer.h"
#include "CBSPPart.h"
#include "CViewParameters.h"
#include "Memory.h"
#include "RenderManager.h"

extern Vector **bspPointTemp;
extern short *bspIndexStack;
Expand Down
2 changes: 1 addition & 1 deletion src/game/CAbstractPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "CAbstractPlayer.h"

#include "AbstractRenderer.h"
#include "AvaraDefines.h"
#include "CBSPWorld.h"
#include "CScaledBSP.h"
Expand All @@ -37,7 +38,6 @@
#include "Parser.h"
#include "Preferences.h"
#include "FastMat.h"
#include "RenderManager.h"

#include "Debug.h"

Expand Down
23 changes: 18 additions & 5 deletions src/game/CAvaraApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <json.hpp>
#include "Tags.h"
#include "Debug.h"
#include "RenderManager.h"
#include "ModernOpenGLRenderer.h"

// included while we fake things out
#include "CPlayerManager.h"
Expand Down Expand Up @@ -74,9 +74,15 @@ CAvaraAppImpl::CAvaraAppImpl() : CApplication("Avara") {
itsGame = std::make_unique<CAvaraGame>(Get<FrameTime>(kFrameTimeTag));
gCurrentGame = itsGame.get();

gRenderer = new RenderManager(RenderMode::GL3, mSDLWindow, mNVGContext);
gRenderer->UpdateViewRect(mPixelRatio);
if (mNVGContext) {
ui = std::make_unique<CHUD>(gCurrentGame);
ui->LoadImages(mNVGContext);
}

gRenderer = new ModernOpenGLRenderer(mSDLWindow);
gRenderer->UpdateViewRect(mSize.x, mSize.y, mPixelRatio);
gRenderer->SetFOV(Number(kFOV));
gRenderer->ResetLights();

itsGame->IAvaraGame(this);

Expand Down Expand Up @@ -165,6 +171,13 @@ void CAvaraAppImpl::drawContents() {
previewAngle += FIX3(1);
}
itsGame->Render();
if (ui) {
if (Get<bool>(kShowNewHUD)) {
ui->RenderNewHUD(mNVGContext);
} else {
ui->Render(mNVGContext);
}
}
}

// display only the game screen, not the widgets
Expand All @@ -173,8 +186,8 @@ void CAvaraAppImpl::RenderContents() {
gRenderer->RefreshWindow();
}

void CAvaraAppImpl::WindowResized() {
gRenderer->UpdateViewRect(mPixelRatio);
void CAvaraAppImpl::WindowResized(int width, int height) {
gRenderer->UpdateViewRect(width, height, mPixelRatio);
//performLayout();
}

Expand Down
4 changes: 3 additions & 1 deletion src/game/CAvaraApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "CApplication.h"
//#include "PolyColor.h"
#include "CHUD.h"
#include "CLevelWindow.h"
#include "CNetworkWindow.h"
#include "CServerWindow.h"
Expand Down Expand Up @@ -71,6 +72,7 @@ class CAvaraAppImpl : public CApplication, public CAvaraApp {
std::unique_ptr<CAvaraGame> itsGame;
CNetManager *gameNet;
CommandManager *itsTui;
std::unique_ptr<CHUD> ui;

public:
CPlayerWindow *playerWindow;
Expand Down Expand Up @@ -101,7 +103,7 @@ class CAvaraAppImpl : public CApplication, public CAvaraApp {
virtual void RenderContents() override;

virtual bool DoCommand(int theCommand) override;
virtual void WindowResized() override;
virtual void WindowResized(int width, int height) override;

virtual void Done() override;

Expand Down
4 changes: 2 additions & 2 deletions src/game/CAvaraGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "Preferences.h"
#include "ARGBColor.h"
#include "Debug.h"
#include "RenderManager.h"
#include "AbstractRenderer.h"

void CAvaraGame::InitMixer(Boolean silentFlag) {
CSoundMixer *aMixer;
Expand Down Expand Up @@ -583,7 +583,7 @@ void CAvaraGame::EndScript() {
vp->SetLight(i, 0, 0, 0, DEFAULT_LIGHT_COLOR, kLightOff);
}
}
gRenderer->UpdateLights();
gRenderer->ApplyLights();

color = *ARGBColor::Parse(ReadStringVar(iMissileArmedColor));
ColorManager::setMissileArmedColor(color);
Expand Down
2 changes: 1 addition & 1 deletion src/game/CDepot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "CDepot.h"

#include "AbstractRenderer.h"
#include "CAbstractMissile.h"
#include "CAvaraGame.h"
#include "CBSPWorld.h"
Expand All @@ -21,7 +22,6 @@
#include "CSmart.h"
#include "CSmartPart.h"
#include "CViewParameters.h"
#include "RenderManager.h"

void CDepot::IDepot(CAvaraGame *theGame) {
itsGame = theGame;
Expand Down
2 changes: 1 addition & 1 deletion src/game/CForceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "CForceField.h"

#include "AbstractRenderer.h"
#include "CBSPWorld.h"
#include "CSmartPart.h"
#include "CWallActor.h"
#include "RenderManager.h"

extern CWallActor *lastWallActor;

Expand Down
2 changes: 1 addition & 1 deletion src/game/CFreeSolid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

#include "CFreeSolid.h"

#include "AbstractRenderer.h"
#include "CBSPWorld.h"
#include "CSmartPart.h"
#include "CWallActor.h"
#include "RenderManager.h"

extern CWallActor *lastWallActor;

Expand Down
3 changes: 1 addition & 2 deletions src/game/CGroundColorAdjuster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

#include "CGroundColorAdjuster.h"

#include "AbstractRenderer.h"
#include "CWorldShader.h"

#include "RenderManager.h"

CAbstractActor *CGroundColorAdjuster::EndScript() {
CAbstractActor::EndScript();

Expand Down
5 changes: 3 additions & 2 deletions src/game/CHUD.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "CHUD.h"
#include "AbstractRenderer.h"
#include "CAbstractPlayer.h"
#include "CAvaraGame.h"
#include "ColorManager.h"
#include "CPlayerManager.h"
#include "AvaraDefines.h"
#include "CScoreKeeper.h"
#include "ARGBColor.h"
#include "RenderManager.h"

#include <stdint.h>

Expand Down Expand Up @@ -1269,8 +1269,9 @@ void CHUD::RenderNewHUD(NVGcontext *ctx) {
}
}

if (!player)
if (!player) {
return;
}

if(spectatePlayer != NULL)
player = spectatePlayer;
Expand Down
2 changes: 1 addition & 1 deletion src/game/CHologramActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "CHologramActor.h"

#include "AbstractRenderer.h"
#include "AssetManager.h"
#include "CBSPPart.h"
#include "CBSPWorld.h"
#include "RenderManager.h"

void CHologramActor::BeginScript() {
CPlacedActors::BeginScript();
Expand Down
2 changes: 1 addition & 1 deletion src/game/CScout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

#include "CScout.h"

#include "AbstractRenderer.h"
#include "CAbstractPlayer.h"
#include "CSmartPart.h"
#include "CViewParameters.h"
#include "RenderManager.h"
//#include "Mat2D.h"

#define kScoutBSP 220
Expand Down
2 changes: 1 addition & 1 deletion src/game/CSkyColorAdjuster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "CSkyColorAdjuster.h"

#include "AbstractRenderer.h"
#include "CWorldShader.h"
#include "RenderManager.h"

void CSkyColorAdjuster::BeginScript() {
ProgramLongVar(iCount, 8);
Expand Down
2 changes: 1 addition & 1 deletion src/game/CWalkerActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "CWalkerActor.h"

#include "AbstractRenderer.h"
#include "AssetManager.h"
#include "AvaraDefines.h"
#include "CBSPWorld.h"
Expand All @@ -20,7 +21,6 @@
#include "CViewParameters.h"
#include "KeyFuncs.h"
#include "Preferences.h"
#include "RenderManager.h"

#define SCOUTPLATFORM FIX3(1500)
#define MAXHEADHEIGHT FIX3(1750)
Expand Down
2 changes: 1 addition & 1 deletion src/game/CWallDoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "CWallDoor.h"

#include "AbstractRenderer.h"
#include "CBSPWorld.h"
#include "CSmartPart.h"
#include "CWallActor.h"
#include "RenderManager.h"

extern CWallActor *lastWallActor;

Expand Down
2 changes: 1 addition & 1 deletion src/game/CWallSolid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#include "CWallSolid.h"

#include "AbstractRenderer.h"
#include "CBSPWorld.h"
#include "CSmartPart.h"
#include "CWallActor.h"
#include "RenderManager.h"

extern CWallActor *lastWallActor;

Expand Down
4 changes: 3 additions & 1 deletion src/gui/CApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ json CApplication::_defaultPrefs = ReadDefaultPrefs();
CApplication::CApplication(std::string title) :
nanogui::Screen(nanogui::Vector2i(_prefs[kWindowWidth], _prefs[kWindowHeight]), title, true, _prefs[kFullScreenTag], 8, 8, 24, 8, _prefs[kMultiSamplesTag]) {
gApplication = this;
setResizeCallback([this](nanogui::Vector2i newSize) { this->WindowResized(); });
setResizeCallback([this](nanogui::Vector2i newSize) {
this->WindowResized(newSize.x, newSize.y);
});

ColorManager::refresh(this); // Init ColorManager from prefs.
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/CApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CApplication : public nanogui::Screen {
// Called when preference values change.
virtual void PrefChanged(std::string name);

virtual void WindowResized() {}
virtual void WindowResized(int width, int height) {}

// Screen overrides.
virtual bool handleSDLEvent(SDL_Event &event);
Expand Down
2 changes: 1 addition & 1 deletion src/level/LevelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

#include "LevelLoader.h"

#include "AbstractRenderer.h"
#include "AssetManager.h"
#include "CAvaraGame.h"
#include "CWallActor.h"
#include "FastMat.h"
#include "Memory.h"
#include "Parser.h"
#include "pugixml.hpp"
#include "RenderManager.h"

#include <SDL2/SDL.h>

Expand Down
Loading

0 comments on commit 0026ace

Please sign in to comment.