mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-03 10:09:40 -06:00
Load psf texture on init so its readey for rendertime (#1356)
This commit is contained in:
@@ -789,7 +789,7 @@ void RenderableStars::initializeGL() {
|
||||
);
|
||||
|
||||
//loadShapeTexture();
|
||||
|
||||
loadPSFTexture();
|
||||
renderPSFToTexture();
|
||||
}
|
||||
|
||||
@@ -808,6 +808,39 @@ void RenderableStars::deinitializeGL() {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableStars::loadPSFTexture() {
|
||||
_pointSpreadFunctionTexture = nullptr;
|
||||
if (!_pointSpreadFunctionTexturePath.value().empty() &&
|
||||
std::filesystem::exists(_pointSpreadFunctionTexturePath.value()))
|
||||
{
|
||||
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
);
|
||||
|
||||
if (_pointSpreadFunctionTexture) {
|
||||
LDEBUG(fmt::format(
|
||||
"Loaded texture from '{}'",
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
));
|
||||
_pointSpreadFunctionTexture->uploadTexture();
|
||||
}
|
||||
_pointSpreadFunctionTexture->setFilter(
|
||||
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
|
||||
);
|
||||
|
||||
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_pointSpreadFunctionTexturePath
|
||||
);
|
||||
_pointSpreadFunctionFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) {
|
||||
_pointSpreadFunctionTextureIsDirty = true;
|
||||
}
|
||||
);
|
||||
}
|
||||
_pointSpreadFunctionTextureIsDirty = false;
|
||||
|
||||
}
|
||||
|
||||
void RenderableStars::renderPSFToTexture() {
|
||||
// Saves current FBO first
|
||||
GLint defaultFBO;
|
||||
@@ -1214,35 +1247,7 @@ void RenderableStars::update(const UpdateData&) {
|
||||
|
||||
if (_pointSpreadFunctionTextureIsDirty) {
|
||||
LDEBUG("Reloading Point Spread Function texture");
|
||||
_pointSpreadFunctionTexture = nullptr;
|
||||
if (!_pointSpreadFunctionTexturePath.value().empty() &&
|
||||
std::filesystem::exists(_pointSpreadFunctionTexturePath.value()))
|
||||
{
|
||||
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
);
|
||||
|
||||
if (_pointSpreadFunctionTexture) {
|
||||
LDEBUG(fmt::format(
|
||||
"Loaded texture from '{}'",
|
||||
absPath(_pointSpreadFunctionTexturePath)
|
||||
));
|
||||
_pointSpreadFunctionTexture->uploadTexture();
|
||||
}
|
||||
_pointSpreadFunctionTexture->setFilter(
|
||||
ghoul::opengl::Texture::FilterMode::AnisotropicMipMap
|
||||
);
|
||||
|
||||
_pointSpreadFunctionFile = std::make_unique<ghoul::filesystem::File>(
|
||||
_pointSpreadFunctionTexturePath
|
||||
);
|
||||
_pointSpreadFunctionFile->setCallback(
|
||||
[&](const ghoul::filesystem::File&) {
|
||||
_pointSpreadFunctionTextureIsDirty = true;
|
||||
}
|
||||
);
|
||||
}
|
||||
_pointSpreadFunctionTextureIsDirty = false;
|
||||
loadPSFTexture();
|
||||
}
|
||||
|
||||
if (_colorTextureIsDirty) {
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
|
||||
bool isReady() const override;
|
||||
|
||||
void loadPSFTexture();
|
||||
void renderPSFToTexture();
|
||||
void render(const RenderData& data, RendererTasks& rendererTask) override;
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
Reference in New Issue
Block a user