diff --git a/assets/textures/Cube_GLab_1.png b/assets/textures/Cube_GLab_1.png new file mode 100644 index 0000000000000000000000000000000000000000..dde2eea7829efe08f4841cd5e0c2f832fb243d6c Binary files /dev/null and b/assets/textures/Cube_GLab_1.png differ diff --git a/assets/textures/Cube_GLab_2.png b/assets/textures/Cube_GLab_2.png new file mode 100644 index 0000000000000000000000000000000000000000..5529901db2254ea4a144a954502f548275c7c47e Binary files /dev/null and b/assets/textures/Cube_GLab_2.png differ diff --git a/assets/textures/Cube_GLab_3.png b/assets/textures/Cube_GLab_3.png new file mode 100644 index 0000000000000000000000000000000000000000..5d5da902f3a75d14435bc76d5c0cb9fc7d2a4fdc Binary files /dev/null and b/assets/textures/Cube_GLab_3.png differ diff --git a/assets/textures/Cube_White.png b/assets/textures/Cube_White.png new file mode 100644 index 0000000000000000000000000000000000000000..7a051769c27b4638b734fbf8271301b351245541 Binary files /dev/null and b/assets/textures/Cube_White.png differ diff --git a/source/main.cpp b/source/main.cpp index 39b4cf180d747e14ab73b2dc73a1b5e663883808..1a7e2905d9ce09d619bf17d1d2916475cdeb0a19 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -34,7 +34,7 @@ int main(int argc, const char * argv[]) { try { //? Window megu::Window window; - window.open("Window", WINDOW_WIDTH, WINDOW_HEIGHT); + window.open("Isometric Window", 360, 360); megu::error::opengl_error::check(); std::cout << "Window Inited" << std::endl; @@ -42,22 +42,21 @@ int main(int argc, const char * argv[]) { //? Group megu::ImageGroup group; megu::ImageGroup group_2; - megu::ImageGroup group_3; - + std::cout << "Group Inited" << std::endl; //? Image 1 std::vector<int> map = { - 2, 2, 1, 1, 1, 1, 1, 2, 0, 0, - 0, 0, 2, 1, 1, 1, 1, 2, 0, 0, - 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, - 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, - 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, - 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, - 0, 0, 2, 1, 1, 1, 1, 2, 0, 0, - 0, 0, 2, 1, 1, 1, 1, 2, 0, 0, - 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, - 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, + 0, 0, 0, 3, 2, 2, 3, 0, 0, 0, + 0, 0, 3, 2, 1, 1, 2, 3, 0, 0, + 0, 3, 2, 2, 1, 1, 2, 2, 3, 0, + 0, 3, 2, 1, 1, 1, 1, 2, 3, 0, + 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; size_t x = 0; @@ -66,10 +65,13 @@ int main(int argc, const char * argv[]) { std::vector<std::unique_ptr<megu::Image>> images; megu::Texture texture_1; - texture_1.store(megu::TextureBuffer("assets/textures/Cube_Blue.png")); + texture_1.store(megu::TextureBuffer("assets/textures/Cube_GLab_1.png")); megu::Texture texture_2; - texture_2.store(megu::TextureBuffer("assets/textures/Cube_Red.png")); + texture_2.store(megu::TextureBuffer("assets/textures/Cube_GLab_2.png")); + + megu::Texture texture_3; + texture_3.store(megu::TextureBuffer("assets/textures/Cube_GLab_3.png")); for(auto id : map) { if(x == 10) { @@ -79,10 +81,23 @@ int main(int argc, const char * argv[]) { if(id != 0) { - images.push_back(std::make_unique<megu::Image>(id == 1 ? texture_1 : texture_2)); + switch (id) { + case 1: + images.push_back(std::make_unique<megu::Image>(texture_1)); + break; + + case 2: + images.push_back(std::make_unique<megu::Image>(texture_2)); + break; + + case 3: + images.push_back(std::make_unique<megu::Image>(texture_3)); + break; + } + glm::vec2 pos = to_screen_coordinate({x, y}, 32.f, 32.f, 1.f); - images.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); + images.back()->setPosition({pos.x + window.width()/2 - 16.f, pos.y + window.height()/4}); } ++x; @@ -93,7 +108,7 @@ int main(int argc, const char * argv[]) { i.get()->setSize({32.f, 32.f}); } - std::cout << "Image Inited 1" << std::endl; + std::cout << "Images 1 Inited" << std::endl; //? Image 2 std::vector<int> map_2 = { @@ -101,7 +116,7 @@ int main(int argc, const char * argv[]) { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -114,22 +129,18 @@ int main(int argc, const char * argv[]) { std::vector<std::unique_ptr<megu::Image>> images_2; - megu::Texture texture_3; - texture_3.store(megu::TextureBuffer("assets/textures/Cube_Yellow.png")); + megu::Texture texture_4; + texture_4.store(megu::TextureBuffer("assets/textures/Cube_White.png")); for(auto id : map_2) { if(x_2 == 10) { x_2 = 0; ++y_2; } - - - if(id == 0) { - images_2.push_back(std::make_unique<megu::Image>(texture_3)); - glm::vec2 pos = to_screen_coordinate({x_2, y_2}, 32.f, 32.f); - - images_2.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); - } + + images_2.push_back(std::make_unique<megu::Image>(texture_4)); + glm::vec2 pos = to_screen_coordinate({x_2, y_2}, 32.f, 32.f, 0.f); + images_2.back()->setPosition({pos.x + window.width()/2 - 16.f, pos.y + window.height()/4}); ++x_2; } @@ -139,53 +150,7 @@ int main(int argc, const char * argv[]) { i.get()->setSize({32.f, 32.f}); } - std::cout << "Image Inited 3" << std::endl; - - //? Image 2 - std::vector<int> map_3 = { - 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - }; - - size_t x_3 = 0; - size_t y_3 = 0; - - std::vector<std::unique_ptr<megu::Image>> images_3; - - megu::Texture texture_4; - texture_4.store(megu::TextureBuffer("assets/textures/Cube_Green.png")); - - for(auto id : map_3) { - if(x_3 == 10) { - x_3 = 0; - ++y_3; - } - - - if(id != 0) { - images_3.push_back(std::make_unique<megu::Image>(texture_4)); - glm::vec2 pos = to_screen_coordinate({x_3, y_3}, 32.f, 32.f, 2.f); - - images_3.back()->setPosition({pos.x + window.width()/2, pos.y + window.height()/2}); - } - - ++x_3; - } - - for(auto & i : images_3) { - group_3.add(*i); - i.get()->setSize({32.f, 32.f}); - } - - std::cout << "Image Inited 2" << std::endl; + std::cout << "Images 2 Inited" << std::endl; //? ImGui ImGui::CreateContext(); @@ -194,14 +159,11 @@ int main(int argc, const char * argv[]) { //? Engines megu::GraphicEngine engine(window); - megu::Renderer basic_renderer(640*2, 360*2); + megu::Renderer basic_renderer(360, 360); engine.push(0, basic_renderer); - engine.push(1, basic_renderer); - engine.push(2, basic_renderer); - engine.push(1, 1, group_3); - engine.push(1, 0, group); + engine.push(0, 1, group); engine.push(0, 0, group_2); //? Render Loop @@ -216,7 +178,7 @@ int main(int argc, const char * argv[]) { frameCount++; if(currentTime - previousTime >= 1.0) { - window.setTitle(std::to_string(frameCount)); + //window.setTitle(std::to_string(frameCount)); frameCount = 0; previousTime = currentTime;