Test shaders for lab2
This commit is contained in:
parent
92f95588e0
commit
3360e35186
@ -14,5 +14,6 @@ add_executable(
|
||||
src/variants/lab1/variant6.cpp
|
||||
src/variants/lab1/variant8.cpp
|
||||
src/variants/lab1/variant9.cpp
|
||||
src/variants/lab2/variant3.cpp
|
||||
)
|
||||
target_link_libraries(labs PRIVATE Qt5::Core Qt5::Widgets renderer_api utilities qt_utilities)
|
||||
|
@ -53,8 +53,14 @@ namespace BGTU::ComputerGraphicsLabWork::Impl {
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_4, &vmngr, &Variants::VariantsManager::set_variant_4);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_5, &vmngr, &Variants::VariantsManager::set_variant_5);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_6, &vmngr, &Variants::VariantsManager::set_variant_6);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_7, &vmngr, &Variants::VariantsManager::set_variant_7);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_8, &vmngr, &Variants::VariantsManager::set_variant_8);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_9, &vmngr, &Variants::VariantsManager::set_variant_9);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F1, &vmngr, &Variants::VariantsManager::set_lab_1);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F2, &vmngr, &Variants::VariantsManager::set_lab_2);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F3, &vmngr, &Variants::VariantsManager::set_lab_3);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F4, &vmngr, &Variants::VariantsManager::set_lab_4);
|
||||
QObject::connect(&kbd, &KeyboardCatcherWidget::key_pressed_F5, &vmngr, &Variants::VariantsManager::set_lab_5);
|
||||
|
||||
QtUtilities::SeparateThreadedDefaultRendererLinear<SpriteData> renderer{};
|
||||
renderer.set_sprite_data_provider(&sprites_data);
|
||||
|
130
programs/labs1_5/src/variants/lab2/variant3.cpp
Normal file
130
programs/labs1_5/src/variants/lab2/variant3.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include <QMutex>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shapes/circle.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/shader.hpp>
|
||||
#include "../variants.hpp"
|
||||
#include "../sprite_data.hpp"
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Impl::Variants::Lab2 {
|
||||
namespace {
|
||||
template<double z, RendererApi::Color::Transparent edge_color, double center_distance_multiplier, double center_angle_degrees, double radius_multiplier>
|
||||
class Circle : public RendererApi::Sprite<SpriteData::ShapeData, Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl>> {
|
||||
private:
|
||||
QMutex sync;
|
||||
|
||||
enum class ShaderType : unsigned {
|
||||
SOLID_RED,
|
||||
SOLID_GREEN,
|
||||
SOLID_BLUE,
|
||||
RADIAL_DARK_RED,
|
||||
RADIAL_DARK_GREEN,
|
||||
RADIAL_DARK_BLUE,
|
||||
RADIAL_LIGHT_RED,
|
||||
RADIAL_LIGHT_GREEN,
|
||||
RADIAL_LIGHT_BLUE,
|
||||
RADIAL_TRANSPARENT_RED,
|
||||
RADIAL_TRANSPARENT_GREEN,
|
||||
RADIAL_TRANSPARENT_BLUE,
|
||||
SECTOR_STATIC,
|
||||
SECTOR_ROTATED_POS,
|
||||
SECTOR_ROTATED_NEG,
|
||||
};
|
||||
|
||||
ShaderType current_shader;
|
||||
|
||||
template<class receiver_t>
|
||||
void _select_shader(SpriteData::ShapeData const *data, receiver_t receiver) const {
|
||||
const_cast<QMutex *>(&(this->sync))->lock();
|
||||
ShaderType t = this->current_shader;
|
||||
const_cast<QMutex *>(&(this->sync))->unlock();
|
||||
switch (t) {
|
||||
case ShaderType::SOLID_RED: {
|
||||
auto s = Utilities::MonoShader::static_<RendererApi::Color{255, 0, 0}>;
|
||||
receiver(s);
|
||||
return;
|
||||
}
|
||||
case ShaderType::SOLID_GREEN: {
|
||||
auto s = Utilities::MonoShader::static_<RendererApi::Color{0, 255, 0}>;
|
||||
receiver(s);
|
||||
return;
|
||||
}
|
||||
case ShaderType::SOLID_BLUE: {
|
||||
auto s = Utilities::MonoShader::static_<RendererApi::Color{0, 0, 255}>;
|
||||
receiver(s);
|
||||
return;
|
||||
}
|
||||
case ShaderType::RADIAL_DARK_RED:
|
||||
case ShaderType::RADIAL_DARK_GREEN:
|
||||
case ShaderType::RADIAL_DARK_BLUE:
|
||||
case ShaderType::RADIAL_LIGHT_RED:
|
||||
case ShaderType::RADIAL_LIGHT_GREEN:
|
||||
case ShaderType::RADIAL_LIGHT_BLUE:
|
||||
case ShaderType::RADIAL_TRANSPARENT_RED:
|
||||
case ShaderType::RADIAL_TRANSPARENT_GREEN:
|
||||
case ShaderType::RADIAL_TRANSPARENT_BLUE:
|
||||
case ShaderType::SECTOR_STATIC:
|
||||
case ShaderType::SECTOR_ROTATED_POS:
|
||||
case ShaderType::SECTOR_ROTATED_NEG:;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static inline ShaderType const next_shader_type[] = {
|
||||
ShaderType::SOLID_GREEN,
|
||||
ShaderType::SOLID_BLUE,
|
||||
ShaderType::RADIAL_DARK_RED,
|
||||
ShaderType::RADIAL_DARK_GREEN,
|
||||
ShaderType::RADIAL_DARK_BLUE,
|
||||
ShaderType::RADIAL_LIGHT_RED,
|
||||
ShaderType::RADIAL_LIGHT_GREEN,
|
||||
ShaderType::RADIAL_LIGHT_BLUE,
|
||||
ShaderType::RADIAL_TRANSPARENT_RED,
|
||||
ShaderType::RADIAL_TRANSPARENT_GREEN,
|
||||
ShaderType::RADIAL_TRANSPARENT_BLUE,
|
||||
ShaderType::SECTOR_STATIC,
|
||||
ShaderType::SECTOR_ROTATED_POS,
|
||||
ShaderType::SECTOR_ROTATED_NEG,
|
||||
ShaderType::SOLID_RED
|
||||
};
|
||||
|
||||
public:
|
||||
Circle() : sync{}, current_shader{ShaderType::SOLID_RED} {}
|
||||
|
||||
|
||||
Circle(Circle &&other) : sync{}, current_shader{other.current_shader} {
|
||||
|
||||
}
|
||||
|
||||
void draw(Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame, SpriteData::ShapeData const *data) const final {
|
||||
this->_select_shader(
|
||||
data,
|
||||
[&]<class shader_t>(shader_t const &shader) {
|
||||
Utilities::Shapes::iterate_circle_fill(
|
||||
data->pos_rotated(data->radius * center_distance_multiplier, center_angle_degrees),
|
||||
data->radius * radius_multiplier,
|
||||
[&](bool is_edge, RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) {
|
||||
if (is_edge) {
|
||||
frame->add_voxel(x, y, z, edge_color);
|
||||
} else {
|
||||
frame->add_voxel(x, y, z, shader.get_color(x, y));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void clicked() final {
|
||||
this->sync.lock();
|
||||
this->current_shader = next_shader_type[(unsigned)this->current_shader];
|
||||
this->sync.unlock();
|
||||
}
|
||||
};
|
||||
}
|
||||
variant_sprites variant3 = variant_sprites::make(
|
||||
Circle<4.0, {255, 255, 255}, 0.0, 0.0, 1.0>{},
|
||||
Circle<2.0, {255, 255, 255}, 0.6666666666666, 0.0, 0.16666666666666666>{},
|
||||
Circle<2.0, {255, 255, 255}, 0.6666666666666, 120.0, 0.16666666666666666>{},
|
||||
Circle<2.0, {255, 255, 255}, 0.6666666666666, -120.0, 0.16666666666666666>{},
|
||||
Circle<1.0, {255, 255, 255}, 0.0, 0.0, 0.5>{}
|
||||
);
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QElapsedTimer>
|
||||
#include "bgtu/computer_graphics_lab_work/renderer_api/point.hpp"
|
||||
#include "bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp"
|
||||
#include "bgtu/computer_graphics_lab_work/utilities/matrix.hpp"
|
||||
#include "bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp"
|
||||
#include "bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp"
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/point.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/renderer_api/sprite.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/matrix.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/zoomed_voxel_painter.hpp>
|
||||
|
||||
|
||||
namespace BGTU::ComputerGraphicsLabWork::Impl {
|
||||
|
@ -41,7 +41,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
public:
|
||||
e0 value;
|
||||
|
||||
constexpr _make(e0 v) : value{std::move(v)} {};
|
||||
constexpr _make(e0 &v) : value{std::move(v)} {};
|
||||
|
||||
constexpr void export_pointers(sprite_t **dst, std::size_t pos) {
|
||||
dst[pos] = &this->value;
|
||||
@ -54,7 +54,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
e0 value;
|
||||
_make<en...> next;
|
||||
|
||||
constexpr _make(e0 v, en...nv) : value{std::move(v)}, next{nv...} {};
|
||||
constexpr _make(e0& v, en&...nv) : value{std::move(v)}, next{nv...} {};
|
||||
|
||||
constexpr void export_pointers(sprite_t **dst, std::size_t pos) {
|
||||
dst[pos] = &this->value;
|
||||
@ -65,7 +65,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
public:
|
||||
|
||||
template<class ...sprites_t>
|
||||
constexpr static variant_sprites make(sprites_t...sprites) {
|
||||
constexpr static variant_sprites make(sprites_t&&...sprites) {
|
||||
static _make<sprites_t...> i{sprites...};
|
||||
static sprite_t *p[sizeof...(sprites)];
|
||||
|
||||
@ -73,6 +73,11 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
return variant_sprites{p, sizeof...(sprites)};
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr variant_sprites make<>() {
|
||||
return variant_sprites{nullptr, 0};
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
template<void (...sprites)(Utilities::ZoomedVoxelPainter<BGTU::ComputerGraphicsLabWork::Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> *frame,
|
||||
@ -136,6 +141,10 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
extern variant_sprites variant9;
|
||||
}
|
||||
|
||||
namespace Lab2 {
|
||||
extern variant_sprites variant3;
|
||||
}
|
||||
|
||||
|
||||
class VariantsManager : public QObject {
|
||||
Q_OBJECT
|
||||
@ -178,8 +187,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant1);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -187,8 +197,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant2);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -196,8 +207,12 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant3);
|
||||
return;
|
||||
case LabNo::L2:
|
||||
this->_set_sprites(Lab2::variant3);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -205,8 +220,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant4);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -214,8 +230,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant5);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -223,8 +240,16 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant6);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
inline void set_variant_7() {
|
||||
switch (this->get_current_lab()) {
|
||||
default:
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -232,8 +257,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant8);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -241,8 +267,9 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
switch (this->get_current_lab()) {
|
||||
case LabNo::L1:
|
||||
this->_set_sprites(Lab1::variant9);
|
||||
return;
|
||||
default:
|
||||
(void) 0;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@ -253,22 +280,19 @@ namespace BGTU::ComputerGraphicsLabWork::Impl::Variants {
|
||||
|
||||
inline void set_lab_2() {
|
||||
this->set_current_lab(LabNo::L2);
|
||||
this->_set_sprites(Lab1::variant3);
|
||||
this->_set_sprites(Lab2::variant3);
|
||||
};
|
||||
|
||||
inline void set_lab_3() {
|
||||
this->set_current_lab(LabNo::L3);
|
||||
this->_set_sprites(Lab1::variant3);
|
||||
};
|
||||
|
||||
inline void set_lab_4() {
|
||||
this->set_current_lab(LabNo::L4);
|
||||
this->_set_sprites(Lab1::variant3);
|
||||
};
|
||||
|
||||
inline void set_lab_5() {
|
||||
this->set_current_lab(LabNo::L5);
|
||||
this->_set_sprites(Lab1::variant3);
|
||||
};
|
||||
};
|
||||
}
|
@ -18,6 +18,7 @@ namespace BGTU::ComputerGraphicsLabWork::Impl {
|
||||
Utilities::ZoomedVoxelPainter<Utilities::DefaultVoxelDrawerCache::VoxelPainterImpl> zoomed_painter{frame, data->central_pixel_tl, data->pixel_size};
|
||||
|
||||
for (std::size_t i = 0; i < data->sub_sprites_count; i++) {
|
||||
zoomed_painter.current_owner = data->sub_sprites[i];
|
||||
data->sub_sprites[i]->draw(&zoomed_painter, &data->shape_data);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace BGTU::ComputerGraphicsLabWork::QtUtilities {
|
||||
this->owners[y * this->width() + x] = o;
|
||||
}
|
||||
|
||||
[[nodiscard]] RendererApi::SpriteMetadata const *getPixelOwner(unsigned x, unsigned y) const {
|
||||
[[nodiscard]] RendererApi::SpriteMetadata *getPixelOwner(unsigned x, unsigned y) const {
|
||||
assert(x < this->width());
|
||||
assert(y < this->height());
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QStyle>
|
||||
#include <QPaintEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <bgtu/computer_graphics_lab_work/utilities/default_renderer_linear.hpp>
|
||||
#include "owned_qimage.hpp"
|
||||
#include "separate_threaded_renderer.hpp"
|
||||
@ -69,5 +70,13 @@ namespace BGTU::ComputerGraphicsLabWork::QtUtilities {
|
||||
this->renderer->set_frame_size(event->size().width(), event->size().height());
|
||||
emit this->resized(event->size().width(), event->size().height());
|
||||
}
|
||||
|
||||
void mousePressEvent(QMouseEvent *event) override {
|
||||
this->sync.lock();
|
||||
auto sprite = this->current_image->getPixelOwner(event->x(), event->y());
|
||||
this->sync.unlock();
|
||||
if (sprite != nullptr)
|
||||
sprite->clicked();
|
||||
}
|
||||
};
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
namespace BGTU::ComputerGraphicsLabWork::RendererApi {
|
||||
class SpriteMetadata {
|
||||
public:
|
||||
virtual void clicked() {};
|
||||
virtual inline void clicked() {};
|
||||
};
|
||||
|
||||
template<class _data_t, class _voxel_painter_t = VirtualVoxelPainter>
|
||||
|
@ -9,11 +9,19 @@
|
||||
namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
class Shader {
|
||||
public:
|
||||
[[nodiscard]] virtual RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const = 0;
|
||||
[[nodiscard]] virtual RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const = 0;
|
||||
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2> p) const {
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointF<2> p) const {
|
||||
return this->get_color(p.x, p.y);
|
||||
};
|
||||
#if 0
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) {
|
||||
return this->get_color(static_cast<RendererApi::PointF<2>::component_t>(x), static_cast<RendererApi::PointF<2>::component_t>(y));
|
||||
};
|
||||
#endif
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2> p) const {
|
||||
return this->get_color((RendererApi::PointF<2>) p);
|
||||
};
|
||||
|
||||
class Empty;
|
||||
|
||||
@ -24,7 +32,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
public:
|
||||
constexpr Empty() noexcept = default;
|
||||
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final {
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final {
|
||||
return RendererApi::Color::Transparent{0, 0, 0, 0};
|
||||
};
|
||||
|
||||
@ -88,7 +96,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
public:
|
||||
constexpr explicit MonoShader(RendererApi::Color::Transparent c) noexcept: c{c} {}
|
||||
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final {
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final {
|
||||
return this->c;
|
||||
};
|
||||
|
||||
@ -99,21 +107,17 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
|
||||
static constexpr RendererApi::Color::Transparent const COLOR = _color;
|
||||
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const noexcept final {
|
||||
[[nodiscard]] constexpr RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const noexcept final {
|
||||
return _color;
|
||||
};
|
||||
|
||||
private:
|
||||
static MonoShader::Static<_color> const INSTANCE;
|
||||
|
||||
public:
|
||||
operator MonoShader::Static<_color> const *() const noexcept { // NOLINT(*-explicit-constructor)
|
||||
return &INSTANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
MonoShader::Static<_color> const *operator->() const noexcept {
|
||||
return &INSTANCE;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -127,9 +131,6 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
static MonoShader::Static<color> const static_;
|
||||
};
|
||||
|
||||
template<RendererApi::Color::Transparent color>
|
||||
constexpr MonoShader::Static<color> const MonoShader::Static<color>::INSTANCE{};
|
||||
|
||||
template<RendererApi::Color::Transparent color>
|
||||
constexpr MonoShader::Static<color> const MonoShader::static_{};
|
||||
|
||||
@ -142,7 +143,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
public:
|
||||
inline TransformedShader(Shader const *s, Matrix4d t) : shader{s}, transform{t} {}
|
||||
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) const override {
|
||||
[[nodiscard]] inline RendererApi::Color::Transparent get_color(RendererApi::PointF<2>::component_t x, RendererApi::PointF<2>::component_t y) const final {
|
||||
RendererApi::PointF<3> in{x, y, 0};
|
||||
RendererApi::PointF<3> out = this->transform * in;
|
||||
return this->shader->get_color(out.x, out.y);
|
||||
|
@ -13,6 +13,10 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes {
|
||||
edger_receiver_t edge_point_receiver,
|
||||
fill_receiver_t fill_line_receiver
|
||||
) {
|
||||
if (r == 0) {
|
||||
edge_point_receiver(cx, cy);
|
||||
return;
|
||||
}
|
||||
RendererApi::PointI<2>::component_t x = 0, y = r;
|
||||
RendererApi::PointI<2>::component_t last_y = r + 1;
|
||||
RendererApi::PointI<2>::component_t _r2 = r * r;
|
||||
@ -50,10 +54,12 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes {
|
||||
edge_point_receiver(cx + x, cy + y);
|
||||
|
||||
edge_point_receiver(cx - y, cy + x);
|
||||
fill_line_receiver(cy + x, cx - y + 1, cx + y);
|
||||
edge_point_receiver(cx + y, cy + x);
|
||||
|
||||
if (x > 0) {
|
||||
edge_point_receiver(cx - y, cy - x);
|
||||
fill_line_receiver(cy - x, cx - y + 1, cx + y);
|
||||
edge_point_receiver(cx + y, cy - x);
|
||||
}
|
||||
|
||||
@ -84,7 +90,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes {
|
||||
cx, cy, r,
|
||||
[&](RendererApi::PointI<2>::component_t x, RendererApi::PointI<2>::component_t y) { receiver(true, x, y); },
|
||||
[&](RendererApi::PointI<2>::component_t y, RendererApi::PointI<2>::component_t x1, RendererApi::PointI<2>::component_t x2) {
|
||||
for (RendererApi::PointI<2>::component_t x = x1; x < x2; x++) receiver(x, y);
|
||||
for (RendererApi::PointI<2>::component_t x = x1; x < x2; x++) receiver(false, x, y);
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -95,7 +101,7 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities::Shapes {
|
||||
RendererApi::PointI<2>::component_t r,
|
||||
receiver_t receiver
|
||||
) {
|
||||
iterate_circle_fill_lines<receiver_t>(c.x, c.y, r, receiver);
|
||||
iterate_circle_fill<receiver_t>(c.x, c.y, r, receiver);
|
||||
}
|
||||
|
||||
template<class receiver_t>
|
||||
|
@ -28,6 +28,8 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
std::size_t pixel_size
|
||||
) noexcept: dst{dst}, cx{center_tl.x}, cy{center_tl.y}, pixel_size{pixel_size} {}
|
||||
|
||||
RendererApi::SpriteMetadata *current_owner = nullptr;
|
||||
|
||||
void add_voxel(long long x, long long y, double z, RendererApi::Color::Transparent c) final {
|
||||
Shapes::fill_square<unzoomed_painter_t>(
|
||||
this->dst,
|
||||
@ -35,7 +37,8 @@ namespace BGTU::ComputerGraphicsLabWork::Utilities {
|
||||
this->cy + y * this->pixel_size,
|
||||
this->pixel_size,
|
||||
z,
|
||||
c
|
||||
c,
|
||||
current_owner
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user