forked from mia/Aegisub
Better dealing of shaders.
Originally committed to SVN as r976.
This commit is contained in:
parent
6b26ebd99b
commit
77e21c985d
1 changed files with 18 additions and 6 deletions
|
@ -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) {
|
||||||
Initialize();
|
if (UseShaders()) {
|
||||||
glUseProgramObjectARB(i);
|
Initialize();
|
||||||
|
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) {
|
||||||
Initialize();
|
if (UseShaders()) {
|
||||||
SetShader(0);
|
Initialize();
|
||||||
glDeleteObjectARB(i);
|
SetShader(0);
|
||||||
|
glDeleteObjectARB(i);
|
||||||
|
if (glGetError()) throw _T("Error removing shader program.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue