From 99e9dce99faabd9d3b09c6ef6d4766cd254b556e Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 22 Jan 2007 22:57:45 +0000 Subject: [PATCH] Made a million changes to GL mode, and one of them seems to have fixed video display on ATI cards. Originally committed to SVN as r879. --- aegisub/video_context.cpp | 18 +++++++++++++++--- aegisub/video_display.cpp | 23 +++++++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index 149fbd52a..2339fde76 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -37,6 +37,8 @@ //////////// // Includes #include "setup.h" +#include +#include #include #include #include @@ -376,7 +378,7 @@ wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) { // Get GL Texture of frame GLuint VideoContext::GetFrameAsTexture(int n) { // Already uploaded - if (n == lastFrame) return lastTex; + if (n == lastFrame || n == -1) return lastTex; // Get frame AegiVideoFrame frame = GetFrame(n); @@ -414,6 +416,12 @@ GLuint VideoContext::GetFrameAsTexture(int n) { glBindTexture(GL_TEXTURE_2D, lastTex); if (glGetError() != 0) throw _T("Error binding texture."); + // Texture parameters + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + // Load image data into texture int height = frame.h; if (frame.format == FORMAT_YV12) height = frame.h * 3 / 2; @@ -421,12 +429,16 @@ GLuint VideoContext::GetFrameAsTexture(int n) { int th = SmallestPowerOf2(frame.h); texW = float(frame.w)/float(tw); texH = float(frame.h)/float(th); - glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,tw,th,0,format,GL_UNSIGNED_BYTE,NULL); + glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,tw,th,0,format,GL_UNSIGNED_BYTE,NULL); if (glGetError() != 0) throw _T("Error allocating texture."); // Set texture - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); if (glGetError() != 0) throw _T("Error setting hinting."); + + // Set priority + float priority = 1.0f; + glPrioritizeTextures(1,&lastTex,&priority); } // Load texture data diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index a28bdb7fd..a5ae5ffc4 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -37,12 +37,13 @@ //////////// // Includes #include "setup.h" +#include +#include #include #include #include #include #include -#include #include "utils.h" #include "video_display.h" #include "video_display_visual.h" @@ -88,10 +89,14 @@ BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas) END_EVENT_TABLE() +////////////// +// Parameters +int attribList[2] = { WX_GL_RGBA , 0 }; + /////////////// // Constructor VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) -: wxGLCanvas (parent, id, NULL, pos, size, style, name) +: wxGLCanvas (parent, id, attribList, pos, size, style, name) { // Set options ControlSlider = NULL; @@ -169,20 +174,21 @@ void VideoDisplay::Render() { // Draw interleaved frame or luma of YV12 glDisable(GL_BLEND); + glBindTexture(GL_TEXTURE_2D, VideoContext::Get()->GetFrameAsTexture(-1)); glColor4f(1.0f,1.0f,1.0f,1.0f); glBegin(GL_QUADS); // Top-left glTexCoord2f(left,top); glVertex2f(0,0); - // Top-right - glTexCoord2f(right,top); - glVertex2f(sw,0); - // Bottom-right - glTexCoord2f(right,bot); - glVertex2f(sw,sh); // Bottom-left glTexCoord2f(left,bot); glVertex2f(0,sh); + // Bottom-right + glTexCoord2f(right,bot); + glVertex2f(sw,sh); + // Top-right + glTexCoord2f(right,top); + glVertex2f(sw,0); glEnd(); // Draw UV planes @@ -194,6 +200,7 @@ void VideoDisplay::Render() { visual->DrawOverlay(); // Swap buffers + glFinish(); SwapBuffers(); }