From 2d7a99a3ae5c1d2a875137bb85ce17845c06bca4 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 13 Dec 2015 21:22:36 -0400 Subject: [PATCH] Set the internal wrap mode for videos to clamp. Fixes video playback on some OpenGL ES devices. --- src/modules/graphics/opengl/Video.cpp | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/modules/graphics/opengl/Video.cpp b/src/modules/graphics/opengl/Video.cpp index 4f33f4fb9..e552b804d 100644 --- a/src/modules/graphics/opengl/Video.cpp +++ b/src/modules/graphics/opengl/Video.cpp @@ -79,23 +79,23 @@ bool Video::loadVolatile() // Create the textures using the initial frame data. auto frame = (const love::video::VideoStream::Frame*) stream->getFrontBuffer(); - gl.bindTexture(textures[0]); - gl.setTextureFilter(filter); + int widths[3] = {frame->yw, frame->cw, frame->cw}; + int heights[3] = {frame->yh, frame->ch, frame->ch}; - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, frame->yw, frame->yh, - 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->yplane); + const unsigned char *data[3] = {frame->yplane, frame->cbplane, frame->crplane}; - gl.bindTexture(textures[1]); - gl.setTextureFilter(filter); + Texture::Wrap wrap; // Clamp wrap mode. - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, frame->cw, frame->ch, - 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->cbplane); + for (int i = 0; i < 3; i++) + { + gl.bindTexture(textures[i]); - gl.bindTexture(textures[2]); - gl.setTextureFilter(filter); + gl.setTextureFilter(filter); + gl.setTextureWrap(wrap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, frame->cw, frame->ch, - 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->crplane); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, widths[i], heights[i], 0, + GL_LUMINANCE, GL_UNSIGNED_BYTE, data[i]); + } return true; } @@ -154,17 +154,17 @@ void Video::update() { auto frame = (const love::video::VideoStream::Frame*) stream->getFrontBuffer(); - gl.bindTexture(textures[0]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->yw, frame->yh, - GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->yplane); + int widths[3] = {frame->yw, frame->cw, frame->cw}; + int heights[3] = {frame->yh, frame->ch, frame->ch}; - gl.bindTexture(textures[1]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->cw, frame->ch, - GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->cbplane); + const unsigned char *data[3] = {frame->yplane, frame->cbplane, frame->crplane}; - gl.bindTexture(textures[2]); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, frame->cw, frame->ch, - GL_LUMINANCE, GL_UNSIGNED_BYTE, frame->crplane); + for (int i = 0; i < 3; i++) + { + gl.bindTexture(textures[i]); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, widths[i], heights[i], + GL_LUMINANCE, GL_UNSIGNED_BYTE, data[i]); + } } }