From 2f2f0d9aac258fc843407c122e1438f40077f27e Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 13 Dec 2009 19:27:45 +0000 Subject: [PATCH] Fix some assorted VideoOutGL-related stupidity. Updates #1056. Originally committed to SVN as r3864. --- aegisub/src/video_display.cpp | 6 ++-- aegisub/src/video_out_gl.cpp | 68 ++++++++++++++++------------------- aegisub/src/video_out_gl.h | 5 ++- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 3bba27b74..859f589a0 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -217,14 +217,14 @@ void VideoDisplay::SetFrame(int frameNumber) { wxLogError( L"Failed to initialize video display. Closing other running programs and updating your video card drivers may fix this.\n" L"Error message reported: %s", - err.GetMessage()); + err.GetMessage().c_str()); context->Reset(); } catch (const VideoOutRenderException& err) { wxLogError( L"Could not upload video frame to graphics card.\n" L"Error message reported: %s", - err.GetMessage()); + err.GetMessage().c_str()); } } Render(); @@ -322,7 +322,7 @@ catch (const VideoOutException &err) { wxLogError( _T("An error occurred trying to render the video frame on the screen.\n") _T("Error message reported: %s"), - err.GetMessage()); + err.GetMessage().c_str()); VideoContext::Get()->Reset(); } catch (const wxChar *err) { diff --git a/aegisub/src/video_out_gl.cpp b/aegisub/src/video_out_gl.cpp index 094563b6a..e979a3af0 100644 --- a/aegisub/src/video_out_gl.cpp +++ b/aegisub/src/video_out_gl.cpp @@ -61,45 +61,41 @@ #define CHECK_INIT_ERROR(cmd) cmd; if (GLenum err = glGetError()) throw VideoOutInitException(_T(#cmd), err) #define CHECK_ERROR(cmd) cmd; if (GLenum err = glGetError()) throw VideoOutRenderException(_T(#cmd), err) -namespace { - /// @brief Structure tracking all precomputable information about a subtexture - struct TextureInfo { - /// The OpenGL texture id this is for - GLuint textureID; - /// The byte offset into the frame's data block - int dataOffset; - int sourceH; - int sourceW; +/// @brief Structure tracking all precomputable information about a subtexture +struct VideoOutGL::TextureInfo { + /// The OpenGL texture id this is for + GLuint textureID; + /// The byte offset into the frame's data block + int dataOffset; + int sourceH; + int sourceW; - int textureH; - int textureW; + int textureH; + int textureW; - float destH; - float destW; - float destX; - float destY; + float destH; + float destW; + float destX; + float destY; - float texTop; - float texBottom; - float texLeft; - float texRight; - }; - /// @brief Test if a texture can be created - /// @param width The width of the texture - /// @param height The height of the texture - /// @param format The texture's format - /// @return Whether the texture could be created. - bool TestTexture(int width, int height, GLint format) { - GLuint texture; - glGenTextures(1, &texture); - glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); - glDeleteTextures(1, &texture); - while (glGetError()) { } // Silently swallow all errors as we don't care why it failed if it did + float texTop; + float texBottom; + float texLeft; + float texRight; +}; - wxLogDebug("VideoOutGL::TestTexture: %dx%d\n", width, height); - return format != 0; - } +/// @brief Test if a texture can be created +/// @param width The width of the texture +/// @param height The height of the texture +/// @param format The texture's format +/// @return Whether the texture could be created. +static bool TestTexture(int width, int height, GLint format) { + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format); + while (glGetError()) { } // Silently swallow all errors as we don't care why it failed if it did + + wxLogDebug("VideoOutGL::TestTexture: %dx%d\n", width, height); + return format != 0; } VideoOutGL::VideoOutGL() @@ -136,8 +132,6 @@ void VideoOutGL::DetectOpenGLCapabilities() { supportsRectangularTextures = TestTexture(maxTextureSize, maxTextureSize >> 1, internalFormat); // Test GL_CLAMP_TO_EDGE support - GLuint texture; - glGenTextures(1, &texture); glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); if (glGetError()) { diff --git a/aegisub/src/video_out_gl.h b/aegisub/src/video_out_gl.h index d7b7c539c..ef3cf8bd5 100644 --- a/aegisub/src/video_out_gl.h +++ b/aegisub/src/video_out_gl.h @@ -41,14 +41,13 @@ #endif class AegiVideoFrame; -namespace { - struct TextureInfo; -} /// @class VideoOutGL /// @brief OpenGL based video renderer class VideoOutGL { private: + struct TextureInfo; + /// The maximum texture size supported by the user's graphics card int maxTextureSize; /// Whether rectangular textures are supported by the user's graphics card