diff --git a/src/BufferCopy/ColorBufferToRDRAM.cpp b/src/BufferCopy/ColorBufferToRDRAM.cpp index ce72c23f..532ad3db 100644 --- a/src/BufferCopy/ColorBufferToRDRAM.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM.cpp @@ -44,18 +44,21 @@ ColorBufferToRDRAM::~ColorBufferToRDRAM() void ColorBufferToRDRAM::init() { // generate a framebuffer - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glGenFramebuffers(1, &m_FBO); +// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +// glGenFramebuffers(1, &m_FBO); + m_FBO = gfxContext.createFramebuffer(); _init(); } void ColorBufferToRDRAM::destroy() { _destroyFBTexure(); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - if (m_FBO != 0) { - glDeleteFramebuffers(1, &m_FBO); - m_FBO = 0; + +// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + if (m_FBO.isNotNull()) { + gfxContext.deleteFramebuffer(m_FBO); +// glDeleteFramebuffers(1, &m_FBO); + m_FBO.reset(); } } @@ -109,7 +112,9 @@ void ColorBufferToRDRAM::_initFBTexture(void) // check if everything is OK assert(checkFBO()); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + + gfxContext.bindFramebuffer(graphics::bufferTarget::DRAW_FRAMEBUFFER, graphics::ObjectHandle()); + // glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); _initBuffers(); } diff --git a/src/BufferCopy/ColorBufferToRDRAM.h b/src/BufferCopy/ColorBufferToRDRAM.h index 1b65bea2..208251c7 100644 --- a/src/BufferCopy/ColorBufferToRDRAM.h +++ b/src/BufferCopy/ColorBufferToRDRAM.h @@ -4,6 +4,7 @@ #include #include #include +#include struct CachedTexture; struct FrameBuffer; @@ -25,13 +26,13 @@ protected: virtual ~ColorBufferToRDRAM(); CachedTexture * m_pTexture; - std::vector m_pixelData; + std::vector m_pixelData; private: virtual void _init() = 0; virtual void _initBuffers(void) = 0; virtual void _destroyBuffers(void) = 0; - virtual bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) = 0; + virtual bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) = 0; virtual void _cleanUp() = 0; union RGBA { @@ -56,7 +57,7 @@ private: static u16 _RGBAtoRGBA16(u32 _c); static u32 _RGBAtoRGBA32(u32 _c); - GLuint m_FBO; + graphics::ObjectHandle m_FBO; FrameBuffer * m_pCurFrameBuffer; u32 m_frameCount; u32 m_startAddress; diff --git a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp index a5ed7f6a..f1c7f72c 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.cpp @@ -52,7 +52,7 @@ void ColorBufferToRDRAM_BufferStorageExt::_destroyBuffers(void) m_PBO[index] = 0; } -bool ColorBufferToRDRAM_BufferStorageExt::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) +bool ColorBufferToRDRAM_BufferStorageExt::_readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) { const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); GLenum colorFormat, colorType, colorFormatBytes; diff --git a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.h b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.h index 3b6e97e1..419050df 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.h +++ b/src/BufferCopy/ColorBufferToRDRAM_BufferStorageExt.h @@ -10,7 +10,7 @@ public: ~ColorBufferToRDRAM_BufferStorageExt() = default; private: - bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) override; + bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) override; void _cleanUp() override; void _init(void) override; void _initBuffers(void) override; diff --git a/src/BufferCopy/ColorBufferToRDRAM_GL.cpp b/src/BufferCopy/ColorBufferToRDRAM_GL.cpp index b6b7280f..e1ae04fc 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_GL.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM_GL.cpp @@ -36,7 +36,7 @@ void ColorBufferToRDRAM_GL::_initBuffers(void) glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } -bool ColorBufferToRDRAM_GL::_readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) +bool ColorBufferToRDRAM_GL::_readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) { const graphics::FramebufferTextureFormats & fbTexFormat = gfxContext.getFramebufferTextureFormats(); GLenum colorFormat, colorType, colorFormatBytes; diff --git a/src/BufferCopy/ColorBufferToRDRAM_GL.h b/src/BufferCopy/ColorBufferToRDRAM_GL.h index 79113ca3..ab3e2db2 100644 --- a/src/BufferCopy/ColorBufferToRDRAM_GL.h +++ b/src/BufferCopy/ColorBufferToRDRAM_GL.h @@ -11,7 +11,7 @@ public: private: void _init() override; void _destroyBuffers() override; - bool _readPixels(GLint _x0, GLint _y0, GLsizei _width, GLsizei _height, u32 _size, bool _sync) override; + bool _readPixels(s32 _x0, s32 _y0, u32 _width, u32 _height, u32 _size, bool _sync) override; void _cleanUp() override; void _initBuffers(void) override; static const int _numPBO = 3;