Un-commenting Line 166 stops all rendering, also, it appears circles are gone?
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
2024-10-22 13:26:04 -04:00
parent aa4a29961c
commit e4a4f01b28
3 changed files with 87 additions and 7 deletions

View File

@@ -319,15 +319,46 @@ namespace JGL {
/// @param A
/// @param B
/// @param thickness
void DrawLine(const Color4& color, const Vector3& A, const Vector3& B, float thickness = 1);
void FillSphere(const Color3& color, const Sphere& sphere);
void WireframeSphere(const Color3& color, const Sphere& sphere, float thickness = 1);
void DrawLine(const Color4& color, const Vector3& A, const Vector3& B, float thickness = 1.f);
void WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f);
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void WireframeIcosphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f);
void WireframeIcosphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void WireframeCubesphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f);
void WireframeCubesphere(const Color4& color, const Sphere& sphere, float thickness = 1.f);
void FillSphere(const Color4& color, const Vector3& position, float radius);
void FillSphere(const Color4& color, const Sphere& sphere);
void FillIcosphere(const Color4& color, const Vector3& position, float radius);
void FillIcosphere(const Color4& color, const Sphere& sphere);
void FillCubesphere(const Color4& color, const Vector3& position, float radius);
void FillCubesphere(const Color4& color, const Sphere& sphere);
void WireframeAABB(const Color4& color, const AABB& aabb);
void WireframeAABB(const Color4& color, const Vector3& pos, const Vector3& radii, float thickness = 1.f);
void FillAABB(const Color4& color, const AABB& aabb);
void FillAABB(const Color4& color, const Vector3& pos, const Vector3& radii);
void WireframeCylinder();
void FillCylinder();
void WireframePrism();
void FillPrism();
void WireframePipe();
void FillPipe();
void WireframeCone();
void FillCone();
void WireframeTorus();
void FillTorus();
void FillOBB(const Color3& color, const OBB& obb);
void WireframeOBB(const Color3& color, const OBB& obb, float thickness = 1);
void WireframeOBB(const Color3& color, const OBB& obb, float thickness = 1.f);
void FillCapsule(const Color3& color, const Capsule& capsule);
void WireframeCapsule(const Color3& color, const Capsule& cap, float thickness = 1);
void WireframeCapsule(const Color3& color, const Capsule& cap, float thickness = 1.f);
void FillTriangleMesh(const Color3& color, const TriangleMesh& mesh);
void WireframeTriangleMesh(const Color3& color, const TriangleMesh& mesh, float thickness = 1);
void WireframeTriangleMesh(const Color3& color, const TriangleMesh& mesh, float thickness = 1.f);
/// Draws a string of text in 3D space, with an arbitrary rotation.
/// @param color

View File

@@ -163,6 +163,7 @@ public:
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-1,-0.125,1});
J3D::DrawLine(Colors::Red, {-0.33,-0.125,1}, {-0.33,0.25,1});
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
//J3D::WireframeSphere(Colors::Green, {0,0,0}, 0.25f, 1.f);
J3D::End();
J2D::Begin(j2d_render_target, true);

View File

@@ -620,7 +620,8 @@ namespace JGL {
GLfloat angle, x, y;
int i = 0;
for (angle = 0.0f; angle < (2.f * Math::Pi); angle += step) {
for (angle = 0.0f; angle < (2.f * Math::Pi); angle += step)
{
x = radius * std::cos(angle) + center.x;
y = radius * std::sin(angle) + center.y;
if (i < subdivisions)
@@ -1059,5 +1060,52 @@ namespace JGL {
glDrawArrays(GL_LINES, 0, 2);
glColor4fv(baseColor);
}
void J3D::WireframeSphere(const Color4 &color, const Vector3 &position, float radius, float thickness) {
if (!inJ3D)
Logger::Error("Drawing J3D element before J3D begin.");
std::vector<Vector3> vertices;
double r;
int lats;
int longs;
int i, j;
for (i = 0; i <= lats; i++)
{
float lat0 = J3ML::Math::Pi * (-0.5f + (float)(i-1) / lats);
float z0 = J3ML::Math::Sin(lat0);
float zr0 = J3ML::Math::Cos(lat0);
float lat1 = J3ML::Math::Pi * (-0.5f + (float)i / lats);
float z1 = J3ML::Math::Sin(lat1);
float zr1 = J3ML::Math::Cos(lat1);
glBegin(GL_LINES);
for (j = 0; j <= longs; j++)
{
float lng = 2.f * J3ML::Math::Pi * (float) (j - 1) / longs;
float x = J3ML::Math::Cos(lng);
float y = J3ML::Math::Sin(lng);
//glNormal3f(x * zr0, y*zr0, z0);
glVertex3f(r * x * zr0, r * y * zr0, r * z0);
//glNormal3f(x * zr1, y * zr1, z1);
glVertex3f(r * x * zr1, r * y * zr1, r * z1);
}
glEnd();
}
glLineWidth(thickness);
glColor4ubv(color.ptr());
glVertexPointer(3, GL_FLOAT, sizeof(Vector3), vertices.data());
glDrawArrays(GL_LINE_LOOP, 0, vertices.size());
glColor4fv(baseColor);
}
#pragma endregion
}