update Assets container - template-based now

This commit is contained in:
MihailRis
2024-06-22 22:30:14 +03:00
parent 848d121099
commit d54b6b2e58
20 changed files with 68 additions and 143 deletions
+2 -2
View File
@@ -126,8 +126,8 @@ std::unique_ptr<Atlas> BlocksPreview::build(
size_t count = indices->countBlockDefs();
size_t iconSize = ITEM_ICON_SIZE;
Shader* shader = assets->getShader("ui3d");
Atlas* atlas = assets->getAtlas("blocks");
auto shader = assets->get<Shader>("ui3d");
auto atlas = assets->get<Atlas>("blocks");
Viewport viewport(iconSize, iconSize);
DrawContext pctx(nullptr, viewport, nullptr);
+1 -1
View File
@@ -60,7 +60,7 @@ void ModelBatch::draw(const model::Model& model) {
Lightmap::extract(light, 3) / 15.0f
);
for (const auto& mesh : model.meshes) {
auto texture = assets->getTexture(mesh.texture);
auto texture = assets->get<Texture>(mesh.texture);
if (texture) {
texture->bind();
} else {
+3 -3
View File
@@ -59,7 +59,7 @@ Skybox::~Skybox() {
}
void Skybox::drawBackground(Camera* camera, Assets* assets, int width, int height) {
Shader* backShader = assets->getShader("background");
auto backShader = assets->get<Shader>("background");
backShader->use();
backShader->uniformMatrix("u_view", camera->getView(false));
backShader->uniform1f("u_zoom", camera->zoom*camera->getFov()/(M_PI*0.5f));
@@ -107,7 +107,7 @@ void Skybox::draw(
DrawContext ctx = pctx.sub();
ctx.setBlendMode(BlendMode::addition);
Shader* shader = assets->getShader("ui3d");
auto shader = assets->get<Shader>("ui3d");
shader->use();
shader->uniformMatrix("u_projview", camera->getProjView(false));
shader->uniformMatrix("u_apply", glm::mat4(1.0f));
@@ -117,7 +117,7 @@ void Skybox::draw(
float opacity = glm::pow(1.0f-fog, 7.0f);
for (auto& sprite : sprites) {
batch3d->texture(assets->getTexture(sprite.texture));
batch3d->texture(assets->get<Texture>(sprite.texture));
float sangle = daytime * M_PI*2 + sprite.phase;
float distance = sprite.distance;
+7 -7
View File
@@ -68,7 +68,7 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
auto assets = engine->getAssets();
skybox = std::make_unique<Skybox>(
settings.graphics.skyboxResolution.get(),
assets->getShader("skybox_gen")
assets->get<Shader>("skybox_gen")
);
}
@@ -154,9 +154,9 @@ void WorldRenderer::renderLevel(
Camera* camera,
const EngineSettings& settings
) {
Assets* assets = engine->getAssets();
Atlas* atlas = assets->getAtlas("blocks");
Shader* shader = assets->getShader("main");
auto assets = engine->getAssets();
auto atlas = assets->get<Atlas>("blocks");
auto shader = assets->get<Shader>("main");
auto indices = level->content->getIndices();
@@ -292,8 +292,8 @@ void WorldRenderer::draw(
const EngineSettings& settings = engine->getSettings();
skybox->refresh(pctx, world->daytime, 1.0f+world->fog*2.0f, 4);
Assets* assets = engine->getAssets();
Shader* linesShader = assets->getShader("lines");
auto assets = engine->getAssets();
auto linesShader = assets->get<Shader>("lines");
// World render scope with diegetic HUD included
{
@@ -323,7 +323,7 @@ void WorldRenderer::draw(
}
// Rendering fullscreen quad with
auto screenShader = assets->getShader("screen");
auto screenShader = assets->get<Shader>("screen");
screenShader->use();
screenShader->uniform1f("u_timer", Window::time());
screenShader->uniform1f("u_dayTime", level->getWorld()->daytime);