Fix some assorted VideoOutGL-related stupidity. Updates #1056.

Originally committed to SVN as r3864.
This commit is contained in:
Thomas Goyne 2009-12-13 19:27:45 +00:00
parent fedd8ecce6
commit 2f2f0d9aac
3 changed files with 36 additions and 43 deletions

View file

@ -217,14 +217,14 @@ void VideoDisplay::SetFrame(int frameNumber) {
wxLogError( wxLogError(
L"Failed to initialize video display. Closing other running programs and updating your video card drivers may fix this.\n" 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", L"Error message reported: %s",
err.GetMessage()); err.GetMessage().c_str());
context->Reset(); context->Reset();
} }
catch (const VideoOutRenderException& err) { catch (const VideoOutRenderException& err) {
wxLogError( wxLogError(
L"Could not upload video frame to graphics card.\n" L"Could not upload video frame to graphics card.\n"
L"Error message reported: %s", L"Error message reported: %s",
err.GetMessage()); err.GetMessage().c_str());
} }
} }
Render(); Render();
@ -322,7 +322,7 @@ catch (const VideoOutException &err) {
wxLogError( wxLogError(
_T("An error occurred trying to render the video frame on the screen.\n") _T("An error occurred trying to render the video frame on the screen.\n")
_T("Error message reported: %s"), _T("Error message reported: %s"),
err.GetMessage()); err.GetMessage().c_str());
VideoContext::Get()->Reset(); VideoContext::Get()->Reset();
} }
catch (const wxChar *err) { catch (const wxChar *err) {

View file

@ -61,45 +61,41 @@
#define CHECK_INIT_ERROR(cmd) cmd; if (GLenum err = glGetError()) throw VideoOutInitException(_T(#cmd), err) #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) #define CHECK_ERROR(cmd) cmd; if (GLenum err = glGetError()) throw VideoOutRenderException(_T(#cmd), err)
namespace { /// @brief Structure tracking all precomputable information about a subtexture
/// @brief Structure tracking all precomputable information about a subtexture struct VideoOutGL::TextureInfo {
struct TextureInfo { /// The OpenGL texture id this is for
/// The OpenGL texture id this is for GLuint textureID;
GLuint textureID; /// The byte offset into the frame's data block
/// The byte offset into the frame's data block int dataOffset;
int dataOffset; int sourceH;
int sourceH; int sourceW;
int sourceW;
int textureH; int textureH;
int textureW; int textureW;
float destH; float destH;
float destW; float destW;
float destX; float destX;
float destY; float destY;
float texTop; float texTop;
float texBottom; float texBottom;
float texLeft; float texLeft;
float texRight; 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
wxLogDebug("VideoOutGL::TestTexture: %dx%d\n", width, height); /// @brief Test if a texture can be created
return format != 0; /// @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() VideoOutGL::VideoOutGL()
@ -136,8 +132,6 @@ void VideoOutGL::DetectOpenGLCapabilities() {
supportsRectangularTextures = TestTexture(maxTextureSize, maxTextureSize >> 1, internalFormat); supportsRectangularTextures = TestTexture(maxTextureSize, maxTextureSize >> 1, internalFormat);
// Test GL_CLAMP_TO_EDGE support // 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); 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); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
if (glGetError()) { if (glGetError()) {

View file

@ -41,14 +41,13 @@
#endif #endif
class AegiVideoFrame; class AegiVideoFrame;
namespace {
struct TextureInfo;
}
/// @class VideoOutGL /// @class VideoOutGL
/// @brief OpenGL based video renderer /// @brief OpenGL based video renderer
class VideoOutGL { class VideoOutGL {
private: private:
struct TextureInfo;
/// The maximum texture size supported by the user's graphics card /// The maximum texture size supported by the user's graphics card
int maxTextureSize; int maxTextureSize;
/// Whether rectangular textures are supported by the user's graphics card /// Whether rectangular textures are supported by the user's graphics card