diff --git a/tests/test_checks.py b/tests/test_checks.py index 6c3eeeae..bc5bc68a 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -213,3 +213,30 @@ def test_egl_ext_enumerate(): @check_test def test_feedbackvarying(): """Tests that feedback varying buffer operations work""" + + +@check_test +def test_test_sf2946226(): + """Test sourceforge bug vs. regressions""" + + +@glut_only +@check_test +def test_test_instanced_draw_detect(): + """Test that instanced draw extension can be identified""" + + +@glut_only +@check_test +def test_test_gldouble_ctypes(): + """Test use of gldouble array in ctypes""" + + +@check_test +def test_test_glgetactiveuniform(): + """Test use of gldouble array in ctypes""" + + +@check_test +def test_test_glgetfloat_leak(): + """Test use of gldouble array in ctypes""" diff --git a/tests/test_gldouble_ctypes.py b/tests/test_gldouble_ctypes.py index c2c67e58..e56c0638 100644 --- a/tests/test_gldouble_ctypes.py +++ b/tests/test_gldouble_ctypes.py @@ -1,96 +1,116 @@ """Test simple functions (i.e. no pointers involved)""" + from __future__ import print_function -#import OpenGL -#OpenGL.USE_ACCELERATE = False + +# import OpenGL +# OpenGL.USE_ACCELERATE = False from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * from OpenGL.GL import GLdouble from OpenGL.arrays import arraydatatype -handler = arraydatatype.ArrayDatatype.getHandler( GLdouble * 16 ) -handler.registerReturn( ) -import time,traceback + +handler = arraydatatype.ArrayDatatype.getHandler(GLdouble * 16) +handler.registerReturn() +import time, traceback, os + start = time.time() window = None + + def display(): try: - glutSetWindow(window); - glClearColor (0.0, 0.0, (time.time()%1.0)/1.0, 0.0) - glClear (GL_COLOR_BUFFER_BIT) - glMatrixMode(GL_PROJECTION); + glutSetWindow(window) + glClearColor(0.0, 0.0, (time.time() % 1.0) / 1.0, 0.0) + glClear(GL_COLOR_BUFFER_BIT) + glMatrixMode(GL_PROJECTION) # For some reason the GL_PROJECTION_MATRIX is overflowing with a single push! # glPushMatrix() - matrix = glGetDoublev( GL_PROJECTION_MATRIX) + matrix = glGetDoublev(GL_PROJECTION_MATRIX) print('matrix', type(matrix), matrix[:][:]) glutSwapBuffers() except Exception: traceback.print_exc() sys.exit(0) -size = (250,250) -def reshape( *args ): - global size + + +size = (250, 250) + + +def reshape(*args): + global size size = args - glViewport( *( (0,0)+args) ) + glViewport(*((0, 0) + args)) display() -def ontimer( *args ): - print('timer', args, '@time', time.time()-start) - glutTimerFunc( 1000, ontimer, 24 ) + + +def ontimer(*args): + print('timer', args, '@time', time.time() - start) + glutTimerFunc(1000, ontimer, 24) + + def idle(): - delta = time.time()-start - if delta < 10: - global size - x,y = size + delta = time.time() - start + if delta < 2: + global size + x, y = size if delta < 5: change = +1 else: change = -1 - x = x-change - y = y+change + x = x - change + y = y + change if x < 1: x = 1 if y < 1: y = 1 - glutReshapeWindow( x, y ) - size = (x,y) + glutReshapeWindow(x, y) + size = (x, y) glutSetWindow(window) glutPostRedisplay() else: - glutDestroyWindow( window ) + glutDestroyWindow(window) print('window destroyed') + sys.stdout.write('OK') + sys.stdout.flush() try: - if fgDeinitialize: fgDeinitialize(False) + if fgDeinitialize: + fgDeinitialize(False) except NameError: - pass # Older PyOpenGL, you may see a seg-fault here... - import sys - sys.exit( 0 ) -def printFunction( name ): - def onevent( *args ): - print('%s -> %s'%(name, ", ".join( [str(a) for a in args ]))) + pass # Older PyOpenGL, you may see a seg-fault here... + os._exit(0) + + +def printFunction(name): + def onevent(*args): + print('%s -> %s' % (name, ", ".join([str(a) for a in args]))) + return onevent if __name__ == "__main__": import sys + newArgv = glutInit(sys.argv) print('newArguments', newArgv) - glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ) + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(250, 250) glutInitWindowPosition(100, 100) window = glutCreateWindow("hello") print('window', repr(window)) glutDisplayFunc(display) glutReshapeFunc(reshape) - glutMouseFunc(printFunction( 'Mouse' )) - glutEntryFunc(printFunction( 'Entry' )) - glutKeyboardFunc( printFunction( 'Keyboard' )) - glutKeyboardUpFunc( printFunction( 'KeyboardUp' )) - glutMotionFunc( printFunction( 'Motion' )) - glutPassiveMotionFunc( printFunction( 'PassiveMotion' )) - glutVisibilityFunc( printFunction( 'Visibility' )) - glutWindowStatusFunc( printFunction( 'WindowStatus' )) - glutSpecialFunc( printFunction( 'Special' )) - glutSpecialUpFunc( printFunction( 'SpecialUp' )) - glutTimerFunc( 1000, ontimer, 23 ) - - glutIdleFunc( idle ) + glutMouseFunc(printFunction('Mouse')) + glutEntryFunc(printFunction('Entry')) + glutKeyboardFunc(printFunction('Keyboard')) + glutKeyboardUpFunc(printFunction('KeyboardUp')) + glutMotionFunc(printFunction('Motion')) + glutPassiveMotionFunc(printFunction('PassiveMotion')) + glutVisibilityFunc(printFunction('Visibility')) + glutWindowStatusFunc(printFunction('WindowStatus')) + glutSpecialFunc(printFunction('Special')) + glutSpecialUpFunc(printFunction('SpecialUp')) + glutTimerFunc(1000, ontimer, 23) + + glutIdleFunc(idle) glutMainLoop() diff --git a/tests/test_glgetactiveuniform.py b/tests/test_glgetactiveuniform.py index 8d8a2c99..f1fb703c 100644 --- a/tests/test_glgetactiveuniform.py +++ b/tests/test_glgetactiveuniform.py @@ -12,20 +12,22 @@ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex * scale; } """ + + def main(): pygame.init() disp = pygame.display.set_mode((1024, 768), OPENGL | DOUBLEBUF) - program = compileProgram( - compileShader( vertex_shader, GL_VERTEX_SHADER ) - ) + program = compileProgram(compileShader(vertex_shader, GL_VERTEX_SHADER)) nu = glGetProgramiv(program, GL_ACTIVE_UNIFORMS) for i in range(nu): name, size, type = glGetActiveUniform(program, i) print('CORE - ', name, size, type) - glGetActiveUniformARB( program, i ) + glGetActiveUniformARB(program, i) print('ARB - ', name, size, type) + print('OK') + if __name__ == "__main__": main() diff --git a/tests/test_glgetfloat_leak.py b/tests/test_glgetfloat_leak.py index f98490cc..937718ba 100644 --- a/tests/test_glgetfloat_leak.py +++ b/tests/test_glgetfloat_leak.py @@ -1,33 +1,37 @@ #!/usr/bin/python from __future__ import print_function -import sys +import sys, os import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * +import psutil + def main(): pygame.init() - pygame.display.set_mode((800,600), pygame.OPENGL| - pygame.DOUBLEBUF) + pygame.display.set_mode((800, 600), pygame.OPENGL | pygame.DOUBLEBUF) glClearColor(1.0, 0.0, 0.0, 1.0) - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) done = False while not done: - for i in range(0,50000): + mem = 0 + for i in range(0, 500): + if i == 10: + mem = psutil.Process(os.getpid()).memory_percent() + if i > 400: + new_mem = psutil.Process(os.getpid()).memory_percent() + assert new_mem == mem + break + modelview_matrix = glGetFloatv(GL_MODELVIEW_MATRIX) assert modelview_matrix is not None - if not i % 500: - sys.stdout.write('.') - print() - pygame.display.flip() + break + sys.stdout.write('OK\n') + sys.stdout.flush() - eventlist = pygame.event.get() - for event in eventlist: - if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE: - done = True if __name__ == '__main__': main() diff --git a/tests/test_instanced_draw_detect.py b/tests/test_instanced_draw_detect.py index 4ef026c2..c613cf3b 100644 --- a/tests/test_instanced_draw_detect.py +++ b/tests/test_instanced_draw_detect.py @@ -1,35 +1,40 @@ from __future__ import print_function +import sys from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.extensions import alternate from OpenGL.GL.ARB.draw_instanced import * from OpenGL.GL.EXT.draw_instanced import * + def detect(): glutInit([]) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH) - glutInitWindowSize(200,200) + glutInitWindowSize(200, 200) glutCreateWindow("Detection") - + functions = ( - glDrawArraysInstanced, - glDrawArraysInstancedARB, + glDrawArraysInstanced, + glDrawArraysInstancedARB, glDrawArraysInstancedEXT, - #glDrawArraysInstancedNV, is GLES only + # glDrawArraysInstancedNV, is GLES only ) - + for function in functions: print(function.__name__, bool(function)) - - any = alternate( *functions ) - + + any = alternate(*functions) + print(any, bool(any)) + sys.stdout.write('OK\n') + sys.stdout.flush() try: - if fgDeinitialize: fgDeinitialize(False) + if fgDeinitialize: + fgDeinitialize(False) except NameError: - pass # Older PyOpenGL, you may see a seg-fault here... - + pass # Older PyOpenGL, you may see a seg-fault here... + if __name__ == "__main__": detect() diff --git a/tests/test_sf2946226.py b/tests/test_sf2946226.py index e5bd1eeb..0df82fd6 100644 --- a/tests/test_sf2946226.py +++ b/tests/test_sf2946226.py @@ -1,43 +1,51 @@ import pygame, sys from pygame.locals import * import OpenGL + OpenGL.USE_ACCELERATE = False from OpenGL.GL import * from OpenGL.GL.EXT.framebuffer_object import * from OpenGL import error -def draw (): - glClearColor(0.0,0.0,0.0,0.0) + +def draw(): + glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) - #draw stuff here + # draw stuff here pygame.display.flip() + def main(): pygame.init() - pygame.display.set_mode((512,512),OPENGL | DOUBLEBUF) + pygame.display.set_mode((512, 512), OPENGL | DOUBLEBUF) - #setup a texture - tex = glGenTextures(1); - glBindTexture(GL_TEXTURE_2D, tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, - GL_UNSIGNED_BYTE, None); - glBindTexture(GL_TEXTURE_2D, 0); + # setup a texture + tex = glGenTextures(1) + glBindTexture(GL_TEXTURE_2D, tex) + glTexImage2D( + GL_TEXTURE_2D, 0, GL_RGBA8, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, None + ) + glBindTexture(GL_TEXTURE_2D, 0) - #setup teh fbo + # setup teh fbo fbo = glGenFramebuffersEXT(1) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo) glBindTexture(GL_TEXTURE_2D, tex) - #this call produces an error! + # this call produces an error! - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, - GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, tex, 0) + glFramebufferTexture2DEXT( + GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0 + ) while 1: - event=pygame.event.poll () + event = pygame.event.poll() if event.type is QUIT: sys.exit(0) draw() + print('OK') + break + if __name__ == "__main__": main() diff --git a/tests/test_vbo_memusage.py b/tests/test_vbo_memusage.py index 8487f71f..d4374f05 100644 --- a/tests/test_vbo_memusage.py +++ b/tests/test_vbo_memusage.py @@ -1,5 +1,5 @@ import pygamegltest -import os +import os, sys # We have to import at least *one* VBO implementation... from OpenGL import GL, arrays @@ -53,3 +53,5 @@ def test_sf_2980896(): """Shouldn't have any (or at least much) extra RAM allocated, lost: %s on iteration %d""" % (current - memory, i) ) # fails only when run in the whole suite... + sys.stdout.write('OK\n') + sys.stdout.flush()