diff options
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/spritesheet/floor_atlas.json | 2046 | ||||
-rw-r--r-- | tests/spritesheet/test.cpp | 12 | ||||
-rw-r--r-- | tests/testshared.h | 33 | ||||
-rw-r--r-- | yage/core/imageloader.cpp | 8 | ||||
-rw-r--r-- | yage/core/spritesheet.cpp | 37 | ||||
-rw-r--r-- | yage/core/spritesheet.h | 4 |
7 files changed, 1087 insertions, 1054 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5b7d6fd3..707492aa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,3 +33,4 @@ make_test(syncqueue 1) make_test(active 1) make_test(struct ${SIMULATION_RUNS}) make_test(engine ${SIMULATION_RUNS}) +make_test(render ${SIMULATION_RUNS}) diff --git a/tests/spritesheet/floor_atlas.json b/tests/spritesheet/floor_atlas.json index ff9f0aa1..e6defd22 100644 --- a/tests/spritesheet/floor_atlas.json +++ b/tests/spritesheet/floor_atlas.json @@ -1,1026 +1,1026 @@ { - "width": 512, - "height": 352, - "sprites": { - "sandstone_floor6.png": { - "x": 0, - "y": 0, - "width": 32, - "height": 32 - }, - "pedestal_ne.png": { - "x": 32, - "y": 0, - "width": 32, - "height": 32 - }, - "marble_floor4.png": { - "x": 64, - "y": 0, - "width": 32, - "height": 32 - }, - "pebble_brown2.png": { - "x": 96, - "y": 0, - "width": 32, - "height": 32 - }, - "sandstone_floor4.png": { - "x": 128, - "y": 0, - "width": 32, - "height": 32 - }, - "hive2.png": { - "x": 160, - "y": 0, - "width": 32, - "height": 32 - }, - "lair1.png": { - "x": 192, - "y": 0, - "width": 32, - "height": 32 - }, - "crystal_floor3.png": { - "x": 224, - "y": 0, - "width": 32, - "height": 32 - }, - "volcanic_floor1.png": { - "x": 256, - "y": 0, - "width": 32, - "height": 32 - }, - "snake2.png": { - "x": 288, - "y": 0, - "width": 32, - "height": 32 - }, - "lava2.png": { - "x": 320, - "y": 0, - "width": 32, - "height": 32 - }, - "cobble_blood5.png": { - "x": 352, - "y": 0, - "width": 32, - "height": 32 - }, - "dirt_ne.png": { - "x": 384, - "y": 0, - "width": 32, - "height": 32 - }, - "mesh2.png": { - "x": 416, - "y": 0, - "width": 32, - "height": 32 - }, - "cobble_blood7.png": { - "x": 448, - "y": 0, - "width": 32, - "height": 32 - }, - "sandstone_floor2.png": { - "x": 480, - "y": 0, - "width": 32, - "height": 32 - }, - "dirt_e.png": { - "x": 0, - "y": 32, - "width": 32, - "height": 32 - }, - "pedestal_se.png": { - "x": 32, - "y": 32, - "width": 32, - "height": 32 - }, - "rough_red0.png": { - "x": 64, - "y": 32, - "width": 32, - "height": 32 - }, - "grey_dirt2.png": { - "x": 96, - "y": 32, - "width": 32, - "height": 32 - }, - "bog_green2.png": { - "x": 128, - "y": 32, -n "width": 32, - "height": 32 - }, - "floor_sand_stone3.png": { - "x": 160, - "y": 32, - "width": 32, - "height": 32 - }, - "tomb0.png": { - "x": 192, - "y": 32, - "width": 32, - "height": 32 - }, - "pedestal_sw.png": { - "x": 224, - "y": 32, - "width": 32, - "height": 32 - }, - "pebble_brown3.png": { - "x": 256, - "y": 32, - "width": 32, - "height": 32 - }, - "floor_vines3.png": { - "x": 288, - "y": 32, - "width": 32, - "height": 32 - }, - "pebble_brown1.png": { - "x": 320, - "y": 32, - "width": 32, - "height": 32 - }, - "crystal_floor0.png": { - "x": 352, - "y": 32, - "width": 32, - "height": 32 - }, - "rect_gray3.png": { - "x": 384, - "y": 32, - "width": 32, - "height": 32 - }, - "floor_sand_stone4.png": { - "x": 416, - "y": 32, - "width": 32, - "height": 32 - }, - "floor_sand_stone0.png": { - "x": 448, - "y": 32, - "width": 32, - "height": 32 - }, - "cobble_blood6.png": { - "x": 480, - "y": 32, - "width": 32, - "height": 32 - }, - "floor_nerves2.png": { - "x": 0, - "y": 64, - "width": 32, - "height": 32 - }, - "ice2.png": { - "x": 32, - "y": 64, - "width": 32, - "height": 32 - }, - "lair0.png": { - "x": 64, - "y": 64, - "width": 32, - "height": 32 - }, - "rough_red1.png": { - "x": 96, - "y": 64, - "width": 32, - "height": 32 - }, - "pebble_brown0.png": { - "x": 128, - "y": 64, - "width": 32, - "height": 32 - }, - "snake3.png": { - "x": 160, - "y": 64, - "width": 32, - "height": 32 - }, - "volcanic_floor2.png": { - "x": 192, - "y": 64, - "width": 32, - "height": 32 - }, - "pebble_brown7.png": { - "x": 224, - "y": 64, - "width": 32, - "height": 32 - }, - "floor_sand_stone1.png": { - "x": 256, - "y": 64, - "width": 32, - "height": 32 - }, - "floor_nerves6.png": { - "x": 288, - "y": 64, - "width": 32, - "height": 32 - }, - "cobble_blood10.png": { - "x": 320, - "y": 64, - "width": 32, - "height": 32 - }, - "dirt_n.png": { - "x": 352, - "y": 64, - "width": 32, - "height": 32 - }, - "mesh0.png": { - "x": 384, - "y": 64, - "width": 32, - "height": 32 - }, - "sandstone_floor7.png": { - "x": 416, - "y": 64, - "width": 32, - "height": 32 - }, - "volcanic_floor6.png": { - "x": 448, - "y": 64, - "width": 32, - "height": 32 - }, - "sandstone_floor0.png": { - "x": 480, - "y": 64, - "width": 32, - "height": 32 - }, - "rough_red3.png": { - "x": 0, - "y": 96, - "width": 32, - "height": 32 - }, - "pedestal_e.png": { - "x": 32, - "y": 96, - "width": 32, - "height": 32 - }, - "ice1.png": { - "x": 64, - "y": 96, - "width": 32, - "height": 32 - }, - "floor_nerves0.png": { - "x": 96, - "y": 96, - "width": 32, - "height": 32 - }, - "swamp0.png": { - "x": 128, - "y": 96, - "width": 32, - "height": 32 - }, - "dirt2.png": { - "x": 160, - "y": 96, - "width": 32, - "height": 32 - }, - "floor_sand_stone6.png": { - "x": 192, - "y": 96, - "width": 32, - "height": 32 - }, - "pedestal_s.png": { - "x": 224, - "y": 96, - "width": 32, - "height": 32 - }, - "pedestal_full.png": { - "x": 256, - "y": 96, - "width": 32, - "height": 32 - }, - "volcanic_floor4.png": { - "x": 288, - "y": 96, - "width": 32, - "height": 32 - }, - "pebble_brown4.png": { - "x": 320, - "y": 96, - "width": 32, - "height": 32 - }, - "dirt1.png": { - "x": 352, - "y": 96, - "width": 32, - "height": 32 - }, - "sandstone_floor5.png": { - "x": 384, - "y": 96, - "width": 32, - "height": 32 - }, - "rough_red2.png": { - "x": 416, - "y": 96, - "width": 32, - "height": 32 - }, - "rect_gray0.png": { - "x": 448, - "y": 96, - "width": 32, - "height": 32 - }, - "rect_gray2.png": { - "x": 480, - "y": 96, - "width": 32, - "height": 32 - }, - "floor_nerves5.png": { - "x": 0, - "y": 128, - "width": 32, - "height": 32 - }, - "swamp2.png": { - "x": 32, - "y": 128, - "width": 32, - "height": 32 - }, - "grey_dirt7.png": { - "x": 64, - "y": 128, - "width": 32, - "height": 32 - }, - "cobble_blood8.png": { - "x": 96, - "y": 128, - "width": 32, - "height": 32 - }, - "grey_dirt0.png": { - "x": 128, - "y": 128, - "width": 32, - "height": 32 - }, - "cobble_blood1.png": { - "x": 160, - "y": 128, - "width": 32, - "height": 32 - }, - "volcanic_floor3.png": { - "x": 192, - "y": 128, - "width": 32, - "height": 32 - }, - "lair2.png": { - "x": 224, - "y": 128, - "width": 32, - "height": 32 - }, - "lava0.png": { - "x": 256, - "y": 128, - "width": 32, - "height": 32 - }, - "cobble_blood4.png": { - "x": 288, - "y": 128, - "width": 32, - "height": 32 - }, - "grey_dirt1.png": { - "x": 320, - "y": 128, - "width": 32, - "height": 32 - }, - "pedestal_nw.png": { - "x": 352, - "y": 128, - "width": 32, - "height": 32 - }, - "crystal_floor5.png": { - "x": 384, - "y": 128, - "width": 32, - "height": 32 - }, - "bog_green3.png": { - "x": 416, - "y": 128, - "width": 32, - "height": 32 - }, - "marble_floor2.png": { - "x": 448, - "y": 128, - "width": 32, - "height": 32 - }, - "mesh3.png": { - "x": 480, - "y": 128, - "width": 32, - "height": 32 - }, - "pedestal_w.png": { - "x": 0, - "y": 160, - "width": 32, - "height": 32 - }, - "swamp1.png": { - "x": 32, - "y": 160, - "width": 32, - "height": 32 - }, - "snake0.png": { - "x": 64, - "y": 160, - "width": 32, - "height": 32 - }, - "crystal_floor4.png": { - "x": 96, - "y": 160, - "width": 32, - "height": 32 - }, - "cobble_blood12.png": { - "x": 128, - "y": 160, - "width": 32, - "height": 32 - }, - "floor_vines4.png": { - "x": 160, - "y": 160, - "width": 32, - "height": 32 - }, - "floor_vines2.png": { - "x": 192, - "y": 160, - "width": 32, - "height": 32 - }, - "floor_nerves1.png": { - "x": 224, - "y": 160, - "width": 32, - "height": 32 - }, - "snake1.png": { - "x": 256, - "y": 160, - "width": 32, - "height": 32 - }, - "dirt_sw.png": { - "x": 288, - "y": 160, - "width": 32, - "height": 32 - }, - "dirt0.png": { - "x": 320, - "y": 160, - "width": 32, - "height": 32 - }, - "hive0.png": { - "x": 352, - "y": 160, - "width": 32, - "height": 32 - }, - "grey_dirt3.png": { - "x": 384, - "y": 160, - "width": 32, - "height": 32 - }, - "floor_nerves3.png": { - "x": 416, - "y": 160, - "width": 32, - "height": 32 - }, - "marble_floor5.png": { - "x": 448, - "y": 160, - "width": 32, - "height": 32 - }, - "bog_green1.png": { - "x": 480, - "y": 160, - "width": 32, - "height": 32 - }, - "sandstone_floor3.png": { - "x": 0, - "y": 192, - "width": 32, - "height": 32 - }, - "bog_green0.png": { - "x": 32, - "y": 192, - "width": 32, - "height": 32 - }, - "pedestal_n.png": { - "x": 64, - "y": 192, - "width": 32, - "height": 32 - }, - "hive1.png": { - "x": 96, - "y": 192, - "width": 32, - "height": 32 - }, - "pebble_brown6.png": { - "x": 128, - "y": 192, - "width": 32, - "height": 32 - }, - "floor_sand_stone2.png": { - "x": 160, - "y": 192, - "width": 32, - "height": 32 - }, - "cobble_blood3.png": { - "x": 192, - "y": 192, - "width": 32, - "height": 32 - }, - "sandstone_floor9.png": { - "x": 224, - "y": 192, - "width": 32, - "height": 32 - }, - "swamp3.png": { - "x": 256, - "y": 192, - "width": 32, - "height": 32 - }, - "ice0.png": { - "x": 288, - "y": 192, - "width": 32, - "height": 32 - }, - "marble_floor3.png": { - "x": 320, - "y": 192, - "width": 32, - "height": 32 - }, - "volcanic_floor5.png": { - "x": 352, - "y": 192, - "width": 32, - "height": 32 - }, - "floor_vines6.png": { - "x": 384, - "y": 192, - "width": 32, - "height": 32 - }, - "tutorial_pad.png": { - "x": 416, - "y": 192, - "width": 32, - "height": 32 - }, - "dirt_nw.png": { - "x": 448, - "y": 192, - "width": 32, - "height": 32 - }, - "floor_vines0.png": { - "x": 480, - "y": 192, - "width": 32, - "height": 32 - }, - "grey_dirt4.png": { - "x": 0, - "y": 224, - "width": 32, - "height": 32 - }, - "marble_floor6.png": { - "x": 32, - "y": 224, - "width": 32, - "height": 32 - }, - "grey_dirt6.png": { - "x": 64, - "y": 224, - "width": 32, - "height": 32 - }, - "crystal_floor1.png": { - "x": 96, - "y": 224, - "width": 32, - "height": 32 - }, - "cobble_blood9.png": { - "x": 128, - "y": 224, - "width": 32, - "height": 32 - }, - "ice3.png": { - "x": 160, - "y": 224, - "width": 32, - "height": 32 - }, - "floor_nerves4.png": { - "x": 192, - "y": 224, - "width": 32, - "height": 32 - }, - "dirt_w.png": { - "x": 224, - "y": 224, - "width": 32, - "height": 32 - }, - "pebble_brown5.png": { - "x": 256, - "y": 224, - "width": 32, - "height": 32 - }, - "lair3.png": { - "x": 288, - "y": 224, - "width": 32, - "height": 32 - }, - "rect_gray1.png": { - "x": 320, - "y": 224, - "width": 32, - "height": 32 - }, - "tomb3.png": { - "x": 352, - "y": 224, - "width": 32, - "height": 32 - }, - "floor_vines1.png": { - "x": 384, - "y": 224, - "width": 32, - "height": 32 - }, - "grey_dirt5.png": { - "x": 416, - "y": 224, - "width": 32, - "height": 32 - }, - "floor_vines5.png": { - "x": 448, - "y": 224, - "width": 32, - "height": 32 - }, - "sandstone_floor1.png": { - "x": 480, - "y": 224, - "width": 32, - "height": 32 - }, - "floor_sand_stone5.png": { - "x": 0, - "y": 256, - "width": 32, - "height": 32 - }, - "dirt_se.png": { - "x": 32, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_full.png": { - "x": 64, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass1.png": { - "x": 96, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_yellow2.png": { - "x": 128, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_s.png": { - "x": 160, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_se.png": { - "x": 192, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_red2.png": { - "x": 224, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass2.png": { - "x": 256, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass0-dirt-mix2.png": { - "x": 288, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_blue3.png": { - "x": 320, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_blue2.png": { - "x": 352, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_blue1.png": { - "x": 384, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass0-dirt-mix1.png": { - "x": 416, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_red1.png": { - "x": 448, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_yellow3.png": { - "x": 480, - "y": 256, - "width": 32, - "height": 32 - }, - "grass/grass_sw.png": { - "x": 0, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_yellow1.png": { - "x": 32, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_nw.png": { - "x": 64, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_w.png": { - "x": 96, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_n.png": { - "x": 128, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_e.png": { - "x": 160, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_ne.png": { - "x": 192, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass0-dirt-mix3.png": { - "x": 224, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass0.png": { - "x": 256, - "y": 288, - "width": 32, - "height": 32 - }, - "grass/grass_flowers_red3.png": { - "x": 288, - "y": 288, - "width": 32, - "height": 32 - }, - "crystal_floor2.png": { - "x": 320, - "y": 288, - "width": 32, - "height": 32 - }, - "tomb2.png": { - "x": 352, - "y": 288, - "width": 32, - "height": 32 - }, - "cobble_blood11.png": { - "x": 384, - "y": 288, - "width": 32, - "height": 32 - }, - "cobble_blood2.png": { - "x": 416, - "y": 288, - "width": 32, - "height": 32 - }, - "lava3.png": { - "x": 448, - "y": 288, - "width": 32, - "height": 32 - }, - "volcanic_floor0.png": { - "x": 480, - "y": 288, - "width": 32, - "height": 32 - }, - "mesh1.png": { - "x": 0, - "y": 320, - "width": 32, - "height": 32 - }, - "dirt_full.png": { - "x": 32, - "y": 320, - "width": 32, - "height": 32 - }, - "lava1.png": { - "x": 64, - "y": 320, - "width": 32, - "height": 32 - }, - "tomb1.png": { - "x": 96, - "y": 320, - "width": 32, - "height": 32 - }, - "dirt_s.png": { - "x": 128, - "y": 320, - "width": 32, - "height": 32 - }, - "marble_floor1.png": { - "x": 160, - "y": 320, - "width": 32, - "height": 32 - }, - "floor_sand_stone7.png": { - "x": 192, - "y": 320, - "width": 32, - "height": 32 - }, - "hive3.png": { - "x": 224, - "y": 320, - "width": 32, - "height": 32 - }, - "pebble_brown8.png": { - "x": 256, - "y": 320, - "width": 32, - "height": 32 - }, - "sandstone_floor8.png": { - "x": 288, - "y": 320, - "width": 32, - "height": 32 + "width": 512, + "height": 352, + "sprites": { + "sandstone_floor6.png": { + "x": 0, + "y": 0, + "width": 32, + "height": 32 + }, + "pedestal_ne.png": { + "x": 32, + "y": 0, + "width": 32, + "height": 32 + }, + "marble_floor4.png": { + "x": 64, + "y": 0, + "width": 32, + "height": 32 + }, + "pebble_brown2.png": { + "x": 96, + "y": 0, + "width": 32, + "height": 32 + }, + "sandstone_floor4.png": { + "x": 128, + "y": 0, + "width": 32, + "height": 32 + }, + "hive2.png": { + "x": 160, + "y": 0, + "width": 32, + "height": 32 + }, + "lair1.png": { + "x": 192, + "y": 0, + "width": 32, + "height": 32 + }, + "crystal_floor3.png": { + "x": 224, + "y": 0, + "width": 32, + "height": 32 + }, + "volcanic_floor1.png": { + "x": 256, + "y": 0, + "width": 32, + "height": 32 + }, + "snake2.png": { + "x": 288, + "y": 0, + "width": 32, + "height": 32 + }, + "lava2.png": { + "x": 320, + "y": 0, + "width": 32, + "height": 32 + }, + "cobble_blood5.png": { + "x": 352, + "y": 0, + "width": 32, + "height": 32 + }, + "dirt_ne.png": { + "x": 384, + "y": 0, + "width": 32, + "height": 32 + }, + "mesh2.png": { + "x": 416, + "y": 0, + "width": 32, + "height": 32 + }, + "cobble_blood7.png": { + "x": 448, + "y": 0, + "width": 32, + "height": 32 + }, + "sandstone_floor2.png": { + "x": 480, + "y": 0, + "width": 32, + "height": 32 + }, + "dirt_e.png": { + "x": 0, + "y": 32, + "width": 32, + "height": 32 + }, + "pedestal_se.png": { + "x": 32, + "y": 32, + "width": 32, + "height": 32 + }, + "rough_red0.png": { + "x": 64, + "y": 32, + "width": 32, + "height": 32 + }, + "grey_dirt2.png": { + "x": 96, + "y": 32, + "width": 32, + "height": 32 + }, + "bog_green2.png": { + "x": 128, + "y": 32, + "width": 32, + "height": 32 + }, + "floor_sand_stone3.png": { + "x": 160, + "y": 32, + "width": 32, + "height": 32 + }, + "tomb0.png": { + "x": 192, + "y": 32, + "width": 32, + "height": 32 + }, + "pedestal_sw.png": { + "x": 224, + "y": 32, + "width": 32, + "height": 32 + }, + "pebble_brown3.png": { + "x": 256, + "y": 32, + "width": 32, + "height": 32 + }, + "floor_vines3.png": { + "x": 288, + "y": 32, + "width": 32, + "height": 32 + }, + "pebble_brown1.png": { + "x": 320, + "y": 32, + "width": 32, + "height": 32 + }, + "crystal_floor0.png": { + "x": 352, + "y": 32, + "width": 32, + "height": 32 + }, + "rect_gray3.png": { + "x": 384, + "y": 32, + "width": 32, + "height": 32 + }, + "floor_sand_stone4.png": { + "x": 416, + "y": 32, + "width": 32, + "height": 32 + }, + "floor_sand_stone0.png": { + "x": 448, + "y": 32, + "width": 32, + "height": 32 + }, + "cobble_blood6.png": { + "x": 480, + "y": 32, + "width": 32, + "height": 32 + }, + "floor_nerves2.png": { + "x": 0, + "y": 64, + "width": 32, + "height": 32 + }, + "ice2.png": { + "x": 32, + "y": 64, + "width": 32, + "height": 32 + }, + "lair0.png": { + "x": 64, + "y": 64, + "width": 32, + "height": 32 + }, + "rough_red1.png": { + "x": 96, + "y": 64, + "width": 32, + "height": 32 + }, + "pebble_brown0.png": { + "x": 128, + "y": 64, + "width": 32, + "height": 32 + }, + "snake3.png": { + "x": 160, + "y": 64, + "width": 32, + "height": 32 + }, + "volcanic_floor2.png": { + "x": 192, + "y": 64, + "width": 32, + "height": 32 + }, + "pebble_brown7.png": { + "x": 224, + "y": 64, + "width": 32, + "height": 32 + }, + "floor_sand_stone1.png": { + "x": 256, + "y": 64, + "width": 32, + "height": 32 + }, + "floor_nerves6.png": { + "x": 288, + "y": 64, + "width": 32, + "height": 32 + }, + "cobble_blood10.png": { + "x": 320, + "y": 64, + "width": 32, + "height": 32 + }, + "dirt_n.png": { + "x": 352, + "y": 64, + "width": 32, + "height": 32 + }, + "mesh0.png": { + "x": 384, + "y": 64, + "width": 32, + "height": 32 + }, + "sandstone_floor7.png": { + "x": 416, + "y": 64, + "width": 32, + "height": 32 + }, + "volcanic_floor6.png": { + "x": 448, + "y": 64, + "width": 32, + "height": 32 + }, + "sandstone_floor0.png": { + "x": 480, + "y": 64, + "width": 32, + "height": 32 + }, + "rough_red3.png": { + "x": 0, + "y": 96, + "width": 32, + "height": 32 + }, + "pedestal_e.png": { + "x": 32, + "y": 96, + "width": 32, + "height": 32 + }, + "ice1.png": { + "x": 64, + "y": 96, + "width": 32, + "height": 32 + }, + "floor_nerves0.png": { + "x": 96, + "y": 96, + "width": 32, + "height": 32 + }, + "swamp0.png": { + "x": 128, + "y": 96, + "width": 32, + "height": 32 + }, + "dirt2.png": { + "x": 160, + "y": 96, + "width": 32, + "height": 32 + }, + "floor_sand_stone6.png": { + "x": 192, + "y": 96, + "width": 32, + "height": 32 + }, + "pedestal_s.png": { + "x": 224, + "y": 96, + "width": 32, + "height": 32 + }, + "pedestal_full.png": { + "x": 256, + "y": 96, + "width": 32, + "height": 32 + }, + "volcanic_floor4.png": { + "x": 288, + "y": 96, + "width": 32, + "height": 32 + }, + "pebble_brown4.png": { + "x": 320, + "y": 96, + "width": 32, + "height": 32 + }, + "dirt1.png": { + "x": 352, + "y": 96, + "width": 32, + "height": 32 + }, + "sandstone_floor5.png": { + "x": 384, + "y": 96, + "width": 32, + "height": 32 + }, + "rough_red2.png": { + "x": 416, + "y": 96, + "width": 32, + "height": 32 + }, + "rect_gray0.png": { + "x": 448, + "y": 96, + "width": 32, + "height": 32 + }, + "rect_gray2.png": { + "x": 480, + "y": 96, + "width": 32, + "height": 32 + }, + "floor_nerves5.png": { + "x": 0, + "y": 128, + "width": 32, + "height": 32 + }, + "swamp2.png": { + "x": 32, + "y": 128, + "width": 32, + "height": 32 + }, + "grey_dirt7.png": { + "x": 64, + "y": 128, + "width": 32, + "height": 32 + }, + "cobble_blood8.png": { + "x": 96, + "y": 128, + "width": 32, + "height": 32 + }, + "grey_dirt0.png": { + "x": 128, + "y": 128, + "width": 32, + "height": 32 + }, + "cobble_blood1.png": { + "x": 160, + "y": 128, + "width": 32, + "height": 32 + }, + "volcanic_floor3.png": { + "x": 192, + "y": 128, + "width": 32, + "height": 32 + }, + "lair2.png": { + "x": 224, + "y": 128, + "width": 32, + "height": 32 + }, + "lava0.png": { + "x": 256, + "y": 128, + "width": 32, + "height": 32 + }, + "cobble_blood4.png": { + "x": 288, + "y": 128, + "width": 32, + "height": 32 + }, + "grey_dirt1.png": { + "x": 320, + "y": 128, + "width": 32, + "height": 32 + }, + "pedestal_nw.png": { + "x": 352, + "y": 128, + "width": 32, + "height": 32 + }, + "crystal_floor5.png": { + "x": 384, + "y": 128, + "width": 32, + "height": 32 + }, + "bog_green3.png": { + "x": 416, + "y": 128, + "width": 32, + "height": 32 + }, + "marble_floor2.png": { + "x": 448, + "y": 128, + "width": 32, + "height": 32 + }, + "mesh3.png": { + "x": 480, + "y": 128, + "width": 32, + "height": 32 + }, + "pedestal_w.png": { + "x": 0, + "y": 160, + "width": 32, + "height": 32 + }, + "swamp1.png": { + "x": 32, + "y": 160, + "width": 32, + "height": 32 + }, + "snake0.png": { + "x": 64, + "y": 160, + "width": 32, + "height": 32 + }, + "crystal_floor4.png": { + "x": 96, + "y": 160, + "width": 32, + "height": 32 + }, + "cobble_blood12.png": { + "x": 128, + "y": 160, + "width": 32, + "height": 32 + }, + "floor_vines4.png": { + "x": 160, + "y": 160, + "width": 32, + "height": 32 + }, + "floor_vines2.png": { + "x": 192, + "y": 160, + "width": 32, + "height": 32 + }, + "floor_nerves1.png": { + "x": 224, + "y": 160, + "width": 32, + "height": 32 + }, + "snake1.png": { + "x": 256, + "y": 160, + "width": 32, + "height": 32 + }, + "dirt_sw.png": { + "x": 288, + "y": 160, + "width": 32, + "height": 32 + }, + "dirt0.png": { + "x": 320, + "y": 160, + "width": 32, + "height": 32 + }, + "hive0.png": { + "x": 352, + "y": 160, + "width": 32, + "height": 32 + }, + "grey_dirt3.png": { + "x": 384, + "y": 160, + "width": 32, + "height": 32 + }, + "floor_nerves3.png": { + "x": 416, + "y": 160, + "width": 32, + "height": 32 + }, + "marble_floor5.png": { + "x": 448, + "y": 160, + "width": 32, + "height": 32 + }, + "bog_green1.png": { + "x": 480, + "y": 160, + "width": 32, + "height": 32 + }, + "sandstone_floor3.png": { + "x": 0, + "y": 192, + "width": 32, + "height": 32 + }, + "bog_green0.png": { + "x": 32, + "y": 192, + "width": 32, + "height": 32 + }, + "pedestal_n.png": { + "x": 64, + "y": 192, + "width": 32, + "height": 32 + }, + "hive1.png": { + "x": 96, + "y": 192, + "width": 32, + "height": 32 + }, + "pebble_brown6.png": { + "x": 128, + "y": 192, + "width": 32, + "height": 32 + }, + "floor_sand_stone2.png": { + "x": 160, + "y": 192, + "width": 32, + "height": 32 + }, + "cobble_blood3.png": { + "x": 192, + "y": 192, + "width": 32, + "height": 32 + }, + "sandstone_floor9.png": { + "x": 224, + "y": 192, + "width": 32, + "height": 32 + }, + "swamp3.png": { + "x": 256, + "y": 192, + "width": 32, + "height": 32 + }, + "ice0.png": { + "x": 288, + "y": 192, + "width": 32, + "height": 32 + }, + "marble_floor3.png": { + "x": 320, + "y": 192, + "width": 32, + "height": 32 + }, + "volcanic_floor5.png": { + "x": 352, + "y": 192, + "width": 32, + "height": 32 + }, + "floor_vines6.png": { + "x": 384, + "y": 192, + "width": 32, + "height": 32 + }, + "tutorial_pad.png": { + "x": 416, + "y": 192, + "width": 32, + "height": 32 + }, + "dirt_nw.png": { + "x": 448, + "y": 192, + "width": 32, + "height": 32 + }, + "floor_vines0.png": { + "x": 480, + "y": 192, + "width": 32, + "height": 32 + }, + "grey_dirt4.png": { + "x": 0, + "y": 224, + "width": 32, + "height": 32 + }, + "marble_floor6.png": { + "x": 32, + "y": 224, + "width": 32, + "height": 32 + }, + "grey_dirt6.png": { + "x": 64, + "y": 224, + "width": 32, + "height": 32 + }, + "crystal_floor1.png": { + "x": 96, + "y": 224, + "width": 32, + "height": 32 + }, + "cobble_blood9.png": { + "x": 128, + "y": 224, + "width": 32, + "height": 32 + }, + "ice3.png": { + "x": 160, + "y": 224, + "width": 32, + "height": 32 + }, + "floor_nerves4.png": { + "x": 192, + "y": 224, + "width": 32, + "height": 32 + }, + "dirt_w.png": { + "x": 224, + "y": 224, + "width": 32, + "height": 32 + }, + "pebble_brown5.png": { + "x": 256, + "y": 224, + "width": 32, + "height": 32 + }, + "lair3.png": { + "x": 288, + "y": 224, + "width": 32, + "height": 32 + }, + "rect_gray1.png": { + "x": 320, + "y": 224, + "width": 32, + "height": 32 + }, + "tomb3.png": { + "x": 352, + "y": 224, + "width": 32, + "height": 32 + }, + "floor_vines1.png": { + "x": 384, + "y": 224, + "width": 32, + "height": 32 + }, + "grey_dirt5.png": { + "x": 416, + "y": 224, + "width": 32, + "height": 32 + }, + "floor_vines5.png": { + "x": 448, + "y": 224, + "width": 32, + "height": 32 + }, + "sandstone_floor1.png": { + "x": 480, + "y": 224, + "width": 32, + "height": 32 + }, + "floor_sand_stone5.png": { + "x": 0, + "y": 256, + "width": 32, + "height": 32 + }, + "dirt_se.png": { + "x": 32, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_full.png": { + "x": 64, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass1.png": { + "x": 96, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_yellow2.png": { + "x": 128, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_s.png": { + "x": 160, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_se.png": { + "x": 192, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_red2.png": { + "x": 224, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass2.png": { + "x": 256, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass0-dirt-mix2.png": { + "x": 288, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_blue3.png": { + "x": 320, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_blue2.png": { + "x": 352, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_blue1.png": { + "x": 384, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass0-dirt-mix1.png": { + "x": 416, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_red1.png": { + "x": 448, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_yellow3.png": { + "x": 480, + "y": 256, + "width": 32, + "height": 32 + }, + "grass/grass_sw.png": { + "x": 0, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_yellow1.png": { + "x": 32, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_nw.png": { + "x": 64, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_w.png": { + "x": 96, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_n.png": { + "x": 128, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_e.png": { + "x": 160, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_ne.png": { + "x": 192, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass0-dirt-mix3.png": { + "x": 224, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass0.png": { + "x": 256, + "y": 288, + "width": 32, + "height": 32 + }, + "grass/grass_flowers_red3.png": { + "x": 288, + "y": 288, + "width": 32, + "height": 32 + }, + "crystal_floor2.png": { + "x": 320, + "y": 288, + "width": 32, + "height": 32 + }, + "tomb2.png": { + "x": 352, + "y": 288, + "width": 32, + "height": 32 + }, + "cobble_blood11.png": { + "x": 384, + "y": 288, + "width": 32, + "height": 32 + }, + "cobble_blood2.png": { + "x": 416, + "y": 288, + "width": 32, + "height": 32 + }, + "lava3.png": { + "x": 448, + "y": 288, + "width": 32, + "height": 32 + }, + "volcanic_floor0.png": { + "x": 480, + "y": 288, + "width": 32, + "height": 32 + }, + "mesh1.png": { + "x": 0, + "y": 320, + "width": 32, + "height": 32 + }, + "dirt_full.png": { + "x": 32, + "y": 320, + "width": 32, + "height": 32 + }, + "lava1.png": { + "x": 64, + "y": 320, + "width": 32, + "height": 32 + }, + "tomb1.png": { + "x": 96, + "y": 320, + "width": 32, + "height": 32 + }, + "dirt_s.png": { + "x": 128, + "y": 320, + "width": 32, + "height": 32 + }, + "marble_floor1.png": { + "x": 160, + "y": 320, + "width": 32, + "height": 32 + }, + "floor_sand_stone7.png": { + "x": 192, + "y": 320, + "width": 32, + "height": 32 + }, + "hive3.png": { + "x": 224, + "y": 320, + "width": 32, + "height": 32 + }, + "pebble_brown8.png": { + "x": 256, + "y": 320, + "width": 32, + "height": 32 + }, + "sandstone_floor8.png": { + "x": 288, + "y": 320, + "width": 32, + "height": 32 + } } - } } diff --git a/tests/spritesheet/test.cpp b/tests/spritesheet/test.cpp index 4d4cc1a4..7fe4e77f 100644 --- a/tests/spritesheet/test.cpp +++ b/tests/spritesheet/test.cpp @@ -6,21 +6,17 @@ * ---------------------------------------------------------------------------- */ -/** @file */ - #include <gtest/gtest.h> #include <yage/yage.h> +#include "../testshared.h" + using namespace yage; TEST(SpriteSheet, Load) { - /// @todo add a test to test the spritesheet loading + SpriteSheet sp("tests/spritesheet/floor_atlas.png", "tests/spritesheet/floor_atlas.json"); ASSERT_TRUE(true); } -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} +OPENGL_TEST_MAIN(LogLevel::DEBUG) diff --git a/tests/testshared.h b/tests/testshared.h new file mode 100644 index 00000000..4418072c --- /dev/null +++ b/tests/testshared.h @@ -0,0 +1,33 @@ +/** --------------------------------------------------------------------------- + * @file: testshared.h + * + * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#ifndef TEST_TESTSHARED_H +#define TEST_TESTSHARED_H + +#define OPENGL_TEST_MAIN(LOGLEVEL) \ + int main(int argc, char **argv) \ + { \ + yLogger.setLevel(LOGLEVEL); \ + ::testing::InitGoogleTest(&argc, argv); \ + ::yage::init(); \ + ::yage::Window x; \ + x.create("Window", 800, 600); \ + auto ret = RUN_ALL_TESTS(); \ + ::yage::quit(); \ + return ret; \ + } + +#define TEST_MAIN(LOGLEVEL) \ + int main(int argc, char **argv) \ + { \ + yLogger.setLevel(LOGLEVEL); \ + testing::InitGoogleTest(&argc, argv); \ + return RUN_ALL_TESTS(); \ + } + +#endif diff --git a/yage/core/imageloader.cpp b/yage/core/imageloader.cpp index 23bc9a25..4cd583d1 100644 --- a/yage/core/imageloader.cpp +++ b/yage/core/imageloader.cpp @@ -10,22 +10,28 @@ #include "../data/texture.h" #include "logger.h" #include "stb_image.h" +#include <iostream> #include <glad/glad.h> #include <iostream> #include <stdexcept> +using std::cout; + namespace yage { Texture ImageLoader::loadPng(const std::string &file_path) { int width, height, num_channels; + yLogDebug << "Loading image from disk: " << file_path; unsigned char *data = stbi_load(file_path.c_str(), &width, &height, &num_channels, 0); - + yLogDebug << "Sucessfully loaded file"; Texture texture(0, static_cast<int>(width), static_cast<int>(height)); + yLogDebug << "Creating texture"; + cout << "Hello"; glGenTextures(1, &texture.id); glBindTexture(GL_TEXTURE_2D, texture.id); diff --git a/yage/core/spritesheet.cpp b/yage/core/spritesheet.cpp index 4ecdcf71..f3f99619 100644 --- a/yage/core/spritesheet.cpp +++ b/yage/core/spritesheet.cpp @@ -18,24 +18,30 @@ #include <sstream> #include <stdexcept> +#include <iostream> + using rapidjson::Document; using yage::details::Coordinate; using yage::details::SpriteMap; +using std::cout; + namespace yage { SpriteSheet::SpriteSheet(std::string pngFileName, std::string jsonFileName) { int jsonWidth, jsonHeight; + fileLocations_ = parseJson(jsonWidth, jsonHeight, fileContent(jsonFileName)); texture_ = ImageLoader::loadPng(pngFileName); - - if (texture_.width != jsonWidth) + if (texture_.width != jsonWidth) { throw std::runtime_error("JSON width does not match texture width"); - if (texture_.height != jsonHeight) + } + if (texture_.height != jsonHeight) { throw std::runtime_error("JSON height does not match texture height"); + } } std::string SpriteSheet::fileContent(std::string jsonFileName) const @@ -54,27 +60,16 @@ SpriteMap SpriteSheet::parseJson(int &width, int &height, SpriteMap spriteMap; Document jsonAtlas; jsonAtlas.Parse(jsonContent.c_str()); - width = jsonAtlas["width"].GetInt(); height = jsonAtlas["height"].GetInt(); - for (auto &texture : jsonAtlas["sprites"].GetObject()) { - Coordinate coord; - for (auto &value : texture.value.GetObject()) { - std::string keyName{value.value.GetString()}; - int keyValue{value.value.GetInt()}; - if (keyName == "x") { - coord.x = keyValue; - } else if (keyName == "y") { - coord.y = keyValue; - } else if (keyName == "width") { - coord.width = keyValue; - } else if (keyName == "height") { - coord.height = keyValue; - } else { - throw std::runtime_error("JSON key incorrect: " + keyName); - } - } + Coordinate coord; + for(auto &texture : jsonAtlas["sprites"].GetObject()) { + auto texVal = texture.value.GetObject(); + coord.x = texVal["x"].GetInt(); + coord.y = texVal["y"].GetInt(); + coord.width = texVal["width"].GetInt(); + coord.height = texVal["height"].GetInt(); spriteMap[texture.name.GetString()] = coord; } diff --git a/yage/core/spritesheet.h b/yage/core/spritesheet.h index 7b089d25..ea1db44b 100644 --- a/yage/core/spritesheet.h +++ b/yage/core/spritesheet.h @@ -16,6 +16,7 @@ * spritesheet. */ #include "../data/texture.h" +#include "../util/noncopyable.h" #include <rapidjson/reader.h> @@ -46,9 +47,10 @@ typedef std::map<std::string, details::Coordinate> SpriteMap; } // namespace details -class SpriteSheet +class SpriteSheet : public NonCopyable { public: + SpriteSheet() = default; SpriteSheet(std::string pngFileName, std::string jsonFileName); void sprite(std::string spriteName) const; |