mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
General cleanup
Adapt to changes in Ghoul Make use of TextureManager Jenkins compile fix
This commit is contained in:
@@ -24,13 +24,16 @@
|
||||
|
||||
#include <modules/base/rendering/renderableplaneimagelocal.h>
|
||||
|
||||
#include <modules/base/basemodule.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/io/texture/texturereader.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/crc32.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <fstream>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
|
||||
@@ -91,7 +94,8 @@ void RenderablePlaneImageLocal::initializeGL() {
|
||||
|
||||
void RenderablePlaneImageLocal::deinitializeGL() {
|
||||
_textureFile = nullptr;
|
||||
_texture = nullptr;
|
||||
|
||||
BaseModule::TextureManager.release(_texture);
|
||||
RenderablePlane::deinitializeGL();
|
||||
}
|
||||
|
||||
@@ -110,27 +114,36 @@ void RenderablePlaneImageLocal::update(const UpdateData& data) {
|
||||
|
||||
void RenderablePlaneImageLocal::loadTexture() {
|
||||
if (!_texturePath.value().empty()) {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
|
||||
ghoul::opengl::Texture* t = _texture;
|
||||
|
||||
if (texture) {
|
||||
LDEBUGC(
|
||||
"RenderablePlane",
|
||||
fmt::format("Loaded texture from '{}'", absPath(_texturePath))
|
||||
);
|
||||
texture->uploadTexture();
|
||||
unsigned int hash = ghoul::hashCRC32File(_texturePath);
|
||||
|
||||
_texture = BaseModule::TextureManager.request(
|
||||
std::to_string(hash),
|
||||
[path = _texturePath]() -> std::unique_ptr<ghoul::opengl::Texture> {
|
||||
std::unique_ptr<ghoul::opengl::Texture> texture =
|
||||
ghoul::io::TextureReader::ref().loadTexture(absPath(path));
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than
|
||||
// linear
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
if (texture) {
|
||||
LDEBUGC(
|
||||
"RenderablePlaneImageLocal",
|
||||
fmt::format("Loaded texture from '{}'", absPath(path))
|
||||
);
|
||||
texture->uploadTexture();
|
||||
|
||||
_texture = std::move(texture);
|
||||
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
|
||||
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
_textureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
);
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
BaseModule::TextureManager.release(t);
|
||||
|
||||
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
|
||||
_textureFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) { _textureIsDirty = true; }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user