mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-27 22:40:41 -05:00
Remove default texture from TileProvider
This commit is contained in:
@@ -52,7 +52,7 @@ namespace openspace {
|
||||
, _tileCache(tileCacheSize)
|
||||
, _framesSinceLastRequestFlush(0)
|
||||
{
|
||||
initDefaultTexture();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,23 +60,6 @@ namespace openspace {
|
||||
clearRequestQueue();
|
||||
}
|
||||
|
||||
void TileProvider::initDefaultTexture() {
|
||||
// Set a temporary texture
|
||||
std::string fileName = "textures/earth_bluemarble.jpg";
|
||||
_defaultTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(fileName)));
|
||||
|
||||
if (_defaultTexture) {
|
||||
LDEBUG("Loaded texture from '" << fileName << "'");
|
||||
_defaultTexture->uploadTexture();
|
||||
|
||||
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
|
||||
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
|
||||
//_testTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
|
||||
_defaultTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
|
||||
_defaultTexture->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToBorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TileProvider::prerender() {
|
||||
initTexturesFromLoadedData();
|
||||
@@ -117,7 +100,7 @@ namespace openspace {
|
||||
uvTransform.uvOffset = glm::vec2(0, 0);
|
||||
uvTransform.uvScale = glm::vec2(1, 1);
|
||||
|
||||
for (int i = 0; i < levelOffset && chunkIndex.level > 2; i++) {
|
||||
for (int i = 0; i < levelOffset && chunkIndex.level > 1; i++) {
|
||||
transformFromParent(chunkIndex, uvTransform);
|
||||
chunkIndex = chunkIndex.parent();
|
||||
}
|
||||
@@ -134,8 +117,8 @@ namespace openspace {
|
||||
std::shared_ptr<Texture> texture = _tileCache.get(key).texture;
|
||||
return { texture, uvTransform };
|
||||
}
|
||||
else if (chunkIndex.level <= 1) {
|
||||
return { getDefaultTexture(), uvTransform };
|
||||
else if (chunkIndex.level < 1) {
|
||||
return { nullptr, uvTransform };
|
||||
}
|
||||
else {
|
||||
// We don't have the tile for the requested level
|
||||
@@ -179,11 +162,6 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Texture> TileProvider::getDefaultTexture() {
|
||||
return _defaultTexture;
|
||||
}
|
||||
|
||||
TileDepthTransform TileProvider::depthTransform() {
|
||||
return _asyncTextureDataProvider->getTextureDataProvider()->getDepthTransform();
|
||||
}
|
||||
|
||||
@@ -81,8 +81,7 @@ namespace openspace {
|
||||
|
||||
~TileProvider();
|
||||
|
||||
Tile getHighestResolutionTile(
|
||||
ChunkIndex chunkIndex,
|
||||
Tile getHighestResolutionTile(ChunkIndex chunkIndex,
|
||||
TileUvTransform uvTransform = {glm::vec2(0.0f,0.0f), glm::vec2(1.0f,1.0f)});
|
||||
/**
|
||||
\param levelOffset gives a tile from a parent chunk with that particular
|
||||
@@ -92,7 +91,6 @@ namespace openspace {
|
||||
Tile getHighestResolutionParentTile(ChunkIndex chunkIndex, int levelOffset = 1);
|
||||
|
||||
std::shared_ptr<Texture> getOrStartFetchingTile(ChunkIndex chunkIndex);
|
||||
std::shared_ptr<Texture> getDefaultTexture();
|
||||
TileDepthTransform depthTransform();
|
||||
|
||||
void prerender();
|
||||
@@ -119,17 +117,12 @@ namespace openspace {
|
||||
/**
|
||||
Creates an OpenGL texture and pushes the data to the GPU.
|
||||
*/
|
||||
void initializeAndAddToCache(
|
||||
std::shared_ptr<TileIOResult> uninitedTexture);
|
||||
void initializeAndAddToCache(std::shared_ptr<TileIOResult> uninitedTexture);
|
||||
|
||||
void clearRequestQueue();
|
||||
|
||||
void initTexturesFromLoadedData();
|
||||
|
||||
void initDefaultTexture();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -143,9 +136,6 @@ namespace openspace {
|
||||
|
||||
|
||||
std::shared_ptr<AsyncTileDataProvider> _asyncTextureDataProvider;
|
||||
|
||||
std::shared_ptr<Texture> _defaultTexture;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -168,6 +168,16 @@ namespace openspace {
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
if (tile.texture == nullptr ||
|
||||
tileParent1.texture == nullptr ||
|
||||
tileParent2.texture == nullptr)
|
||||
{
|
||||
// don't render if no tile was available
|
||||
programObject->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
TileDepthTransform depthTransform = tileProvider->depthTransform();
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
@@ -240,6 +250,16 @@ namespace openspace {
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
|
||||
if (tile.texture == nullptr ||
|
||||
tileParent1.texture == nullptr ||
|
||||
tileParent2.texture == nullptr)
|
||||
{
|
||||
// don't render if no tile was available
|
||||
programObject->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColor[i].activate();
|
||||
tile.texture->bind();
|
||||
@@ -392,6 +412,16 @@ namespace openspace {
|
||||
Tile tile = tileProvider->getHighestResolutionTile(chunk.index());
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
if (tile.texture == nullptr ||
|
||||
tileParent1.texture == nullptr ||
|
||||
tileParent2.texture == nullptr)
|
||||
{
|
||||
// don't render if no tile was available
|
||||
programObject->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
TileDepthTransform depthTransform = tileProvider->depthTransform();
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
@@ -463,6 +493,16 @@ namespace openspace {
|
||||
Tile tileParent1 = tileProvider->getHighestResolutionParentTile(chunk.index(), 1);
|
||||
Tile tileParent2 = tileProvider->getHighestResolutionParentTile(chunk.index(), 2);
|
||||
|
||||
|
||||
if (tile.texture == nullptr ||
|
||||
tileParent1.texture == nullptr ||
|
||||
tileParent2.texture == nullptr)
|
||||
{
|
||||
// don't render if no tile was available
|
||||
programObject->deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
// The texture needs a unit to sample from
|
||||
texUnitColor[i].activate();
|
||||
tile.texture->bind();
|
||||
|
||||
Reference in New Issue
Block a user