Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
managerTextureFunctions.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
26 std::string texturePath, std::string textureName)
27{
28 for (auto& textureDetail : getTextureDetails()) {
29 if (textureDetail.textureName == textureName) {
30 break;
31 }
32 }
33 return engine.textureManager.addTexture(texturePath, textureName);
34}
36{
37 engine.textureManager.removeTexture(textureNo);
38}
39
40std::vector<Chronos::Manager::TextureDetails>
42{
43 std::vector<Chronos::Manager::TextureDetails> textureDetails;
44 for (auto& texture : engine.textureManager.textures) {
46 details.textureNo = texture.first;
47 details.textureName = texture.second.textureName;
48 details.texturePath = texture.second.texturePath;
49 details.height = texture.second.height;
50 details.width = texture.second.width;
51#ifdef ENABLE_EDITOR
52 details.descriptorSet = texture.second.descriptorSet;
53#endif
54 textureDetails.push_back(details);
55 }
56 return textureDetails;
57}
Main API for chronos. Any applications should include this file.
Chronos::Engine::TextureManager textureManager
Used to create and manage textures.
Definition engine.hpp:107
int addTexture(std::string texturePath, std::string textureName)
Adds a texture to the texture manager.
Chronos::Engine::Engine engine
The backend Vulkan engine, used for rendering the desired shapes and text.s.
Definition chronos.hpp:509
void removeTexture(int textureNo)
Removes the texture from the window.
int addTexture(std::string texturePath, std::string textureName)
Loads a texture from file.
std::vector< TextureDetails > getTextureDetails()
Returns the details of all textures defined.
Holds some details about the texture.
Definition chronos.hpp:90