1 | #!parrot |
---|
2 | # Copyright (C) 2009, Parrot Foundation. |
---|
3 | # $Id$ |
---|
4 | |
---|
5 | =head1 NAME |
---|
6 | |
---|
7 | t/library/opengl.t -- OpenGL Tests |
---|
8 | |
---|
9 | =head1 SYNOPSIS |
---|
10 | |
---|
11 | ./parrot t/library/opengl.t |
---|
12 | |
---|
13 | =head1 DESCRIPTION |
---|
14 | |
---|
15 | Test Parrot's opengl interface. |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | .const int TESTS = 7 |
---|
20 | |
---|
21 | .sub 'main' :main |
---|
22 | .param pmc argv |
---|
23 | |
---|
24 | load_bytecode 'library/Test/More.pbc' |
---|
25 | .local pmc exports, curr_namespace, test_namespace |
---|
26 | curr_namespace = get_namespace |
---|
27 | test_namespace = get_namespace [ 'Test'; 'More' ] |
---|
28 | exports = split ' ', 'plan diag ok nok is is_deeply like isa_ok skip isnt todo' |
---|
29 | |
---|
30 | test_namespace.'export_to'(curr_namespace, exports) |
---|
31 | |
---|
32 | load_bytecode "library/config.pbc" |
---|
33 | .local pmc conf_hash |
---|
34 | conf_hash = _config() |
---|
35 | $S1 = conf_hash['has_opengl'] |
---|
36 | if $S1 == '1' goto HAS_OPENGL |
---|
37 | skip(TESTS, "no opengl") |
---|
38 | goto END |
---|
39 | |
---|
40 | HAS_OPENGL: |
---|
41 | plan(TESTS) |
---|
42 | |
---|
43 | .include 'opengl_defines.pasm' |
---|
44 | load_bytecode 'OpenGL.pbc' |
---|
45 | 'ok'(1, 'loaded OpenGL.pbc') |
---|
46 | |
---|
47 | load_bytecode 'library/NCI/call_toolkit_init.pbc' |
---|
48 | 'ok'(2, 'loaded call_toolkit_init.pbc') |
---|
49 | |
---|
50 | .local pmc import_gl |
---|
51 | import_gl = get_global ['OpenGL'], '_export_all_functions' |
---|
52 | import_gl() |
---|
53 | 'ok'(3, '_export_all_functions') |
---|
54 | |
---|
55 | glutInitWindowSize(20, 20) |
---|
56 | 'ok'(4, 'glutInitWindowSize') |
---|
57 | |
---|
58 | # Initialize GLUT |
---|
59 | .local pmc argc |
---|
60 | .local int count |
---|
61 | count = argv |
---|
62 | argc = new 'Integer' |
---|
63 | argc = count |
---|
64 | glutInit(argc, argv) |
---|
65 | 'ok'(5, 'glutInit') |
---|
66 | |
---|
67 | # Set display mode, create GLUT window, return window handle |
---|
68 | .local int mode |
---|
69 | mode = .GLUT_DOUBLE | .GLUT_RGBA |
---|
70 | mode |= .GLUT_DEPTH |
---|
71 | mode |= .GLUT_STENCIL |
---|
72 | glutInitDisplayMode(mode) |
---|
73 | 'ok'(6, 'glutInitDisplayMode') |
---|
74 | |
---|
75 | .local int window_id |
---|
76 | window_id = glutCreateWindow('test') |
---|
77 | if window_id goto OK_7 |
---|
78 | 'nok'(7, 'glutCreateWindow') |
---|
79 | goto END |
---|
80 | OK_7: |
---|
81 | 'ok'(7, 'glutCreateWindow') |
---|
82 | |
---|
83 | END: |
---|
84 | .end |
---|
85 | |
---|
86 | # Local Variables: |
---|
87 | # mode: pir |
---|
88 | # fill-column: 100 |
---|
89 | # End: |
---|
90 | # vim: expandtab shiftwidth=4 ft=pir: |
---|