Made video context respect the setting of "video use pixel shaders", which was being ignored by ffmpeg, since it can only output yv12.

Originally committed to SVN as r975.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-01 23:27:22 +00:00
parent bef344645b
commit 6b26ebd99b
2 changed files with 12 additions and 1 deletions

View File

@ -293,6 +293,7 @@ void OpenGLWrapper::Initialize() {
initialized = true;
glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) glGetProc("glUseProgramObjectARB");
if (!glUseProgramObjectARB) throw _T("OpenGL shader support not available.");
glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) glGetProc("glDeleteObjectARB");
glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) glGetProc("glCreateProgramObjectARB");
glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) glGetProc("glAttachObjectARB");
@ -330,13 +331,17 @@ GLuint OpenGLWrapper::CreateShaderProgram(GLuint vertex,GLuint pixel) {
// Create instance
Initialize();
GLuint program = glCreateProgramObjectARB();
if (glGetError()) throw _T("Error creating shader program.");
// Attach shaders
glAttachObjectARB(program,vertex);
if (glGetError()) throw _T("Error attaching vertex shader to shader program.");
glAttachObjectARB(program,pixel);
if (glGetError()) throw _T("Error attaching pixel shader to shader program.");
// Link
glLinkProgramARB(program);
if (glGetError()) throw _T("Error attaching linking shader program.");
// Return
return program;
@ -349,6 +354,7 @@ GLuint OpenGLWrapper::CreateStandardVertexShader() {
// Create instance
Initialize();
GLuint shader = glCreateShaderObjectARB(GL_VERTEX_SHADER);
if (glGetError()) throw _T("Error generating vertex shader.");
// Read source
char source[] =
@ -360,7 +366,9 @@ GLuint OpenGLWrapper::CreateStandardVertexShader() {
// Compile
const GLchar *src = source;
glShaderSourceARB(shader,1,&src,NULL);
if (glGetError()) throw _T("Error acquiring source for vertex shader.");
glCompileShaderARB(shader);
if (glGetError()) throw _T("Error compiling vertex shader.");
// Return
return shader;
@ -373,6 +381,7 @@ GLuint OpenGLWrapper::CreateYV12PixelShader() {
// Create instance
Initialize();
GLuint shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
if (glGetError()) throw _T("Error generating pixel shader.");
// Read source
char source[] =
@ -399,7 +408,9 @@ GLuint OpenGLWrapper::CreateYV12PixelShader() {
// Compile
const GLchar *src = source;
glShaderSourceARB(shader,1,&src,NULL);
if (glGetError()) throw _T("Error acquiring source for vertex shader.");
glCompileShaderARB(shader);
if (glGetError()) throw _T("Error compiling vertex shader.");
// Return
return shader;

View File

@ -480,7 +480,7 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
glPrioritizeTextures(1,&lastTex,&priority);
// Create shader if necessary
if (frame.format == FORMAT_YV12 && yv12shader == 0) {
if (frame.format == FORMAT_YV12 && yv12shader == 0 && OpenGLWrapper::UseShaders()) {
yv12shader = OpenGLWrapper::CreateYV12Shader(texW,texH,float(frame.pitch[1])/float(tw));
}
}