Skip to content

Commit

Permalink
Sprite and Shape use ptrs (#92)
Browse files Browse the repository at this point in the history
* Sprite and Shape use ptrs
  • Loading branch information
Jerboa-app authored Sep 11, 2024
1 parent 122773e commit e90cc2f
Show file tree
Hide file tree
Showing 25 changed files with 570 additions and 349 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ if (ANDROID)
"src/font.cpp"
"src/glyph.cpp"
"src/shader.cpp"
"src/spriteRenderer.cpp"
"src/warning.cpp"
"src/jGL/common.cpp"
"src/id.cpp"
Expand Down Expand Up @@ -161,7 +160,6 @@ IF (TEST_SUITE)
"src/jGL/OpenGL/*.cpp"
"src/jGL/shader.cpp"
"src/jGL/warning.cpp"
"src/jGL/spriteRenderer.cpp"
"src/id.cpp"
"src/jGL/Display/*.cpp"
"src/jGL/common.cpp"
Expand Down Expand Up @@ -219,7 +217,6 @@ IF (TEST_SUITE)
${TEST_SRC}
"src/jGL/shader.cpp"
"src/jGL/warning.cpp"
"src/jGL/spriteRenderer.cpp"
"src/id.cpp"
"src/jGL/font.cpp"
"src/jGL/glyph.cpp"
Expand Down
3 changes: 2 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(Particles)
add_subdirectory(Sprite)
add_subdirectory(Shape)
add_subdirectory(Shape)
add_subdirectory(SpriteBenchmark)
14 changes: 8 additions & 6 deletions examples/Shape/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ int main(int argv, char ** argc)
jGLInstance->setTextProjection(glm::ortho(0.0,double(resX),0.0,double(resY)));
jGLInstance->setMSAA(1);

std::vector<std::shared_ptr<jGL::Shape>> shapes;
std::vector<jGL::Shape> shapes;
std::vector<jGL::Transform> trans;
std::vector<glm::vec4> cols;

RNG rng;
uint64_t n = 1000000;
Expand All @@ -46,16 +47,17 @@ int main(int argv, char ** argc)

shapes.reserve(n);
trans.reserve(n);
cols.reserve(n);
for (unsigned i = 0; i < n; i++)
{
trans.push_back(jGL::Transform(rng.nextFloat(), rng.nextFloat(), 0.0, 0.001f));
cols.push_back(glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0));
shapes.push_back
(
std::make_shared<jGL::Shape>
(
trans[i],
glm::vec4(rng.nextFloat(), rng.nextFloat(), rng.nextFloat(), 1.0)
)
{
&trans[i],
&cols[i]
}
);

circles->add(shapes[i], std::to_string(i));
Expand Down
Loading

0 comments on commit e90cc2f

Please sign in to comment.