Add proper disposing to colered triangle graphics example
This commit is contained in:
parent
c4291dcc20
commit
97ac18d3d2
@ -69,14 +69,41 @@ static void draw_with_model_matrix(ShimattaOpenglGraphics *self, mat4 m, mat4 n)
|
|||||||
draw(self);
|
draw(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shimatta_opengl_colored_triangle_dispose(GObject *obj)
|
||||||
|
{
|
||||||
|
ShimattaOpenglColoredTriangle *self;
|
||||||
|
ShimattaOpenglColoredTrianglePrivate *priv;
|
||||||
|
|
||||||
|
self = SHIMATTA_OPENGL_COLORED_TRIANGLE(obj);
|
||||||
|
priv = shimatta_opengl_colored_triangle_get_instance_private(self);
|
||||||
|
|
||||||
|
if (priv->vao) {
|
||||||
|
glDeleteVertexArrays(1, &priv->vao);
|
||||||
|
priv->vao = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->vbo) {
|
||||||
|
glDeleteBuffers(1, &priv->vbo);
|
||||||
|
priv->vbo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_clear_object(&priv->prog);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS(shimatta_opengl_colored_triangle_parent_class)->dispose(obj);
|
||||||
|
}
|
||||||
|
|
||||||
void shimatta_opengl_colored_triangle_class_init(ShimattaOpenglColoredTriangleClass *klass)
|
void shimatta_opengl_colored_triangle_class_init(ShimattaOpenglColoredTriangleClass *klass)
|
||||||
{
|
{
|
||||||
ShimattaOpenglGraphicsClass *gclass;
|
ShimattaOpenglGraphicsClass *gclass;
|
||||||
|
GObjectClass *oclass;
|
||||||
|
|
||||||
gclass = SHIMATTA_OPENGL_GRAPHICS_CLASS(klass);
|
gclass = SHIMATTA_OPENGL_GRAPHICS_CLASS(klass);
|
||||||
|
oclass = G_OBJECT_CLASS(klass);
|
||||||
|
|
||||||
gclass->draw = draw;
|
gclass->draw = draw;
|
||||||
gclass->realize = realize;
|
gclass->realize = realize;
|
||||||
gclass->draw_with_model_matrix = draw_with_model_matrix;
|
gclass->draw_with_model_matrix = draw_with_model_matrix;
|
||||||
|
oclass->dispose = shimatta_opengl_colored_triangle_dispose;
|
||||||
}
|
}
|
||||||
|
|
||||||
void shimatta_opengl_colored_triangle_init(ShimattaOpenglColoredTriangle *self)
|
void shimatta_opengl_colored_triangle_init(ShimattaOpenglColoredTriangle *self)
|
||||||
|
Loading…
Reference in New Issue
Block a user