Index: experimental/fiddle/OSMesaContextHolder.cpp |
diff --git a/experimental/fiddle/OSMesaContextHolder.cpp b/experimental/fiddle/OSMesaContextHolder.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b2c73de487ffd715f465a98a0c01f9d33636a3a |
--- /dev/null |
+++ b/experimental/fiddle/OSMesaContextHolder.cpp |
@@ -0,0 +1,30 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include <stdio.h> |
+#include <stdint.h> |
+ |
+#include <GL/osmesa.h> |
+ |
+#include "OSMesaContextHolder.h" |
+ |
+OSMesaContextHolder::OSMesaContextHolder() { |
+ fOSMesaContext = OSMesaCreateContextExt(0x1, 0, 0, 0, nullptr); |
+ if (!fOSMesaContext) { |
+ fputs("Unable to get OSMesa context.\n", stderr); |
+ } else { |
+ static uint32_t buffer[16 * 16]; |
+ OSMesaMakeCurrent(fOSMesaContext, &buffer, 0x1401, 16, 16); |
+ } |
+} |
+ |
+OSMesaContextHolder::~OSMesaContextHolder() { |
+ if (fOSMesaContext) { |
+ OSMesaDestroyContext(fOSMesaContext); |
+ } |
+} |
+ |