Windows compile fixes

This commit is contained in:
Alexander Bock
2016-12-03 01:20:53 +01:00
parent 694cc4d6cd
commit afd60683a3
12 changed files with 382 additions and 416 deletions
+86 -86
View File
@@ -37,115 +37,115 @@ namespace openspace {
namespace globebrowsing {
struct TileMetaData {
std::vector<float> maxValues;
std::vector<float> minValues;
std::vector<bool> hasMissingData;
struct TileMetaData {
std::vector<float> maxValues;
std::vector<float> minValues;
std::vector<bool> hasMissingData;
void serialize(std::ostream& s);
static TileMetaData deserialize(std::istream& s);
};
void serialize(std::ostream& s);
static TileMetaData deserialize(std::istream& s);
};
struct TextureFormat {
ghoul::opengl::Texture::Format ghoulFormat;
GLuint glFormat;
};
struct TextureFormat {
ghoul::opengl::Texture::Format ghoulFormat;
GLuint glFormat;
};
using namespace ghoul::opengl;
using namespace ghoul::opengl;
struct RawTile {
RawTile();
struct RawTile {
RawTile();
char* imageData;
glm::uvec3 dimensions;
std::shared_ptr<TileMetaData> tileMetaData;
TileIndex tileIndex;
CPLErr error;
size_t nBytesImageData;
char* imageData;
glm::uvec3 dimensions;
std::shared_ptr<TileMetaData> tileMetaData;
TileIndex tileIndex;
CPLErr error;
size_t nBytesImageData;
void serializeMetaData(std::ostream& s);
static RawTile deserializeMetaData(std::istream& s);
void serializeMetaData(std::ostream& s);
static RawTile deserializeMetaData(std::istream& s);
static RawTile createDefaultRes();
static RawTile createDefaultRes();
};
};
struct TileUvTransform {
glm::vec2 uvOffset;
glm::vec2 uvScale;
};
struct TileUvTransform {
glm::vec2 uvOffset;
glm::vec2 uvScale;
};
/**
* Defines a status and may have a Texture and TileMetaData
*/
struct Tile {
std::shared_ptr<Texture> texture;
std::shared_ptr<TileMetaData> metaData;
/**
* Defines a status and may have a Texture and TileMetaData
* Describe if this Tile is good for usage (OK) or otherwise
* the reason why it is not.
*/
struct Tile {
std::shared_ptr<Texture> texture;
std::shared_ptr<TileMetaData> metaData;
enum class Status {
/**
* E.g when texture data is not currently in memory.
* texture and tileMetaData are both null
*/
Unavailable,
/**
* Describe if this Tile is good for usage (OK) or otherwise
* the reason why it is not.
* Can be set by <code>TileProvider</code>s if the requested
* <code>TileIndex</code> is undefined for that particular
* provider.
* texture and metaData are both null
*/
enum class Status {
/**
* E.g when texture data is not currently in memory.
* texture and tileMetaData are both null
*/
Unavailable,
OutOfRange,
/**
* Can be set by <code>TileProvider</code>s if the requested
* <code>TileIndex</code> is undefined for that particular
* provider.
* texture and metaData are both null
*/
OutOfRange,
/**
* An IO Error happend
* texture and metaData are both null
*/
IOError,
/**
* An IO Error happend
* texture and metaData are both null
*/
IOError,
/**
* The Texture is uploaded to the GPU and good for usage.
* texture is defined. metaData may be defined.
*/
OK
} status;
/**
* The Texture is uploaded to the GPU and good for usage.
* texture is defined. metaData may be defined.
*/
OK
} status;
/**
* Instantiates a new tile with a single color.
*
* \param size The size of texture to be created
* \param color defined RGBA values in range 0-255.
*
* \returns a Tile with status OK and the a texture
* with the requested size and color
*/
static Tile createPlainTile(const glm::uvec2& size, const glm::uvec4& color);
static glm::vec2 compensateSourceTextureSampling(
glm::vec2 startOffset,
glm::vec2 sizeDiff,
glm::uvec2 resolution,
glm::vec2 tileUV);
static glm::vec2 TileUvToTextureSamplePosition(
const TileUvTransform uvTransform,
glm::vec2 tileUV,
glm::uvec2 resolution);
/**
* A tile with status unavailable that any user can return to
* indicate that a tile was unavailable.
/**
* Instantiates a new tile with a single color.
*
* \param size The size of texture to be created
* \param color defined RGBA values in range 0-255.
*
* \returns a Tile with status OK and the a texture
* with the requested size and color
*/
static const Tile TileUnavailable;
static Tile createPlainTile(const glm::uvec2& size, const glm::uvec4& color);
};
static glm::vec2 compensateSourceTextureSampling(
glm::vec2 startOffset,
glm::vec2 sizeDiff,
glm::uvec2 resolution,
glm::vec2 tileUV);
static glm::vec2 TileUvToTextureSamplePosition(
const TileUvTransform uvTransform,
glm::vec2 tileUV,
glm::uvec2 resolution);
/**
* A tile with status unavailable that any user can return to
* indicate that a tile was unavailable.
*/
static const Tile TileUnavailable;
};
} // namespace globebrowsing
} // namespace openspace
+1 -1
View File
@@ -31,7 +31,7 @@
#include <vector>
#include <stdint.h>
namespace ghoul{
namespace ghoul {
class Dictionary;
}
@@ -25,6 +25,8 @@
#ifndef __TEXT_TILE_PROVIDER_H__
#define __TEXT_TILE_PROVIDER_H__
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <memory>
#include <ghoul/logging/logmanager.h>
@@ -37,109 +39,108 @@
#include <ghoul/font/fontmanager.h>
#include <modules/globebrowsing/tile/asynctilereader.h>
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <modules/globebrowsing/other/lrucache.h>
#include <modules/globebrowsing/geometry/ellipsoid.h>
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
// TILE PROVIDER //
//////////////////////////////////////////////////////////////////////////////////////////
namespace openspace {
namespace globebrowsing {
using namespace ghoul::fontrendering;
using namespace ghoul::fontrendering;
/**
* Enables a simple way of providing tiles with any type of rendered text.
* Internally it handles setting up a FBO for rendering the text, and defines a new
* interface, consisting of only a single method for subclasses to implement:
* renderText(const FontRenderer&, const TileIndex&) const;
*/
class TextTileProvider : public TileProvider {
public:
/**
* Default constructor with default values for texture and font size
*/
TextTileProvider(const glm::uvec2& textureSize = {512, 512}, size_t fontSize = 48);
virtual ~TextTileProvider();
// The TileProvider interface below is implemented in this class
virtual Tile getTile(const TileIndex& tileIndex);
virtual Tile getDefaultTile();
virtual Tile::Status getTileStatus(const TileIndex& index);
virtual TileDepthTransform depthTransform();
virtual void update();
virtual void reset();
virtual int maxLevel();
/**
* Returns the tile which will be used to draw text onto.
* Default implementation returns a tile with a plain transparent texture.
*/
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
/**
* Allow overriding of hash function.
* Default is <code>TileIndex::hashKey()</code>
*
* \param tileIndex tileIndex to hash
* \returns hashkey used for in LRU cache for this tile
*/
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
/**
* Uses the fontRenderer to render some text onto the tile texture provided in
* backgroundTile(const TileIndex& tileIndex).
*
* \param fontRenderer used for rendering text onto texture
* \param tileIndex associated with the tile to be rendered onto
*/
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const = 0;
protected:
std::shared_ptr<ghoul::fontrendering::Font> _font;
glm::uvec2 _textureSize;
size_t _fontSize;
private:
Tile createChunkIndexTile(const TileIndex& tileIndex);
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
TileCache _tileCache;
GLuint _fbo;
};
/**
* Provides <code>Tile</code>s with the chunk index rendered as text onto its tiles.
*/
class TileIndexTileProvider : public TextTileProvider {
public:
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
};
/**
* Constructed with an ellipsoid and uses that to render the longitudal length of each
* of each tile.
/**
* Enables a simple way of providing tiles with any type of rendered text.
* Internally it handles setting up a FBO for rendering the text, and defines a new
* interface, consisting of only a single method for subclasses to implement:
* renderText(const FontRenderer&, const TileIndex&) const;
*/
class SizeReferenceTileProvider : public TextTileProvider {
public:
SizeReferenceTileProvider(const ghoul::Dictionary& dictionary);
class TextTileProvider : public TileProvider {
public:
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
/**
* Default constructor with default values for texture and font size
*/
TextTileProvider(const glm::uvec2& textureSize = {512, 512}, size_t fontSize = 48);
virtual ~TextTileProvider();
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
// The TileProvider interface below is implemented in this class
virtual Tile getTile(const TileIndex& tileIndex);
virtual Tile getDefaultTile();
virtual Tile::Status getTileStatus(const TileIndex& index);
virtual TileDepthTransform depthTransform();
virtual void update();
virtual void reset();
virtual int maxLevel();
private:
/**
* Returns the tile which will be used to draw text onto.
* Default implementation returns a tile with a plain transparent texture.
*/
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
int roundedLongitudalLength(const TileIndex& tileIndex) const;
Ellipsoid _ellipsoid;
Tile _backgroundTile;
};
/**
* Allow overriding of hash function.
* Default is <code>TileIndex::hashKey()</code>
*
* \param tileIndex tileIndex to hash
* \returns hashkey used for in LRU cache for this tile
*/
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
/**
* Uses the fontRenderer to render some text onto the tile texture provided in
* backgroundTile(const TileIndex& tileIndex).
*
* \param fontRenderer used for rendering text onto texture
* \param tileIndex associated with the tile to be rendered onto
*/
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const = 0;
protected:
std::shared_ptr<ghoul::fontrendering::Font> _font;
glm::uvec2 _textureSize;
size_t _fontSize;
private:
Tile createChunkIndexTile(const TileIndex& tileIndex);
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
TileCache _tileCache;
GLuint _fbo;
};
/**
* Provides <code>Tile</code>s with the chunk index rendered as text onto its tiles.
*/
class TileIndexTileProvider : public TextTileProvider {
public:
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
};
/**
* Constructed with an ellipsoid and uses that to render the longitudal length of each
* of each tile.
*/
class SizeReferenceTileProvider : public TextTileProvider {
public:
SizeReferenceTileProvider(const ghoul::Dictionary& dictionary);
virtual void renderText(const FontRenderer& fontRenderer, const TileIndex& tileIndex) const;
virtual Tile backgroundTile(const TileIndex& tileIndex) const;
virtual TileHashKey toHash(const TileIndex& tileIndex) const;
private:
int roundedLongitudalLength(const TileIndex& tileIndex) const;
Ellipsoid _ellipsoid;
Tile _backgroundTile;
};
} // namespace globebrowsing
} // namespace openspace
@@ -63,7 +63,7 @@ float TileProvider::noDataValueAsFloat() {
return std::numeric_limits<float>::min();
}
ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxParents){
ChunkTile TileProvider::getChunkTile(TileIndex tileIndex, int parents, int maxParents) {
TileUvTransform uvTransform;
uvTransform.uvOffset = glm::vec2(0, 0);
uvTransform.uvScale = glm::vec2(1, 1);
@@ -25,6 +25,8 @@
#ifndef __TILE_PROVIDER_H__
#define __TILE_PROVIDER_H__
#include <modules/globebrowsing/tile/tileindex.h>
#include <ghoul/filesystem/filesystem.h> // absPath
#include <ghoul/opengl/texture.h>
#include <ghoul/misc/dictionary.h>
@@ -33,6 +35,7 @@
#include <modules/globebrowsing/tile/tile.h>
#include <modules/globebrowsing/other/lrucache.h>
#include <modules/globebrowsing/tile/chunktile.h>
//////////////////////////////////////////////////////////////////////////////////////////
// TILE PROVIDER //
@@ -41,121 +44,118 @@
namespace openspace {
namespace globebrowsing {
class ChunkTile;
class ChunkTilePile;
using namespace ghoul::opengl;
using namespace ghoul::opengl;
/**
* Interface for providing <code>Tile</code>s given a
* <code>TileIndex</code>.
*/
class TileProvider {
public:
/**
* Interface for providing <code>Tile</code>s given a
* <code>TileIndex</code>.
* Factory method for instantiating different implementations of
* <code>TileProviders</code>. The provided dictionary must
* define a key specifying what implementation of TileProvider
* to be instantiated.
*/
class TileProvider {
public:
static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary);
/**
* Factory method for instantiating different implementations of
* <code>TileProviders</code>. The provided dictionary must
* define a key specifying what implementation of TileProvider
* to be instantiated.
*/
static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary);
/**
* Empty default constructor
*/
TileProvider() {};
/**
* Empty default constructor
*/
TileProvider() {};
/**
* Implementations of the TileProvider interface must implement
* a constructor taking a dictionary as input. The provided
* dictionary must define a key specifying what implementation
* of TileProvider to be instantiated.
*/
TileProvider(const ghoul::Dictionary& dictionary);
/**
* Implementations of the TileProvider interface must implement
* a constructor taking a dictionary as input. The provided
* dictionary must define a key specifying what implementation
* of TileProvider to be instantiated.
*/
TileProvider(const ghoul::Dictionary& dictionary);
/**
* Virtual destructor that subclasses should override to do
* clean up.
*/
virtual ~TileProvider() { }
/**
* Virtual destructor that subclasses should override to do
* clean up.
*/
virtual ~TileProvider() { }
/**
* Method for querying tiles, given a specified <code>TileIndex</code>.
*
* This method is expected to be invoked multiple times per frame,
* and should therefore return quickly, e.g. not perform heavy I/O
* operations. However, invoking this method may spawn separate threads
* to perform such operations. Therefore, programmers shoud
* note that there is no guarantee that the <code>Tile</code>
* status and texture will be consistent over different invocations
* of this method.
*
* \param tileIndex specifying a region of a map for which
* we want tile data.
*
* \returns The tile corresponding to the TileIndex by the time
* the method was invoked.
*/
virtual Tile getTile(const TileIndex& tileIndex) = 0;
/**
* Method for querying tiles, given a specified <code>TileIndex</code>.
*
* This method is expected to be invoked multiple times per frame,
* and should therefore return quickly, e.g. not perform heavy I/O
* operations. However, invoking this method may spawn separate threads
* to perform such operations. Therefore, programmers shoud
* note that there is no guarantee that the <code>Tile</code>
* status and texture will be consistent over different invocations
* of this method.
*
* \param tileIndex specifying a region of a map for which
* we want tile data.
*
* \returns The tile corresponding to the TileIndex by the time
* the method was invoked.
*/
virtual Tile getTile(const TileIndex& tileIndex) = 0;
virtual ChunkTile getChunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
virtual ChunkTile getChunkTile(TileIndex tileIndex, int parents = 0, int maxParents = 1337);
virtual ChunkTilePile getChunkTilePile(TileIndex tileIndex, int pileSize);
virtual ChunkTilePile getChunkTilePile(TileIndex tileIndex, int pileSize);
/**
* TileProviders must be able to provide a defualt
* <code>Tile</code> which may be used by clients in cases when
* requested tiles were unavailable.
*
* \returns A default tile
*/
virtual Tile getDefaultTile() = 0;
/**
* TileProviders must be able to provide a defualt
* <code>Tile</code> which may be used by clients in cases when
* requested tiles were unavailable.
*
* \returns A default tile
*/
virtual Tile getDefaultTile() = 0;
/**
* Returns the status of a <code>Tile</code>. The <code>Tile::Status</code>
* corresponds the <code>Tile</code> that would be returned
* if the function <code>getTile</code> would be invoked with the same
* <code>TileIndex</code> argument at this point in time.
*/
virtual Tile::Status getTileStatus(const TileIndex& index) = 0;
/**
* Returns the status of a <code>Tile</code>. The <code>Tile::Status</code>
* corresponds the <code>Tile</code> that would be returned
* if the function <code>getTile</code> would be invoked with the same
* <code>TileIndex</code> argument at this point in time.
*/
virtual Tile::Status getTileStatus(const TileIndex& index) = 0;
/**
* Get the associated depth transform for this TileProvider.
* This is necessary for TileProviders serving height map
* data, in order to correcly map pixel values to meters.
*/
virtual TileDepthTransform depthTransform() = 0;
/**
* Get the associated depth transform for this TileProvider.
* This is necessary for TileProviders serving height map
* data, in order to correcly map pixel values to meters.
*/
virtual TileDepthTransform depthTransform() = 0;
/**
* This method should be called once per frame. Here, TileProviders
* are given the opportunity to update their internal state.
*/
virtual void update() = 0;
/**
* This method should be called once per frame. Here, TileProviders
* are given the opportunity to update their internal state.
*/
virtual void update() = 0;
/**
* Provides a uniform way of all TileProviders to reload or
* restore all of its internal state. This is mainly useful
* for debugging purposes.
*/
virtual void reset() = 0;
/**
* Provides a uniform way of all TileProviders to reload or
* restore all of its internal state. This is mainly useful
* for debugging purposes.
*/
virtual void reset() = 0;
/**
* \returns The maximum level as defined by <code>TileIndex</code>
* that this TileProvider is able provide.
*/
virtual int maxLevel() = 0;
/**
* \returns The maximum level as defined by <code>TileIndex</code>
* that this TileProvider is able provide.
*/
virtual int maxLevel() = 0;
/**
* \returns the no data value for the dataset. Default is the minimum float avalue.
*/
virtual float noDataValueAsFloat();
};
/**
* \returns the no data value for the dataset. Default is the minimum float avalue.
*/
virtual float noDataValueAsFloat();
};
typedef LRUCache<TileHashKey, Tile> TileCache;
typedef LRUCache<TileHashKey, Tile> TileCache;
} // namespace globebrowsing
} // namespace openspace
@@ -81,7 +81,7 @@ namespace globebrowsing {
}
TileDepthTransform TileProviderByIndex::depthTransform() {
_defaultTileProvider->depthTransform();
return _defaultTileProvider->depthTransform();
}
void TileProviderByIndex::update() {