From fbae2ba72b4d0b34c69d71e98208acd04c639fb5 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 5 Jun 2006 11:45:33 +0000 Subject: [PATCH] Move/add checks to avoid crashes and make error messages less confusing git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18580 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/gl_common.c | 22 +++++++++++----------- libvo/vo_gl.c | 4 ++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 29da053578..25cb11e96a 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -513,6 +513,11 @@ static void glSetupYUVCombiners(float uvcos, float uvsin) { GLfloat ucoef[4]; GLfloat vcoef[4]; GLint i; + if (!CombinerInput || !CombinerOutput || + !CombinerParameterfv || !CombinerParameteri) { + mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Combiner functions missing!\n"); + return; + } glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV, &i); if (i < 2) mp_msg(MSGT_VO, MSGL_ERR, @@ -521,11 +526,6 @@ static void glSetupYUVCombiners(float uvcos, float uvsin) { if (i < 3) mp_msg(MSGT_VO, MSGL_ERR, "[gl] 3 texture units needed for YUV combiner support (found %i)\n", i); - if (!CombinerInput || !CombinerOutput || - !CombinerParameterfv || !CombinerParameteri) { - mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Combiner functions missing!\n"); - return; - } fillUVcoeff(ucoef, vcoef, uvcos, uvsin); CombinerParameterfv(GL_CONSTANT_COLOR0_NV, ucoef); CombinerParameterfv(GL_CONSTANT_COLOR1_NV, vcoef); @@ -572,6 +572,12 @@ static void glSetupYUVCombinersATI(float uvcos, float uvsin) { GLfloat ucoef[4]; GLfloat vcoef[4]; GLint i; + if (!BeginFragmentShader || !EndFragmentShader || + !SetFragmentShaderConstant || !SampleMap || + !ColorFragmentOp2 || !ColorFragmentOp3) { + mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Combiner (ATI) functions missing!\n"); + return; + } glGetIntegerv(GL_NUM_FRAGMENT_REGISTERS_ATI, &i); if (i < 3) mp_msg(MSGT_VO, MSGL_ERR, @@ -580,12 +586,6 @@ static void glSetupYUVCombinersATI(float uvcos, float uvsin) { if (i < 3) mp_msg(MSGT_VO, MSGL_ERR, "[gl] 3 texture units needed for YUV combiner (ATI) support (found %i)\n", i); - if (!BeginFragmentShader || !EndFragmentShader || - !SetFragmentShaderConstant || !SampleMap || - !ColorFragmentOp2 || !ColorFragmentOp3) { - mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Combiner (ATI) functions missing!\n"); - return; - } fillUVcoeff(ucoef, vcoef, uvcos, uvsin); BeginFragmentShader(); SetFragmentShaderConstant(GL_CON_0_ATI, ucoef); diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index d026d9deb7..bcb65737b0 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -274,6 +274,10 @@ static int initGl(uint32_t d_width, uint32_t d_height) { glBindTexture(GL_TEXTURE_2D, lookupTex); case YUV_CONVERSION_FRAGMENT_POW: case YUV_CONVERSION_FRAGMENT: + if (!GenPrograms || !BindProgram) { + mp_msg(MSGT_VO, MSGL_ERR, "[gl] fragment program functions missing!\n"); + break; + } GenPrograms(1, &fragprog); BindProgram(GL_FRAGMENT_PROGRAM, fragprog); break;