summaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-21 23:29:40 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-21 23:29:40 (GMT)
commit3a283d4f3c571dc8a891f2cdc348c204f7f9300b (patch)
tree93cd53ceb2b509c6715b224e3ba142213dbd8173 /src/interface
parentdea70befcf770a767f1cbeecdd149930f6d4c0b8 (diff)
downloadpowder-3a283d4f3c571dc8a891f2cdc348c204f7f9300b.zip
powder-3a283d4f3c571dc8a891f2cdc348c204f7f9300b.tar.gz
Nice graphics for Showing windows
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/Engine.cpp32
-rw-r--r--src/interface/Engine.h2
2 files changed, 32 insertions, 2 deletions
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index 19da36e..85a6293 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -19,7 +19,9 @@ Engine::Engine():
mousexp_(0),
mouseyp_(0),
FpsLimit(60.0f),
- windows(stack<Window*>())
+ windows(stack<Window*>()),
+ lastBuffer(NULL),
+ prevBuffers(stack<pixel*>())
{
}
@@ -61,15 +63,34 @@ void Engine::ShowWindow(Window * window)
}
if(state_)
{
+ if(lastBuffer)
+ {
+ prevBuffers.push(lastBuffer);
+ }
+ lastBuffer = (pixel*)malloc((width_ * height_) * PIXELSIZE);
+ g->fillrect(0, 0, width_, height_, 0, 0, 0, 100);
+ memcpy(lastBuffer, g->vid, (width_ * height_) * PIXELSIZE);
+
windows.push(state_);
}
state_ = window;
+
}
void Engine::CloseWindow()
{
if(!windows.empty())
{
+ if(!prevBuffers.empty())
+ {
+ lastBuffer = prevBuffers.top();
+ prevBuffers.pop();
+ }
+ else
+ {
+ free(lastBuffer);
+ lastBuffer = NULL;
+ }
state_ = windows.top();
windows.pop();
}
@@ -120,10 +141,17 @@ void Engine::Tick(float dt)
void Engine::Draw()
{
+ if(lastBuffer && !(state_->Position.X == 0 && state_->Position.Y == 0 && state_->Size.X == width_ && state_->Size.Y == height_))
+ {
+ memcpy(g->vid, lastBuffer, (width_ * height_) * PIXELSIZE);
+ }
+ else
+ {
+ g->Clear();
+ }
if(state_)
state_->DoDraw();
g->Blit();
- g->Clear();
}
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
diff --git a/src/interface/Engine.h b/src/interface/Engine.h
index 7bf78f9..a648119 100644
--- a/src/interface/Engine.h
+++ b/src/interface/Engine.h
@@ -54,6 +54,8 @@ namespace ui
float FpsLimit;
Graphics * g;
private:
+ pixel * lastBuffer;
+ std::stack<pixel*> prevBuffers;
std::stack<Window*> windows;
//Window* statequeued_;
Window* state_;