5#ifndef IMGUI_DEFINE_MATH_OPERATORS
6#define IMGUI_DEFINE_MATH_OPERATORS
13#include <gtest/gtest.h>
36 BoundRomTest::SetUp();
39 drawer_ = std::make_unique<zelda3::ObjectDrawer>(
rom());
42 bg1_ = std::make_unique<gfx::BackgroundBuffer>(512, 512);
43 bg2_ = std::make_unique<gfx::BackgroundBuffer>(512, 512);
53 BoundRomTest::TearDown();
61 for (
int i = 0; i < 16; i++) {
62 int intensity = i * 16;
77 std::unique_ptr<zelda3::ObjectDrawer>
drawer_;
78 std::unique_ptr<gfx::BackgroundBuffer>
bg1_;
79 std::unique_ptr<gfx::BackgroundBuffer>
bg2_;
85 std::vector<zelda3::RoomObject> objects;
86 objects.push_back(CreateTestObject(0x10, 5, 5, 0x12, 0));
87 objects.push_back(CreateTestObject(0x20, 10, 10, 0x22, 0));
92 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
93 ASSERT_TRUE(status.ok()) <<
"Drawing failed: " << status.message();
96 auto& bg1_bitmap = bg1_->bitmap();
97 EXPECT_TRUE(bg1_bitmap.is_active());
98 EXPECT_GT(bg1_bitmap.width(), 0);
103 std::vector<zelda3::RoomObject> objects;
104 objects.push_back(CreateTestObject(0x10, 5, 5, 0x12, 0));
105 objects.push_back(CreateTestObject(0x20, 10, 10, 0x22, 1));
106 objects.push_back(CreateTestObject(0x30, 15, 15, 0x12, 2));
111 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
112 ASSERT_TRUE(status.ok());
115 EXPECT_TRUE(bg1_->bitmap().is_active());
116 EXPECT_TRUE(bg2_->bitmap().is_active());
121 std::vector<zelda3::RoomObject> objects;
126 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
128 EXPECT_TRUE(status.ok());
133 std::vector<zelda3::RoomObject> objects;
136 for (
int i = 0; i < 100; i++) {
137 int x = (i % 10) * 5;
138 int y = (i / 10) * 5;
139 objects.push_back(CreateTestObject(0x10 + (i % 20), x, y, 0x12, i % 2));
145 auto start = std::chrono::high_resolution_clock::now();
146 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
147 auto end = std::chrono::high_resolution_clock::now();
149 ASSERT_TRUE(status.ok());
151 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
153 EXPECT_LT(duration.count(), 1000) <<
"Rendered 100 objects in " << duration.count() <<
"ms";
158 std::vector<zelda3::RoomObject> objects;
161 objects.push_back(CreateTestObject(0x10, 0, 0, 0x12, 0));
162 objects.push_back(CreateTestObject(0x10, 63, 63, 0x12, 0));
163 objects.push_back(CreateTestObject(0x10, 32, 32, 0x12, 0));
168 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
169 EXPECT_TRUE(status.ok());
175 std::vector<int> object_types = {
176 0x00, 0x01, 0x02, 0x03,
183 for (
int obj_type : object_types) {
184 std::vector<zelda3::RoomObject> objects;
185 objects.push_back(CreateTestObject(obj_type, 10, 10, 0x12, 0));
190 auto status = drawer_->DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
193 std::cout <<
"Object type 0x" << std::hex << obj_type << std::dec
194 <<
" not renderable: " << status.message() << std::endl;
203 std::vector<zelda3::RoomObject> objects;
204 objects.push_back(CreateTestObject(0x10, 5, 5));
209 auto status = null_drawer.
DrawObjectList(objects, *bg1_, *bg2_, palette_group_);
210 EXPECT_FALSE(status.ok());
211 EXPECT_EQ(status.code(), absl::StatusCode::kFailedPrecondition);
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
void AddColor(const SnesColor &color)
Tests for ObjectDrawer with realistic dungeon scenarios.
std::unique_ptr< gfx::BackgroundBuffer > bg1_
zelda3::RoomObject CreateTestObject(int id, int x, int y, int size=0x12, int layer=0)
gfx::PaletteGroup palette_group_
gfx::PaletteGroup CreateTestPaletteGroup()
std::unique_ptr< gfx::BackgroundBuffer > bg2_
std::unique_ptr< zelda3::ObjectDrawer > drawer_
Draws dungeon objects to background buffers using game patterns.
absl::Status DrawObjectList(const std::vector< RoomObject > &objects, gfx::BackgroundBuffer &bg1, gfx::BackgroundBuffer &bg2, const gfx::PaletteGroup &palette_group)
Draw all objects in a room.
TEST_F(DungeonObjectRenderingE2ETests, RunAllTests)
Main namespace for the application.
Represents a group of palettes.
void AddPalette(SnesPalette pal)