1 package require
Tcl 8.5
5 Copyright
(c
) 2008, 2009 Apple Inc.
7 Permission is hereby granted
, free of charge
, to any person
8 obtaining a copy of this software and associated documentation files
9 (the
"Software"), to deal in the Software without restriction
,
10 including without limitation the rights to use
, copy
, modify
, merge
,
11 publish
, distribute
, sublicense
, and
/or sell copies of the Software
,
12 and to permit persons to whom the Software is furnished to do so
,
13 subject to the following conditions
:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND
,
19 EXPRESS OR IMPLIED
, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY
, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
22 HOLDER
(S
) BE LIABLE FOR ANY CLAIM
, DAMAGES OR OTHER LIABILITY
,
23 WHETHER IN AN ACTION OF CONTRACT
, TORT OR OTHERWISE
, ARISING FROM
,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
27 Except as contained in this notice
, the name
(s
) of the above
28 copyright holders shall not be used in advertising or otherwise to
29 promote the sale
, use or other dealings in this Software without
30 prior written authorization.
36 ** License Applicability. Except to the extent portions of this
file are
37 ** made subject to an alternative license as permitted in the SGI Free
38 ** Software License B
, Version
1.1 (the
"License"), the contents of this
39 ** file are subject only to the provisions of the License. You may not use
40 ** this
file except in compliance with the License. You may obtain a copy
41 ** of the License at Silicon Graphics
, Inc.
, attn
: Legal Services
, 1600
42 ** Amphitheatre Parkway
, Mountain View
, CA
94043-1351, or at
:
44 ** http://oss.sgi.com
/projects
/FreeB
46 ** Note that
, as provided in the License
, the Software is distributed on an
47 ** "AS IS" basis
, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
48 ** DISCLAIMED
, INCLUDING
, WITHOUT LIMITATION
, ANY IMPLIED WARRANTIES AND
49 ** CONDITIONS OF MERCHANTABILITY
, SATISFACTORY QUALITY
, FITNESS FOR A
50 ** PARTICULAR PURPOSE
, AND NON-INFRINGEMENT.
52 ** Original Code. The Original Code is
: OpenGL Sample Implementation
,
53 ** Version
1.2.1, released January
26, 2000, developed by Silicon Graphics
,
54 ** Inc. The Original Code is Copyright
(c
) 1991-2000 Silicon Graphics
, Inc.
55 ** Copyright in any portions created by third parties is as indicated
56 ** elsewhere herein. All Rights Reserved.
58 ** Additional Notice Provisions
: This software was created using the
59 ** OpenGL
(R
) version
1.2.1 Sample Implementation published by SGI
, but has
60 ** not been independently verified as being compliant with the OpenGL
(R
)
61 ** version
1.2.1 Specification.
66 static void
*glsym
(void
*handle
, const char
*name
) {
67 void
*sym
= dlsym
(handle
, name
);
70 fprintf
(stderr
, "Error: symbol not found: '%s'. "
71 "Error information: %s\n",
83 #define LIBGLNAME "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"
86 (void
)dlerror
(); /*drain dlerror
()*/
88 handle
= dlopen
(LIBGLNAME
, RTLD_LAZY
);
91 fprintf
(stderr
, "error: unable to dlopen "
92 LIBGLNAME
" :" "%s\n", dlerror
());
97 set this_script
[info script
]
99 proc main
{argc argv
} {
101 puts stderr
"syntax is: [set ::this_script] serialized-array-file output.c"
106 set fd
[open [lindex $argv 0] r
]
107 array set api
[read $fd]
110 set fd
[open [lindex $argv 1] w
]
112 puts $fd "/* This file was automatically generated by [set ::this_script]. */"
116 #define GL_GLEXT_PROTOTYPES
119 #include "glxclient.h"
120 #include "apple_xgl_api.h"
121 #include "apple_glx_context.h"
124 puts $fd "struct apple_xgl_api __gl_api;"
126 set sorted
[lsort -dictionary [array names api
]]
128 set exclude
[list DrawBuffer DrawBuffers DrawBuffersARB
]
130 #These are special to glXMakeContextCurrent.
131 #See also: apple_xgl_api_read.c.
132 lappend exclude ReadPixels CopyPixels CopyColorTable
134 #This is excluded to work with surface updates.
135 lappend exclude Viewport
138 if {$f in
$exclude} {
146 foreach p
[dict get
$attr parameters
] {
147 append pstr
"[lindex $p 0] [lindex $p 1], "
150 set pstr
[string trimright
$pstr ", "]
152 if {![string length
$pstr]} {
158 foreach p
[dict get
$attr parameters
] {
159 append callvars
"[lindex $p end], "
162 set callvars
[string trimright
$callvars ", "]
165 if {"void" ne
[dict get
$attr return]} {
169 if {[dict exists
$attr noop
]} {
170 if {"void" eq
[dict get
$attr return]} {
173 set body
"return 0; /*noop*/"
175 } elseif
{[dict exists
$attr alias_for
]} {
176 set alias
[dict get
$attr alias_for
]
177 set body
"[set return] gl[set alias]([set callvars]);"
179 set body
"[set return]__gl_api.[set f]([set callvars]);"
182 puts $fd "GLAPI [dict get $attr return] APIENTRY gl[set f]([set pstr]) \{\n\t$body\n\}"
185 puts $fd $::init_code
187 puts $fd "void apple_xgl_init_direct(void) \{"
188 puts $fd "\tvoid *handle;"
190 puts $fd $::dlopen_code
198 if {[dict exists
$attr alias_for
] ||
[dict exists
$attr noop
]} {
199 #Function f is an alias_for another, so we shouldn't try
204 puts $fd "\t__gl_api.$f = glsym(handle, \"gl$f\");"
212 exit [main
$::argc $::argv]