Better dealing of shaders.

Originally committed to SVN as r976.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-02 00:44:47 +00:00
parent 6b26ebd99b
commit 77e21c985d
1 changed files with 18 additions and 6 deletions

View File

@ -265,7 +265,13 @@ void OpenGLWrapper::SetModeFill() {
////////////////////////// //////////////////////////
// Are shaders available? // Are shaders available?
bool OpenGLWrapper::ShadersAvailable() { bool OpenGLWrapper::ShadersAvailable() {
return IsExtensionSupported("GL_ARB_vertex_shader") && IsExtensionSupported("GL_ARB_fragment_shader"); bool available = IsExtensionSupported("GL_ARB_vertex_shader") && IsExtensionSupported("GL_ARB_fragment_shader");
static bool first = true;
if (first) {
first = false;
wxMessageBox(_T("Warning, OpenGL shaders are not available on this machine. YV12 video will be on greyscale."),_T("GL Shaders Error"));
}
return available;
} }
@ -311,17 +317,23 @@ void OpenGLWrapper::Initialize() {
////////////////////// //////////////////////
// Set current shader // Set current shader
void OpenGLWrapper::SetShader(GLuint i) { void OpenGLWrapper::SetShader(GLuint i) {
if (UseShaders()) {
Initialize(); Initialize();
glUseProgramObjectARB(i); glUseProgramObjectARB(i);
if (glGetError()) throw _T("Could not set shader program.");
}
} }
////////////////////////// //////////////////////////
// Destroy shader program // Destroy shader program
void OpenGLWrapper::DestroyShaderProgram(GLuint i) { void OpenGLWrapper::DestroyShaderProgram(GLuint i) {
if (UseShaders()) {
Initialize(); Initialize();
SetShader(0); SetShader(0);
glDeleteObjectARB(i); glDeleteObjectARB(i);
if (glGetError()) throw _T("Error removing shader program.");
}
} }