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();
|
||||
|
||||
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_indices(6);
|
||||
|
||||
|
@ -430,10 +430,10 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
|
|||
const float r = 1.0f;
|
||||
const float t = 1.0f;
|
||||
const float b = -1.0f;
|
||||
init_data.add_vertex(Vec2f(l, b), Vec2f(0.0f, 0.0f));
|
||||
init_data.add_vertex(Vec2f(r, b), Vec2f(1.0f, 0.0f));
|
||||
init_data.add_vertex(Vec2f(r, t), Vec2f(1.0f, 1.0f));
|
||||
init_data.add_vertex(Vec2f(l, t), Vec2f(0.0f, 1.0f));
|
||||
init_data.add_vertex(Vec3f(l, b, 0.0f), Vec3f::UnitZ(), Vec2f(0.0f, 0.0f));
|
||||
init_data.add_vertex(Vec3f(r, b, 0.0f), Vec3f::UnitZ(), Vec2f(1.0f, 0.0f));
|
||||
init_data.add_vertex(Vec3f(r, t, 0.0f), Vec3f::UnitZ(), Vec2f(1.0f, 1.0f));
|
||||
init_data.add_vertex(Vec3f(l, t, 0.0f), Vec3f::UnitZ(), Vec2f(0.0f, 1.0f));
|
||||
|
||||
// indices
|
||||
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());
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
assert(format.vertex_layout == EVertexLayout::P4);
|
||||
|
@ -238,13 +251,14 @@ size_t GLModel::Geometry::vertex_stride_floats(const Format& format)
|
|||
{
|
||||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P2: { return 2; }
|
||||
case EVertexLayout::P2T2: { return 4; }
|
||||
case EVertexLayout::P3: { return 3; }
|
||||
case EVertexLayout::P3T2: { return 5; }
|
||||
case EVertexLayout::P3N3: { return 6; }
|
||||
case EVertexLayout::P4: { return 4; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P2: { return 2; }
|
||||
case EVertexLayout::P2T2: { return 4; }
|
||||
case EVertexLayout::P3: { return 3; }
|
||||
case EVertexLayout::P3T2: { return 5; }
|
||||
case EVertexLayout::P3N3: { return 6; }
|
||||
case EVertexLayout::P3N3T2: { return 8; }
|
||||
case EVertexLayout::P4: { return 4; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -253,12 +267,13 @@ size_t GLModel::Geometry::position_stride_floats(const Format& format)
|
|||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P2:
|
||||
case EVertexLayout::P2T2: { return 2; }
|
||||
case EVertexLayout::P2T2: { return 2; }
|
||||
case EVertexLayout::P3:
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P3N3: { return 3; }
|
||||
case EVertexLayout::P4: { return 4; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2: { return 3; }
|
||||
case EVertexLayout::P4: { return 4; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -271,6 +286,7 @@ size_t GLModel::Geometry::position_offset_floats(const Format& format)
|
|||
case EVertexLayout::P3:
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2:
|
||||
case EVertexLayout::P4: { return 0; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
|
@ -280,8 +296,9 @@ size_t GLModel::Geometry::normal_stride_floats(const Format& format)
|
|||
{
|
||||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P3N3: { return 3; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2: { return 3; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -289,8 +306,9 @@ size_t GLModel::Geometry::normal_offset_floats(const Format& format)
|
|||
{
|
||||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P3N3: { return 3; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2: { return 3; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -299,8 +317,9 @@ size_t GLModel::Geometry::tex_coord_stride_floats(const Format& format)
|
|||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P2T2:
|
||||
case EVertexLayout::P3T2: { return 2; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P3N3T2: { return 2; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -308,9 +327,10 @@ size_t GLModel::Geometry::tex_coord_offset_floats(const Format& format)
|
|||
{
|
||||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P2T2: { return 2; }
|
||||
case EVertexLayout::P3T2: { return 3; }
|
||||
default: { assert(false); return 0; }
|
||||
case EVertexLayout::P2T2: { return 2; }
|
||||
case EVertexLayout::P3T2: { return 3; }
|
||||
case EVertexLayout::P3N3T2: { return 6; }
|
||||
default: { assert(false); return 0; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -334,6 +354,7 @@ bool GLModel::Geometry::has_position(const Format& format)
|
|||
case EVertexLayout::P3:
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2:
|
||||
case EVertexLayout::P4: { return true; }
|
||||
default: { assert(false); return false; }
|
||||
};
|
||||
|
@ -347,9 +368,10 @@ bool GLModel::Geometry::has_normal(const Format& format)
|
|||
case EVertexLayout::P2T2:
|
||||
case EVertexLayout::P3:
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P4: { return false; }
|
||||
case EVertexLayout::P3N3: { return true; }
|
||||
default: { assert(false); return false; }
|
||||
case EVertexLayout::P4: { return false; }
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P3N3T2: { return true; }
|
||||
default: { assert(false); return false; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -358,12 +380,13 @@ bool GLModel::Geometry::has_tex_coord(const Format& format)
|
|||
switch (format.vertex_layout)
|
||||
{
|
||||
case EVertexLayout::P2T2:
|
||||
case EVertexLayout::P3T2: { return true; }
|
||||
case EVertexLayout::P3T2:
|
||||
case EVertexLayout::P3N3T2: { return true; }
|
||||
case EVertexLayout::P2:
|
||||
case EVertexLayout::P3:
|
||||
case EVertexLayout::P3N3:
|
||||
case EVertexLayout::P4: { return false; }
|
||||
default: { assert(false); return false; }
|
||||
case EVertexLayout::P4: { return false; }
|
||||
default: { assert(false); return false; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace GUI {
|
|||
P3, // position 3 floats
|
||||
P3T2, // position 3 floats + texture coords 2 floats
|
||||
P3N3, // position 3 floats + normal 3 floats
|
||||
P3N3T2, // position 3 floats + normal 3 floats + texture coords 2 floats
|
||||
P4, // position 4 floats
|
||||
};
|
||||
|
||||
|
@ -66,12 +67,13 @@ namespace GUI {
|
|||
void reserve_vertices(size_t vertices_count) { vertices.reserve(vertices_count * vertex_stride_floats(format)); }
|
||||
void reserve_indices(size_t indices_count) { indices.reserve(indices_count); }
|
||||
|
||||
void add_vertex(const Vec2f& position); // EVertexLayout::P2
|
||||
void add_vertex(const Vec2f& position, const Vec2f& tex_coord); // EVertexLayout::P2T2
|
||||
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 Vec3f& normal); // EVertexLayout::P3N3
|
||||
void add_vertex(const Vec4f& position); // EVertexLayout::P4
|
||||
void add_vertex(const Vec2f& position); // EVertexLayout::P2
|
||||
void add_vertex(const Vec2f& position, const Vec2f& tex_coord); // EVertexLayout::P2T2
|
||||
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 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 set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue