Skip to content

Commit

Permalink
TESTSUITE More test suites added to the check suite
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfletch committed Dec 30, 2024
1 parent 738b6ee commit 7ae3a58
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 92 deletions.
27 changes: 27 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
114 changes: 67 additions & 47 deletions tests/test_gldouble_ctypes.py
Original file line number Diff line number Diff line change
@@ -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()
10 changes: 6 additions & 4 deletions tests/test_glgetactiveuniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
30 changes: 17 additions & 13 deletions tests/test_glgetfloat_leak.py
Original file line number Diff line number Diff line change
@@ -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()
29 changes: 17 additions & 12 deletions tests/test_instanced_draw_detect.py
Original file line number Diff line number Diff line change
@@ -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()
38 changes: 23 additions & 15 deletions tests/test_sf2946226.py
Original file line number Diff line number Diff line change
@@ -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()
Loading

0 comments on commit 7ae3a58

Please sign in to comment.