Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
managerShapeFunctions.cpp
Go to the documentation of this file.
1/*
2Copyright (c) 2024 Rahul Satish Vadhyar
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
23#include "chronos.hpp"
24#include "ColoredRectangle.hpp"
25#include "TexturedRectangle.hpp"
28{
31 shape->params = shapeParams;
32 shape->init(&this->engine.device, this->engine.commandPool,
33 &(this->engine.swapChain), this->engine.objectManager.textureSampler,
34 &this->engine.objectManager.renderPass);
35 return engine.objectManager.addObject(shape);
36}
37
39 Chronos::Manager::ShapeParams shapeParams, int texture)
40{
43 shape->params = shapeParams;
44 shape->init(&this->engine.device, this->engine.commandPool,
45 &(this->engine.swapChain), this->engine.objectManager.textureSampler,
46 this->engine.textureManager.textures[texture],
47 &this->engine.objectManager.renderPass);
48 return engine.objectManager.addObject(shape);
49}
50
51std::vector<std::pair<int, Chronos::Manager::ShapeParams>>
53{
54 std::vector<std::pair<int, Chronos::Manager::ShapeParams>> shapeDetails;
55 for (auto const& [objectNo, object] : engine.objectManager.objects) {
56 if (object->objectType
60 shapeDetails.push_back(std::make_pair(objectNo, shape->params));
61 } else if (object->objectType
65 shapeDetails.push_back(std::make_pair(objectNo, shape->params));
66 }
67 }
68 return shapeDetails;
69}
71 int objectNo, Chronos::Manager::ShapeParams shapeParams)
72{
73 if (engine.objectManager.objects.count(objectNo) == 0) {
74 throw std::runtime_error("Shape does not exist");
75 }
76 if (engine.objectManager.objects[objectNo]->objectType
78 && engine.objectManager.objects[objectNo]->objectType
80 throw std::runtime_error("Object is not a shape object");
81 }
82 if (engine.objectManager.objects[objectNo]->objectType
86 engine.objectManager.objects[objectNo];
87 shape->params = shapeParams;
88 } else if (engine.objectManager.objects[objectNo]->objectType
92 engine.objectManager.objects[objectNo];
93 shape->params = shapeParams;
94 }
95}
Contains the class for creating a rectangle filled with texture.
Contains the class for creating a rectangle filled with texture.
Main API for chronos. Any applications should include this file.
void init(Chronos::Engine::Device *device, VkCommandPool commandPool, Chronos::Engine::SwapChain *swapChain, VkSampler textureSampler, VkRenderPass *renderPass)
Chronos::Manager::ShapeParams params
Chronos::Engine::Device device
This is the object that manages the device.
Definition engine.hpp:233
Chronos::Engine::ObjectManager objectManager
Definition engine.hpp:99
void init(Chronos::Engine::Device *device, VkCommandPool commandPool, Chronos::Engine::SwapChain *swapChain, VkSampler textureSampler, Chronos::Engine::Texture texture, VkRenderPass *renderPass)
Chronos::Manager::ShapeParams params
Chronos::Engine::Engine engine
The backend Vulkan engine, used for rendering the desired shapes and text.s.
Definition chronos.hpp:509
void updateShape(int objectNo, Chronos::Manager::ShapeParams shapeParams)
Updates the polygon(any) with the new parameters.
int addShape(Chronos::Manager::ShapeParams shapeParams, int texture)
Adds a textured rectangle to the window.
std::vector< std::pair< int, Chronos::Manager::ShapeParams > > getShapeDetails()
Parameters for creating a shape(any)