Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ else()
endif()

add_custom_target(CopyHeader
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h
BYPRODUCTS ${REPO_ROOT_DIR}/olcPixelGameEngine3.h
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h
DEPENDS olcPixelGameEngine3.h
)

Expand Down
30 changes: 30 additions & 0 deletions dev/src/vector2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@ namespace olc
{
return { static_cast<F>(this->x), static_cast<F>(this->y) };
}

template<size_t N>
auto& get() & {
return std::get<N>(xy);
}

template<size_t N>
const auto& get() const & {
return std::get<N>(xy);
}

template<size_t N>
auto&& get() && {
return std::get<N>(xy);
}

template<size_t N>
const auto& get() const && {
return std::get<N>(xy);
}
};

// Multiplication operator overloads between vectors and scalars, and vectors and vectors
Expand Down Expand Up @@ -356,6 +376,16 @@ namespace olc
typedef v_2d<float> vf2d;
typedef v_2d<double> vd2d;
}

namespace std {
template<typename T>
struct tuple_size<olc::v_2d<T>> : std::integral_constant<std::size_t, 2> {};


template<typename T, size_t N>
struct tuple_element<N, olc::v_2d<T>> : tuple_element<N, tuple<T, T>> {};
}

#define PGE_VECTOR2D_DECLARED 1
#endif
//! END DECLARATION
30 changes: 30 additions & 0 deletions dev/src/vector4d.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,26 @@ namespace olc
{
return { static_cast<F>(this->x), static_cast<F>(this->y), static_cast<F>(this->z), static_cast<F>(this->w) };
}

template<size_t N>
auto& get() & {
return std::get<N>(xyzw);
}

template<size_t N>
const auto& get() const & {
return std::get<N>(xyzw);
}

template<size_t N>
auto&& get() && {
return std::get<N>(xyzw);
}

template<size_t N>
const auto& get() const && {
return std::get<N>(xyzw);
}
};

// Multiplication operator overloads between vectors and scalars, and vectors and vectors
Expand Down Expand Up @@ -343,6 +363,16 @@ namespace olc
typedef v_4d<float> vf4d;
typedef v_4d<double> vd4d;
}

namespace std {
template<typename T>
struct tuple_size<olc::v_4d<T>> : std::integral_constant<std::size_t, 4> {};


template<typename T, size_t N>
struct tuple_element<N, olc::v_4d<T>> : tuple_element<N, tuple<T, T, T, T>> {};
}

#define PGE_VECTOR4D_DECLARED 1
#endif
//! END DECLARATION
10 changes: 8 additions & 2 deletions examples/olcPGE3_3DCube.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
olc::PixelGameEngine3 Example - olc::SanityCube!!!

Draws teh infamous olc::SanityCube using the hardware 3D rendering capabilities.
Draws the infamous olc::SanityCube using the hardware 3D rendering capabilities.

Licenced under the OLC-3 License
*/
Expand All @@ -12,6 +12,8 @@
#define OLC_PGE3_APPLICATION
#include "../olcPixelGameEngine3.h"

#include <format>

// Example application demonstrating basic 3D rendering. This class
// overrides the olc::PixelGameEngine base class by implementing
// the OnUserCreate() and OnUserUpdate() functions
Expand Down Expand Up @@ -123,7 +125,11 @@ class Example_3DCube : public olc::PixelGameEngine
draw.Line({ 0,0,0 }, { 0, 1, 0 }, olc::Colour::GREEN);
draw.Line({ 0,0,0 }, { 0, 0, 1 }, olc::Colour::BLUE);

draw.StringProp({ 4, 4 }, "+X: Right\n-X: Left\n+Y: Up\n-Y: Down\n+Z: Q\n-Z: A\nSPIN: Space", olc::Colour::BLACK);
// Decompose the quaternion to demonstrate the structured binding support
const auto [x, y, z, w] = vViewTranslate;
draw.String({ 4, 4 }, std::format("X:{: 4.1f} Y:{: 4.1f} Z:{: 4.1f} W:{: 4.1f}", x, y, z, w), olc::Colour::BLACK);
draw.StringProp({ 4, 14 }, "+X: Right\n-X: Left\n+Y: Up\n-Y: Down\n+Z: Q\n-Z: A\nSPIN: Space", olc::Colour::BLACK);


// Successful frame
return true;
Expand Down
6 changes: 6 additions & 0 deletions examples/olcPGE3_WorldTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ class Example_WorldTransform: public olc::PixelGameEngine
// Get Mouse in "transformed world" space
olc::vf2d vMouseWorld = draw.ScreenToWorld(vMouseScreen);

// Unpack the mouse coordinate to x and y just for fun and to serve as a compilation test for unpacking v_2d objects
const auto& [x1, y1] = vMouseWorld;
auto& [x2, y2] = vMouseWorld;
auto [x3, y3] = vMouseWorld;
auto&& [x4, y4] = vMouseWorld;

// Draw Status
draw.WorldReset();
draw.StringProp({ 8, 300 }, "Offset: Arrow Keys, Scale: Shift & Arrow Keys, Rotate: Q/A, SPACE: Reset");
Expand Down
60 changes: 60 additions & 0 deletions olcPixelGameEngine3.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,26 @@ namespace olc
{
return { static_cast<F>(this->x), static_cast<F>(this->y) };
}

template<size_t N>
auto& get() & {
return std::get<N>(xy);
}

template<size_t N>
const auto& get() const & {
return std::get<N>(xy);
}

template<size_t N>
auto&& get() && {
return std::get<N>(xy);
}

template<size_t N>
const auto& get() const && {
return std::get<N>(xy);
}
};

// Multiplication operator overloads between vectors and scalars, and vectors and vectors
Expand Down Expand Up @@ -1010,6 +1030,16 @@ namespace olc
typedef v_2d<float> vf2d;
typedef v_2d<double> vd2d;
}

namespace std {
template<typename T>
struct tuple_size<olc::v_2d<T>> : std::integral_constant<std::size_t, 2> {};


template<typename T, size_t N>
struct tuple_element<N, olc::v_2d<T>> : tuple_element<N, tuple<T, T>> {};
}

#define PGE_VECTOR2D_DECLARED 1
#endif

Expand Down Expand Up @@ -1182,6 +1212,26 @@ namespace olc
{
return { static_cast<F>(this->x), static_cast<F>(this->y), static_cast<F>(this->z), static_cast<F>(this->w) };
}

template<size_t N>
auto& get() & {
return std::get<N>(xyzw);
}

template<size_t N>
const auto& get() const & {
return std::get<N>(xyzw);
}

template<size_t N>
auto&& get() && {
return std::get<N>(xyzw);
}

template<size_t N>
const auto& get() const && {
return std::get<N>(xyzw);
}
};

// Multiplication operator overloads between vectors and scalars, and vectors and vectors
Expand Down Expand Up @@ -1342,6 +1392,16 @@ namespace olc
typedef v_4d<float> vf4d;
typedef v_4d<double> vd4d;
}

namespace std {
template<typename T>
struct tuple_size<olc::v_4d<T>> : std::integral_constant<std::size_t, 4> {};


template<typename T, size_t N>
struct tuple_element<N, olc::v_4d<T>> : tuple_element<N, tuple<T, T, T, T>> {};
}

#define PGE_VECTOR4D_DECLARED 1
#endif

Expand Down
Loading