From 5f206dab356e378ff1e7f22fdb03d986b1974df8 Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Sat, 28 Dec 2019 11:49:07 -0500 Subject: [PATCH] DEMO provide a running version of code in bug report in #34 --- tests/gh_bug32.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/gh_bug32.py diff --git a/tests/gh_bug32.py b/tests/gh_bug32.py new file mode 100644 index 00000000..012d2b2f --- /dev/null +++ b/tests/gh_bug32.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python +"""Tests bug report #32 from github""" +import os +if not os.environ.get( 'PYOPENGL_PLATFORM' ): + os.environ['PYOPENGL_PLATFORM'] = 'osmesa' +from math import pi, sin, cos +import OpenGL +OpenGL.USE_ACCELERATE = False +from OpenGL.GL import * +from OpenGL.GL.ARB.fragment_program import glGenProgramsARB +from OpenGL.GLU import * +from OpenGL.osmesa import * +width = height = 300 + +shared_win = None +# Current OSMesa does not seem to support RGB, only RGBA, +# note also the use of the OSMESA_* constants here, they +# seem to match the GL constants, but can't be too careful. +# Also see ./osdemo.py for a working sample of offscreen +# rendering using OSMesa. +ctx = OSMesaCreateContext(OSMESA_RGBA, shared_win) +buf = arrays.GLubyteArray.zeros((height, width, 4)) +mesap = arrays.ArrayDatatype.dataPointer(buf) +assert(OSMesaMakeCurrent(ctx, GLuint(mesap), GL_UNSIGNED_BYTE, width, height)) \ No newline at end of file