diff options
| author | 2024-10-19 12:05:15 -0400 | |
|---|---|---|
| committer | 2024-10-19 12:13:26 -0400 | |
| commit | 42e8c4d28b6fe9cc5e041f02e0c85b390d49a218 (patch) | |
| tree | 59080eec3dd79d225bb31fb0f7e646cc22880d39 /src | |
| parent | 2bb807dd32e1c18a6f1e8f22c25141de3334de9f (diff) | |
| download | mauri-42e8c4d28b6fe9cc5e041f02e0c85b390d49a218.tar.gz mauri-42e8c4d28b6fe9cc5e041f02e0c85b390d49a218.tar.bz2 mauri-42e8c4d28b6fe9cc5e041f02e0c85b390d49a218.zip | |
Attempt to make usable and packageable
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gl.cc | 22 | ||||
| -rw-r--r-- | src/gl.h | 4 | ||||
| -rw-r--r-- | src/mauri.cc | 2 | ||||
| -rw-r--r-- | src/objects/material.cc | 10 | ||||
| -rw-r--r-- | src/objects/model.cc | 2 | ||||
| -rw-r--r-- | src/objects/model.h | 2 | ||||
| -rw-r--r-- | src/objects/pass.cc | 22 | ||||
| -rw-r--r-- | src/objects/scene.cc | 2 | ||||
| -rw-r--r-- | src/texture.cc | 12 | ||||
| -rw-r--r-- | src/util.h | 1 |
10 files changed, 41 insertions, 38 deletions
@@ -350,22 +350,20 @@ RenderTexture::RenderTexture(bool no_interp, bool clamp, bool filtering, s32 mm_ glBindTexture(GL_TEXTURE_2D, 0); } -auto RenderTexture::upload(byte *data, s32 width, s32 height, s32 level, bool dxt) -> void +auto RenderTexture::upload(const void *ptr, s32 width, s32 height, s32 level, s32 iformat) -> void { - if (asset_manager()->prepare_output && data && level == 0) + if (asset_manager()->prepare_output && ptr && level == 0) { - this->save_pixels(data, width, height); + this->save_pixels(ptr, width, height, iformat == GL_UNSIGNED_INT_8_8_8_8); } if (!context()->is_draw_enabled()) return; this->bind(0); - s32 iformat = (dxt) ? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_BYTE; - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, width, height, 0, - format, iformat, data); + format, iformat, ptr); } auto RenderTexture::bind(s32 index) -> void @@ -395,10 +393,18 @@ static auto pack_red(byte r) -> u32 return (255 << 24 | 0 << 16 | 0 << 8 | r); } -auto RenderTexture::save_pixels(byte *data, s32 width, s32 height) -> void +auto RenderTexture::save_pixels(const void *ptr, s32 width, s32 height, bool dxt) -> void { this->pixels.resize(width * height); - byte *dp = data; + if (dxt) + { + for (s32 i = 0; i < width * height; i++) + { + this->pixels[i] = aki_htonl(((u32 *)ptr)[i]); + } + return; + } + byte *dp = (byte *)ptr; switch (format) { case GL_RGBA: @@ -95,11 +95,11 @@ class RenderTexture std::vector<u32> pixels; - auto upload(byte *data, s32 width, s32 height, s32 level, bool dxt = false) -> void; + auto upload(const void *ptr, s32 width, s32 height, s32 level, s32 iformat = GL_UNSIGNED_BYTE) -> void; auto bind(s32 index) -> void; private: - auto save_pixels(byte *data, s32 width, s32 height) -> void; + auto save_pixels(const void *ptr, s32 width, s32 height, bool dxt) -> void; }; class RenderFramebuffer diff --git a/src/mauri.cc b/src/mauri.cc index 737af65..74e2fb1 100644 --- a/src/mauri.cc +++ b/src/mauri.cc @@ -68,7 +68,7 @@ auto wmain(s32 argc, wchar_t **argv) -> s32 return EXIT_FAILURE; } - if (!stl_global_init()) return EXIT_FAILURE; + if (!stl_global_init(false)) return EXIT_FAILURE; if (args.found("package")) { diff --git a/src/objects/material.cc b/src/objects/material.cc index 7c36d13..8b582ff 100644 --- a/src/objects/material.cc +++ b/src/objects/material.cc @@ -31,11 +31,6 @@ auto Material::load(Engine *engine, Object *object, MaterialType type, Pass *pas { switch (type) { - case MATERIAL_EFFECT: - { - pass0->load(engine, MATERIAL_PASS, pass); - break; - } case MATERIAL_MODEL: { Pass model_pass; @@ -59,6 +54,11 @@ auto Material::load(Engine *engine, Object *object, MaterialType type, Pass *pas break; } + case MATERIAL_EFFECT: + { + pass0->load(engine, MATERIAL_PASS, pass); + break; + } } } } diff --git a/src/objects/model.cc b/src/objects/model.cc index f5ce9c4..1eb958d 100644 --- a/src/objects/model.cc +++ b/src/objects/model.cc @@ -16,6 +16,8 @@ auto Model::parse(Parser &pr, const std::string &path) -> Model * pr.map_value<bool>(root, "fullscreen", &model->fullscreen, false); pr.map_value<bool>(root, "passthrough", &model->passthrough, false); + pr.map_value<vec2>(root, "cropoffset", &model->cropoffset, vec2(0.f)); + pr.map_value<f32>(root, "width", &model->width, 0.f); pr.map_value<f32>(root, "height", &model->height, 0.f); diff --git a/src/objects/model.h b/src/objects/model.h index d000bd7..d34130b 100644 --- a/src/objects/model.h +++ b/src/objects/model.h @@ -16,6 +16,8 @@ class Model bool fullscreen = false; bool passthrough = false; + vec2 cropoffset; + f32 width; f32 height; diff --git a/src/objects/pass.cc b/src/objects/pass.cc index a7cfc09..afe7c8a 100644 --- a/src/objects/pass.cc +++ b/src/objects/pass.cc @@ -1,4 +1,5 @@ #include "../gl.h" +#include "../context.h" #include "pass.h" @@ -199,10 +200,6 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) if (this->model && i == 0 && this->textures[0]) { - if (this->textures[0]->is_gif()) - { - pass->combos.push_back(Combo("SPRITESHEET", 1)); - } this->object->create_objects(engine, this->textures[0]); objects_created = true; } @@ -222,7 +219,7 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) { // Take value as reference because "uniform_override->value" points // to the value stored in the parser. This allows changing that value - // to have an instant effect. + // to have an immediate effect. uniform->value = &uniform_override->value; break; } @@ -276,9 +273,9 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) #ifdef _DEBUG_ debug("PASS (%s)", this->command == COPY ? "copy" : "draw"); - debug(" object: %s (passthrough: %d, fullscreen %d)", this->object->name.c_str(), - this->object->passthrough, this->object->fullscreen); - debug(" visible: %d", this->object->visible); + debug(" object: %s (passthrough: %s, fullscreen %s)", this->object->name.c_str(), + AL_BOOLSTR(this->object->passthrough), AL_BOOLSTR(this->object->fullscreen)); + debug(" visible: %s", AL_BOOLSTR(this->object->visible)); debug(" shader: %s", this->shader->origin()->name.c_str()); debug(" target: %s", pass->target.c_str()); debug(" textures (%u):", this->shader->origin()->texture_count); @@ -287,7 +284,7 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) switch (this->texture_types[i]) { case STATIC: - if (pass->textures[i].empty() && !this->shader->origin()->textures[i].empty()) + if (!this->shader->origin()->textures[i].empty() && pass->textures[i] == this->shader->origin()->textures[i]) { debug(" [%u] %s (DEFAULT)", i, this->shader->origin()->textures[i].c_str()); } @@ -307,8 +304,8 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) debug(" %s %s %s", uniform_type_to_string(uniform->type).c_str(), uniform->uname.c_str(), glm::to_string(*uniform->value).c_str()); } - debug(" model: %d", this->model); - debug(" combine: %d", this->combine); + debug(" model: %s", AL_BOOLSTR(this->model)); + debug(" combine: %s", AL_BOOLSTR(this->combine)); #endif } @@ -343,8 +340,7 @@ auto RenderPass::draw(Engine *engine) -> void Render::color_mask(1.f, 1.f, 1.f, this->combine ? 0.f : 1.f); - engine->view.default_viewport( - adjusted_target->buffer->width, adjusted_target->buffer->height); + engine->view.default_viewport(adjusted_target->buffer->width, adjusted_target->buffer->height); this->render_object->draw(); diff --git a/src/objects/scene.cc b/src/objects/scene.cc index 832cea6..21a2449 100644 --- a/src/objects/scene.cc +++ b/src/objects/scene.cc @@ -57,7 +57,6 @@ auto Scene::get_object_by_id(u32 id) -> Object * auto Scene::load(Engine *engine) -> void { - /* if (this->objects.size() > 0) { for (auto it = this->objects.begin(); it != this->objects.end();) @@ -66,7 +65,6 @@ auto Scene::load(Engine *engine) -> void else it++; } } - */ for (Object *object : this->objects) { diff --git a/src/texture.cc b/src/texture.cc index 8b7aa23..ea29bc0 100644 --- a/src/texture.cc +++ b/src/texture.cc @@ -108,25 +108,23 @@ Texture::Texture(Asset *asset) { case RGBA8888: texture->format = GL_RGBA; - texture->upload(buffer, mm_width, mm_height, i, false); + texture->upload(buffer, mm_width, mm_height, i); break; case DXT5: { - u32 *decompressed = new u32[decompressed_byte_count]; + u32 *decompressed = new u32[(mm_width + 3) * (mm_height + 3)]; BlockDecompressImageDXT5(mm_width, mm_height, buffer, decompressed); texture->format = GL_RGBA; - assert(decompressed); - texture->upload((byte *)decompressed, mm_width, mm_height, i, true); + texture->upload((byte *)decompressed, mm_width, mm_height, i, GL_UNSIGNED_INT_8_8_8_8); delete[] decompressed; break; } case DXT1: { - u32 *decompressed = new u32[decompressed_byte_count * 2]; + u32 *decompressed = new u32[(mm_width + 3) * (mm_height + 3)]; BlockDecompressImageDXT1(mm_width, mm_height, buffer, decompressed); texture->format = GL_RGBA; - assert(decompressed); - texture->upload((byte *)decompressed, mm_width, mm_height, i, true); + texture->upload((byte *)decompressed, mm_width, mm_height, i, GL_UNSIGNED_INT_8_8_8_8); delete[] decompressed; break; } @@ -3,6 +3,7 @@ extern "C" { #include <al/types.h> +#include <aki/socket.h> } #include "log.h" |