Require RenderState for DrawLines (one of them)
parent
9e6d7938ca
commit
1bdb7dc915
|
@ -507,9 +507,8 @@ void ModelViewer::DrawAabb()
|
|||
vector3f(aabb.min.x, aabb.max.y, aabb.max.z),
|
||||
};
|
||||
|
||||
m_renderer->SetRenderState(m_bgState);
|
||||
m_renderer->DrawLines(8, verts + 0, Color::GREEN, Graphics::LINE_STRIP);
|
||||
m_renderer->DrawLines(8, verts + 8, Color::GREEN, Graphics::LINE_STRIP);
|
||||
m_renderer->DrawLines(8, verts + 0, Color::GREEN, m_bgState, Graphics::LINE_STRIP);
|
||||
m_renderer->DrawLines(8, verts + 8, Color::GREEN, m_bgState, Graphics::LINE_STRIP);
|
||||
}
|
||||
|
||||
//Draw grid and axes
|
||||
|
@ -542,8 +541,7 @@ void ModelViewer::DrawGrid(const matrix4x4f &trans, float radius)
|
|||
}
|
||||
|
||||
m_renderer->SetTransform(trans);
|
||||
m_renderer->SetRenderState(m_bgState);
|
||||
m_renderer->DrawLines(points.size(), &points[0], Color(128));//Color(0.0f,0.2f,0.0f,1.0f));
|
||||
m_renderer->DrawLines(points.size(), &points[0], Color(128), m_bgState);//Color(0.0f,0.2f,0.0f,1.0f));
|
||||
|
||||
//industry-standard red/green/blue XYZ axis indiactor
|
||||
const int numAxVerts = 6;
|
||||
|
|
|
@ -407,7 +407,7 @@ void ScannerWidget::DrawBlobs(bool below)
|
|||
const float y_blob = y_base - m_y * SCANNER_YSHRINK * float(pos.y) * m_scale;
|
||||
|
||||
const vector3f verts[] = { vector3f(x, y_base, 0.f), vector3f(x, y_blob, 0.f) };
|
||||
m_renderer->DrawLines(2, &verts[0], *color);
|
||||
m_renderer->DrawLines(2, &verts[0], *color, m_renderState);
|
||||
|
||||
vector3f blob(x, y_blob, 0.f);
|
||||
m_renderer->DrawPoints(1, &blob, color, m_renderState, pointSize);
|
||||
|
|
|
@ -483,7 +483,9 @@ void SystemInfoView::BodyIcon::Draw()
|
|||
Color portColor = Color(64, 128, 128, 255);
|
||||
// The -0.1f offset seems to be the best compromise to make the circles closed (e.g. around Mars), symmetric, fitting with selection
|
||||
// and not overlapping to much with asteroids
|
||||
Graphics::Drawables::Circle circle = Graphics::Drawables::Circle(size[0]*0.5f, size[0]*0.5f-0.1f, size[1]*0.5f, 0.f, portColor);
|
||||
Graphics::Drawables::Circle circle =
|
||||
Graphics::Drawables::Circle(size[0]*0.5f, size[0]*0.5f-0.1f, size[1]*0.5f, 0.f,
|
||||
portColor, m_renderState);
|
||||
circle.Draw(m_renderer);
|
||||
}
|
||||
if (GetSelected()) {
|
||||
|
|
|
@ -30,6 +30,9 @@ SystemView::SystemView()
|
|||
{
|
||||
SetTransparency(true);
|
||||
|
||||
Graphics::RenderStateDesc rsd;
|
||||
m_lineState = Pi::renderer->CreateRenderState(rsd); //m_renderer not set yet
|
||||
|
||||
m_realtime = true;
|
||||
|
||||
Gui::Screen::PushFont("OverlayFont");
|
||||
|
@ -149,9 +152,9 @@ void SystemView::PutOrbit(const Orbit *orbit, const vector3d &offset, const Colo
|
|||
if (num_vertices > 1) {
|
||||
// don't close the loop for hyperbolas and parabolas and crashed ellipses
|
||||
if ((orbit->GetEccentricity() > 1.0) || (num_vertices < int(COUNTOF(vts))))
|
||||
m_renderer->DrawLines(num_vertices, vts, color, LINE_STRIP);
|
||||
m_renderer->DrawLines(num_vertices, vts, color, m_lineState, LINE_STRIP);
|
||||
else
|
||||
m_renderer->DrawLines(num_vertices, vts, color, LINE_LOOP);
|
||||
m_renderer->DrawLines(num_vertices, vts, color, m_lineState, LINE_LOOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +302,7 @@ void SystemView::PutSelectionBox(const vector3d &worldPos, const Color &col)
|
|||
vector3f(x2, y2, 0.f),
|
||||
vector3f(x1, y2, 0.f)
|
||||
};
|
||||
m_renderer->DrawLines(4, &verts[0], col, Graphics::LINE_LOOP);
|
||||
m_renderer->DrawLines(4, &verts[0], col, m_lineState, Graphics::LINE_LOOP);
|
||||
}
|
||||
|
||||
Gui::Screen::LeaveOrtho();
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
sigc::connection m_onMouseWheelCon;
|
||||
|
||||
std::unique_ptr<Graphics::Drawables::Disk> m_bodyIcon;
|
||||
Graphics::RenderState *m_lineState;
|
||||
};
|
||||
|
||||
#endif /* _SYSTEMVIEW_H */
|
||||
|
|
|
@ -25,23 +25,26 @@ protected:
|
|||
|
||||
class Circle : public Drawable {
|
||||
public:
|
||||
Circle(float radius, const Color &c) : m_color(c) {
|
||||
Circle(float radius, const Color &c, RenderState *state) : m_color(c) {
|
||||
m_renderState = state;
|
||||
for (float theta=0; theta < 2*float(M_PI); theta += 0.05f*float(M_PI)) {
|
||||
m_verts.push_back(vector3f(radius*sin(theta), radius*cos(theta), 0));
|
||||
}
|
||||
}
|
||||
Circle(float radius, float x, float y, float z, const Color &c) : m_color(c) {
|
||||
Circle(float radius, float x, float y, float z, const Color &c, RenderState *state) : m_color(c) {
|
||||
m_renderState = state;
|
||||
for (float theta=0; theta < 2*float(M_PI); theta += 0.05f*float(M_PI)) {
|
||||
m_verts.push_back(vector3f(radius*sin(theta) + x, radius*cos(theta) + y, z));
|
||||
}
|
||||
}
|
||||
Circle(float radius, const vector3f ¢er, const Color &c) : m_color(c) {
|
||||
Circle(float radius, const vector3f ¢er, const Color &c, RenderState *state) : m_color(c) {
|
||||
m_renderState = state;
|
||||
for (float theta=0; theta < 2*float(M_PI); theta += 0.05f*float(M_PI)) {
|
||||
m_verts.push_back(vector3f(radius*sin(theta) + center.x, radius*cos(theta) + center.y, center.z));
|
||||
}
|
||||
}
|
||||
virtual void Draw(Renderer *renderer) {
|
||||
renderer->DrawLines(m_verts.size(), &m_verts[0], m_color, LINE_LOOP);
|
||||
renderer->DrawLines(m_verts.size(), &m_verts[0], m_color, m_renderState, LINE_LOOP);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -140,9 +140,9 @@ public:
|
|||
//per-vertex colour lines
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color *colors, LineType type=LINE_SINGLE) { return false; }
|
||||
//flat colour lines
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color &color, LineType type=LINE_SINGLE) { return false; }
|
||||
virtual bool DrawLines2D(int vertCount, const vector2f *vertices, const Color &color, Graphics::RenderState*, LineType type=LINE_SINGLE) { return false; }
|
||||
virtual bool DrawPoints(int count, const vector3f *points, const Color *colors, Graphics::RenderState*, float pointSize=1.f) { return false; }
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color &color, RenderState*, LineType type=LINE_SINGLE) { return false; }
|
||||
virtual bool DrawLines2D(int vertCount, const vector2f *vertices, const Color &color, RenderState*, LineType type=LINE_SINGLE) { return false; }
|
||||
virtual bool DrawPoints(int count, const vector3f *points, const Color *colors, RenderState*, float pointSize=1.f) { return false; }
|
||||
//unindexed triangle draw
|
||||
virtual bool DrawTriangles(const VertexArray *vertices, RenderState *state, Material *material, PrimitiveType type=TRIANGLES) { return false; }
|
||||
//indexed triangle draw
|
||||
|
|
|
@ -376,6 +376,7 @@ bool RendererGL2::DrawLines(int count, const vector3f *v, const Color *c, LineTy
|
|||
|
||||
vtxColorProg->Use();
|
||||
vtxColorProg->invLogZfarPlus1.Set(m_invLogZfarPlus1);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(vector3f), v);
|
||||
|
@ -387,14 +388,17 @@ bool RendererGL2::DrawLines(int count, const vector3f *v, const Color *c, LineTy
|
|||
return true;
|
||||
}
|
||||
|
||||
bool RendererGL2::DrawLines(int count, const vector3f *v, const Color &c, LineType t)
|
||||
bool RendererGL2::DrawLines(int count, const vector3f *v, const Color &c, RenderState *state, LineType t)
|
||||
{
|
||||
PROFILE_SCOPED()
|
||||
if (count < 2 || !v) return false;
|
||||
|
||||
SetRenderState(state);
|
||||
|
||||
flatColorProg->Use();
|
||||
flatColorProg->diffuse.Set(c);
|
||||
flatColorProg->invLogZfarPlus1.Set(m_invLogZfarPlus1);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(vector3f), v);
|
||||
glDrawArrays(t, 0, count);
|
||||
|
|
|
@ -70,9 +70,9 @@ public:
|
|||
|
||||
virtual bool SetScissor(bool enabled, const vector2f &pos = vector2f(0.0f), const vector2f &size = vector2f(0.0f));
|
||||
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color *colors, LineType type=LINE_SINGLE);
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color &color, LineType type=LINE_SINGLE);
|
||||
virtual bool DrawLines2D(int vertCount, const vector2f *vertices, const Color &color, Graphics::RenderState*, LineType type=LINE_SINGLE) override;
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color *colors, LineType type=LINE_SINGLE) override;
|
||||
virtual bool DrawLines(int vertCount, const vector3f *vertices, const Color &color, RenderState*, LineType type=LINE_SINGLE);
|
||||
virtual bool DrawLines2D(int vertCount, const vector2f *vertices, const Color &color, RenderState*, LineType type=LINE_SINGLE) override;
|
||||
virtual bool DrawPoints(int count, const vector3f *points, const Color *colors, RenderState*, float pointSize=1.f) override;
|
||||
virtual bool DrawTriangles(const VertexArray *vertices, RenderState *state, Material *material, PrimitiveType type=TRIANGLES) override;
|
||||
virtual bool DrawSurface(const Surface *surface, RenderState *rs) override;
|
||||
|
|
|
@ -74,8 +74,10 @@ void TextEntry::Draw()
|
|||
|
||||
Container::Draw();
|
||||
|
||||
if (IsSelected())
|
||||
GetContext()->GetRenderer()->DrawLines(2, m_cursorVertices, Color::WHITE);
|
||||
if (IsSelected()) {
|
||||
GetContext()->GetRenderer()->DrawLines(2, m_cursorVertices,
|
||||
Color::WHITE, GetContext()->GetSkin().GetAlphaBlendState());
|
||||
}
|
||||
}
|
||||
|
||||
TextEntry *TextEntry::SetText(const std::string &text)
|
||||
|
|
Loading…
Reference in New Issue