OpenGL: Make all buffers expected to be the right width
Jeffrey Pfau jeffrey@endrift.com
Sat, 16 Jan 2016 02:29:03 -0800
7 files changed,
15 insertions(+),
16 deletions(-)
M
src/platform/opengl/gl.c
→
src/platform/opengl/gl.c
@@ -99,12 +99,12 @@ struct GBAGLContext* context = (struct GBAGLContext*) v;
glBindTexture(GL_TEXTURE_2D, context->tex); #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame); #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, frame); #endif #else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, GL_RGBA, GL_UNSIGNED_BYTE, frame); #endif }
M
src/platform/opengl/gles2.c
→
src/platform/opengl/gles2.c
@@ -278,7 +278,6 @@
void GBAGLES2ContextPostFrame(struct VideoBackend* v, const void* frame) { struct GBAGLES2Context* context = (struct GBAGLES2Context*) v; glBindTexture(GL_TEXTURE_2D, context->tex); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 256); #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame);
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -366,7 +366,7 @@ buffer = m_queue.dequeue();
} else { buffer = m_free.takeLast(); } - memcpy(buffer, backing, 256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); + memcpy(buffer, backing, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); m_queue.enqueue(buffer); m_mutex.unlock(); }
M
src/platform/qt/DisplayQt.cpp
→
src/platform/qt/DisplayQt.cpp
@@ -41,12 +41,12 @@ return;
} #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), 256, 256, QImage::Format_RGB16); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB16); #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), 256, 256, QImage::Format_RGB555); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB555); #endif #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), 256, 256, QImage::Format_RGB32); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, QImage::Format_RGB32); #endif }
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -32,8 +32,8 @@ using namespace std;
GameController::GameController(QObject* parent) : QObject(parent) - , m_drawContext(new uint32_t[256 * VIDEO_HORIZONTAL_PIXELS]) - , m_frontBuffer(new uint32_t[256 * 256]) + , m_drawContext(new uint32_t[VIDEO_VERTICAL_PIXELS * VIDEO_HORIZONTAL_PIXELS]) + , m_frontBuffer(new uint32_t[VIDEO_VERTICAL_PIXELS * VIDEO_HORIZONTAL_PIXELS]) , m_threadContext() , m_activeKeys(0) , m_inactiveKeys(0)@@ -62,7 +62,7 @@ {
m_renderer = new GBAVideoSoftwareRenderer; GBAVideoSoftwareRendererCreate(m_renderer); m_renderer->outputBuffer = (color_t*) m_drawContext; - m_renderer->outputBufferStride = 256; + m_renderer->outputBufferStride = VIDEO_HORIZONTAL_PIXELS; GBACheatDeviceCreate(&m_cheatDevice);@@ -127,7 +127,7 @@ };
m_threadContext.frameCallback = [](GBAThread* context) { GameController* controller = static_cast<GameController*>(context->userData); - memcpy(controller->m_frontBuffer, controller->m_drawContext, 256 * VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); + memcpy(controller->m_frontBuffer, controller->m_drawContext, VIDEO_VERTICAL_PIXELS * VIDEO_HORIZONTAL_PIXELS * BYTES_PER_PIXEL); QMetaObject::invokeMethod(controller, "frameAvailable", Q_ARG(const uint32_t*, controller->m_frontBuffer)); if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) { GBAThreadPauseFromThread(context);
M
src/platform/sdl/gl-sdl.c
→
src/platform/sdl/gl-sdl.c
@@ -30,8 +30,8 @@
bool GBASDLGLInit(struct SDLSoftwareRenderer* renderer) { GBASDLGLCommonInit(renderer); - renderer->d.outputBuffer = malloc(256 * 256 * BYTES_PER_PIXEL); - renderer->d.outputBufferStride = 256; + renderer->d.outputBuffer = malloc(VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); + renderer->d.outputBufferStride = VIDEO_HORIZONTAL_PIXELS; GBAGLContextCreate(&renderer->gl); renderer->gl.d.user = renderer;
M
src/platform/sdl/gles2-sdl.c
→
src/platform/sdl/gles2-sdl.c
@@ -93,8 +93,8 @@ #else
GBASDLGLCommonInit(renderer); #endif - renderer->d.outputBuffer = memalign(16, 256 * 256 * 4); - renderer->d.outputBufferStride = 256; + renderer->d.outputBuffer = memalign(16, VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4); + renderer->d.outputBufferStride = VIDEO_HORIZONTAL_PIXELS; GBAGLES2ContextCreate(&renderer->gl2); renderer->gl2.d.user = renderer;