Fix for Windows.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include <J3ML/Geometry/Sphere.hpp>
|
||||
#include <J3ML/Geometry/Capsule.hpp>
|
||||
#include <J3ML/Geometry/Triangle2D.hpp>
|
||||
#include <J3ML/J3ML.hpp>
|
||||
#include <JGL/types/Font.h>
|
||||
|
||||
/// OpenGL Wrapper for rendering 2D & 3D graphics in both a 2D and 3D context.
|
||||
@@ -371,7 +372,7 @@ namespace JGL::J3D {
|
||||
/// @param thickness The line-width to draw the Icosahedron outline with.
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
void WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, uint sectors = 10, uint stacks = 10);
|
||||
void WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws the outline of a Sphere in 3D space.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -379,7 +380,7 @@ namespace JGL::J3D {
|
||||
/// @param thickness The line-width to draw the Icosahedron outline with.
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, uint sectors = 10, uint stacks = 10);
|
||||
void WireframeSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws outlines of multiple spheres in 3D space.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -389,7 +390,7 @@ namespace JGL::J3D {
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
/// @note The "Position" of the spheres is expected to be in world space.
|
||||
void BatchWireframeSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness = 1.f, uint sectors = 10, uint stacks = 10);
|
||||
void BatchWireframeSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness = 1.f, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws outlines of a sphere in 3D space. Calculates a cross section and revolves it around the center.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -399,7 +400,7 @@ namespace JGL::J3D {
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param revolutions The number of times to revolve the cross section about the center.
|
||||
/// @param draw_stacks Whether or not to draw the stacks of the sphere.
|
||||
void WireframeRevoSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, uint sectors = 10, uint revolutions = 10, bool draw_stacks = false);
|
||||
void WireframeRevoSphere(const Color4& color, const Vector3& position, float radius, float thickness = 1.f, unsigned int sectors = 10, unsigned int revolutions = 10, bool draw_stacks = false);
|
||||
|
||||
/// Draws the outline of a Sphere in 3D space.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -408,7 +409,7 @@ namespace JGL::J3D {
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param revolutions The number of times to revolve the cross section about the center.
|
||||
/// @param draw_stacks Whether or not to draw the stacks of the sphere.
|
||||
void WireframeRevoSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, uint sectors = 10, uint revolutions = 10, bool draw_stacks = false);
|
||||
void WireframeRevoSphere(const Color4& color, const Sphere& sphere, float thickness = 1.f, unsigned int sectors = 10, unsigned int revolutions = 10, bool draw_stacks = false);
|
||||
|
||||
/// Draws outlines of multiple spheres in 3D space. Calculates a cross section and revolves it around the center.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -420,7 +421,7 @@ namespace JGL::J3D {
|
||||
/// @param draw_stacks Whether or not to draw the stacks of the sphere.
|
||||
/// @note The "Position" of the spheres is expected to be in world space.
|
||||
/// @note This method of drawing a sphere is *probably* the fastest out of all of them.
|
||||
void BatchWireframeRevoSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness = 1.f, uint sectors = 10, uint revolutions = 10, bool draw_stacks = false);
|
||||
void BatchWireframeRevoSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness = 1.f, unsigned int sectors = 10, unsigned int revolutions = 10, bool draw_stacks = false);
|
||||
|
||||
/// Draws the outline of an Icosphere in 3D space.
|
||||
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
|
||||
@@ -462,14 +463,14 @@ namespace JGL::J3D {
|
||||
/// @param radius The size to draw the Sphere at.
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
void FillSphere(const Color4& color, const Vector3& position, float radius, uint sectors = 10, uint stacks = 10);
|
||||
void FillSphere(const Color4& color, const Vector3& position, float radius, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws a solid Sphere in 3D space.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
/// @param sphere The mathematically-defined sphere object to be rendered.
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
void FillSphere(const Color4& color, const Sphere& sphere, uint sectors = 10, uint stacks = 10);
|
||||
void FillSphere(const Color4& color, const Sphere& sphere, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws multiple solid Spheres in 3D space.
|
||||
/// @param color A 3-or-4 channel color value. @see class Color3, class Color4
|
||||
@@ -477,7 +478,7 @@ namespace JGL::J3D {
|
||||
/// @param sphere_count The number of spheres to be rendered.
|
||||
/// @param sectors The amount of latitudinal subdivisions to perform when computing the sphere.
|
||||
/// @param stacks The amount of longitudinal subdivisions to perform when computing the sphere.
|
||||
void BatchFillSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, uint sectors = 10, uint stacks = 10);
|
||||
void BatchFillSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, unsigned int sectors = 10, unsigned int stacks = 10);
|
||||
|
||||
/// Draws a solid Icosphere in 3D space.
|
||||
/// @note An Icosphere is an approximation of a sphere that is generated by recursively subdividing an Icosahedron.
|
||||
|
4
main.cpp
4
main.cpp
@@ -152,7 +152,7 @@ public:
|
||||
//J3D::ChangeFOV(fov);
|
||||
|
||||
sprite_radians += 0.005;
|
||||
textAngle.y += (5.f * delta_time);
|
||||
textAngle.y += (1);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
Sphere sphere = {{0,0, 0.5f}, 0.2125};
|
||||
J3D::BatchWireframeRevoSphere(Colors::Green, &sphere, 1, 1, 16, 16, true);
|
||||
J3D::FillAABB(Colors::Whites::AliceBlue, {0,0,0.5f}, {0.1f, 0.1f, 0.1f});
|
||||
//J3D::WireframeAABB(Colors::Gray, {0,0,0.5f}, {0.11f, 0.06f, 0.11f});
|
||||
J3D::WireframeAABB(Colors::Gray, {0,0,0.5f}, {0.11f, 0.06f, 0.11f});
|
||||
|
||||
AABB boxes[1] = {{Vector3(-0.2125, -0.2125,0.28750), Vector3(0.2125,0.2125,0.7125)}};
|
||||
J3D::BatchWireframeAABB(Colors::Yellow, boxes, 1, 1);
|
||||
|
29
src/JGL.cpp
29
src/JGL.cpp
@@ -1071,16 +1071,16 @@ namespace JGL {
|
||||
glColor4fv(baseColor);
|
||||
}
|
||||
|
||||
void J3D::WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness, uint sectors, uint stacks) {
|
||||
void J3D::WireframeSphere(const Color4& color, const Vector3& position, float radius, float thickness, unsigned int sectors, unsigned int stacks) {
|
||||
Sphere sphere = {position, radius};
|
||||
BatchWireframeSphere(color,& sphere, 1, thickness, sectors, stacks);
|
||||
}
|
||||
|
||||
void J3D::WireframeSphere(const Color4& color, const Sphere& sphere, float thickness, uint sectors, uint stacks) {
|
||||
void J3D::WireframeSphere(const Color4& color, const Sphere& sphere, float thickness, unsigned int sectors, unsigned int stacks) {
|
||||
BatchWireframeSphere(color,& sphere, 1, thickness, sectors, stacks);
|
||||
}
|
||||
|
||||
void J3D::BatchWireframeSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness, uint sectors, uint stacks) {
|
||||
void J3D::BatchWireframeSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness, unsigned int sectors, unsigned int stacks) {
|
||||
if (!inJ3D)
|
||||
Logger::Error("Drawing J3D element before J3D begin.");
|
||||
|
||||
@@ -1090,7 +1090,7 @@ namespace JGL {
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i <= sectors; i++) {
|
||||
float lat = M_PI * (-0.5 + (float) i / sectors);
|
||||
float lat = J3ML::Math::Pi * (-0.5 + (float) i / sectors);
|
||||
float z = J3ML::Math::Sin(lat);
|
||||
float zr = J3ML::Math::Cos(lat);
|
||||
|
||||
@@ -1122,23 +1122,23 @@ namespace JGL {
|
||||
glColor4fv(baseColor);
|
||||
}
|
||||
|
||||
void J3D::WireframeRevoSphere(const Color4& color, const Vector3& position, float radius, float thickness, uint sectors, uint revolutions, bool draw_stacks) {
|
||||
void J3D::WireframeRevoSphere(const Color4& color, const Vector3& position, float radius, float thickness, unsigned int sectors, unsigned int revolutions, bool draw_stacks) {
|
||||
Sphere sphere = {position, radius};
|
||||
BatchWireframeRevoSphere(color,& sphere, 1, thickness, sectors, revolutions, draw_stacks);
|
||||
}
|
||||
|
||||
void J3D::WireframeRevoSphere(const Color4& color, const Sphere& sphere, float thickness, uint sectors, uint revolutions, bool draw_stacks) {
|
||||
void J3D::WireframeRevoSphere(const Color4& color, const Sphere& sphere, float thickness, unsigned int sectors, unsigned int revolutions, bool draw_stacks) {
|
||||
BatchWireframeRevoSphere(color,& sphere, 1, thickness, sectors, revolutions, draw_stacks);
|
||||
}
|
||||
|
||||
void J3D::BatchWireframeRevoSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness, uint sectors, uint revolutions, bool draw_stacks) {
|
||||
void J3D::BatchWireframeRevoSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, float thickness, unsigned int sectors, unsigned int revolutions, bool draw_stacks) {
|
||||
float r = 1;
|
||||
std::vector<Vector3> vertices;
|
||||
vertices.reserve((sectors + 1) * (revolutions + 1));
|
||||
|
||||
std::vector<Vector3> cross_section(sectors + 1);
|
||||
for (int i = 0; i <= sectors; i++) {
|
||||
float lat = M_PI * (-0.5 + (float)i / sectors);
|
||||
float lat = J3ML::Math::Pi * (-0.5 + (float)i / sectors);
|
||||
float z = J3ML::Math::Sin(lat);
|
||||
float zr = J3ML::Math::Cos(lat);
|
||||
cross_section[i] = Vector3(0, zr * r, z * r);
|
||||
@@ -1146,7 +1146,7 @@ namespace JGL {
|
||||
|
||||
// Revolve
|
||||
for (int j = 0; j <= revolutions; j++) {
|
||||
float lng = 2 * M_PI * (float)j / revolutions;
|
||||
float lng = 2 * J3ML::Math::Pi * (float)j / revolutions;
|
||||
float cosLng = J3ML::Math::Cos(lng);
|
||||
float sinLng = J3ML::Math::Sin(lng);
|
||||
|
||||
@@ -1354,22 +1354,22 @@ namespace JGL {
|
||||
BatchFillAABB(color, &aabb, 1);
|
||||
}
|
||||
|
||||
void J3D::FillSphere(const Color4& color, const Sphere& sphere, uint sectors, uint stacks) {
|
||||
void J3D::FillSphere(const Color4& color, const Sphere& sphere, unsigned int sectors, unsigned int stacks) {
|
||||
BatchFillSphere(color, &sphere, 1, sectors, stacks);
|
||||
}
|
||||
|
||||
void J3D::BatchFillSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, uint sectors, uint stacks) {
|
||||
void J3D::BatchFillSphere(const Color4& color, const Sphere* spheres, const size_t& sphere_count, unsigned int sectors, unsigned int stacks) {
|
||||
if (!inJ3D)
|
||||
Logger::Error("Drawing J3D element before J3D begin.");
|
||||
|
||||
float r = 1;
|
||||
std::vector<Vector3> vertices((sectors + 1) * (stacks + 1));
|
||||
std::vector<GLuint> indices; indices.reserve(sectors * stacks * 6);
|
||||
std::vector<unsigned int> indices; indices.reserve(sectors * stacks * 6);
|
||||
|
||||
float two_pi = 2 * J3ML::Math::Pi;
|
||||
int index = 0;
|
||||
for (int i = 0; i <= sectors; i++) {
|
||||
float lat = M_PI * (-0.5 + (float) i / sectors);
|
||||
float lat = J3ML::Math::Pi * (-0.5 + (float) i / sectors);
|
||||
float z = J3ML::Math::Sin(lat);
|
||||
float zr = J3ML::Math::Cos(lat);
|
||||
|
||||
@@ -1421,7 +1421,7 @@ namespace JGL {
|
||||
glColor4fv(oldColor);
|
||||
}
|
||||
|
||||
void J3D::FillSphere(const Color4& color, const Vector3& position, float radius, uint sectors, uint stacks) {
|
||||
void J3D::FillSphere(const Color4& color, const Vector3& position, float radius, unsigned int sectors, unsigned int stacks) {
|
||||
Sphere sphere = {position, radius};
|
||||
BatchFillSphere(color, &sphere, 1, sectors, stacks);
|
||||
}
|
||||
@@ -1452,7 +1452,6 @@ namespace JGL {
|
||||
glPopMatrix();
|
||||
}
|
||||
glColor4fv(oldColor);
|
||||
|
||||
}
|
||||
|
||||
void J3D::WireframeOBB(const Color4& color, const OBB& obb, float thickness) {
|
||||
|
Reference in New Issue
Block a user