Add front drawing layer for UI

This commit is contained in:
Henrik Rydgard 2012-04-12 22:16:30 +02:00
parent 8656ec051c
commit 35ed4e02d1
2 changed files with 9 additions and 2 deletions

View file

@ -8,6 +8,7 @@
#include "gfx_es2/draw_buffer.h" #include "gfx_es2/draw_buffer.h"
DrawBuffer ui_draw2d; DrawBuffer ui_draw2d;
DrawBuffer ui_draw2d_front;
UIState uistate; UIState uistate;
// Theme. // Theme.
@ -19,6 +20,7 @@ static int themeCheckOffImage;
void UIInit(const Atlas *atlas, int uiFont, int buttonImage, int checkOn, int checkOff) { void UIInit(const Atlas *atlas, int uiFont, int buttonImage, int checkOn, int checkOff) {
ui_draw2d.SetAtlas(atlas); ui_draw2d.SetAtlas(atlas);
ui_draw2d_front.SetAtlas(atlas);
themeAtlas = atlas; themeAtlas = atlas;
themeUIFont = uiFont; themeUIFont = uiFont;
themeButtonImage = buttonImage; themeButtonImage = buttonImage;
@ -53,6 +55,7 @@ bool UIRegionHit(int x, int y, int w, int h, int margin) {
void UIBegin() { void UIBegin() {
uistate.hotitem = 0; uistate.hotitem = 0;
ui_draw2d.Begin(); ui_draw2d.Begin();
ui_draw2d_front.Begin();
} }
void UIEnd() { void UIEnd() {
@ -64,6 +67,7 @@ void UIEnd() {
} }
} }
ui_draw2d.End(); ui_draw2d.End();
ui_draw2d_front.End();
uistate.lastx = uistate.mousex; uistate.lastx = uistate.mousex;
uistate.lasty = uistate.mousey; uistate.lasty = uistate.mousey;

View file

@ -108,6 +108,7 @@ struct Atlas;
// This is the drawbuffer used for UI. Remember to flush it at the end of the frame. // This is the drawbuffer used for UI. Remember to flush it at the end of the frame.
// TODO: One should probably pass it in through UIInit. // TODO: One should probably pass it in through UIInit.
extern DrawBuffer ui_draw2d; extern DrawBuffer ui_draw2d;
extern DrawBuffer ui_draw2d_front; // for things that need to be on top of the rest
void UIInit(const Atlas *atlas, int uiFont, int buttonImage, int checkOn, int checkOff); void UIInit(const Atlas *atlas, int uiFont, int buttonImage, int checkOn, int checkOff);
@ -189,4 +190,6 @@ int UIList(int id, int x, int y, int w, int h, UIListAdapter *adapter, UIListSta
// Do this afterwards (or similar): // Do this afterwards (or similar):
// ShaderManager::SetUIProgram(); // ShaderManager::SetUIProgram();
// ui_draw2d.Flush(ShaderManager::Program()); // ui_draw2d.Flush(ShaderManager::Program());
// ui_draw2d_front.Flush(ShaderManager::Program());
void UIEnd(); void UIEnd();