2012-11-20 22:35:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2013-05-27 22:32:00 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "math/geom2d.h"
|
|
|
|
#include "gfx/texture_atlas.h"
|
|
|
|
|
2012-11-20 22:35:40 +00:00
|
|
|
// Everything you need to draw a UI collected into a single unit that can be passed around.
|
|
|
|
// Everything forward declared so this header is safe everywhere.
|
|
|
|
|
|
|
|
struct GLSLProgram;
|
|
|
|
class Texture;
|
|
|
|
class DrawBuffer;
|
|
|
|
|
2013-05-27 22:32:00 +00:00
|
|
|
// Kind of ugly connection to UI.
|
|
|
|
namespace UI {
|
|
|
|
struct Theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
class DrawBuffer;
|
|
|
|
|
2013-03-30 18:23:02 +00:00
|
|
|
// Who should own this? Really not sure.
|
2012-11-20 22:35:40 +00:00
|
|
|
class UIContext {
|
|
|
|
public:
|
|
|
|
UIContext() : uishader_(0), uitexture_(0), uidrawbuffer_(0), uidrawbufferTop_(0) {}
|
|
|
|
|
2012-11-21 14:30:43 +00:00
|
|
|
void Init(const GLSLProgram *uishader, const GLSLProgram *uishadernotex, Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) {
|
2012-11-20 22:35:40 +00:00
|
|
|
uishader_ = uishader;
|
2012-11-21 14:30:43 +00:00
|
|
|
uishadernotex_ = uishadernotex;
|
2012-11-20 22:35:40 +00:00
|
|
|
uitexture_ = uitexture;
|
|
|
|
uidrawbuffer_ = uidrawbuffer;
|
|
|
|
uidrawbufferTop_ = uidrawbufferTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Begin();
|
2013-03-30 18:23:02 +00:00
|
|
|
void BeginNoTex();
|
2012-11-21 14:30:43 +00:00
|
|
|
void Flush();
|
2012-11-20 22:35:40 +00:00
|
|
|
void End();
|
2013-03-30 18:23:02 +00:00
|
|
|
|
2013-03-30 19:10:01 +00:00
|
|
|
void RebindTexture() const;
|
2012-11-20 22:35:40 +00:00
|
|
|
|
2013-05-27 22:32:00 +00:00
|
|
|
// TODO: Support transformed bounds using stencil
|
|
|
|
void PushScissor(const Bounds &bounds);
|
|
|
|
void PopScissor();
|
|
|
|
|
|
|
|
void ActivateTopScissor();
|
|
|
|
|
|
|
|
DrawBuffer *Draw() const { return uidrawbuffer_; }
|
|
|
|
|
|
|
|
const UI::Theme *theme;
|
|
|
|
|
2012-11-20 22:35:40 +00:00
|
|
|
private:
|
|
|
|
// TODO: Collect these into a UIContext
|
|
|
|
const GLSLProgram *uishader_;
|
2012-11-21 14:30:43 +00:00
|
|
|
const GLSLProgram *uishadernotex_;
|
2012-11-20 22:35:40 +00:00
|
|
|
Texture *uitexture_;
|
|
|
|
DrawBuffer *uidrawbuffer_;
|
|
|
|
DrawBuffer *uidrawbufferTop_;
|
2013-05-27 22:32:00 +00:00
|
|
|
|
|
|
|
std::vector<Bounds> scissorStack_;
|
2012-11-20 22:35:40 +00:00
|
|
|
};
|