Skip to content

Commit

Permalink
Client|GuiRootWidget: 2D projection matrix utility, widget deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 18, 2013
1 parent b3a1e67 commit f330060
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doomsday/client/include/ui/widgets/guirootwidget.h
Expand Up @@ -22,6 +22,7 @@
#include <de/RootWidget>
#include <de/AtlasTexture>
#include <de/GLShaderBank>
#include <de/Matrix>

class ClientWindow;

Expand Down Expand Up @@ -49,6 +50,11 @@ class GuiRootWidget : public de::RootWidget
de::AtlasTexture &atlas();
de::GLShaderBank &shaders();

/**
* Returns the default projection for 2D graphics.
*/
de::Matrix4f projMatrix2D() const;

// Events.
void update();

Expand Down
16 changes: 15 additions & 1 deletion doomsday/client/src/ui/widgets/guirootwidget.cpp
Expand Up @@ -35,6 +35,14 @@ DENG2_PIMPL(GuiRootWidget)
window(win),
atlas(0)
{}

~Instance()
{
// Tell all widgets to release their resource allocations. The base
// class destructor will destroy all widgets, but this class governs
// shared GL resources, so we'll ask the widgets to do this now.
self.notifyTree(&Widget::deinitialize);
}
};

GuiRootWidget::GuiRootWidget(ClientWindow *window)
Expand All @@ -58,7 +66,7 @@ AtlasTexture &GuiRootWidget::atlas()
{
d->atlas.reset(AtlasTexture::newWithRowAllocator(
Atlas::BackingStore | Atlas::AllowDefragment,
GLTexture::maximumSize()));
GLTexture::maximumSize().min(GLTexture::Size(4096, 4096))));
}
return *d->atlas;
}
Expand All @@ -68,6 +76,12 @@ GLShaderBank &GuiRootWidget::shaders()
return ClientApp::glShaderBank();
}

Matrix4f GuiRootWidget::projMatrix2D() const
{
RootWidget::Size const size = viewSize();
return Matrix4f::ortho(0, size.x, 0, size.y);
}

void GuiRootWidget::update()
{
// Allow GL operations.
Expand Down

0 comments on commit f330060

Please sign in to comment.