2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-10 16:27:43 +00:00

Deadlock fix and toolbar shading

This commit is contained in:
Jack Andersen
2015-12-03 15:35:01 -10:00
parent bd0becc9c0
commit f53127290d
11 changed files with 128 additions and 53 deletions

View File

@@ -2,52 +2,55 @@
#include "Specter/Toolbar.hpp"
#include "Specter/ViewResources.hpp"
#define TOOLBAR_GAUGE 28
namespace Specter
{
static LogVisor::LogModule Log("Specter::Space");
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory)
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData& theme)
{
static const Zeus::RGBA32 tex[3] =
{
{0,0,0,64},
{0,0,0,0},
{255,255,255,64}
{255,255,255,64},
{255,255,255,64},
{0,0,0,64}
};
m_shadingTex = factory->newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, tex, 12);
}
Toolbar::Toolbar(ViewResources& system, View& parentView, Position tbPos)
: View(system, parentView), m_tbPos(tbPos), m_gauge(system.pixelFactor() * 25)
Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos)
: View(res, parentView), m_tbPos(tbPos), m_gauge(res.pixelFactor() * TOOLBAR_GAUGE)
{
m_tbBlockBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
m_tbVertsBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(ToolbarVert), 10);
m_tbBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
m_tbVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(ToolbarVert), 10);
if (!system.m_viewRes.m_texVtxFmt)
if (!res.m_viewRes.m_texVtxFmt)
{
boo::VertexElementDescriptor vdescs[] =
{
{m_tbVertsBuf, nullptr, boo::VertexSemantic::Position4},
{m_tbVertsBuf, nullptr, boo::VertexSemantic::UV4}
};
m_tbVtxFmt = system.m_factory->newVertexFormat(2, vdescs);
m_tbVtxFmt = res.m_factory->newVertexFormat(2, vdescs);
boo::IGraphicsBuffer* bufs[] = {m_tbBlockBuf};
boo::ITexture* texs[] = {system.m_toolbarRes.m_shadingTex};
m_tbShaderBinding = system.m_factory->newShaderDataBinding(system.m_viewRes.m_texShader,
m_tbVtxFmt, m_tbVertsBuf, nullptr,
nullptr, 1, bufs, 1, texs);
boo::ITexture* texs[] = {res.m_toolbarRes.m_shadingTex};
m_tbShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_texShader,
m_tbVtxFmt, m_tbVertsBuf, nullptr,
nullptr, 1, bufs, 1, texs);
}
else
{
boo::IGraphicsBuffer* bufs[] = {m_tbBlockBuf};
boo::ITexture* texs[] = {system.m_toolbarRes.m_shadingTex};
m_tbShaderBinding = system.m_factory->newShaderDataBinding(system.m_viewRes.m_texShader,
system.m_viewRes.m_texVtxFmt,
m_tbVertsBuf, nullptr,
nullptr, 1, bufs, 1, texs);
boo::ITexture* texs[] = {res.m_toolbarRes.m_shadingTex};
m_tbShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_texShader,
res.m_viewRes.m_texVtxFmt,
m_tbVertsBuf, nullptr,
nullptr, 1, bufs, 1, texs);
}
commitResources(system);
setBackground(res.themeData().toolbarBackground());
commitResources(res);
}
void Toolbar::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
@@ -64,7 +67,8 @@ void Toolbar::mouseMove(const boo::SWindowCoord& coord)
void Toolbar::resetResources(ViewResources& res)
{
m_gauge = res.pixelFactor() * 25;
m_gauge = res.pixelFactor() * TOOLBAR_GAUGE;
setBackground(res.themeData().toolbarBackground());
updateSize();
}
@@ -73,12 +77,16 @@ void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
View::resized(root, sub);
setHorizontalVerts(sub.size[0]);
m_tbVertsBuf->load(&m_tbVerts, sizeof(ToolbarVert) * 10);
m_tbBlock.setViewRect(root, sub);
m_tbBlockBuf->load(&m_tbBlock, sizeof(ViewBlock));
}
void Toolbar::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
gfxQ->setShaderDataBinding(m_tbShaderBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 10);
}
}