From 9ff8f42d7f2d73d41a1ee1a2666090dcc7e2b64e Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 13 Oct 2009 22:19:31 +0000 Subject: [PATCH] Get the video display closer to working with W7's emulated OpenGL. It can now display video, but there are visible seams between the textures. Originally committed to SVN as r3711. --- aegisub/src/video_out_gl.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/aegisub/src/video_out_gl.cpp b/aegisub/src/video_out_gl.cpp index fd149b63a..ef64f42f0 100644 --- a/aegisub/src/video_out_gl.cpp +++ b/aegisub/src/video_out_gl.cpp @@ -116,10 +116,6 @@ void VideoOutGL::InitTextures(int width, int height, GLenum format, int bpp) { if (width == frameWidth && height == frameHeight && format == frameFormat) return; wxLogDebug("VideoOutGL::InitTextures: Video size: %dx%d\n", width, height); - frameWidth = width; - frameHeight = height; - frameFormat = format; - // If nessesary, detect what the user's OpenGL supports if (maxTextureSize == 0) { // Test for supported internalformats @@ -161,8 +157,8 @@ void VideoOutGL::InitTextures(int width, int height, GLenum format, int bpp) { int sourceH = maxTextureSize; // If the last row doesn't need a full texture, shrink it to the smallest one possible - if (i == textureRows - 1 && frameHeight % maxTextureSize > 0) { - sourceH = frameHeight % maxTextureSize; + if (i == textureRows - 1 && height % maxTextureSize > 0) { + sourceH = height % maxTextureSize; } for (int j = 0; j < textureCols; j++) { TextureInfo& ti = textureList[i * textureCols + j]; @@ -174,8 +170,8 @@ void VideoOutGL::InitTextures(int width, int height, GLenum format, int bpp) { ti.sourceW = maxTextureSize; // If the last column doesn't need a full texture, shrink it to the smallest one possible - if (j == textureCols - 1 && frameWidth % maxTextureSize > 0) { - ti.sourceW = frameWidth % maxTextureSize; + if (j == textureCols - 1 && width % maxTextureSize > 0) { + ti.sourceW = width % maxTextureSize; } int w = SmallestPowerOf2(ti.sourceW); @@ -186,11 +182,11 @@ void VideoOutGL::InitTextures(int width, int height, GLenum format, int bpp) { ti.texH = float(ti.sourceH) / h; // destW/H is the percent of the output which this texture covers - ti.destW = float(ti.sourceW) / frameWidth; - ti.destH = float(ti.sourceH) / frameHeight; + ti.destW = float(ti.sourceW) / width; + ti.destH = float(ti.sourceH) / height; ti.textureID = textureIdList[i * textureCols + j]; - ti.dataOffset = sourceY * frameWidth * bpp + sourceX * bpp; + ti.dataOffset = sourceY * width * bpp + sourceX * bpp; // Actually create the texture and set the scaling mode glBindTexture(GL_TEXTURE_2D, ti.textureID); @@ -202,17 +198,25 @@ void VideoOutGL::InitTextures(int width, int height, GLenum format, int bpp) { if (GLenum err = glGetError()) throw VideoOutOpenGLException(L"glTexParameteri(GL_TEXTURE_MIN_FILTER)", err); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (GLenum err = glGetError()) throw VideoOutOpenGLException(L"glTexParameteri(GL_TEXTURE_MAG_FILTER)", err); + + // GL_CLAMP_TO_EDGE was added in OpenGL 1.2, and W7's emulation only supports 1.1 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + if (glGetError()) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); if (GLenum err = glGetError()) throw VideoOutOpenGLException(L"glTexParameteri(GL_TEXTURE_WRAP_S)", err); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (glGetError()) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); if (GLenum err = glGetError()) throw VideoOutOpenGLException(L"glTexParameteri(GL_TEXTURE_WRAP_T)", err); destX += ti.destW; sourceX += ti.sourceW; } - destY += float(sourceH) / frameHeight; + destY += float(sourceH) / height; sourceY += sourceH; } + + frameWidth = width; + frameHeight = height; + frameFormat = format; } void VideoOutGL::DisplayFrame(AegiVideoFrame frame, int sw, int sh) {