mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Tech ENABLE_LEGACY_OPENGL_REMOVAL - Fixed rendering of layer editing background on older OpenGL compatibility profile
(cherry picked from commit prusa3d/PrusaSlicer@642f64cb41)
This commit is contained in:
parent
19ad0ca4d9
commit
461fa63cbf
3 changed files with 62 additions and 37 deletions
|
@ -421,7 +421,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
||||||
m_profile.background.reset();
|
m_profile.background.reset();
|
||||||
|
|
||||||
GLModel::Geometry init_data;
|
GLModel::Geometry init_data;
|
||||||
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2 };
|
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3T2 };
|
||||||
init_data.reserve_vertices(4);
|
init_data.reserve_vertices(4);
|
||||||
init_data.reserve_indices(6);
|
init_data.reserve_indices(6);
|
||||||
|
|
||||||
|
@ -430,10 +430,10 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
||||||
const float r = 1.0f;
|
const float r = 1.0f;
|
||||||
const float t = 1.0f;
|
const float t = 1.0f;
|
||||||
const float b = -1.0f;
|
const float b = -1.0f;
|
||||||
init_data.add_vertex(Vec2f(l, b), Vec2f(0.0f, 0.0f));
|
init_data.add_vertex(Vec3f(l, b, 0.0f), Vec3f::UnitZ(), Vec2f(0.0f, 0.0f));
|
||||||
init_data.add_vertex(Vec2f(r, b), Vec2f(1.0f, 0.0f));
|
init_data.add_vertex(Vec3f(r, b, 0.0f), Vec3f::UnitZ(), Vec2f(1.0f, 0.0f));
|
||||||
init_data.add_vertex(Vec2f(r, t), Vec2f(1.0f, 1.0f));
|
init_data.add_vertex(Vec3f(r, t, 0.0f), Vec3f::UnitZ(), Vec2f(1.0f, 1.0f));
|
||||||
init_data.add_vertex(Vec2f(l, t), Vec2f(0.0f, 1.0f));
|
init_data.add_vertex(Vec3f(l, t, 0.0f), Vec3f::UnitZ(), Vec2f(0.0f, 1.0f));
|
||||||
|
|
||||||
// indices
|
// indices
|
||||||
init_data.add_triangle(0, 1, 2);
|
init_data.add_triangle(0, 1, 2);
|
||||||
|
|
|
@ -97,6 +97,19 @@ void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal)
|
||||||
vertices.emplace_back(normal.z());
|
vertices.emplace_back(normal.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLModel::Geometry::add_vertex(const Vec3f& position, const Vec3f& normal, const Vec2f& tex_coord)
|
||||||
|
{
|
||||||
|
assert(format.vertex_layout == EVertexLayout::P3N3T2);
|
||||||
|
vertices.emplace_back(position.x());
|
||||||
|
vertices.emplace_back(position.y());
|
||||||
|
vertices.emplace_back(position.z());
|
||||||
|
vertices.emplace_back(normal.x());
|
||||||
|
vertices.emplace_back(normal.y());
|
||||||
|
vertices.emplace_back(normal.z());
|
||||||
|
vertices.emplace_back(tex_coord.x());
|
||||||
|
vertices.emplace_back(tex_coord.y());
|
||||||
|
}
|
||||||
|
|
||||||
void GLModel::Geometry::add_vertex(const Vec4f& position)
|
void GLModel::Geometry::add_vertex(const Vec4f& position)
|
||||||
{
|
{
|
||||||
assert(format.vertex_layout == EVertexLayout::P4);
|
assert(format.vertex_layout == EVertexLayout::P4);
|
||||||
|
@ -243,6 +256,7 @@ size_t GLModel::Geometry::vertex_stride_floats(const Format& format)
|
||||||
case EVertexLayout::P3: { return 3; }
|
case EVertexLayout::P3: { return 3; }
|
||||||
case EVertexLayout::P3T2: { return 5; }
|
case EVertexLayout::P3T2: { return 5; }
|
||||||
case EVertexLayout::P3N3: { return 6; }
|
case EVertexLayout::P3N3: { return 6; }
|
||||||
|
case EVertexLayout::P3N3T2: { return 8; }
|
||||||
case EVertexLayout::P4: { return 4; }
|
case EVertexLayout::P4: { return 4; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
|
@ -256,7 +270,8 @@ size_t GLModel::Geometry::position_stride_floats(const Format& format)
|
||||||
case EVertexLayout::P2T2: { return 2; }
|
case EVertexLayout::P2T2: { return 2; }
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3: { return 3; }
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2: { return 3; }
|
||||||
case EVertexLayout::P4: { return 4; }
|
case EVertexLayout::P4: { return 4; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
|
@ -271,6 +286,7 @@ size_t GLModel::Geometry::position_offset_floats(const Format& format)
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P4: { return 0; }
|
case EVertexLayout::P4: { return 0; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
|
@ -280,7 +296,8 @@ size_t GLModel::Geometry::normal_stride_floats(const Format& format)
|
||||||
{
|
{
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P3N3: { return 3; }
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2: { return 3; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -289,7 +306,8 @@ size_t GLModel::Geometry::normal_offset_floats(const Format& format)
|
||||||
{
|
{
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P3N3: { return 3; }
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2: { return 3; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -299,7 +317,8 @@ size_t GLModel::Geometry::tex_coord_stride_floats(const Format& format)
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P2T2:
|
case EVertexLayout::P2T2:
|
||||||
case EVertexLayout::P3T2: { return 2; }
|
case EVertexLayout::P3T2:
|
||||||
|
case EVertexLayout::P3N3T2: { return 2; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -310,6 +329,7 @@ size_t GLModel::Geometry::tex_coord_offset_floats(const Format& format)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P2T2: { return 2; }
|
case EVertexLayout::P2T2: { return 2; }
|
||||||
case EVertexLayout::P3T2: { return 3; }
|
case EVertexLayout::P3T2: { return 3; }
|
||||||
|
case EVertexLayout::P3N3T2: { return 6; }
|
||||||
default: { assert(false); return 0; }
|
default: { assert(false); return 0; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -334,6 +354,7 @@ bool GLModel::Geometry::has_position(const Format& format)
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2:
|
||||||
case EVertexLayout::P4: { return true; }
|
case EVertexLayout::P4: { return true; }
|
||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
|
@ -348,7 +369,8 @@ bool GLModel::Geometry::has_normal(const Format& format)
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3T2:
|
case EVertexLayout::P3T2:
|
||||||
case EVertexLayout::P4: { return false; }
|
case EVertexLayout::P4: { return false; }
|
||||||
case EVertexLayout::P3N3: { return true; }
|
case EVertexLayout::P3N3:
|
||||||
|
case EVertexLayout::P3N3T2: { return true; }
|
||||||
default: { assert(false); return false; }
|
default: { assert(false); return false; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -358,7 +380,8 @@ bool GLModel::Geometry::has_tex_coord(const Format& format)
|
||||||
switch (format.vertex_layout)
|
switch (format.vertex_layout)
|
||||||
{
|
{
|
||||||
case EVertexLayout::P2T2:
|
case EVertexLayout::P2T2:
|
||||||
case EVertexLayout::P3T2: { return true; }
|
case EVertexLayout::P3T2:
|
||||||
|
case EVertexLayout::P3N3T2: { return true; }
|
||||||
case EVertexLayout::P2:
|
case EVertexLayout::P2:
|
||||||
case EVertexLayout::P3:
|
case EVertexLayout::P3:
|
||||||
case EVertexLayout::P3N3:
|
case EVertexLayout::P3N3:
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace GUI {
|
||||||
P3, // position 3 floats
|
P3, // position 3 floats
|
||||||
P3T2, // position 3 floats + texture coords 2 floats
|
P3T2, // position 3 floats + texture coords 2 floats
|
||||||
P3N3, // position 3 floats + normal 3 floats
|
P3N3, // position 3 floats + normal 3 floats
|
||||||
|
P3N3T2, // position 3 floats + normal 3 floats + texture coords 2 floats
|
||||||
P4, // position 4 floats
|
P4, // position 4 floats
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ namespace GUI {
|
||||||
void add_vertex(const Vec3f& position); // EVertexLayout::P3
|
void add_vertex(const Vec3f& position); // EVertexLayout::P3
|
||||||
void add_vertex(const Vec3f& position, const Vec2f& tex_coord); // EVertexLayout::P3T2
|
void add_vertex(const Vec3f& position, const Vec2f& tex_coord); // EVertexLayout::P3T2
|
||||||
void add_vertex(const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
void add_vertex(const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
||||||
|
void add_vertex(const Vec3f& position, const Vec3f& normal, const Vec2f& tex_coord); // EVertexLayout::P3N3T2
|
||||||
void add_vertex(const Vec4f& position); // EVertexLayout::P4
|
void add_vertex(const Vec4f& position); // EVertexLayout::P4
|
||||||
|
|
||||||
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue