File: gh_bug32.py

package info (click to toggle)
pyopengl 3.1.6%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,732 kB
  • sloc: python: 106,016; makefile: 8
file content (24 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))