diff options
author | Andre Susano Pinto <andresusanopinto@gmail.com> | 2008-06-21 01:36:15 +0400 |
---|---|---|
committer | Andre Susano Pinto <andresusanopinto@gmail.com> | 2008-06-21 01:36:15 +0400 |
commit | ffbe42129e0d043214daf9b07125d9d8140d1c74 (patch) | |
tree | 6c99776cfcfadd32347eacb287c69deaa1b35651 /source/gameengine/Ketsji/BL_Shader.cpp | |
parent | 824eac5095924ffdc1fea213a925054c88bf05d7 (diff) |
svn merge -r 15202:15292 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/gameengine/Ketsji/BL_Shader.cpp')
-rw-r--r-- | source/gameengine/Ketsji/BL_Shader.cpp | 306 |
1 files changed, 119 insertions, 187 deletions
diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 105a87e767b..15350db6650 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -1,21 +1,5 @@ - -#ifdef WIN32 -#include <windows.h> -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include <OpenGL/gl.h> -#include <OpenGL/glu.h> -#else -#include <GL/gl.h> -/* #if defined(__sun__) && !defined(__sparc__) -#include <mesa/glu.h> -#else -*/ -#include <GL/glu.h> -/* #endif */ -#endif +#include "GL/glew.h" #include <iostream> #include "BL_Shader.h" @@ -31,7 +15,6 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -//using namespace bgl; #define spit(x) std::cout << x << std::endl; #define SORT_UNIFORMS 1 @@ -46,7 +29,7 @@ BL_Uniform::BL_Uniform(int data_size) mDataLen(data_size) { #ifdef SORT_UNIFORMS - MT_assert(mDataLen <= UNIFORM_MAX_LEN); + MT_assert((int)mDataLen <= UNIFORM_MAX_LEN); mData = (void*)MEM_mallocN(mDataLen, "shader-uniform-alloc"); #endif } @@ -63,7 +46,6 @@ BL_Uniform::~BL_Uniform() void BL_Uniform::Apply(class BL_Shader *shader) { -#ifdef GL_ARB_shader_objects #ifdef SORT_UNIFORMS MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData); @@ -74,48 +56,47 @@ void BL_Uniform::Apply(class BL_Shader *shader) { case UNI_FLOAT: { float *f = (float*)mData; - bgl::blUniform1fARB(mLoc,(GLfloat)*f); + glUniform1fARB(mLoc,(GLfloat)*f); }break; case UNI_INT: { int *f = (int*)mData; - bgl::blUniform1iARB(mLoc, (GLint)*f); + glUniform1iARB(mLoc, (GLint)*f); }break; case UNI_FLOAT2: { float *f = (float*)mData; - bgl::blUniform2fvARB(mLoc,1, (GLfloat*)f); + glUniform2fvARB(mLoc,1, (GLfloat*)f); }break; case UNI_FLOAT3: { float *f = (float*)mData; - bgl::blUniform3fvARB(mLoc,1,(GLfloat*)f); + glUniform3fvARB(mLoc,1,(GLfloat*)f); }break; case UNI_FLOAT4: { float *f = (float*)mData; - bgl::blUniform4fvARB(mLoc,1,(GLfloat*)f); + glUniform4fvARB(mLoc,1,(GLfloat*)f); }break; case UNI_INT2: { int *f = (int*)mData; - bgl::blUniform2ivARB(mLoc,1,(GLint*)f); + glUniform2ivARB(mLoc,1,(GLint*)f); }break; case UNI_INT3: { int *f = (int*)mData; - bgl::blUniform3ivARB(mLoc,1,(GLint*)f); + glUniform3ivARB(mLoc,1,(GLint*)f); }break; case UNI_INT4: { int *f = (int*)mData; - bgl::blUniform4ivARB(mLoc,1,(GLint*)f); + glUniform4ivARB(mLoc,1,(GLint*)f); }break; case UNI_MAT4: { float *f = (float*)mData; - bgl::blUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); + glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); }break; case UNI_MAT3: { float *f = (float*)mData; - bgl::blUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); + glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); }break; } mDirty = false; #endif -#endif } void BL_Uniform::SetData(int location, int type,bool transpose) @@ -144,17 +125,14 @@ BL_Shader::BL_Shader(PyTypeObject *T) mError(0), mDirty(true) { - // if !RAS_EXT_support._ARB_shader_objects this class will not be used + // if !GLEW_ARB_shader_objects this class will not be used //for (int i=0; i<MAXTEX; i++) { // mSampler[i] = BL_Sampler(); //} } -using namespace bgl; - BL_Shader::~BL_Shader() { -#ifdef GL_ARB_shader_objects //for (int i=0; i<MAXTEX; i++){ // if(mSampler[i].mOwn) { // if(mSampler[i].mTexture) @@ -164,14 +142,13 @@ BL_Shader::~BL_Shader() ClearUniforms(); if( mShader ) { - bgl::blDeleteObjectARB(mShader); + glDeleteObjectARB(mShader); mShader = 0; } vertProg = 0; fragProg = 0; mOk = 0; - bgl::blUseProgramObjectARB(0); -#endif//GL_ARB_shader_objects + glUseProgramObjectARB(0); } void BL_Shader::ClearUniforms() @@ -266,8 +243,6 @@ void BL_Shader::UnloadShader() bool BL_Shader::LinkProgram() { -#ifdef GL_ARB_shader_objects - int vertlen = 0, fraglen=0, proglen=0; int vertstatus=0, fragstatus=0, progstatus=0; unsigned int tmpVert=0, tmpFrag=0, tmpProg=0; @@ -281,25 +256,25 @@ bool BL_Shader::LinkProgram() spit("Invalid GLSL sources"); return false; } - if( !RAS_EXT_support._ARB_fragment_shader) { + if( !GLEW_ARB_fragment_shader) { spit("Fragment shaders not supported"); return false; } - if( !RAS_EXT_support._ARB_vertex_shader) { + if( !GLEW_ARB_vertex_shader) { spit("Vertex shaders not supported"); return false; } // -- vertex shader ------------------ - tmpVert = bgl::blCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); - bgl::blShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0); - bgl::blCompileShaderARB(tmpVert); - bgl::blGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*) &vertlen); + tmpVert = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + glShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0); + glCompileShaderARB(tmpVert); + glGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*) &vertlen); // print info if any if( vertlen > 0 && vertlen < MAX_LOG_LEN){ logInf = (char*)MEM_mallocN(vertlen, "vert-log"); - bgl::blGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf); + glGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf); if(char_len >0) { spit("---- Vertex Shader Error ----"); spit(logInf); @@ -308,20 +283,20 @@ bool BL_Shader::LinkProgram() logInf=0; } // check for compile errors - bgl::blGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus); + glGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus); if(!vertstatus) { spit("---- Vertex shader failed to compile ----"); goto programError; } // -- fragment shader ---------------- - tmpFrag = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); - bgl::blShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0); - bgl::blCompileShaderARB(tmpFrag); - bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen); + tmpFrag = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + glShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0); + glCompileShaderARB(tmpFrag); + glGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen); if(fraglen >0 && fraglen < MAX_LOG_LEN){ logInf = (char*)MEM_mallocN(fraglen, "frag-log"); - bgl::blGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf); + glGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf); if(char_len >0) { spit("---- Fragment Shader Error ----"); spit(logInf); @@ -330,7 +305,7 @@ bool BL_Shader::LinkProgram() logInf=0; } - bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus); + glGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus); if(!fragstatus){ spit("---- Fragment shader failed to compile ----"); goto programError; @@ -339,17 +314,17 @@ bool BL_Shader::LinkProgram() // -- program ------------------------ // set compiled vert/frag shader & link - tmpProg = bgl::blCreateProgramObjectARB(); - bgl::blAttachObjectARB(tmpProg, tmpVert); - bgl::blAttachObjectARB(tmpProg, tmpFrag); - bgl::blLinkProgramARB(tmpProg); - bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen); - bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus); + tmpProg = glCreateProgramObjectARB(); + glAttachObjectARB(tmpProg, tmpVert); + glAttachObjectARB(tmpProg, tmpFrag); + glLinkProgramARB(tmpProg); + glGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen); + glGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus); if(proglen > 0 && proglen < MAX_LOG_LEN) { logInf = (char*)MEM_mallocN(proglen, "prog-log"); - bgl::blGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf); + glGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf); if(char_len >0) { spit("---- GLSL Program ----"); spit(logInf); @@ -365,24 +340,24 @@ bool BL_Shader::LinkProgram() // set mShader = tmpProg; - bgl::blDeleteObjectARB(tmpVert); - bgl::blDeleteObjectARB(tmpFrag); + glDeleteObjectARB(tmpVert); + glDeleteObjectARB(tmpFrag); mOk = 1; mError = 0; return true; programError: if(tmpVert) { - bgl::blDeleteObjectARB(tmpVert); + glDeleteObjectARB(tmpVert); tmpVert=0; } if(tmpFrag) { - bgl::blDeleteObjectARB(tmpFrag); + glDeleteObjectARB(tmpFrag); tmpFrag=0; } if(tmpProg) { - bgl::blDeleteObjectARB(tmpProg); + glDeleteObjectARB(tmpProg); tmpProg=0; } @@ -390,9 +365,6 @@ programError: mUse = 0; mError = 1; return false; -#else - return false; -#endif//GL_ARB_shader_objects } const char *BL_Shader::GetVertPtr() @@ -428,15 +400,13 @@ unsigned int BL_Shader::GetProg() void BL_Shader::SetSampler(int loc, int unit) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(loc, unit); + glUniform1iARB(loc, unit); } -#endif } // //void BL_Shader::InitializeSampler(int unit, BL_Texture* texture) @@ -449,31 +419,28 @@ void BL_Shader::SetSampler(int loc, int unit) void BL_Shader::SetProg(bool enable) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if( mShader != 0 && mOk && enable) { - bgl::blUseProgramObjectARB(mShader); + glUseProgramObjectARB(mShader); } else { - bgl::blUseProgramObjectARB(0); + glUseProgramObjectARB(0); } } -#endif } void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) { -#ifdef GL_ARB_shader_objects if(!Ok() || !mPreDef.size()) return; - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { MT_Matrix4x4 model; @@ -578,210 +545,185 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) } } } -#endif } int BL_Shader::GetAttribLocation(const STR_String& name) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - return bgl::blGetAttribLocationARB(mShader, name.ReadPtr()); + return glGetAttribLocationARB(mShader, name.ReadPtr()); } -#endif + return -1; } void BL_Shader::BindAttribute(const STR_String& attr, int loc) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blBindAttribLocationARB(mShader, loc, attr.ReadPtr()); + glBindAttribLocationARB(mShader, loc, attr.ReadPtr()); } -#endif } int BL_Shader::GetUniformLocation(const STR_String& name) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { MT_assert(mShader!=0); - int location = bgl::blGetUniformLocationARB(mShader, name.ReadPtr()); + int location = glGetUniformLocationARB(mShader, name.ReadPtr()); if(location == -1) spit("Invalid uniform value: " << name.ReadPtr() << "."); return location; } -#endif + return -1; } void BL_Shader::SetUniform(int uniform, const MT_Tuple2& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[2]; vec.getValue(value); - bgl::blUniform2fvARB(uniform, 1, value); + glUniform2fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Tuple3& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[3]; vec.getValue(value); - bgl::blUniform3fvARB(uniform, 1, value); + glUniform3fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Tuple4& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[4]; vec.getValue(value); - bgl::blUniform4fvARB(uniform, 1, value); + glUniform4fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const unsigned int& val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(uniform, val); + glUniform1iARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const int val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(uniform, val); + glUniform1iARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const float& val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1fARB(uniform, val); + glUniform1fARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[16]; vec.getValue(value); - bgl::blUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); + glUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[9]; value[0] = (float)vec[0][0]; value[1] = (float)vec[1][0]; value[2] = (float)vec[2][0]; value[3] = (float)vec[0][1]; value[4] = (float)vec[1][1]; value[5] = (float)vec[2][1]; value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[7] = (float)vec[2][2]; - bgl::blUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); + glUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } -#endif } void BL_Shader::SetUniform(int uniform, const float* val, int len) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if(len == 2) - bgl::blUniform2fvARB(uniform, 1,(GLfloat*)val); + glUniform2fvARB(uniform, 1,(GLfloat*)val); else if (len == 3) - bgl::blUniform3fvARB(uniform, 1,(GLfloat*)val); + glUniform3fvARB(uniform, 1,(GLfloat*)val); else if (len == 4) - bgl::blUniform4fvARB(uniform, 1,(GLfloat*)val); + glUniform4fvARB(uniform, 1,(GLfloat*)val); else MT_assert(0); } -#endif } void BL_Shader::SetUniform(int uniform, const int* val, int len) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if(len == 2) - bgl::blUniform2ivARB(uniform, 1, (GLint*)val); + glUniform2ivARB(uniform, 1, (GLint*)val); else if (len == 3) - bgl::blUniform3ivARB(uniform, 1, (GLint*)val); + glUniform3ivARB(uniform, 1, (GLint*)val); else if (len == 4) - bgl::blUniform4ivARB(uniform, 1, (GLint*)val); + glUniform4ivARB(uniform, 1, (GLint*)val); else MT_assert(0); } -#endif } @@ -849,7 +791,6 @@ PyParentObject BL_Shader::Parents[] = { KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" ) { -#ifdef GL_ARB_shader_objects if(mShader !=0 && mOk ) { // already set... @@ -862,7 +803,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg vertProg = v; fragProg = f; if( LinkProgram() ) { - bgl::blUseProgramObjectARB( mShader ); + glUseProgramObjectARB( mShader ); mUse = apply!=0; Py_Return; } @@ -871,24 +812,19 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg mUse = 0; Py_Return; } - return NULL; -#else Py_Return; -#endif } KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" ) { -#ifdef GL_ARB_shader_objects ClearUniforms(); - bgl::blUseProgramObjectARB(0); + glUseProgramObjectARB(0); - bgl::blDeleteObjectARB(mShader); + glDeleteObjectARB(mShader); mShader = 0; mOk = 0; mUse = 0; -#endif Py_Return; } @@ -909,7 +845,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") { -#ifdef GL_ARB_shader_objects if(mError) { Py_INCREF(Py_None); return Py_None; @@ -919,15 +854,15 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") return NULL; } int stat = 0; - bgl::blValidateProgramARB(mShader); - bgl::blGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat); + glValidateProgramARB(mShader); + glGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat); if(stat > 0 && stat < MAX_LOG_LEN) { int char_len=0; char *logInf = (char*)MEM_mallocN(stat, "validate-log"); - bgl::blGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf); + glGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf); if(char_len >0) { spit("---- GLSL Validation ----"); spit(logInf); @@ -935,7 +870,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") MEM_freeN(logInf); logInf=0; } -#endif//GL_ARB_shader_objects Py_Return; } @@ -1412,7 +1346,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) { -#ifdef GL_ARB_shader_objects if(mError) { Py_INCREF(Py_None); return Py_None; @@ -1424,11 +1357,10 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) return NULL; } mAttr=SHD_TANGENT; - bgl::blUseProgramObjectARB(mShader); - bgl::blBindAttribLocationARB(mShader, mAttr, "Tangent"); + glUseProgramObjectARB(mShader); + glBindAttribLocationARB(mShader, mAttr, "Tangent"); Py_Return; } -#endif return NULL; } |