metaforce/specter/include/Specter/View.hpp

76 lines
1.9 KiB
C++
Raw Normal View History

2015-11-21 01:14:49 +00:00
#ifndef SPECTER_VIEW_HPP
#define SPECTER_VIEW_HPP
2015-11-21 23:45:02 +00:00
#include <boo/boo.hpp>
2015-11-25 01:46:30 +00:00
#include "CVector3f.hpp"
#include "CMatrix4f.hpp"
#include "CTransform.hpp"
#include "CColor.hpp"
2015-11-21 23:45:02 +00:00
2015-11-26 00:24:01 +00:00
#include <boo/graphicsdev/GL.hpp>
#include <boo/graphicsdev/D3D.hpp>
#include <boo/graphicsdev/Metal.hpp>
2015-11-21 01:14:49 +00:00
namespace Specter
{
2015-11-26 00:24:01 +00:00
class ViewSystem;
2015-11-21 01:14:49 +00:00
class View
{
2015-11-26 00:24:01 +00:00
boo::IGraphicsBufferD* m_bgVertBuf;
boo::IGraphicsBufferD* m_bgInstBuf;
boo::IVertexFormat* m_bgVtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_bgShaderBinding;
Zeus::CVector3f m_bgRect[4];
Zeus::CColor m_bgColor;
2015-11-26 07:35:43 +00:00
int m_bgValidSlots = 0;
protected:
struct VertexBlock
{
Zeus::CMatrix4f m_mv;
2015-11-26 23:03:56 +00:00
void setViewRect(const boo::SWindowRect& root, const boo::SWindowRect& sub)
{
m_mv[0][0] = 2.0f / root.size[0];
m_mv[1][1] = 2.0f / root.size[1];
m_mv[3][0] = sub.location[0] * m_mv[0][0] - 1.0f;
m_mv[3][1] = sub.location[1] * m_mv[1][1] - 1.0f;
}
2015-11-26 07:35:43 +00:00
} m_viewVertBlock;
#define SPECTER_VIEW_VERT_BLOCK_GLSL\
"uniform SpecterViewBlock\n"\
"{\n"\
" mat4 mv;\n"\
"};\n"
boo::IGraphicsBufferD* m_viewVertBlockBuf;
2015-11-26 00:24:01 +00:00
public:
class System
{
friend class ViewSystem;
friend class View;
boo::IShaderPipeline* m_solidShader = nullptr;
boo::IVertexFormat* m_vtxFmt = nullptr; /* Not OpenGL */
void init(boo::GLDataFactory* factory);
#if _WIN32
void init(boo::ID3DDataFactory* factory);
#elif BOO_HAS_METAL
void init(boo::MetalDataFactory* factory);
#endif
};
2015-11-25 01:46:30 +00:00
protected:
2015-11-26 00:24:01 +00:00
View(ViewSystem& system);
2015-11-21 23:45:02 +00:00
public:
2015-11-26 23:03:56 +00:00
View() = delete;
2015-11-26 07:35:43 +00:00
void setBackground(Zeus::CColor color) {m_bgColor = color; m_bgValidSlots = 0;}
2015-11-26 23:03:56 +00:00
virtual void resized(const boo::SWindowRect &root, const boo::SWindowRect& sub);
2015-11-26 00:24:01 +00:00
virtual void draw(boo::IGraphicsCommandQueue* gfxQ);
2015-11-21 01:14:49 +00:00
};
}
#endif // SPECTER_VIEW_HPP