Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 9936670

Browse files
committed
Add textures to Primitive and BasicDrawable
1 parent cbd4954 commit 9936670

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Lib/Include/Tkge/Graphics/Drawable.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ namespace Tkge::Graphics
2424
.vertices = this->GetVertices(),
2525
.indices = this->GetIndices(),
2626
.topology = this->GetTopology(),
27+
.texture = texture,
2728
};
2829
}
30+
31+
const Texture* texture{nullptr};
2932
};
3033

3134
template <std::derived_from<IGeometry> TGeometry>

Lib/Include/Tkge/Graphics/Primitive.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include <Tkge/Graphics/Texture.hpp>
23
#include <Tkge/Graphics/Vertex.hpp>
34
#include <span>
45

@@ -10,5 +11,6 @@ namespace Tkge::Graphics
1011
std::span<const std::uint32_t> indices{};
1112

1213
vk::PrimitiveTopology topology{vk::PrimitiveTopology::eTriangleList};
14+
const Texture* texture{nullptr};
1315
};
1416
} // namespace Tkge::Graphics

Lib/Src/Graphics/Renderer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace Tkge::Graphics
5757
}
5858

5959
UpdateInstances(instances);
60-
if (!WriteSets(nullptr)) { return; }
60+
if (!WriteSets(primitive.texture)) { return; }
6161

6262
_renderPass->get_command_buffer().setViewport(0, _viewport);
6363

@@ -106,6 +106,7 @@ namespace Tkge::Graphics
106106
.setSampler(_resourcePool->GetSampler(texture.sampler));
107107
auto wds = vk::WriteDescriptorSet{};
108108
wds.setImageInfo(dii).setDescriptorCount(1).setDescriptorType(vk::DescriptorType::eCombinedImageSampler).setDstSet(set).setDstBinding(binding);
109+
descriptorWrites.push_back(wds);
109110
};
110111

111112
auto& ubo00 = _resourcePool->AllocateBuffer(vk::BufferUsageFlagBits::eUniformBuffer, sizeof(glm::mat4));

0 commit comments

Comments
 (0)