110 lines
5.3 KiB
C++
110 lines
5.3 KiB
C++
#include <cmath>
|
|
#include <array>
|
|
#include <iostream>
|
|
#include <QApplication>
|
|
#include <QMainWindow>
|
|
#include <QTimer>
|
|
#include <bgtu/computer_graphics_lab_work/renderer_api/color.hpp>
|
|
#include <bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp>
|
|
#include <bgtu/computer_graphics_lab_work/utilities/voxel_painter_exporter_to_packed_array.hpp>
|
|
#include <bgtu/computer_graphics_lab_work/qt_utilities/separate_threaded_renderer.hpp>
|
|
#include <bgtu/computer_graphics_lab_work/qt_utilities/renderer_widget.hpp>
|
|
#include <bgtu/computer_graphics_lab_work/qt_utilities/keyboard_catcher_widget.hpp>
|
|
#include "variants/sprite_data.hpp"
|
|
#include "pixel_grid_sprite.hpp"
|
|
#include "variants/variants.hpp"
|
|
#include "zoomed_scene_sprite.hpp"
|
|
|
|
namespace BGTU::ComputerGraphicsLabWork::Impl {
|
|
int main(int argc, char **argv) {
|
|
#if 1
|
|
QApplication qApplication{argc, argv};
|
|
|
|
PixelGridSprite pixels_grid_sprite{RendererApi::Color{0, 0, 0}, RendererApi::Color{16, 16, 16}};
|
|
ZoomedSceneSprite zoomed_scene_sprite{};
|
|
|
|
auto sprites = std::to_array<RendererApi::Sprite<SpriteData, Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *const>({
|
|
&pixels_grid_sprite,
|
|
&zoomed_scene_sprite
|
|
});
|
|
|
|
|
|
SpriteData::Provider sprites_data{0.1};
|
|
sprites_data.set_pixel_size(16);
|
|
|
|
|
|
Variants::VariantsManager vmngr{};
|
|
QObject::connect(&vmngr, &Variants::VariantsManager::set_sprites, &sprites_data, &SpriteData::Provider::set_sub_sprites);
|
|
vmngr.set_lab_1();
|
|
|
|
QMainWindow w{};
|
|
|
|
QtUtilities::KeyboardCatcherWidget kbd{&w};
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_PageDown, &sprites_data, &SpriteData::Provider::decrease_pixel_size);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_PageUp, &sprites_data, &SpriteData::Provider::increase_pixel_size);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_G, &sprites_data, &SpriteData::Provider::invert_show_grid);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_1, &vmngr, &Variants::VariantsManager::set_variant_1);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_2, &vmngr, &Variants::VariantsManager::set_variant_2);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_3, &vmngr, &Variants::VariantsManager::set_variant_3);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_4, &vmngr, &Variants::VariantsManager::set_variant_4);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_5, &vmngr, &Variants::VariantsManager::set_variant_5);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_6, &vmngr, &Variants::VariantsManager::set_variant_6);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_7, &vmngr, &Variants::VariantsManager::set_variant_7);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_8, &vmngr, &Variants::VariantsManager::set_variant_8);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_9, &vmngr, &Variants::VariantsManager::set_variant_9);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_F1, &vmngr, &Variants::VariantsManager::set_lab_1);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_F2, &vmngr, &Variants::VariantsManager::set_lab_2);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_F3, &vmngr, &Variants::VariantsManager::set_lab_3);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_F4, &vmngr, &Variants::VariantsManager::set_lab_4);
|
|
QObject::connect(&kbd, &QtUtilities::KeyboardCatcherWidget::key_pressed_F5, &vmngr, &Variants::VariantsManager::set_lab_5);
|
|
|
|
QtUtilities::SeparateThreadedDefaultRendererLinear<SpriteData> renderer{};
|
|
renderer.set_sprite_data_provider(&sprites_data);
|
|
renderer.set_sprites(sprites.data(), sprites.size());
|
|
renderer.set_background(BGTU::ComputerGraphicsLabWork::RendererApi::Color{0, 0, 0});
|
|
|
|
QtUtilities::RendererWidget<SpriteData> canvas{&renderer, &kbd};
|
|
QObject::connect(&canvas, &QtUtilities::_RendererWidget_SignalSlots::resized, &sprites_data, &SpriteData::Provider::set_frame_size);
|
|
w.setCentralWidget(&canvas);
|
|
w.show();
|
|
|
|
QApplication::exec();
|
|
|
|
return 0;
|
|
#else
|
|
//Utilities::Shapes::iterate_line(-3,-3, 3, 0, [](long long x, long long y) {
|
|
// std::cout << x << "\t\t" << y << std::endl;
|
|
//});
|
|
//return 0;
|
|
|
|
Utilities::Shapes::iterate_triangle_fill_h_lines(
|
|
-1, -3,
|
|
3, 0,
|
|
-2, 3,
|
|
[](long long x, long long y) {
|
|
std::cout << x << "\t" << y << std::endl;
|
|
},
|
|
[](long long y, long long x1, long long x2) { std::cout << x1 << ">" << x2 << '\t' << y << std::endl; }
|
|
);
|
|
|
|
// for (int y = 3; y >= -3; y--) {
|
|
// for (int x = -3; x <= 3; x++) {
|
|
//// if (x != 0) {
|
|
// std::cout /*<< '(' << y << ',' << x << '|' << (double)y / (double)x << '|'*/ << std::atan2((double) y , (double) x) / std::numbers::pi_v<double> * 360 << "\t ";
|
|
//// }
|
|
// }
|
|
// std::cout << std::endl;
|
|
// }
|
|
|
|
// auto c = Utilities::apply_transparent_color(*(RendererApi::Color *) &bg, fg);
|
|
// std::cout << c.red << c.green << c.blue << std::endl;
|
|
|
|
return 0;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
return BGTU::ComputerGraphicsLabWork::Impl::main(argc, argv);
|
|
} |