mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-03 10:58:34 -06:00
Merge remote-tracking branch 'origin/master' into feature/statlogs
This commit is contained in:
@@ -52,19 +52,19 @@ void* PixelBuffer::mapBuffer(Access access) {
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length, GLbitfield access) {
|
||||
void* PixelBuffer::mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access) {
|
||||
void* dataPtr = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, offset, length, access);
|
||||
_isMapped = dataPtr ? true : false;
|
||||
return dataPtr;
|
||||
}
|
||||
|
||||
bool PixelBuffer::unMapBuffer() {
|
||||
bool success = glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
GLboolean success = glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
||||
if (!success) {
|
||||
LERROR("Unable to unmap pixel buffer, data may be corrupt!");
|
||||
}
|
||||
_isMapped = false;
|
||||
return success;
|
||||
return success == GL_TRUE;
|
||||
}
|
||||
|
||||
void PixelBuffer::bind() {
|
||||
|
||||
@@ -44,26 +44,26 @@ public:
|
||||
* All kinds of usage for pixel buffer objects as defined by the OpenGL standard.
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml
|
||||
*/
|
||||
enum class Usage {
|
||||
StreamDraw = GL_STREAM_DRAW,
|
||||
StreamRead = GL_STREAM_READ,
|
||||
StreamCopy = GL_STREAM_COPY,
|
||||
StaticDraw = GL_STATIC_DRAW,
|
||||
StaticRead = GL_STATIC_READ,
|
||||
StaticCopy = GL_STATIC_COPY,
|
||||
DynamicDraw = GL_DYNAMIC_DRAW,
|
||||
DynamicRead = GL_DYNAMIC_READ,
|
||||
DynamicCopy = GL_DYNAMIC_COPY
|
||||
};
|
||||
enum class Usage : std::underlying_type_t<GLenum> {
|
||||
StreamDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_DRAW),
|
||||
StreamRead = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_READ),
|
||||
StreamCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STREAM_COPY),
|
||||
StaticDraw = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_DRAW),
|
||||
StaticRead = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_READ),
|
||||
StaticCopy = static_cast<std::underlying_type_t<GLenum>>(GL_STATIC_COPY),
|
||||
DynamicDraw = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_DRAW),
|
||||
DynamicRead = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_READ),
|
||||
DynamicCopy = static_cast<std::underlying_type_t<GLenum>>(GL_DYNAMIC_COPY)
|
||||
};
|
||||
|
||||
/**
|
||||
* Access hints for OpenGL buffer mapping
|
||||
* See: https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glMapBuffer.xml
|
||||
*/
|
||||
enum class Access {
|
||||
ReadOnly = GL_READ_ONLY,
|
||||
WriteOnly = GL_WRITE_ONLY,
|
||||
ReadWrite = GL_READ_WRITE
|
||||
enum class Access : std::underlying_type_t<GLenum> {
|
||||
ReadOnly = static_cast<std::underlying_type_t<GLenum>>(GL_READ_ONLY),
|
||||
WriteOnly = static_cast<std::underlying_type_t<GLenum>>(GL_WRITE_ONLY),
|
||||
ReadWrite = static_cast<std::underlying_type_t<GLenum>>(GL_READ_WRITE)
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
* \returns the DMA address to the mapped buffer. Returns nullptr if the mapping
|
||||
* failed
|
||||
*/
|
||||
void* mapBufferRange(GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
void* mapBufferRange(GLintptr offset, GLsizeiptr length, BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Maps the default buffer and makes the data available on the GPU
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
* is already mapped or if something else failed.
|
||||
*/
|
||||
void* mapBufferRange(KeyType key, GLintptr offset, GLsizeiptr length,
|
||||
GLbitfield access);
|
||||
BufferAccessMask access);
|
||||
|
||||
/**
|
||||
* Unmaps all buffers in the PixelBufferContainer.
|
||||
|
||||
@@ -63,7 +63,7 @@ void* PixelBufferContainer<KeyType>::mapBuffer(KeyType key, PixelBuffer::Access
|
||||
|
||||
template <class KeyType>
|
||||
void* PixelBufferContainer<KeyType>::mapBufferRange(KeyType key, GLintptr offset,
|
||||
GLsizeiptr length, GLbitfield access)
|
||||
GLsizeiptr length, BufferAccessMask access)
|
||||
{
|
||||
typename std::map<KeyType, int>::const_iterator iter = _indexMap.find(key);
|
||||
bool notFoundAmongMappedBuffers = iter == _indexMap.end();
|
||||
|
||||
@@ -272,8 +272,8 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
|
||||
dataDest += io.write.region.start.x * _initData.bytesPerPixel();
|
||||
|
||||
GDALRasterBand* gdalRasterBand = _dataset->GetRasterBand(rasterBand);
|
||||
CPLErr readError = CE_Failure;
|
||||
readError = gdalRasterBand->RasterIO(
|
||||
CPLErr readError = CE_Failure;
|
||||
readError = gdalRasterBand->RasterIO(
|
||||
GF_Read,
|
||||
io.read.region.start.x, // Begin read x
|
||||
io.read.region.start.y, // Begin read y
|
||||
|
||||
@@ -361,7 +361,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType)
|
||||
return format;
|
||||
}
|
||||
|
||||
GLuint getOpenGLDataType(GDALDataType gdalType) {
|
||||
GLenum getOpenGLDataType(GDALDataType gdalType) {
|
||||
switch (gdalType) {
|
||||
case GDT_Byte:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
@@ -383,7 +383,7 @@ GLuint getOpenGLDataType(GDALDataType gdalType) {
|
||||
}
|
||||
}
|
||||
|
||||
GDALDataType getGdalDataType(GLuint glType) {
|
||||
GDALDataType getGdalDataType(GLenum glType) {
|
||||
switch (glType) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
return GDT_Byte;
|
||||
@@ -419,7 +419,7 @@ size_t numberOfRasters(ghoul::opengl::Texture::Format format) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t numberOfBytes(GLuint glType) {
|
||||
size_t numberOfBytes(GLenum glType) {
|
||||
switch (glType) {
|
||||
case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
|
||||
case GL_BYTE: return sizeof(GLbyte);
|
||||
@@ -435,7 +435,7 @@ size_t numberOfBytes(GLuint glType) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t getMaximumValue(GLuint glType) {
|
||||
size_t getMaximumValue(GLenum glType) {
|
||||
switch (glType) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
return 1 << 8;
|
||||
@@ -452,7 +452,7 @@ size_t getMaximumValue(GLuint glType) {
|
||||
}
|
||||
}
|
||||
|
||||
float interpretFloat(GLuint glType, const char* src) {
|
||||
float interpretFloat(GLenum glType, const char* src) {
|
||||
switch (glType) {
|
||||
case GL_UNSIGNED_BYTE:
|
||||
return static_cast<float>(*reinterpret_cast<const GLubyte*>(src));
|
||||
@@ -475,7 +475,7 @@ float interpretFloat(GLuint glType, const char* src) {
|
||||
}
|
||||
}
|
||||
|
||||
GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) {
|
||||
switch (format) {
|
||||
case ghoul::opengl::Texture::Format::Red:
|
||||
switch (glType) {
|
||||
@@ -494,7 +494,7 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
case ghoul::opengl::Texture::Format::RG:
|
||||
@@ -514,7 +514,7 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
case ghoul::opengl::Texture::Format::RGB:
|
||||
@@ -534,7 +534,7 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
case ghoul::opengl::Texture::Format::RGBA:
|
||||
@@ -554,7 +554,7 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
case ghoul::opengl::Texture::Format::BGR:
|
||||
@@ -574,7 +574,7 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
case ghoul::opengl::Texture::Format::BGRA:
|
||||
@@ -594,12 +594,17 @@ GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format) {
|
||||
default:
|
||||
ghoul_assert(false, "glType data type unknown");
|
||||
LERROR("glType data type unknown: " << glType);
|
||||
return 0;
|
||||
return GLenum(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LERROR("Unknown format for OpenGL texture: " << format);
|
||||
return 0;
|
||||
LERROR(
|
||||
"Unknown format for OpenGL texture: " <<
|
||||
static_cast<std::underlying_type_t<
|
||||
ghoul::opengl::Texture::Format>
|
||||
>(format)
|
||||
);
|
||||
return GLenum(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace globebrowsing {
|
||||
namespace tiledatatype {
|
||||
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
GLuint getOpenGLDataType(GDALDataType gdalType);
|
||||
GDALDataType getGdalDataType(GLuint glType);
|
||||
GLenum getOpenGLDataType(GDALDataType gdalType);
|
||||
GDALDataType getGdalDataType(GLenum glType);
|
||||
TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType);
|
||||
TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType);
|
||||
size_t getMaximumValue(GDALDataType gdalType);
|
||||
@@ -48,11 +48,11 @@ size_t numberOfBytes(GDALDataType gdalType);
|
||||
float interpretFloat(GDALDataType gdalType, const char* src);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
GLint glTextureFormat(GLuint glType, ghoul::opengl::Texture::Format format);
|
||||
GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfRasters(ghoul::opengl::Texture::Format format);
|
||||
size_t numberOfBytes(GLuint glType);
|
||||
size_t getMaximumValue(GLuint glType);
|
||||
float interpretFloat(GLuint glType, const char* src);
|
||||
size_t numberOfBytes(GLenum glType);
|
||||
size_t getMaximumValue(GLenum glType);
|
||||
float interpretFloat(GLenum glType, const char* src);
|
||||
|
||||
} // namespace tiledatatype
|
||||
} // namespace globebrowsing
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace globebrowsing {
|
||||
|
||||
struct TextureFormat {
|
||||
ghoul::opengl::Texture::Format ghoulFormat;
|
||||
GLint glFormat;
|
||||
GLenum glFormat;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace globebrowsing {
|
||||
const glm::ivec2 TileTextureInitData::tilePixelStartOffset = glm::ivec2(-2);
|
||||
const glm::ivec2 TileTextureInitData::tilePixelSizeDifference = glm::ivec2(4);
|
||||
|
||||
TileTextureInitData::TileTextureInitData(size_t width, size_t height, GLuint glType,
|
||||
TileTextureInitData::TileTextureInitData(size_t width, size_t height, GLenum glType,
|
||||
Format textureFormat, ShouldAllocateDataOnCPU shouldAllocateDataOnCPU)
|
||||
: _glType(glType)
|
||||
, _ghoulTextureFormat(textureFormat)
|
||||
@@ -87,7 +87,7 @@ size_t TileTextureInitData::totalNumBytes() const {
|
||||
return _totalNumBytes;
|
||||
}
|
||||
|
||||
GLuint TileTextureInitData::glType() const {
|
||||
GLenum TileTextureInitData::glType() const {
|
||||
return _glType;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ TileTextureInitData::Format TileTextureInitData::ghoulTextureFormat() const {
|
||||
return _ghoulTextureFormat;
|
||||
}
|
||||
|
||||
GLint TileTextureInitData::glTextureFormat() const {
|
||||
GLenum TileTextureInitData::glTextureFormat() const {
|
||||
return _glTextureFormat;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ void TileTextureInitData::calculateHashKey() {
|
||||
|
||||
_hashKey |= _dimensionsWithoutPadding.x;
|
||||
_hashKey |= _dimensionsWithoutPadding.y << 10;
|
||||
_hashKey |= _glType << (10 + 16);
|
||||
_hashKey |= static_cast<std::underlying_type_t<GLenum>>(_glType) << (10 + 16);
|
||||
_hashKey |= format << (10 + 16 + 4);
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
using ShouldAllocateDataOnCPU = ghoul::Boolean;
|
||||
using Format = ghoul::opengl::Texture::Format;
|
||||
|
||||
TileTextureInitData(size_t width, size_t height, GLuint glType, Format textureFormat,
|
||||
TileTextureInitData(size_t width, size_t height, GLenum glType, Format textureFormat,
|
||||
ShouldAllocateDataOnCPU shouldAllocateDataOnCPU = ShouldAllocateDataOnCPU::No);
|
||||
|
||||
TileTextureInitData(const TileTextureInitData& original);
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
size_t bytesPerPixel() const;
|
||||
size_t bytesPerLine() const;
|
||||
size_t totalNumBytes() const;
|
||||
GLuint glType() const;
|
||||
GLenum glType() const;
|
||||
Format ghoulTextureFormat() const;
|
||||
GLint glTextureFormat() const;
|
||||
GLenum glTextureFormat() const;
|
||||
bool shouldAllocateDataOnCPU() const;
|
||||
HashKey hashKey() const;
|
||||
|
||||
@@ -74,9 +74,9 @@ private:
|
||||
HashKey _hashKey;
|
||||
glm::ivec3 _dimensionsWithPadding;
|
||||
glm::ivec3 _dimensionsWithoutPadding;
|
||||
GLuint _glType;
|
||||
GLenum _glType;
|
||||
Format _ghoulTextureFormat;
|
||||
GLint _glTextureFormat;
|
||||
GLenum _glTextureFormat;
|
||||
size_t _nRasters;
|
||||
size_t _bytesPerDatum;
|
||||
size_t _bytesPerPixel;
|
||||
|
||||
@@ -913,7 +913,8 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) {
|
||||
_dilation.stencilTexture = std::make_unique<ghoul::opengl::Texture>(
|
||||
glm::uvec3(size, 1),
|
||||
ghoul::opengl::Texture::Format::Red,
|
||||
ghoul::opengl::Texture::Format::Red
|
||||
// @TODO: Remove the static cast ---abock
|
||||
static_cast<GLenum>(ghoul::opengl::Texture::Format::Red)
|
||||
);
|
||||
|
||||
if (_dilation.stencilTexture) {
|
||||
|
||||
@@ -285,14 +285,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
bool RenderablePlanet::initialize() {
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
|
||||
GLenum err;
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
std::stringstream ss;
|
||||
ss << "Checking System State. OpenGL error: " << errString << std::endl;
|
||||
LERROR(ss.str());
|
||||
}
|
||||
|
||||
if (_programObject == nullptr && _shadowEnabled && _hasNightTexture) {
|
||||
// shadow program
|
||||
_programObject = renderEngine.buildRenderProgram(
|
||||
@@ -325,22 +317,10 @@ bool RenderablePlanet::initialize() {
|
||||
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
|
||||
_programObject->setIgnoreUniformLocationError(IgnoreError::Yes);
|
||||
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
std::stringstream ss;
|
||||
ss << "Error after load shading programs. OpenGL error: " << errString << std::endl;
|
||||
LERROR(ss.str());
|
||||
}
|
||||
|
||||
_geometry->initialize(this);
|
||||
|
||||
_programObject->deactivate();
|
||||
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
LERROR("Shader Programs Creation. OpenGL error: " << errString);
|
||||
}
|
||||
|
||||
loadTexture();
|
||||
|
||||
return isReady();
|
||||
@@ -553,12 +533,6 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
GLenum err;
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
LERROR("Error after reading color texture. OpenGL error: " << errString);
|
||||
}
|
||||
|
||||
if (_hasNightTexture) {
|
||||
_nightTexture = nullptr;
|
||||
if (_nightTexturePath.value() != "") {
|
||||
@@ -572,11 +546,6 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
LERROR("Error after reading night texture. OpenGL error: " << errString);
|
||||
}
|
||||
|
||||
if (_hasHeightTexture) {
|
||||
_heightMapTexture = nullptr;
|
||||
if (_heightMapTexturePath.value() != "") {
|
||||
@@ -589,11 +558,6 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ((err = glGetError()) != GL_NO_ERROR) {
|
||||
const GLubyte * errString = gluErrorString(err);
|
||||
LERROR("Error after reading height mapping texture. OpenGL error: " << errString);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user