Skip to content

Commit

Permalink
Refactor|RenderSystem: Moved the shader bank to RenderSystem, added r…
Browse files Browse the repository at this point in the history
…enderer.pack

Shaders, appearance profiles, and other rendering-related files will
now be collected into “renderer.pack”.

The GLShaderBank instance owned by the app was moved to a more
suitable location in RenderSystem.
  • Loading branch information
skyjake committed Nov 18, 2013
1 parent 8d7b84c commit 5528f3d
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 23 deletions.
6 changes: 6 additions & 0 deletions doomsday/build/scripts/packres.py
Expand Up @@ -78,6 +78,12 @@ def process_dir(path, dest_path):
[ ('client/data/defaultstyle.pack', '') ] )
p.create('defaultstyle.pack')

# renderer.pack
p = Pack()
p.add_files(
[ ('client/data/renderer.pack', '') ] )
p.create('renderer.pack')

# libdoom.pk3
p = Pack()
p.add_files(
Expand Down
8 changes: 8 additions & 0 deletions doomsday/client/data/renderer.pack/images.dei
@@ -0,0 +1,8 @@
# Images for the Renderer
#
# These images are used as key assets in 2D and 3D rendering.

group fx.lensflares {
# Lens flare images.

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion doomsday/client/include/clientapp.h
Expand Up @@ -62,7 +62,6 @@ class ClientApp : public de::GuiApp
static WindowSystem &windowSystem();
static RenderSystem &renderSystem();
static WidgetActions &widgetActions();
static de::GLShaderBank &glShaderBank();
static de::Games &games();
static de::World &world();

Expand Down
5 changes: 5 additions & 0 deletions doomsday/client/include/render/rendersystem.h
Expand Up @@ -21,6 +21,8 @@

#include <de/System>
#include <de/Vector>
#include <de/GLShaderBank>
#include <de/ImageBank>
#include "DrawLists"
#include "settingsregister.h"

Expand Down Expand Up @@ -64,6 +66,9 @@ class RenderSystem : public de::System
public:
RenderSystem();

de::GLShaderBank &shaders();
de::ImageBank &images();

SettingsRegister &settings();
SettingsRegister &appearanceSettings();

Expand Down
21 changes: 3 additions & 18 deletions doomsday/client/src/clientapp.cpp
Expand Up @@ -129,7 +129,6 @@ DENG2_PIMPL(ClientApp)
WindowSystem *winSys;
RenderSystem *renderSys;
ServerLink *svLink;
GLShaderBank shaderBank;
Games games;
World world;

Expand Down Expand Up @@ -263,14 +262,9 @@ void ClientApp::initialize()
}
#endif

// Load all the shader program definitions.
FS::FoundFiles found;
fileSystem().findAll("shaders.dei", found);
DENG2_FOR_EACH(FS::FoundFiles, i, found)
{
LOG_MSG("Loading shader definitions from %s") << (*i)->description();
d->shaderBank.addFromInfo(**i);
}
// Create the render system.
d->renderSys = new RenderSystem;
addSystem(*d->renderSys);

// Create the window system.
d->winSys = new WindowSystem;
Expand All @@ -292,10 +286,6 @@ void ClientApp::initialize()
addSystem(*d->inputSys);
d->widgetActions.reset(new WidgetActions);

// Create the render system.
d->renderSys = new RenderSystem;
addSystem(*d->renderSys);

// Finally, run the bootstrap script.
scriptSystem().importModule("bootstrap");

Expand Down Expand Up @@ -384,11 +374,6 @@ WidgetActions &ClientApp::widgetActions()
return *app().d->widgetActions;
}

GLShaderBank &ClientApp::glShaderBank()
{
return app().d->shaderBank;
}

Games &ClientApp::games()
{
return app().d->games;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/render/consoleeffect.cpp
Expand Up @@ -60,7 +60,7 @@ bool ConsoleEffect::isInited() const

GLShaderBank &ConsoleEffect::shaders() const
{
return ClientApp::glShaderBank();
return ClientApp::renderSystem().shaders();
}

void ConsoleEffect::glInit()
Expand Down
43 changes: 43 additions & 0 deletions doomsday/client/src/render/rendersystem.cpp
Expand Up @@ -85,11 +85,18 @@ DENG2_PIMPL(RenderSystem)
{
SettingsRegister settings;
SettingsRegister appearanceSettings;
GLShaderBank shaderBank;
ImageBank images;
Store buffer;
DrawLists drawLists;

Instance(Public *i) : Base(i)
{
LOG_AS("RenderSystem");

loadAllShaders();
loadImages();

typedef SettingsRegister SReg;

// Initialize settings.
Expand Down Expand Up @@ -190,11 +197,47 @@ DENG2_PIMPL(RenderSystem)

.define(SReg::FloatCVar, "rend-sky-distance", 1600);
}

/**
* Reads all shader definitions and sets up a Bank where the actual
* compiled shaders are stored once they're needed.
*/
void loadAllShaders()
{
// Load all the shader program definitions.
FS::FoundFiles found;
App::fileSystem().findAll("shaders.dei", found);
DENG2_FOR_EACH(FS::FoundFiles, i, found)
{
LOG_MSG("Loading shader definitions from %s") << (*i)->description();
shaderBank.addFromInfo(**i);
}
}

/**
* Reads the renderer's image definitions and sets up a Bank for caching them
* when they're needed.
*/
void loadImages()
{
Folder const &renderPack = App::fileSystem().find<Folder>("renderer.pack");
images.addFromInfo(renderPack.locate<File>("images.dei"));
}
};

RenderSystem::RenderSystem() : d(new Instance(this))
{}

GLShaderBank &RenderSystem::shaders()
{
return d->shaderBank;
}

ImageBank &RenderSystem::images()
{
return d->images;
}

void RenderSystem::timeChanged(Clock const &)
{
// Nothing to do.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/client/src/ui/framework/guirootwidget.cpp
Expand Up @@ -252,7 +252,7 @@ Id GuiRootWidget::tinyDot() const

GLShaderBank &GuiRootWidget::shaders()
{
return ClientApp::glShaderBank();
return ClientApp::renderSystem().shaders();
}

Matrix4f GuiRootWidget::projMatrix2D() const
Expand Down
2 changes: 0 additions & 2 deletions doomsday/client/src/ui/style.cpp
Expand Up @@ -28,7 +28,6 @@ using namespace de;

DENG2_PIMPL(Style)
{
String packPath;
Record module;
RuleBank rules;
FontBank fonts;
Expand All @@ -53,7 +52,6 @@ DENG2_PIMPL(Style)

void load(String const &path)
{
packPath = path;
Folder const &pack = App::rootFolder().locate<Folder>(path);

rules.addFromInfo(pack.locate<File>("rules.dei"));
Expand Down

0 comments on commit 5528f3d

Please sign in to comment.