Skip to content

Commit 201ab33

Browse files
committed
Corrected declarations of make_display_surface overloads to properly include refresh_rate and the desired frame rate. Renamed implemention of copy_image_surface (it still had the old make_image_surface name). Moved refresh_rate to xenumclasses.h as a result of the make_display_surface fixes. Cleaned up the comparison operators for the classes in the figure_items sub-namespace. Fixed two small bugs in RocksInSpace that blocked the game from building and then from executing (the call to make_display_surface needed to use a float for its frames per second value, and the physics.h header used an array with a max item size of 13, one of its uses had 13 items and so it broke when passed to std::for_each because it hit an out of bounds issue.
1 parent 58db220 commit 201ab33

File tree

9 files changed

+153
-197
lines changed

9 files changed

+153
-197
lines changed

N3888_RefImpl/RocksInSpace/Game.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int rocks_in_space::main()
139139
using namespace std::experimental::io2d;
140140

141141
rocks_in_space::game sd;
142-
auto ds = make_display_surface(640, 480, format::argb32, scaling::letterbox, refresh_rate::as_fast_as_possible, 30.0);
142+
auto ds = make_display_surface(640, 480, format::argb32, scaling::letterbox, refresh_rate::as_fast_as_possible, 30.0f);
143143
ds.draw_callback([&](display_surface& ds) {sd.update(ds); });
144144
return ds.begin_show();
145145
}

N3888_RefImpl/RocksInSpace/Physics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace rocks_in_space
1111
using vel = point_2d;
1212
using acc = point_2d;
1313

14-
using path_vertices = std::array<point_2d, 13>;
14+
using path_vertices = std::array<point_2d, 14>;
1515

1616
struct path_buffer
1717
{

N3888_RefImpl/SampleApp/sample_draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void test_image_load_save(display_surface& ds) {
105105
saveOnce = true;
106106
}
107107

108-
brush imgBrush{ make_image_surface(imgSfc) };
108+
brush imgBrush{ copy_image_surface(imgSfc) };
109109
//brush alphaBrush{ make_image_surface(alphaSfc) };
110110

111111
ds.paint(brush{ rgba_color::cornflower_blue });

N3888_RefImpl/src/io2d.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,21 @@ namespace std::experimental::io2d {
7676
_IO2D_API int format_stride_for_width(format format, int width) noexcept;
7777
_IO2D_API display_surface make_display_surface(int preferredWidth,
7878
int preferredHeight, format preferredFormat,
79-
scaling scl = scaling::letterbox);
79+
scaling scl = scaling::letterbox,
80+
refresh_rate rr = refresh_rate::as_fast_as_possible, float fps = 30.0f);
8081
display_surface make_display_surface(int preferredWidth,
8182
int preferredHeight, format preferredFormat, error_code& ec,
82-
scaling scl = scaling::letterbox) noexcept;
83+
scaling scl = scaling::letterbox,
84+
refresh_rate rr = refresh_rate::as_fast_as_possible, float fps = 30.0f) noexcept;
8385
_IO2D_API display_surface make_display_surface(int preferredWidth,
8486
int preferredHeight, format preferredFormat, int preferredDisplayWidth,
85-
int preferredDisplayHeight, scaling scl = scaling::letterbox);
87+
int preferredDisplayHeight, scaling scl = scaling::letterbox,
88+
refresh_rate rr = refresh_rate::as_fast_as_possible, float fps = 30.0f);
8689
display_surface make_display_surface(int preferredWidth,
8790
int preferredHeight, format preferredFormat, int preferredDisplayWidth,
8891
int preferredDisplayHeight, error_code& ec,
89-
scaling scl = scaling::letterbox) noexcept;
92+
scaling scl = scaling::letterbox,
93+
refresh_rate rr = refresh_rate::as_fast_as_possible, float fps = 30.0f) noexcept;
9094
_IO2D_API image_surface make_image_surface(format format, int width, int height);
9195
_IO2D_API image_surface make_image_surface(format format, int width, int height,
9296
error_code& ec) noexcept;

N3888_RefImpl/src/standalone_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace std {
2020
return image_surface(fmt, width, height);
2121
}
2222

