Removed all dependency on interface rendering mode
parent
465fe59dfb
commit
16200bbeac
|
@ -378,6 +378,9 @@ public:
|
|||
//! Returns UI renderer
|
||||
virtual CUIRenderer* GetUIRenderer() = 0;
|
||||
|
||||
//! Restores device rendering mode
|
||||
virtual void Restore() = 0;
|
||||
|
||||
//! Sets the transform matrix of given type
|
||||
virtual void SetTransform(TransformType type, const Math::Matrix &matrix) = 0;
|
||||
|
||||
|
|
|
@ -359,7 +359,6 @@ bool CEngine::Create()
|
|||
|
||||
auto renderer = m_device->GetUIRenderer();
|
||||
renderer->SetProjection(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
|
||||
Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
|
||||
|
||||
|
@ -3651,8 +3650,6 @@ void CEngine::DrawCaptured3DScene()
|
|||
|
||||
renderer->SetTexture(m_capturedWorldTexture);
|
||||
renderer->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, 4, vertices);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::RenderDebugSphere(const Math::Sphere& sphere, const Math::Matrix& transform, const Gfx::Color& color)
|
||||
|
@ -4114,7 +4111,7 @@ void CEngine::DrawObject(const EngineBaseObjDataTier& p4)
|
|||
|
||||
void CEngine::DrawInterface()
|
||||
{
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
|
||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
||||
|
@ -4219,7 +4216,7 @@ void CEngine::DrawInterface()
|
|||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
||||
m_device->SetRenderState(RENDER_STATE_FOG, false);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
SetInterfaceCoordinates();
|
||||
}
|
||||
|
@ -4750,7 +4747,7 @@ void CEngine::DrawShadowSpots()
|
|||
|
||||
void CEngine::DrawBackground()
|
||||
{
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
if (m_cloud->GetLevel() != 0.0f) // clouds ?
|
||||
{
|
||||
|
@ -4879,8 +4876,6 @@ void CEngine::DrawBackgroundImage()
|
|||
|
||||
m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertices, 4);
|
||||
AddStatisticTriangle(2);
|
||||
|
||||
m_device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::DrawPlanet()
|
||||
|
@ -4927,7 +4922,7 @@ void CEngine::DrawForegroundImage()
|
|||
SetTexture(m_foregroundTex);
|
||||
SetState(ENG_RSTATE_CLAMP | ENG_RSTATE_TTEXTURE_BLACK);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface);
|
||||
m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface);
|
||||
|
@ -4935,8 +4930,6 @@ void CEngine::DrawForegroundImage()
|
|||
|
||||
m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
AddStatisticTriangle(2);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
}
|
||||
|
||||
void CEngine::DrawOverColor()
|
||||
|
@ -4955,7 +4948,7 @@ void CEngine::DrawOverColor()
|
|||
Color(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
};
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
m_device->SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
SetState(m_overMode);
|
||||
|
||||
|
@ -5136,8 +5129,6 @@ void CEngine::DrawMouseSprite(Math::IntPoint pos, Math::IntPoint size, int icon)
|
|||
|
||||
m_device->DrawPrimitive(PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
AddStatisticTriangle(2);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::DrawStats()
|
||||
|
@ -5241,8 +5232,6 @@ void CEngine::DrawStats()
|
|||
std::stringstream str;
|
||||
str << std::fixed << std::setprecision(2) << m_statisticPos.x << "; " << m_statisticPos.z;
|
||||
drawStatsLine( "Position", str.str(), "");
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::DrawTimer()
|
||||
|
@ -5251,8 +5240,6 @@ void CEngine::DrawTimer()
|
|||
|
||||
Math::Point pos(0.98f, 0.98f-m_text->GetAscent(FONT_COMMON, 15.0f));
|
||||
m_text->DrawText(m_timerText, FONT_COMMON, 15.0f, pos, 1.0f, TEXT_ALIGN_RIGHT, 0, Color(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::AddBaseObjTriangles(int baseObjRank, const std::vector<Gfx::ModelTriangle>& triangles)
|
||||
|
@ -5540,8 +5527,6 @@ void CEngine::SetInterfaceCoordinates()
|
|||
|
||||
auto renderer = m_device->GetUIRenderer();
|
||||
renderer->SetProjection(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::EnablePauseBlur()
|
||||
|
@ -5575,8 +5560,6 @@ void CEngine::SetWindowCoordinates()
|
|||
|
||||
auto renderer = m_device->GetUIRenderer();
|
||||
renderer->SetProjection(0.0f, m_size.x, m_size.y, 0.0f);
|
||||
|
||||
m_device->SetRenderMode(RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CEngine::SetUITexture(const std::string& name)
|
||||
|
|
|
@ -157,7 +157,6 @@ public:
|
|||
}
|
||||
|
||||
m_engine.GetDevice()->GetUIRenderer()->Flush();
|
||||
m_engine.GetDevice()->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
|
||||
//const Vertex* vertices = m_quads.front().vertices;
|
||||
//m_engine.GetDevice()->DrawPrimitives(PRIMITIVE_TRIANGLE_STRIP, vertices, m_firsts.data(),
|
||||
|
|
|
@ -514,7 +514,7 @@ bool CGL33Device::Create()
|
|||
glUniform1f(uni.alphaReference, 1.0f);
|
||||
}
|
||||
|
||||
m_uiRenderer = std::make_unique<CGL33UIRenderer>();
|
||||
m_uiRenderer = std::make_unique<CGL33UIRenderer>(this);
|
||||
|
||||
SetRenderMode(RENDER_MODE_NORMAL);
|
||||
|
||||
|
@ -609,6 +609,8 @@ void CGL33Device::BeginScene()
|
|||
|
||||
void CGL33Device::EndScene()
|
||||
{
|
||||
m_uiRenderer->Flush();
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
CheckGLErrors();
|
||||
#endif
|
||||
|
@ -655,6 +657,22 @@ CUIRenderer* CGL33Device::GetUIRenderer()
|
|||
return m_uiRenderer.get();
|
||||
}
|
||||
|
||||
void CGL33Device::Restore()
|
||||
{
|
||||
switch (m_mode)
|
||||
{
|
||||
case 0:
|
||||
glUseProgram(m_normalProgram);
|
||||
break;
|
||||
case 1:
|
||||
glUseProgram(m_interfaceProgram);
|
||||
break;
|
||||
case 2:
|
||||
glUseProgram(m_shadowProgram);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CGL33Device::SetTransform(TransformType type, const Math::Matrix &matrix)
|
||||
{
|
||||
if (type == TRANSFORM_WORLD)
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
void SetRenderMode(RenderMode mode) override;
|
||||
CUIRenderer* GetUIRenderer() override;
|
||||
|
||||
void Restore() override;
|
||||
|
||||
void SetTransform(TransformType type, const Math::Matrix &matrix) override;
|
||||
|
||||
void SetMaterial(const Material &material) override;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "graphics/opengl/gl33renderers.h"
|
||||
|
||||
#include "graphics/opengl/gl33device.h"
|
||||
#include "graphics/opengl/glutil.h"
|
||||
|
||||
#include "graphics/core/vertex.h"
|
||||
|
@ -13,7 +14,8 @@
|
|||
namespace Gfx
|
||||
{
|
||||
|
||||
CGL33UIRenderer::CGL33UIRenderer()
|
||||
CGL33UIRenderer::CGL33UIRenderer(CGL33Device* device)
|
||||
: m_device(device)
|
||||
{
|
||||
GLint shaders[2];
|
||||
|
||||
|
@ -95,7 +97,7 @@ void CGL33UIRenderer::SetProjection(float left, float right, float bottom, float
|
|||
|
||||
glUniformMatrix4fv(m_projectionMatrix, 1, GL_FALSE, glm::value_ptr(matrix));
|
||||
|
||||
glUseProgram(0);
|
||||
m_device->Restore();
|
||||
}
|
||||
|
||||
void CGL33UIRenderer::SetTexture(const Texture& texture)
|
||||
|
@ -166,9 +168,6 @@ void CGL33UIRenderer::Flush()
|
|||
// Draw primitives by grouping by type
|
||||
for (size_t i = 0; i < m_types.size(); i++)
|
||||
{
|
||||
//glDrawArrays(m_types[i], m_firsts[i], m_counts[i]);
|
||||
|
||||
//*
|
||||
size_t count = 1;
|
||||
|
||||
for (; i + count < m_types.size(); count++)
|
||||
|
@ -180,7 +179,6 @@ void CGL33UIRenderer::Flush()
|
|||
glMultiDrawArrays(m_types[i], &m_firsts[i], &m_counts[i], count);
|
||||
|
||||
i += count;
|
||||
// */
|
||||
}
|
||||
|
||||
// Clear buffers
|
||||
|
@ -189,7 +187,7 @@ void CGL33UIRenderer::Flush()
|
|||
m_firsts.clear();
|
||||
m_counts.clear();
|
||||
|
||||
glUseProgram(0);
|
||||
m_device->Restore();
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -35,10 +35,12 @@
|
|||
namespace Gfx
|
||||
{
|
||||
|
||||
class CGL33Device;
|
||||
|
||||
class CGL33UIRenderer : public CUIRenderer
|
||||
{
|
||||
public:
|
||||
CGL33UIRenderer();
|
||||
CGL33UIRenderer(CGL33Device* device);
|
||||
virtual ~CGL33UIRenderer();
|
||||
|
||||
virtual void SetProjection(float left, float right, float bottom, float top) override;
|
||||
|
@ -49,6 +51,8 @@ public:
|
|||
virtual void Flush() override;
|
||||
|
||||
private:
|
||||
CGL33Device* const m_device;
|
||||
|
||||
// location of uni_ProjectionMatrix uniform
|
||||
GLint m_projectionMatrix = -1;
|
||||
|
||||
|
|
|
@ -202,8 +202,6 @@ void CButton::Draw()
|
|||
pos.x = m_pos.x + m_dim.x - 5.0f / 640.0f - 3.0f / 640.0f;
|
||||
DrawIcon(pos, dim, uv1, uv2, 0.0f);
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -149,8 +149,6 @@ void CCheck::Draw()
|
|||
}
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
|
||||
m_dim = iDim;
|
||||
|
||||
// Draw the name.
|
||||
|
|
|
@ -160,8 +160,6 @@ void CColor::Draw()
|
|||
|
||||
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
|
||||
m_engine->AddStatisticTriangle(2);
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CColor::SetRepeat(bool bRepeat)
|
||||
|
|
|
@ -556,8 +556,6 @@ void CControl::Draw()
|
|||
m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
|
||||
}
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draw the vertex array.
|
||||
|
@ -666,8 +664,6 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
|
|||
m_engine->AddStatisticTriangle(6);
|
||||
}
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draws a rectangular icon made up of 9 pieces.
|
||||
|
@ -735,8 +731,6 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
|
|||
|
||||
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertices, 8);
|
||||
m_engine->AddStatisticTriangle(6);
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draw round the hatch of a button.
|
||||
|
@ -782,8 +776,6 @@ void CControl::DrawWarning(Math::Point pos, Math::Point dim)
|
|||
pos.x += dim.x;
|
||||
DrawIcon(pos, dim, uv1, uv2);
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draw the shade under a button.
|
||||
|
@ -818,8 +810,6 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
|
|||
corner.y = 10.0f / 480.0f;
|
||||
|
||||
DrawIcon(pos, dim, uv1, uv2, corner, 6.0f / 256.0f);
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1155,8 +1155,6 @@ void CEdit::Draw()
|
|||
{
|
||||
m_scroll->Draw();
|
||||
}
|
||||
|
||||
m_engine->GetDevice()->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draw an image part.
|
||||
|
|
|
@ -646,8 +646,6 @@ void CGroup::Draw()
|
|||
uv2.y -= dp;
|
||||
DrawIcon(pos, dim, uv1, uv2);
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -354,8 +354,6 @@ void CScroll::Draw()
|
|||
{
|
||||
m_buttonDown->Draw();
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draws a rectangle.
|
||||
|
|
|
@ -216,8 +216,6 @@ void CShortcut::Draw()
|
|||
|
||||
DrawIcon(m_pos, m_dim, uv1, uv2);
|
||||
}
|
||||
|
||||
m_engine->GetDevice()->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draw the vertex array.
|
||||
|
|
|
@ -475,8 +475,6 @@ void CSlider::Draw()
|
|||
m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
std::string CSlider::GetLabel()
|
||||
|
@ -543,8 +541,6 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
|
|||
uv2.y -= dp;
|
||||
|
||||
DrawIcon(pos, dim, uv1, uv2, corner, ex);
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -866,8 +866,6 @@ void CWindow::Draw()
|
|||
DrawHach(pos, dim); // right hatch
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
|
||||
pos.x = m_pos.x+width/2.0f;
|
||||
pos.y = m_pos.y+m_dim.y-0.01f-h*1.10f;
|
||||
m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, width, Gfx::TEXT_ALIGN_CENTER, 0);
|
||||
|
@ -892,8 +890,6 @@ void CWindow::Draw()
|
|||
{
|
||||
control->Draw();
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draws a rectangle.
|
||||
|
@ -1266,8 +1262,6 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
|
|||
corner.y = 6.0f/480.0f;
|
||||
DrawIcon(pos, dim, uv1, uv2, corner, 5.0f/256.0f);
|
||||
}
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
// Draws hatching.
|
||||
|
@ -1312,8 +1306,6 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
|
|||
ppos.x += ddim.x;
|
||||
}
|
||||
while ( !bStop );
|
||||
|
||||
device->SetRenderMode(Gfx::RENDER_MODE_INTERFACE);
|
||||
}
|
||||
|
||||
void CWindow::SetFocus(CControl* focusControl)
|
||||
|
|
Loading…
Reference in New Issue