[gnome-games/glchess-vala] Delete GLX context when widget destroyed
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/glchess-vala] Delete GLX context when widget destroyed
- Date: Sat, 11 Dec 2010 07:55:06 +0000 (UTC)
commit 8cb31805ae8a81dde6b8da86d0c79a6fc5396ffc
Author: Robert Ancell <robert ancell canonical com>
Date: Sat Dec 11 18:41:12 2010 +1100
Delete GLX context when widget destroyed
glchess/src/chess-view-3d.vala | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/glchess/src/chess-view-3d.vala b/glchess/src/chess-view-3d.vala
index b83d6b2..5bece02 100644
--- a/glchess/src/chess-view-3d.vala
+++ b/glchess/src/chess-view-3d.vala
@@ -39,6 +39,7 @@ private class ChessView3D : ChessView
add_events (Gdk.EventMask.BUTTON_PRESS_MASK);
realize.connect (realize_cb);
+ unrealize.connect (unrealize_cb);
double_buffered = false;
try
@@ -102,7 +103,7 @@ private class ChessView3D : ChessView
4, 5, 9, 8, 4, 8, 11, 7, 7, 11, 10, 6, 6, 10, 9, 5};
}
- public void realize_cb ()
+ private void realize_cb ()
{
int[] attributes = { GLX_RGBA,
GLX_RED_SIZE, 1,
@@ -121,6 +122,18 @@ private class ChessView3D : ChessView
context = glXCreateContext (display, visual, null, true);
}
+ private void unrealize_cb ()
+ {
+ /* Wait for any pending GL calls to end */
+ if (drawable == glXGetCurrentDrawable ())
+ {
+ glXWaitGL ();
+ glXMakeCurrent (display, X.None, (GLX.Context) null);
+ }
+
+ glXDestroyContext (display, context);
+ }
+
public override bool configure_event (Gdk.EventConfigure event)
{
int short_edge = int.min (get_allocated_width (), get_allocated_height ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]