23-
image_surface make_image_surface(image_surface& sfc) {
23+
image_surface copy_image_surface(image_surface& sfc) noexcept {
2424
image_surface retval(sfc.format(), sfc.width(), sfc.height());
2525
retval.map([&sfc](mapped_surface& rvms) {
2626
sfc.map([&rvms](mapped_surface& sfcms) {

N3888_RefImpl/src/xenumclasses.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ namespace std::experimental::io2d {
2020
none // Do not scale.
2121
};
2222

23+
enum class refresh_rate {
24+
as_needed,
25+
as_fast_as_possible,
26+
fixed
27+
};
2328
}
2429
}

N3888_RefImpl/src/xio2d_impl.h

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ namespace std::experimental::io2d {
628628
return _Data;
629629
}
630630

631-
inline constexpr bool abs_new_figure::operator==(const abs_new_figure& rhs) const noexcept {
632-
return _Data == rhs._Data;
631+
inline constexpr bool operator==(const abs_new_figure& lhs, const abs_new_figure& rhs) noexcept {
632+
return lhs._Data == rhs._Data;
633633
}
634634

635635
inline constexpr rel_new_figure::rel_new_figure() noexcept {}
@@ -645,13 +645,13 @@ namespace std::experimental::io2d {
645645
return _Data;
646646
}
647647

648-
inline constexpr bool rel_new_figure::operator==(const rel_new_figure& rhs) const noexcept {
649-
return _Data == rhs._Data;
648+
inline constexpr bool operator==(const rel_new_figure& lhs, const rel_new_figure& rhs) noexcept {
649+
return lhs._Data == rhs._Data;
650650
}
651651

652652
inline constexpr close_figure::close_figure() noexcept {}
653653

654-
inline constexpr bool close_figure::operator==(const close_figure&) const noexcept {
654+
inline constexpr bool operator==(const close_figure&, const close_figure&) noexcept {
655655
return true;
656656
}
657657

@@ -667,8 +667,8 @@ namespace std::experimental::io2d {
667667
return _Matrix;
668668
}
669669

670-
inline constexpr bool abs_matrix::operator==(const abs_matrix& rhs) const noexcept {
671-
return _Matrix == rhs._Matrix;
670+
inline constexpr bool operator==(const abs_matrix& lhs, const abs_matrix& rhs) noexcept {
671+
return lhs._Matrix == rhs._Matrix;
672672
}
673673

674674
inline constexpr rel_matrix::rel_matrix(const matrix_2d& m) noexcept
@@ -683,13 +683,13 @@ namespace std::experimental::io2d {
683683
return _Matrix;
684684
}
685685

686-
inline constexpr bool rel_matrix::operator==(const rel_matrix& rhs) const noexcept {
687-
return _Matrix == rhs._Matrix;
686+
inline constexpr bool operator==(const rel_matrix& lhs, const rel_matrix& rhs) noexcept {
687+
return lhs._Matrix == rhs._Matrix;
688688
}
689689

690690
inline constexpr revert_matrix::revert_matrix() noexcept {}
691691

692-
inline constexpr bool revert_matrix::operator==(const revert_matrix&) const noexcept {
692+
inline constexpr bool operator==(const revert_matrix&, const revert_matrix&) noexcept {
693693
return true;
694694
}
695695

@@ -706,8 +706,8 @@ namespace std::experimental::io2d {
706706
return _Data;
707707
}
708708

709-
inline constexpr bool abs_line::operator==(const abs_line& rhs) const noexcept {
710-
return _Data == rhs._Data;
709+
inline constexpr bool operator==(const abs_line& lhs, const abs_line& rhs) noexcept {
710+
return lhs._Data == rhs._Data;
711711
}
712712

713713
inline constexpr rel_line::rel_line(const point_2d& to) noexcept
@@ -723,8 +723,8 @@ namespace std::experimental::io2d {
723723
return _Data;
724724
}
725725

726-
inline constexpr bool rel_line::operator==(const rel_line& rhs) const noexcept {
727-
return _Data == rhs._Data;
726+
inline constexpr bool operator==(const rel_line& lhs, const rel_line& rhs) noexcept {
727+
return lhs._Data == rhs._Data;
728728
}
729729

730730
inline constexpr abs_quadratic_curve::abs_quadratic_curve(const point_2d& cp, const point_2d& ep) noexcept
@@ -747,9 +747,9 @@ namespace std::experimental::io2d {
747747
return _End_pt;
748748
}
749749

750-
inline constexpr bool abs_quadratic_curve::operator==(const abs_quadratic_curve& rhs) const noexcept {
751-
return (_Control_pt == rhs._Control_pt) &&
752-
(_End_pt == rhs._End_pt);
750+
inline constexpr bool operator==(const abs_quadratic_curve& lhs, const abs_quadratic_curve& rhs) noexcept {
751+
return (lhs._Control_pt == rhs._Control_pt) &&
752+
(lhs._End_pt == rhs._End_pt);
753753
}
754754

755755
inline constexpr rel_quadratic_curve::rel_quadratic_curve(const point_2d& cp, const point_2d& ep) noexcept
@@ -772,9 +772,9 @@ namespace std::experimental::io2d {
772772
return _End_pt;
773773
}
774774

775-
inline constexpr bool rel_quadratic_curve::operator==(const rel_quadratic_curve& rhs) const noexcept {
776-
return (_Control_pt == rhs._Control_pt) &&
777-
(_End_pt == rhs._End_pt);
775+
inline constexpr bool operator==(const rel_quadratic_curve& lhs, const rel_quadratic_curve& rhs) noexcept {
776+
return (lhs._Control_pt == rhs._Control_pt) &&
777+
(lhs._End_pt == rhs._End_pt);
778778
}
779779

780780
inline constexpr abs_cubic_curve::abs_cubic_curve(const point_2d& controlPoint1, const point_2d& controlPoint2, const point_2d& endPoint) noexcept
@@ -804,10 +804,10 @@ namespace std::experimental::io2d {
804804
return _End_pt;
805805
}
806806

807-
inline constexpr bool abs_cubic_curve::operator==(const abs_cubic_curve& rhs) const noexcept {
808-
return (_Control_pt1 == rhs._Control_pt1) &&
809-
(_Control_pt2 == rhs._Control_pt2) &&
810-
(_End_pt == rhs._End_pt);
807+
inline constexpr bool operator==(const abs_cubic_curve& lhs, const abs_cubic_curve& rhs) noexcept {
808+
return (lhs._Control_pt1 == rhs._Control_pt1) &&
809+
(lhs._Control_pt2 == rhs._Control_pt2) &&
810+
(lhs._End_pt == rhs._End_pt);
811811
}
812812

813813
inline constexpr rel_cubic_curve::rel_cubic_curve(const point_2d& controlPoint1, const point_2d& controlPoint2, const point_2d& endPoint) noexcept
@@ -837,10 +837,10 @@ namespace std::experimental::io2d {
837837
return _End_pt;
838838
}
839839

840-
inline constexpr bool rel_cubic_curve::operator==(const rel_cubic_curve& rhs) const noexcept {
841-
return (_Control_pt1 == rhs._Control_pt1) &&
842-
(_Control_pt2 == rhs._Control_pt2) &&
843-
(_End_pt == rhs._End_pt);
840+
inline constexpr bool operator==(const rel_cubic_curve& lhs, const rel_cubic_curve& rhs) noexcept {
841+
return (lhs._Control_pt1 == rhs._Control_pt1) &&
842+
(lhs._Control_pt2 == rhs._Control_pt2) &&
843+
(lhs._End_pt == rhs._End_pt);
844844
}
845845

846846
inline constexpr arc::arc() noexcept
@@ -888,12 +888,16 @@ namespace std::experimental::io2d {
888888
return cpt + pt * lmtx;
889889
}
890890

891-
inline constexpr bool arc::operator==(const arc& rhs) const noexcept {
892-
return (_Radius == rhs._Radius) &&
893-
(_Rotation == rhs._Rotation) &&
894-
(_Start_angle == rhs._Start_angle);
891+
inline constexpr bool operator==(const arc& lhs, const arc& rhs) noexcept {
892+
return (lhs._Radius == rhs._Radius) &&
893+
(lhs._Rotation == rhs._Rotation) &&
894+
(lhs._Start_angle == rhs._Start_angle);
895895
}
896-
}
896+
897+
inline constexpr bool operator!=(const arc& lhs, const arc& rhs) noexcept {
898+
return !(lhs == rhs);
899+
}
900+
}
897901

898902
enum class _Path_data_abs_new_path {};
899903
constexpr static _Path_data_abs_new_path _Path_data_abs_new_path_val = {};

0 commit comments

Comments
 (0)