Skip to content

Commit

Permalink
Update jgl to 0-0.0.8 (#189)
Browse files Browse the repository at this point in the history
* Update jgl to 0-0.0.8
  • Loading branch information
Jerboa-app authored Aug 9, 2024
1 parent 47d3329 commit f7d95fd
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 124 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if (SYNTAX_ONLY)
# find_package(OpenGL REQUIRED)
# set(GLEW_INCLUDE include/vendored/glew/include/)
# include_directories(
# include
# ${OPENGL_INCLUDE_DIRS}
# ${GLEW_INCLUDE}
# include/vendored/freetype/include
# include
# ${OPENGL_INCLUDE_DIRS}
# ${GLEW_INCLUDE}
# include/vendored/freetype/include
# include/vendored/glm
# )
# file(GLOB SRC "src/*.cpp")
Expand Down Expand Up @@ -102,7 +102,7 @@ set(${VORBIS_INCLUDE_DIRS} include/vendored/vorbis/include)
file(GLOB MINIAUDIO_SRC "include/vendored/miniaudio/*.c")
include_directories(include/vendored/miniaudio ${VORBIS_INCLUDE_DIRS})
add_library(Miniaudio STATIC ${MINIAUDIO_SRC})
target_link_libraries(Miniaudio vorbisfile ogg ${CMAKE_DL_LIBS})
target_link_libraries(Miniaudio vorbisfile ogg ${CMAKE_DL_LIBS})

include_directories(include include/vendored include/jGL/include)

Expand All @@ -114,16 +114,16 @@ include_directories(include/vendored/zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib_build

set(${SPARSEHASH_INCLUDE_DIRS} include/vendored/sparsehash)

file(GLOB SRC
file(GLOB SRC
"src/*.cpp"
"src/Text/*.cpp"
"src/Object/*.cpp"
"src/Shader/*.cpp"
"src/System/*.cpp"
"src/Component/*.cpp"
"src/Collision/*.cpp"
"src/World/*.cpp"
"src/Maths/*.cpp"
"src/World/*.cpp"
"src/Maths/*.cpp"
"src/Util/*.cpp"
"src/Debug/*.cpp"
"src/Console/*.cpp"
Expand All @@ -136,12 +136,13 @@ if (NOT ANDROID)
file(GLOB STANDALONE_SRC "src/Display/*.cpp")
add_library(Hop STATIC ${SRC} ${STANDALONE_SRC})
target_compile_definitions(Hop PUBLIC GLSL_VERSION="330")

else()
add_library(Hop STATIC ${SRC})
target_compile_definitions(Hop PUBLIC GLSL_VERSION="300 es")
endif()

target_compile_definitions(Hop PUBLIC MAX_SPRITE_BATCH_BOUND_TEXTURES=4)

if(BENCHMARK)
target_compile_definitions(Hop PUBLIC BENCHMARK)
endif()
Expand Down
1 change: 1 addition & 0 deletions demo/android/perlinWorld/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_library(
hopAndroid.cpp)

target_compile_definitions(HopAndroid PUBLIC GLSL_VERSION="300 es")
target_compile_definitions(HopAndroid PUBLIC MAX_SPRITE_BATCH_BOUND_TEXTURES=4)

include_directories(include)
include_directories(.)
Expand Down
44 changes: 22 additions & 22 deletions include/Collision/collisionMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Hop::System::Physics
{}

MeshRectangle
(
(
double llx, double lly,
double ulx, double uly,
double urx, double ury,
Expand All @@ -73,7 +73,7 @@ namespace Hop::System::Physics

bool operator==(const MeshRectangle & rhs)
{
return llx == rhs.llx &&
return llx == rhs.llx &&
lly == rhs.lly &&
ulx == rhs.ulx &&
uly == rhs.uly &&
Expand All @@ -86,12 +86,12 @@ namespace Hop::System::Physics
double llx, lly, ulx, uly, urx, ury, lrx, lry;
};

struct CollisionMesh
struct CollisionMesh
{
CollisionMesh()
{}
// construct a mesh around a model space polygon
// with vertices v with each mesh vertex having
// construct a mesh around a model space polygon
// with vertices v with each mesh vertex having
// radius r in model space
//CollisionMesh(std::vector<Vertex> v, double r = 0.01);

Expand All @@ -100,8 +100,8 @@ namespace Hop::System::Physics
(
std::vector<std::shared_ptr<CollisionPrimitive>> v,
double x,
double y,
double theta,
double y,
double theta,
double scale
)
: CollisionMesh(std::move(v))
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace Hop::System::Physics
cPhysics phys(t.x,t.y,t.theta);
updateWorldMesh(t, phys, 0.0);
}

void add(std::shared_ptr<CollisionPrimitive> c)
{

Expand Down Expand Up @@ -245,10 +245,10 @@ namespace Hop::System::Physics
(
c->x,
c->y,
c->r,
c->r,
c->tag,
c->stiffness,
c->damping,
c->stiffness,
c->damping,
c->effectiveMass
)
);
Expand Down Expand Up @@ -304,7 +304,7 @@ namespace Hop::System::Physics
return worldVertices[i];
}

std::shared_ptr<CollisionPrimitive> operator[](size_t i)
std::shared_ptr<CollisionPrimitive> operator[](size_t i)
{
return worldVertices[i];
}
Expand All @@ -320,7 +320,7 @@ namespace Hop::System::Physics
{
return updateWorldMeshRigid(transform, dt);
}
else
else
{
return updateWorldMeshSoft(transform, physics, dt);
}
Expand All @@ -337,7 +337,7 @@ namespace Hop::System::Physics
double dt
);

double bestAngle(double x, double y, double scale);
double bestAngle(double x, double y, double scaleX, double scaleY);
void centerOfMassWorld(double & cx, double & cy);
void modelToCenterOfMassFrame();

Expand All @@ -347,7 +347,7 @@ namespace Hop::System::Physics

bool getIsRigid(){ return isRigid; }

void calculateIsRigid()
void calculateIsRigid()
{
for (auto v : worldVertices)
{
Expand All @@ -367,7 +367,7 @@ namespace Hop::System::Physics
gx += fx;
gy += fy;
}
else
else
{
for (auto w : worldVertices)
{
Expand All @@ -379,7 +379,7 @@ namespace Hop::System::Physics

double getEffectiveMass() const { return totalEffectiveMass; }

void calculateTotalEffectiveMass()
void calculateTotalEffectiveMass()
{
totalEffectiveMass = 0.0;
for (auto v : worldVertices)
Expand All @@ -397,7 +397,7 @@ namespace Hop::System::Physics
{
return kineticEnergy;
}

bool areSomeRectangles() const { return someRectangles; }

void updateTags()
Expand Down Expand Up @@ -483,8 +483,8 @@ namespace Hop::System::Physics
std::vector<Vertex> v(c.size());
std::transform
(
c.begin(),
c.end(),
c.begin(),
c.end(),
v.begin(),
[](std::shared_ptr<CollisionPrimitive> c)
{
Expand All @@ -498,7 +498,7 @@ namespace Hop::System::Physics
{
r = std::max(r, c->r);
}

return Hop::Maths::boundingBox(v, r);
}

Expand All @@ -509,7 +509,7 @@ namespace Hop::System::Physics
}

std::set<uint64_t> getTags() const { return tags; }

private:

std::vector<std::shared_ptr<MeshPoint>> vertices;
Expand Down
9 changes: 6 additions & 3 deletions include/Debug/collisionMeshDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <jGL/jGL.h>
#include <jLog/jLog.h>
#include <jGL/OpenGL/glShapeRenderer.h>

namespace Hop::Object
{
Expand All @@ -35,14 +36,14 @@ namespace Hop::Debugging
shapes(jgl->createShapeRenderer(256)),
circleShader(std::make_shared<jGL::GL::glShader>
(
Hop::System::Rendering::collisionPrimitiveVertexShader,
jGL::GL::glShapeRenderer::shapeVertexShader,
Hop::System::Rendering::collisionPrimitiveFragmentShader
)
),
rectangleShader(std::make_shared<jGL::GL::glShader>
(
Hop::System::Rendering::rectangleVertexShader,
Hop::System::Rendering::rectangleFragmentShader
jGL::GL::glShapeRenderer::shapeVertexShader,
jGL::GL::glShapeRenderer::rectangleFragmentShader
)
)
{}
Expand All @@ -63,6 +64,8 @@ namespace Hop::Debugging

std::shared_ptr<jGL::Shader> circleShader, rectangleShader;

std::map<std::string, cTransform> circlePos;

};

}
Expand Down
25 changes: 5 additions & 20 deletions include/Shader/meshDebug.shader
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,11 @@

namespace Hop::System::Rendering
{
static const char * collisionPrimitiveVertexShader = "#version " GLSL_VERSION "\n"
"precision lowp float;\n precision lowp int;\n"
"layout(location=0) in vec4 a_position;\n"
"layout(location=1) in vec4 a_offset;\n"
"layout(location=2) in vec4 a_colour;\n"
"uniform mat4 proj;\n"
"out vec2 texCoord;\n"
"out vec4 oColour;\n"
"void main()\n"
"{\n"
"gl_Position = proj*vec4(a_offset.w*a_position.xy+a_offset.xy,0.0,1.0);\n"
"texCoord = a_position.zw;\n"
"oColour = a_colour;\n"
"}";

static const char * collisionPrimitiveFragmentShader = "#version " GLSL_VERSION "\n"
"precision lowp float;\n precision lowp int;\n"
"in vec4 oColour;\n"
"in vec2 texCoord;\n"
"out vec4 colour;\n"
"in vec4 colour;\n"
"layout(location=0) out vec4 fragment;\n"
"float t0 = 0.12;\n"
"float t1 = 0.2025;\n"
"float t2 = 0.25;\n"
Expand All @@ -33,10 +18,10 @@ namespace Hop::System::Rendering
" if (d2 > t2) {discard;}\n"
" float alpha = 1.0-smoothstep(t1, t2, d2);"
" float mixer = 1.0-smoothstep(t0, t1, d2);"
" colour = vec4( mix(vec3(0.0,0.0,0.0),oColour.rgb, mixer), alpha*oColour.a );"
" fragment = vec4( mix(vec3(0.0,0.0,0.0),colour.rgb, mixer), alpha*colour.a );"
"}";

static const char * rectangleVertexShader = "#version " GLSL_VERSION "\n"
static const char * rectangleVertexShader __attribute__((unused)) = "#version " GLSL_VERSION "\n"
"precision lowp float;\n precision lowp int;\n"
"layout(location=0) in vec4 a_position;\n"
"layout(location=1) in vec4 a_offset;\n"
Expand All @@ -60,7 +45,7 @@ namespace Hop::System::Rendering
"th = a_thickness;\n"
"}";

static const char * rectangleFragmentShader = "#version " GLSL_VERSION "\n"
static const char * rectangleFragmentShader __attribute__((unused)) = "#version " GLSL_VERSION "\n"
"precision lowp float;\n precision lowp int;\n"
"in vec4 oColour;\n"
"in vec2 texCoord;\n"
Expand Down
2 changes: 1 addition & 1 deletion include/jGL
Submodule jGL updated 46 files
+3 −1 .github/workflows/build-tests.yml
+18 −0 .github/workflows/docs.yml
+1 −0 .github/workflows/unit-tests.yml
+1 −1 .gitignore
+4 −0 CMakeLists.txt
+5 −0 DOCUMENTATION.md
+34 −18 README.md
+2,622 −0 docs/doxygen.config
+1 −0 docs/index.html
+15 −9 examples/Shape/main.cpp
+0 −31 examples/Shape/main.h
+157 −16 examples/Sprite/main.cpp
+3 −3 examples/Sprite/main.h
+ examples/Sprite/resource/texture/atlas.png
+13 −2 include/jGL/Display/desktopDisplay.h
+94 −12 include/jGL/OpenGL/Texture/glTexture.h
+55 −38 include/jGL/OpenGL/glShapeRenderer.h
+54 −32 include/jGL/OpenGL/glSpriteRenderer.h
+15 −2 include/jGL/OpenGL/openGLInstance.h
+8 −7 include/jGL/Vulkan/Texture/vkTexture.h
+1 −4 include/jGL/Vulkan/vkShapeRenderer.h
+22 −4 include/jGL/Vulkan/vulkanInstance.h
+1 −1 include/jGL/font.h
+4 −1 include/jGL/jGL.h
+41 −19 include/jGL/orthoCam.h
+184 −8 include/jGL/primitive.h
+58 −5 include/jGL/shape.h
+38 −12 include/jGL/shapeRenderer.h
+138 −20 include/jGL/sprite.h
+60 −20 include/jGL/spriteRenderer.h
+21 −14 include/logo.h
+4 −4 src/jGL/Display/desktopDisplay.cpp
+1 −1 src/jGL/OpenGL/Text/glFont.cpp
+15 −57 src/jGL/OpenGL/Texture/glTexture.cpp
+106 −96 src/jGL/OpenGL/glShapeRenderer.cpp
+160 −154 src/jGL/OpenGL/glSpriteRenderer.cpp
+12 −9 src/jGL/Vulkan/Texture/vkTexture.cpp
+2 −2 src/jGL/font.cpp
+19 −0 src/jGL/primitive.cpp
+8 −11 src/jGL/spriteRenderer.cpp
+1 −0 tests/regression/user-macos/CMakeLists.txt
+9 −3 tests/regression/user-macos/main.cpp
+1 −0 tests/regression/user-mingw/CMakeLists.txt
+9 −3 tests/regression/user-mingw/main.cpp
+1 −0 tests/regression/user/CMakeLists.txt
+9 −3 tests/regression/user/main.cpp
Loading

0 comments on commit f7d95fd

Please sign in to comment.