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.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-22 22:57:45 +00:00
parent 563ba5ae76
commit 99e9dce99f
2 changed files with 30 additions and 11 deletions

View File

@ -37,6 +37,8 @@
//////////// ////////////
// Includes // Includes
#include "setup.h" #include "setup.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <wx/image.h> #include <wx/image.h>
#include <string.h> #include <string.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
@ -376,7 +378,7 @@ wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) {
// Get GL Texture of frame // Get GL Texture of frame
GLuint VideoContext::GetFrameAsTexture(int n) { GLuint VideoContext::GetFrameAsTexture(int n) {
// Already uploaded // Already uploaded
if (n == lastFrame) return lastTex; if (n == lastFrame || n == -1) return lastTex;
// Get frame // Get frame
AegiVideoFrame frame = GetFrame(n); AegiVideoFrame frame = GetFrame(n);
@ -414,6 +416,12 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
glBindTexture(GL_TEXTURE_2D, lastTex); glBindTexture(GL_TEXTURE_2D, lastTex);
if (glGetError() != 0) throw _T("Error binding texture."); 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 // Load image data into texture
int height = frame.h; int height = frame.h;
if (frame.format == FORMAT_YV12) height = frame.h * 3 / 2; if (frame.format == FORMAT_YV12) height = frame.h * 3 / 2;
@ -421,12 +429,16 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
int th = SmallestPowerOf2(frame.h); int th = SmallestPowerOf2(frame.h);
texW = float(frame.w)/float(tw); texW = float(frame.w)/float(tw);
texH = float(frame.h)/float(th); 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."); if (glGetError() != 0) throw _T("Error allocating texture.");
// Set 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."); if (glGetError() != 0) throw _T("Error setting hinting.");
// Set priority
float priority = 1.0f;
glPrioritizeTextures(1,&lastTex,&priority);
} }
// Load texture data // Load texture data

View File

@ -37,12 +37,13 @@
//////////// ////////////
// Includes // Includes
#include "setup.h" #include "setup.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <wx/image.h> #include <wx/image.h>
#include <string.h> #include <string.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/config.h> #include <wx/config.h>
#include <GL/glu.h>
#include "utils.h" #include "utils.h"
#include "video_display.h" #include "video_display.h"
#include "video_display_visual.h" #include "video_display_visual.h"
@ -88,10 +89,14 @@ BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
END_EVENT_TABLE() END_EVENT_TABLE()
//////////////
// Parameters
int attribList[2] = { WX_GL_RGBA , 0 };
/////////////// ///////////////
// Constructor // Constructor
VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) 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 // Set options
ControlSlider = NULL; ControlSlider = NULL;
@ -169,20 +174,21 @@ void VideoDisplay::Render() {
// Draw interleaved frame or luma of YV12 // Draw interleaved frame or luma of YV12
glDisable(GL_BLEND); glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, VideoContext::Get()->GetFrameAsTexture(-1));
glColor4f(1.0f,1.0f,1.0f,1.0f); glColor4f(1.0f,1.0f,1.0f,1.0f);
glBegin(GL_QUADS); glBegin(GL_QUADS);
// Top-left // Top-left
glTexCoord2f(left,top); glTexCoord2f(left,top);
glVertex2f(0,0); glVertex2f(0,0);
// Top-right
glTexCoord2f(right,top);
glVertex2f(sw,0);
// Bottom-right
glTexCoord2f(right,bot);
glVertex2f(sw,sh);
// Bottom-left // Bottom-left
glTexCoord2f(left,bot); glTexCoord2f(left,bot);
glVertex2f(0,sh); glVertex2f(0,sh);
// Bottom-right
glTexCoord2f(right,bot);
glVertex2f(sw,sh);
// Top-right
glTexCoord2f(right,top);
glVertex2f(sw,0);
glEnd(); glEnd();
// Draw UV planes // Draw UV planes
@ -194,6 +200,7 @@ void VideoDisplay::Render() {
visual->DrawOverlay(); visual->DrawOverlay();
// Swap buffers // Swap buffers
glFinish();
SwapBuffers(); SwapBuffers();
} }