diff --git a/projects/msvc12/GLideN64.vcxproj b/projects/msvc12/GLideN64.vcxproj
index b8a62217..e0497820 100644
--- a/projects/msvc12/GLideN64.vcxproj
+++ b/projects/msvc12/GLideN64.vcxproj
@@ -438,6 +438,7 @@
+
diff --git a/projects/msvc12/GLideN64.vcxproj.filters b/projects/msvc12/GLideN64.vcxproj.filters
index 3e16fae6..ee909d79 100644
--- a/projects/msvc12/GLideN64.vcxproj.filters
+++ b/projects/msvc12/GLideN64.vcxproj.filters
@@ -643,5 +643,8 @@
Header Files\Graphics\OpenGL
+
+ Header Files\Graphics
+
\ No newline at end of file
diff --git a/src/Graphics/Context.cpp b/src/Graphics/Context.cpp
index 2103cb6b..2a0cdc93 100644
--- a/src/Graphics/Context.cpp
+++ b/src/Graphics/Context.cpp
@@ -15,6 +15,7 @@ void Context::init()
{
m_impl.reset(new opengl::ContextImpl);
m_impl->init();
+ m_fbTexFormats.reset(m_impl->getFramebufferTextureFormats());
}
void Context::destroy()
@@ -100,6 +101,11 @@ void Context::setTextureParameters(const TexParameters & _parameters)
/*---------------Framebuffer-------------*/
+const FramebufferTextureFormats & Context::getFramebufferTextureFormats()
+{
+ return *m_fbTexFormats.get();
+}
+
ObjectHandle Context::createFramebuffer()
{
return m_impl->createFramebuffer();
diff --git a/src/Graphics/Context.h b/src/Graphics/Context.h
index bf4fcc77..e620deff 100644
--- a/src/Graphics/Context.h
+++ b/src/Graphics/Context.h
@@ -7,6 +7,7 @@
#include "CombinerProgram.h"
#include "ShaderProgram.h"
#include "PixelBuffer.h"
+#include "FramebufferTextureFormats.h"
#define GRAPHICS_CONTEXT
@@ -105,6 +106,8 @@ namespace graphics {
/*---------------Framebuffer-------------*/
+ const FramebufferTextureFormats & getFramebufferTextureFormats();
+
ObjectHandle createFramebuffer();
void deleteFramebuffer(ObjectHandle _name);
@@ -210,6 +213,7 @@ namespace graphics {
private:
std::unique_ptr m_impl;
+ std::unique_ptr m_fbTexFormats;
};
}
diff --git a/src/Graphics/ContextImpl.h b/src/Graphics/ContextImpl.h
index 66fae902..21e0f77d 100644
--- a/src/Graphics/ContextImpl.h
+++ b/src/Graphics/ContextImpl.h
@@ -27,6 +27,7 @@ namespace graphics {
virtual void init2DTexture(const Context::InitTextureParams & _params) = 0;
virtual void update2DTexture(const Context::UpdateTextureDataParams & _params) = 0;
virtual void setTextureParameters(const Context::TexParameters & _parameters) = 0;
+ virtual FramebufferTextureFormats * getFramebufferTextureFormats() = 0;
virtual ObjectHandle createFramebuffer() = 0;
virtual void deleteFramebuffer(ObjectHandle _name) = 0;
virtual void addFrameBufferRenderTarget(const Context::FrameBufferRenderTarget & _params) = 0;
diff --git a/src/Graphics/FramebufferTextureFormats.h b/src/Graphics/FramebufferTextureFormats.h
new file mode 100644
index 00000000..e20e4cad
--- /dev/null
+++ b/src/Graphics/FramebufferTextureFormats.h
@@ -0,0 +1,41 @@
+#ifndef GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
+#define GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
+#include "Parameter.h"
+
+namespace graphics {
+
+ struct FramebufferTextureFormats
+ {
+ Parameter colorInternalFormat;
+ Parameter colorFormat;
+ Parameter colorType;
+ u32 colorFormatBytes;
+
+ Parameter monochromeInternalFormat;
+ Parameter monochromeFormat;
+ Parameter monochromeType;
+ u32 monochromeFormatBytes;
+
+ Parameter depthInternalFormat;
+ Parameter depthFormat;
+ Parameter depthType;
+ u32 depthFormatBytes;
+
+ Parameter depthImageInternalFormat;
+ Parameter depthImageFormat;
+ Parameter depthImageType;
+ u32 depthImageFormatBytes;
+
+ Parameter lutInternalFormat;
+ Parameter lutFormat;
+ Parameter lutType;
+ u32 lutFormatBytes;
+
+ virtual ~FramebufferTextureFormats() {}
+
+ protected:
+ virtual void init() = 0;
+ };
+
+}
+#endif // GRAPHICS_FRAMEBUFFER_TEXTUREFORMATS_H
diff --git a/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp b/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp
index 459ad4a7..ee02beaa 100644
--- a/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp
+++ b/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.cpp
@@ -1,3 +1,4 @@
+#include
#include
#include "opengl_GLInfo.h"
#include "opengl_CachedFunctions.h"
@@ -259,6 +260,135 @@ public:
}
};
+/*---------------FramebufferTextureFormats-------------*/
+
+struct FramebufferTextureFormatsGLES2 : public graphics::FramebufferTextureFormats
+{
+ static bool Check(const GLInfo & _glinfo) {
+ return _glinfo.isGLES2;
+ }
+
+ FramebufferTextureFormatsGLES2()
+ {
+ init();
+ }
+
+protected:
+ void init() override
+ {
+ monochromeInternalFormat = GL_RGB;
+ monochromeFormat = GL_RGB;
+ monochromeType = GL_UNSIGNED_SHORT_5_6_5;
+ monochromeFormatBytes = 2;
+
+#ifndef USE_DEPTH_RENDERBUFFER
+ depthInternalFormat = GL_DEPTH_COMPONENT;
+ depthFormatBytes = 4;
+#else
+ depthInternalFormat = GL_DEPTH_COMPONENT16;
+ depthFormatBytes = 2;
+#endif
+
+ depthFormat = GL_DEPTH_COMPONENT;
+ depthType = GL_UNSIGNED_INT;
+
+ if (Utils::isExtensionSupported("GL_OES_rgb8_rgba8")) {
+ colorInternalFormat = GL_RGBA;
+ colorFormat = GL_RGBA;
+ colorType = GL_UNSIGNED_BYTE;
+ colorFormatBytes = 4;
+ }
+ else {
+ colorInternalFormat = GL_RGB;
+ colorFormat = GL_RGB;
+ colorType = GL_UNSIGNED_SHORT_5_6_5;
+ colorFormatBytes = 2;
+ }
+ }
+};
+
+struct FramebufferTextureFormatsGLES3 : public graphics::FramebufferTextureFormats
+{
+ static bool Check(const GLInfo & _glinfo) {
+ return _glinfo.isGLESX && !_glinfo.isGLES2;
+ }
+
+ FramebufferTextureFormatsGLES3()
+ {
+ init();
+ }
+
+protected:
+ void init() override
+ {
+ colorInternalFormat = GL_RGBA8;
+ colorFormat = GL_RGBA;
+ colorType = GL_UNSIGNED_BYTE;
+ colorFormatBytes = 4;
+
+ monochromeInternalFormat = GL_R8;
+ monochromeFormat = GL_RED;
+ monochromeType = GL_UNSIGNED_BYTE;
+ monochromeFormatBytes = 1;
+
+ depthInternalFormat = GL_DEPTH_COMPONENT24;
+ depthFormat = GL_DEPTH_COMPONENT;
+ depthType = GL_UNSIGNED_INT;
+ depthFormatBytes = 4;
+
+ depthImageInternalFormat = GL_RGBA32F;
+ depthImageFormat = GL_RGBA;
+ depthImageType = GL_FLOAT;
+ depthImageFormatBytes = 16;
+
+ lutInternalFormat = GL_R32UI;
+ lutFormat = GL_RED_INTEGER;
+ lutType = GL_UNSIGNED_INT;
+ lutFormatBytes = 4;
+ }
+};
+
+struct FramebufferTextureFormatsOpenGL : public graphics::FramebufferTextureFormats
+{
+ static bool Check(const GLInfo & _glinfo) {
+ return !_glinfo.isGLESX;
+ }
+
+ FramebufferTextureFormatsOpenGL()
+ {
+ init();
+ }
+
+protected:
+ void init() override
+ {
+ colorInternalFormat = GL_RGBA;
+ colorFormat = GL_RGBA;
+ colorType = GL_UNSIGNED_BYTE;
+ colorFormatBytes = 4;
+
+ monochromeInternalFormat = GL_RED;
+ monochromeFormat = GL_RED;
+ monochromeType = GL_UNSIGNED_BYTE;
+ monochromeFormatBytes = 1;
+
+ depthInternalFormat = GL_DEPTH_COMPONENT;
+ depthFormat = GL_DEPTH_COMPONENT;
+ depthType = GL_FLOAT;
+ depthFormatBytes = 4;
+
+ depthImageInternalFormat = GL_RG32F;
+ depthImageFormat = GL_RG;
+ depthImageType = GL_FLOAT;
+ depthImageFormatBytes = 8;
+
+ lutInternalFormat = GL_R16;
+ lutFormat = GL_RED;
+ lutType = GL_UNSIGNED_SHORT;
+ lutFormatBytes = 2;
+ }
+};
+
/*---------------BufferManipulationObjectFactory-------------*/
BufferManipulationObjectFactory::BufferManipulationObjectFactory(const GLInfo & _info,
@@ -314,3 +444,18 @@ CreatePixelWriteBuffer * BufferManipulationObjectFactory::createPixelWriteBuffer
return new CreatePixelWriteBufferT(m_cachedFunctions.geCachedBindBuffer());
}
+
+graphics::FramebufferTextureFormats * BufferManipulationObjectFactory::getFramebufferTextureFormats() const
+{
+ if (FramebufferTextureFormatsOpenGL::Check(m_glInfo))
+ return new FramebufferTextureFormatsOpenGL;
+
+ if (FramebufferTextureFormatsGLES3::Check(m_glInfo))
+ return new FramebufferTextureFormatsGLES3;
+
+ if (FramebufferTextureFormatsGLES2::Check(m_glInfo))
+ return new FramebufferTextureFormatsGLES2;
+
+ assert(false);
+ return nullptr;
+}
diff --git a/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.h b/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.h
index 26e2b104..b371d696 100644
--- a/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.h
+++ b/src/Graphics/OpenGLContext/opengl_BufferManipulationObjectFactory.h
@@ -70,6 +70,8 @@ namespace opengl {
BlitFramebuffers * getBlitFramebuffers() const;
+ graphics::FramebufferTextureFormats * getFramebufferTextureFormats() const;
+
private:
const GLInfo & m_glInfo;
CachedFunctions & m_cachedFunctions;
diff --git a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp
index e8683396..cbfcdf7e 100644
--- a/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp
+++ b/src/Graphics/OpenGLContext/opengl_ContextImpl.cpp
@@ -37,6 +37,7 @@ void ContextImpl::init()
{
BufferManipulationObjectFactory bufferObjectFactory(m_glInfo, *m_cachedFunctions.get());
+ m_fbTexFormats.reset(bufferObjectFactory.getFramebufferTextureFormats());
m_createFramebuffer.reset(bufferObjectFactory.getCreateFramebufferObject());
m_createRenderbuffer.reset(bufferObjectFactory.getCreateRenderbuffer());
m_initRenderbuffer.reset(bufferObjectFactory.getInitRenderbuffer());
@@ -55,18 +56,18 @@ void ContextImpl::init()
void ContextImpl::destroy()
{
- m_cachedFunctions.reset(nullptr);
- m_createTexture.reset(nullptr);
- m_init2DTexture.reset(nullptr);
- m_set2DTextureParameters.reset(nullptr);
+ m_cachedFunctions.reset();
+ m_createTexture.reset();
+ m_init2DTexture.reset();
+ m_set2DTextureParameters.reset();
- m_createFramebuffer.reset(nullptr);
- m_createRenderbuffer.reset(nullptr);
- m_initRenderbuffer.reset(nullptr);
- m_addFramebufferRenderTarget.reset(nullptr);
+ m_createFramebuffer.reset();
+ m_createRenderbuffer.reset();
+ m_initRenderbuffer.reset();
+ m_addFramebufferRenderTarget.reset();
- m_combinerProgramBuilder.reset(nullptr);
+ m_combinerProgramBuilder.reset();
}
void ContextImpl::enable(graphics::Parameter _parameter, bool _enable)
@@ -168,6 +169,11 @@ void ContextImpl::setTextureParameters(const graphics::Context::TexParameters &
/*---------------Framebuffer-------------*/
+graphics::FramebufferTextureFormats * ContextImpl::getFramebufferTextureFormats()
+{
+ return m_fbTexFormats.release();
+}
+
graphics::ObjectHandle ContextImpl::createFramebuffer()
{
return m_createFramebuffer->createFramebuffer();
diff --git a/src/Graphics/OpenGLContext/opengl_ContextImpl.h b/src/Graphics/OpenGLContext/opengl_ContextImpl.h
index ec0d6927..896da6bc 100644
--- a/src/Graphics/OpenGLContext/opengl_ContextImpl.h
+++ b/src/Graphics/OpenGLContext/opengl_ContextImpl.h
@@ -58,6 +58,8 @@ namespace opengl {
/*---------------Framebuffer-------------*/
+ graphics::FramebufferTextureFormats * getFramebufferTextureFormats() override;
+
graphics::ObjectHandle createFramebuffer() override;
void deleteFramebuffer(graphics::ObjectHandle _name) override;
@@ -115,6 +117,7 @@ namespace opengl {
std::unique_ptr m_addFramebufferRenderTarget;
std::unique_ptr m_createPixelWriteBuffer;
std::unique_ptr m_blitFramebuffers;
+ std::unique_ptr m_fbTexFormats;
std::unique_ptr m_graphicsDrawer;
std::unique_ptr m_textDrawer;