some testing

This commit is contained in:
Bailey Harrison 2023-05-27 13:07:25 +01:00
parent e57be9a0e7
commit 7e2da23398
5 changed files with 33 additions and 7 deletions

View File

@ -14,6 +14,7 @@ namespace engine {
~CustomBehaviourSystem();
void OnUpdate(float ts) override;
void OnComponentInsert(uint32_t entity) override;
private:

View File

@ -1135,7 +1135,7 @@ namespace engine {
void GFXDevice::UpdateDescriptorCombinedImageSampler(const gfx::DescriptorSet *set, uint32_t binding, const gfx::Image* image, const gfx::Sampler* sampler)
{
assert(pimpl->FRAMECOUNT == 0);
//assert(pimpl->FRAMECOUNT == 0);
VkDescriptorImageInfo imageInfo{};
imageInfo.sampler = sampler->sampler;
@ -1310,7 +1310,9 @@ namespace engine {
gfx::Image* GFXDevice::CreateImage(uint32_t w, uint32_t h, const void* imageData)
{
assert(imageData != nullptr);
assert(pimpl->FRAMECOUNT == 0);
if (pimpl->FRAMECOUNT != 0) {
//throw std::runtime_error("Framecount must be 0 when creating a texture");
}
gfx::Image* out = new gfx::Image{};

View File

@ -98,6 +98,9 @@ Texture::Texture(RenderData* render_data, const uint8_t* bitmap, int width,
LOG_INFO("Loaded texture: BITMAP, width: {} height: {}", width, height);
}
Texture::~Texture() { gfx_->DestroyImage(image_); }
Texture::~Texture() {
LOG_INFO("Destroying texture...");
gfx_->DestroyImage(image_);
}
} // namespace engine::resources

View File

@ -24,4 +24,9 @@ void CustomBehaviourSystem::OnUpdate(float ts) {
}
}
void CustomBehaviourSystem::OnComponentInsert(uint32_t entity)
{
(void)entity;
}
} // namespace engine

View File

@ -169,8 +169,23 @@ void PlayGame(GameSettings settings) {
(float)height / (float)width;
my_scene->AddComponent<engine::CustomComponent>(textbox)->onUpdate =
[](float ts) {
/* LOG_INFO("Time step: {}", ts); */
[&](float ts) {
(void)ts;
static float time_elapsed;
time_elapsed += ts;
if (time_elapsed >= 1.0f) {
time_elapsed = 0;
LOG_INFO("Time step: {}", ts);
int fpsWidth, fpsHeight;
auto fpsBitmap =
app.GetResource<engine::resources::Font>("builtin.mono")
->GetTextBitmap("fps", 768.0f, fpsWidth, fpsHeight);
textbox_renderable->material->texture_ =
std::make_unique<engine::resources::Texture>(
&app.render_data_, fpsBitmap->data(), fpsWidth, fpsHeight,
engine::resources::Texture::Filtering::kBilinear);
}
};
}