mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 23:48:12 +08:00
Add extra checks when dispose and ensureInitialized
This commit is contained in:
parent
b5e5b4cfa9
commit
107f3ce87a
@ -72,7 +72,7 @@ void SceneViewer::initializeGL() {
|
||||
}
|
||||
|
||||
void SceneViewer::resizeGL(int w, int h) {
|
||||
|
||||
glViewport(0, 0, w, h);
|
||||
}
|
||||
|
||||
void SceneViewer::paintGL() {
|
||||
|
||||
@ -103,6 +103,7 @@ inline void ShaderProgram::unbind() const {
|
||||
}
|
||||
|
||||
inline void ShaderProgram::dispose() {
|
||||
if (_programId == 0) return;
|
||||
OPENGL_EXTRA_FUNCTIONS->glDeleteProgram(_programId);
|
||||
_programId = 0;
|
||||
}
|
||||
@ -110,5 +111,8 @@ inline void ShaderProgram::dispose() {
|
||||
inline void ShaderProgram::ensureInitialized() {
|
||||
if (_programId == 0) {
|
||||
_programId = OPENGL_EXTRA_FUNCTIONS->glCreateProgram();
|
||||
if (_programId == 0) {
|
||||
Logger::error("Failed to create a ShaderProgram");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,7 @@ inline void VertexArrayObject::unbind() const {
|
||||
}
|
||||
|
||||
inline void VertexArrayObject::dispose() {
|
||||
if (_id == 0) return;
|
||||
OPENGL_EXTRA_FUNCTIONS->glDeleteVertexArrays(1, &_id);
|
||||
_id = 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user