OpenGL: Cleaner video output size changing
Vicki Pfau vi@endrift.com
Sun, 20 Aug 2017 23:08:35 -0700
8 files changed,
19 insertions(+),
19 deletions(-)
M
src/gb/core.c
→
src/gb/core.c
@@ -200,7 +200,7 @@ }
static void _GBCoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) { struct GB* gb = core->board; - if (!gb || gb->model != GB_MODEL_SGB || !gb->video.sgbBorders) { + if (gb && (gb->model != GB_MODEL_SGB || !gb->video.sgbBorders)) { *width = GB_VIDEO_HORIZONTAL_PIXELS; *height = GB_VIDEO_VERTICAL_PIXELS; } else {
M
src/platform/opengl/gl.c
→
src/platform/opengl/gl.c
@@ -110,12 +110,12 @@ struct mGLContext* context = (struct mGLContext*) v;
glBindTexture(GL_TEXTURE_2D, context->tex); #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, toPow2(v->width), v->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, v->width, v->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame); #else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, toPow2(v->width), v->height, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, v->width, v->height, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, frame); #endif #else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, toPow2(v->width), v->height, GL_RGBA, GL_UNSIGNED_BYTE, frame); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, v->width, v->height, GL_RGBA, GL_UNSIGNED_BYTE, frame); #endif }
M
src/platform/opengl/gles2.c
→
src/platform/opengl/gles2.c
@@ -318,7 +318,6 @@
void mGLES2ContextPostFrame(struct VideoBackend* v, const void* frame) { struct mGLES2Context* context = (struct mGLES2Context*) v; glBindTexture(GL_TEXTURE_2D, context->tex); - glPixelStorei(GL_UNPACK_ROW_LENGTH, toPow2(v->width)); #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, v->width, v->height, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, frame);
M
src/platform/qt/CoreController.cpp
→
src/platform/qt/CoreController.cpp
@@ -40,8 +40,8 @@ m_threadContext.core = core;
m_threadContext.userData = this; QSize size(256, 512); - m_buffers[0].resize(toPow2(size.width()) * size.height() * sizeof(color_t)); - m_buffers[1].resize(toPow2(size.width()) * size.height() * sizeof(color_t)); + m_buffers[0].resize(size.width() * size.height() * sizeof(color_t)); + m_buffers[1].resize(size.width() * size.height() * sizeof(color_t)); m_buffers[0].fill(0xFF); m_buffers[1].fill(0xFF); m_activeBuffer = &m_buffers[0];@@ -86,13 +86,13 @@
controller->m_resetActions.clear(); QSize size = controller->screenDimensions(); - controller->m_buffers[0].resize(toPow2(size.width()) * size.height() * sizeof(color_t)); - controller->m_buffers[1].resize(toPow2(size.width()) * size.height() * sizeof(color_t)); + controller->m_buffers[0].resize(size.width() * size.height() * sizeof(color_t)); + controller->m_buffers[1].resize(size.width() * size.height() * sizeof(color_t)); controller->m_buffers[0].fill(0xFF); controller->m_buffers[1].fill(0xFF); controller->m_activeBuffer = &controller->m_buffers[0]; - context->core->setVideoBuffer(context->core, reinterpret_cast<color_t*>(controller->m_activeBuffer->data()), toPow2(size.width())); + context->core->setVideoBuffer(context->core, reinterpret_cast<color_t*>(controller->m_activeBuffer->data()), size.width()); controller->finishFrame(); };@@ -736,7 +736,7 @@ m_activeBuffer = &m_buffers[0];
if (m_activeBuffer == m_completeBuffer) { m_activeBuffer = &m_buffers[1]; } - m_threadContext.core->setVideoBuffer(m_threadContext.core, reinterpret_cast<color_t*>(m_activeBuffer->data()), toPow2(screenDimensions().width())); + m_threadContext.core->setVideoBuffer(m_threadContext.core, reinterpret_cast<color_t*>(m_activeBuffer->data()), screenDimensions().width()); for (auto& action : m_frameActions) { action();
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -391,7 +391,7 @@ } else {
buffer = m_free.takeLast(); } QSize size = m_context->screenDimensions(); - memcpy(buffer, backing, toPow2(size.width()) * size.height() * BYTES_PER_PIXEL); + memcpy(buffer, backing, size.width() * size.height() * BYTES_PER_PIXEL); m_queue.enqueue(buffer); m_mutex.unlock(); }
M
src/platform/qt/DisplayQt.cpp
→
src/platform/qt/DisplayQt.cpp
@@ -57,12 +57,12 @@ return;
} #ifdef COLOR_16_BIT #ifdef COLOR_5_6_5 - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), toPow2(m_width), m_height, QImage::Format_RGB16); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_RGB16); #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), toPow2(m_width), m_height, QImage::Format_RGB555); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_RGB555); #endif #else - m_backing = QImage(reinterpret_cast<const uchar*>(buffer), toPow2(m_width), m_height, QImage::Format_ARGB32); + m_backing = QImage(reinterpret_cast<const uchar*>(buffer), m_width, m_height, QImage::Format_ARGB32); m_backing = m_backing.convertToFormat(QImage::Format_RGB32); #endif }
M
src/platform/sdl/gl-sdl.c
→
src/platform/sdl/gl-sdl.c
@@ -33,10 +33,10 @@
bool mSDLGLInit(struct mSDLRenderer* renderer) { mSDLGLCommonInit(renderer); - size_t size = toPow2(renderer->width) * toPow2(renderer->height) * BYTES_PER_PIXEL; + size_t size = renderer->width * renderer->height * BYTES_PER_PIXEL; renderer->outputBuffer = malloc(size); memset(renderer->outputBuffer, 0, size); - renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, toPow2(renderer->width)); + renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width); mGLContextCreate(&renderer->gl); renderer->gl.d.user = renderer;@@ -69,6 +69,7 @@ }
#endif } if (renderer->width != v->width || renderer->height != v->height) { + renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width); v->setDimensions(v, renderer->width, renderer->height); }
M
src/platform/sdl/gles2-sdl.c
→
src/platform/sdl/gles2-sdl.c
@@ -98,14 +98,14 @@ #else
mSDLGLCommonInit(renderer); #endif - size_t size = toPow2(renderer->width) * toPow2(renderer->height) * BYTES_PER_PIXEL; + size_t size = renderer->width * renderer->height * BYTES_PER_PIXEL; #ifndef __APPLE__ renderer->outputBuffer = memalign(16, size); #else posix_memalign((void**) &renderer->outputBuffer, 16, size); #endif memset(renderer->outputBuffer, 0, size); - renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, toPow2(renderer->width)); + renderer->core->setVideoBuffer(renderer->core, renderer->outputBuffer, renderer->width); mGLES2ContextCreate(&renderer->gl2); renderer->gl2.d.user = renderer;