Merge git://factorcode.org/git/factor

db4
Doug Coleman 2008-01-19 09:44:39 -10:00
commit 95c94ac3b5
56 changed files with 1899 additions and 373 deletions

View File

@ -140,7 +140,7 @@ factor: $(DLL_OBJS) $(EXE_OBJS)
clean: clean:
rm -f vm/*.o rm -f vm/*.o
rm -f libfactor.a rm -f factor*.dll libfactor*.*
vm/resources.o: vm/resources.o:
windres vm/factor.rs vm/resources.o windres vm/factor.rs vm/resources.o

View File

@ -358,4 +358,7 @@ M: long-long-type box-return ( type -- )
"ushort*" define-primitive-type "ushort*" define-primitive-type
[ string>u16-alien ] "ushort*" c-type set-c-type-prep [ string>u16-alien ] "ushort*" c-type set-c-type-prep
win64? "longlong" "long" ? "ptrdiff_t" typedef
] with-compilation-unit ] with-compilation-unit

View File

@ -1,5 +1,6 @@
USING: alien alien.c-types alien.structs alien.syntax IN: alien.syntax
alien.syntax.private help.markup help.syntax ; USING: alien alien.c-types alien.structs alien.syntax.private
help.markup help.syntax ;
HELP: DLL" HELP: DLL"
{ $syntax "DLL\" path\"" } { $syntax "DLL\" path\"" }
@ -50,7 +51,13 @@ $nl
HELP: TYPEDEF: HELP: TYPEDEF:
{ $syntax "TYPEDEF: old new" } { $syntax "TYPEDEF: old new" }
{ $values { "old" "a C type" } { "new" "a C type" } } { $values { "old" "a C type" } { "new" "a C type" } }
{ $description "Alises the C type " { $snippet "old" } " under the name " { $snippet "new" } "." } { $description "Aliases the C type " { $snippet "old" } " under the name " { $snippet "new" } " if ." }
{ $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ;
HELP: TYPEDEF-IF:
{ $syntax "TYPEDEF-IF: word old new" }
{ $values { "word" "a word with stack effect " { $snippet "( -- ? )" } } { "old" "a C type" } { "new" "a C type" } }
{ $description "Aliases the C type " { $snippet "old" } " under the name " { $snippet "new" } " if " { $snippet "word" } " evaluates to a true value." }
{ $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ; { $notes "This word differs from " { $link typedef } " in that it runs at parse time, to ensure correct ordering of operations when loading source files. Words defined in source files are compiled before top-level forms are run, so if a source file defines C binding words and uses " { $link typedef } ", the type alias won't be available at compile time." } ;
HELP: C-STRUCT: HELP: C-STRUCT:
@ -81,7 +88,9 @@ HELP: typedef
{ $description "Alises the C type " { $snippet "old" } " under the name " { $snippet "new" } "." } { $description "Alises the C type " { $snippet "old" } " under the name " { $snippet "new" } "." }
{ $notes "Using this word in the same source file which defines C bindings can cause problems, because words are compiled before top-level forms are run. Use the " { $link POSTPONE: TYPEDEF: } " word instead." } ; { $notes "Using this word in the same source file which defines C bindings can cause problems, because words are compiled before top-level forms are run. Use the " { $link POSTPONE: TYPEDEF: } " word instead." } ;
{ typedef POSTPONE: TYPEDEF: } related-words { typedef POSTPONE: TYPEDEF: POSTPONE: TYPEDEF-IF: } related-words
{ POSTPONE: TYPEDEF: typedef POSTPONE: TYPEDEF-IF: } related-words
{ POSTPONE: TYPEDEF-IF: POSTPONE: TYPEDEF: typedef } related-words
HELP: c-struct? HELP: c-struct?
{ $values { "type" "a string" } { "?" "a boolean" } } { $values { "type" "a string" } { "?" "a boolean" } }

View File

@ -23,6 +23,15 @@ IN: alien.syntax
PRIVATE> PRIVATE>
: indirect-quot ( function-ptr-quot return types abi -- quot )
[ alien-indirect ] 3curry compose ;
: define-indirect ( abi return function-ptr-quot function-name parameters -- )
>r pick r> parse-arglist
rot create-in dup reset-generic
>r >r swapd roll indirect-quot r> r>
-rot define-declared ;
: DLL" skip-blank parse-string dlopen parsed ; parsing : DLL" skip-blank parse-string dlopen parsed ; parsing
: ALIEN: scan string>number <alien> parsed ; parsing : ALIEN: scan string>number <alien> parsed ; parsing
@ -37,6 +46,9 @@ PRIVATE>
: TYPEDEF: : TYPEDEF:
scan scan typedef ; parsing scan scan typedef ; parsing
: TYPEDEF-IF:
scan-word execute scan scan rot [ typedef ] [ 2drop ] if ; parsing
: C-STRUCT: : C-STRUCT:
scan in get scan in get
parse-definition parse-definition

View File

@ -51,14 +51,8 @@ HOOK: %save-dispatch-xt compiler-backend ( -- )
M: object %save-dispatch-xt %save-word-xt ; M: object %save-dispatch-xt %save-word-xt ;
! Call C primitive ! Call another word
HOOK: %call-primitive compiler-backend ( label -- ) HOOK: %call compiler-backend ( word -- )
! Call another label
HOOK: %call-label compiler-backend ( label -- )
! Far jump to C primitive
HOOK: %jump-primitive compiler-backend ( label -- )
! Local jump for branches ! Local jump for branches
HOOK: %jump-label compiler-backend ( label -- ) HOOK: %jump-label compiler-backend ( label -- )

View File

@ -97,26 +97,14 @@ M: ppc-backend %epilogue ( n -- )
1 1 rot ADDI 1 1 rot ADDI
0 MTLR ; 0 MTLR ;
: %prepare-primitive ( word -- )
#! Save stack pointer to stack_chain->callstack_top, load XT
4 1 MR
0 11 LOAD32
rc-absolute-ppc-2/2 rel-primitive ;
: (%call) 11 MTLR BLRL ; : (%call) 11 MTLR BLRL ;
M: ppc-backend %call-primitive ( word -- )
%prepare-primitive (%call) ;
: (%jump) 11 MTCTR BCTR ; : (%jump) 11 MTCTR BCTR ;
M: ppc-backend %jump-primitive ( word -- )
%prepare-primitive (%jump) ;
: %load-dlsym ( symbol dll register -- ) : %load-dlsym ( symbol dll register -- )
0 swap LOAD32 rc-absolute-ppc-2/2 rel-dlsym ; 0 swap LOAD32 rc-absolute-ppc-2/2 rel-dlsym ;
M: ppc-backend %call-label ( label -- ) BL ; M: ppc-backend %call ( label -- ) BL ;
M: ppc-backend %jump-label ( label -- ) B ; M: ppc-backend %jump-label ( label -- ) B ;

View File

@ -70,15 +70,7 @@ M: x86-backend %prepare-alien-invoke
temp-reg v>operand 2 cells [+] ds-reg MOV temp-reg v>operand 2 cells [+] ds-reg MOV
temp-reg v>operand 3 cells [+] rs-reg MOV ; temp-reg v>operand 3 cells [+] rs-reg MOV ;
M: x86-backend %call-primitive ( word -- ) M: x86-backend %call ( label -- ) CALL ;
stack-save-reg stack-reg cell neg [+] LEA
address-operand CALL ;
M: x86-backend %jump-primitive ( word -- )
stack-save-reg stack-reg MOV
address-operand JMP ;
M: x86-backend %call-label ( label -- ) CALL ;
M: x86-backend %jump-label ( label -- ) JMP ; M: x86-backend %jump-label ( label -- ) JMP ;

View File

@ -100,21 +100,10 @@ UNION: #terminal
! node ! node
M: node generate-node drop iterate-next ; M: node generate-node drop iterate-next ;
: %call ( word -- )
dup primitive? [ %call-primitive ] [ %call-label ] if ;
: %jump ( word -- ) : %jump ( word -- )
{ dup compiling-label get eq?
{ [ dup compiling-label get eq? ] [ [ drop current-label-start get ] [ %epilogue-later ] if
drop current-label-start get %jump-label %jump-label ;
] }
{ [ dup primitive? ] [
%epilogue-later %jump-primitive
] }
{ [ t ] [
%epilogue-later %jump-label
] }
} cond ;
: generate-call ( label -- next ) : generate-call ( label -- next )
dup maybe-compile dup maybe-compile

View File

@ -1,6 +1,6 @@
IN: temporary IN: temporary
USING: sequences inference.transforms tools.test math kernel USING: sequences inference.transforms tools.test math kernel
quotations ; quotations tools.test.inference ;
: compose-n-quot <repetition> >quotation ; : compose-n-quot <repetition> >quotation ;
: compose-n compose-n-quot call ; : compose-n compose-n-quot call ;
@ -18,3 +18,5 @@ quotations ;
[ 268 ] [ 1 { 8 { 3 2 } } bitfield-quot call ] unit-test [ 268 ] [ 1 { 8 { 3 2 } } bitfield-quot call ] unit-test
[ 512 ] [ 1 { { 1+ 8 } } bitfield-quot call ] unit-test [ 512 ] [ 1 { { 1+ 8 } } bitfield-quot call ] unit-test
\ construct-empty must-infer

View File

@ -1,8 +1,8 @@
! Copyright (C) 2007 Slava Pestov. ! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel words sequences generic math namespaces USING: arrays kernel words sequences generic math namespaces
quotations assocs combinators math.bitfields inference.backend quotations assocs combinators math.bitfields inference.backend
inference.dataflow inference.state tuples.private ; inference.dataflow inference.state tuples.private effects ;
IN: inference.transforms IN: inference.transforms
: pop-literals ( n -- rstate seq ) : pop-literals ( n -- rstate seq )
@ -61,11 +61,21 @@ M: pair (bitfield-quot) ( spec -- quot )
\ set-slots [ <reversed> [get-slots] ] 1 define-transform \ set-slots [ <reversed> [get-slots] ] 1 define-transform
: [construct] ( word quot -- newquot ) \ construct-boa [
>r dup +inlined+ depends-on dup tuple-size r> 2curry ; dup +inlined+ depends-on
dup tuple-size [ <tuple-boa> ] 2curry
] 1 define-transform
\ construct-boa \ construct-empty [
[ [ <tuple-boa> ] [construct] ] 1 define-transform 1 ensure-values
peek-d value? [
pop-literal
dup +inlined+ depends-on
dup tuple-size [ <tuple> ] 2curry
swap infer-quot
] [
\ construct-empty declared-infer
] if
] "infer" set-word-prop
\ construct-empty \ construct-empty 1 1 <effect> "inferred-effect" set-word-prop
[ [ <tuple> ] [construct] ] 1 define-transform

View File

@ -35,6 +35,9 @@ GENERIC: stream-write-table ( table-cells style stream -- )
! Default stream ! Default stream
SYMBOL: stdio SYMBOL: stdio
! Default error stream
SYMBOL: stderr
: close ( -- ) stdio get stream-close ; : close ( -- ) stdio get stream-close ;
: readln ( -- str/f ) stdio get stream-readln ; : readln ( -- str/f ) stdio get stream-readln ;

View File

@ -14,9 +14,10 @@ ARTICLE: "io.streams.c" "ANSI C streams"
{ $subsection fclose } { $subsection fclose }
{ $subsection fgetc } { $subsection fgetc }
{ $subsection fread } { $subsection fread }
"Two standard file handles:" "The three standard file handles:"
{ $subsection stdin } { $subsection stdin-handle }
{ $subsection stdout } ; { $subsection stdout-handle }
{ $subsection stderr-handle } ;
ABOUT: "io.streams.c" ABOUT: "io.streams.c"
@ -64,10 +65,14 @@ HELP: fread ( n alien -- str/f )
{ $description "Reads a sequence of characters from a C FILE* handle, and outputs " { $link f } " on end of file." } { $description "Reads a sequence of characters from a C FILE* handle, and outputs " { $link f } " on end of file." }
{ $errors "Throws an error if the input operation failed." } ; { $errors "Throws an error if the input operation failed." } ;
HELP: stdin HELP: stdin-handle
{ $values { "in" "a C FILE* handle" } } { $values { "in" "a C FILE* handle" } }
{ $description "Outputs the console standard input file handle." } ; { $description "Outputs the console standard input file handle." } ;
HELP: stdout HELP: stdout-handle
{ $values { "out" "a C FILE* handle" } } { $values { "out" "a C FILE* handle" } }
{ $description "Outputs the console standard output file handle." } ; { $description "Outputs the console standard output file handle." } ;
HELP: stderr-handle
{ $values { "out" "a C FILE* handle" } }
{ $description "Outputs the console standard error file handle." } ;

View File

@ -56,12 +56,13 @@ M: c-reader stream-close
M: object init-io ; M: object init-io ;
: stdin 11 getenv ; : stdin-handle 11 getenv ;
: stdout-handle 12 getenv ;
: stdout 12 getenv ; : stderr-handle 38 getenv ;
M: object init-stdio M: object init-stdio
stdin stdout <duplex-c-stream> stdio set-global ; stdin-handle stdout-handle <duplex-c-stream> stdio set-global
stderr-handle <c-writer> <plain-writer> stderr set-global ;
M: object io-multiplex (sleep) ; M: object io-multiplex (sleep) ;

View File

@ -49,7 +49,7 @@ ARTICLE: "basic-combinators" "Basic combinators"
{ $subsection execute } { $subsection execute }
"These words are used to implement " { $emphasis "combinators" } ", which are words that take code from the stack. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:" "These words are used to implement " { $emphasis "combinators" } ", which are words that take code from the stack. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:"
{ $code { $code
": keep ( x quot -- x | quot: x -- )" ": keep ( x quot -- x )"
" over >r call r> ; inline" " over >r call r> ; inline"
} }
"Word inlining is documented in " { $link "declarations" } "." "Word inlining is documented in " { $link "declarations" } "."
@ -557,7 +557,7 @@ HELP: dip
HELP: while HELP: while
{ $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } } { $values { "pred" "a quotation with stack effect " { $snippet "( -- ? )" } } { "body" "a quotation" } { "tail" "a quotation" } }
{ $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "quot" } " is called. After iteration stops, " { $snippet "tail" } " is called." } { $description "Repeatedly calls " { $snippet "pred" } ". If it yields " { $link f } ", iteration stops, otherwise " { $snippet "body" } " is called. After iteration stops, " { $snippet "tail" } " is called." }
{ $notes "In most cases, tail recursion should be used, because it is simpler both in terms of implementation and conceptually. However in some cases this combinator expresses intent better and should be used." { $notes "In most cases, tail recursion should be used, because it is simpler both in terms of implementation and conceptually. However in some cases this combinator expresses intent better and should be used."
$nl $nl
"Strictly speaking, the " { $snippet "tail" } " is not necessary, since the following are equivalent:" "Strictly speaking, the " { $snippet "tail" } " is not necessary, since the following are equivalent:"

View File

@ -15,16 +15,16 @@ IN: namespaces
PRIVATE> PRIVATE>
: namespace ( -- namespace ) namestack* peek ; : namespace ( -- namespace ) namestack* peek ;
: namestack ( -- namestack ) namestack* clone ; inline : namestack ( -- namestack ) namestack* clone ;
: set-namestack ( namestack -- ) >vector 0 setenv ; inline : set-namestack ( namestack -- ) >vector 0 setenv ;
: global ( -- g ) 21 getenv { hashtable } declare ; inline : global ( -- g ) 21 getenv { hashtable } declare ; inline
: init-namespaces ( -- ) global 1array set-namestack ; : init-namespaces ( -- ) global 1array set-namestack ;
: get ( variable -- value ) namestack* assoc-stack ; flushable : get ( variable -- value ) namestack* assoc-stack ; flushable
: set ( value variable -- ) namespace set-at ; : set ( value variable -- ) namespace set-at ;
: on ( variable -- ) t swap set ; inline : on ( variable -- ) t swap set ; inline
: off ( variable -- ) f swap set ; inline : off ( variable -- ) f swap set ; inline
: get-global ( variable -- value ) global at ; inline : get-global ( variable -- value ) global at ;
: set-global ( value variable -- ) global set-at ; inline : set-global ( value variable -- ) global set-at ;
: change ( variable quot -- ) : change ( variable quot -- )
>r dup get r> rot slip set ; inline >r dup get r> rot slip set ; inline

0
core/strings/strings-docs.factor Normal file → Executable file
View File

View File

@ -1,7 +1,7 @@
USING: crypto.sha1 io.files kernel ; USING: crypto.sha1 io.files kernel ;
IN: benchmark.sha1 IN: benchmark.sha1
: sha1-primes-list ( -- seq ) : sha1-primes-list ( -- )
"extra/math/primes/list/list.factor" resource-path file>sha1 ; "extra/math/primes/list/list.factor" resource-path file>sha1 drop ;
MAIN: sha1-primes-list MAIN: sha1-primes-list

View File

@ -0,0 +1 @@
Joe Groff

View File

@ -0,0 +1,152 @@
USING: arrays bunny io io.files kernel
math math.functions math.vectors multiline
namespaces
opengl opengl.gl
prettyprint
sequences ui ui.gadgets ui.gestures ui.render ;
IN: cel-shading
: NEAR-PLANE 1.0 64.0 / ; inline
: FAR-PLANE 4.0 ; inline
: FOV 2.0 sqrt 1+ ; inline
: MOUSE-MOTION-SCALE 0.5 ; inline
: MOUSE-DISTANCE-SCALE 1.0 64.0 / ; inline
: KEY-ROTATE-STEP 1.0 ; inline
: KEY-DISTANCE-STEP 1.0 64.0 / ; inline
: DIMS { 640 480 } ; inline
: FOV-RATIO ( -- fov ) DIMS dup first2 min v/n ;
SYMBOL: last-drag-loc
TUPLE: cel-shading-gadget yaw pitch distance model program ;
: <cel-shading-gadget> ( -- cel-shading-gadget )
cel-shading-gadget construct-gadget
0.0 over set-cel-shading-gadget-yaw
0.0 over set-cel-shading-gadget-pitch
0.375 over set-cel-shading-gadget-distance
maybe-download read-model over set-cel-shading-gadget-model ;
: yaw-cel-shading-gadget ( yaw gadget -- )
[ [ cel-shading-gadget-yaw + ] keep set-cel-shading-gadget-yaw ] keep relayout-1 ;
: pitch-cel-shading-gadget ( pitch gadget -- )
[ [ cel-shading-gadget-pitch + ] keep set-cel-shading-gadget-pitch ] keep relayout-1 ;
: zoom-cel-shading-gadget ( distance gadget -- )
[ [ cel-shading-gadget-distance + ] keep set-cel-shading-gadget-distance ] keep relayout-1 ;
M: cel-shading-gadget pref-dim* ( gadget -- dim )
drop DIMS ;
: -+ ( x -- -x x )
dup neg swap ;
: cel-shading-frustum ( -- -x x -y y near far )
FOV-RATIO NEAR-PLANE FOV / v*n
first2 [ -+ ] 2apply NEAR-PLANE FAR-PLANE ;
STRING: cel-shading-vertex-shader-source
varying vec3 position, normal;
void
main()
{
gl_Position = ftransform();
position = gl_Vertex.xyz;
normal = gl_Normal;
}
;
STRING: cel-shading-fragment-shader-source
varying vec3 position, normal;
uniform vec3 light_direction;
uniform vec4 color;
uniform vec4 ambient, diffuse;
float
smooth_modulate(vec3 direction, vec3 normal)
{
return clamp(dot(direction, normal), 0.0, 1.0);
}
float
modulate(vec3 direction, vec3 normal)
{
float m = smooth_modulate(direction, normal);
return smoothstep(0.0, 0.01, m) * 0.4 + smoothstep(0.49, 0.5, m) * 0.5;
}
void
main()
{
vec3 direction = normalize(light_direction - position);
gl_FragColor = ambient + diffuse * color * vec4(vec3(modulate(direction, normal)), 1);
}
;
: cel-shading-program ( -- program )
cel-shading-vertex-shader-source <vertex-shader> check-gl-shader
cel-shading-fragment-shader-source <fragment-shader> check-gl-shader
2array <gl-program> check-gl-program ;
M: cel-shading-gadget graft* ( gadget -- )
0.0 0.0 0.0 1.0 glClearColor
GL_CULL_FACE glEnable
GL_DEPTH_TEST glEnable
cel-shading-program swap set-cel-shading-gadget-program ;
M: cel-shading-gadget ungraft* ( gadget -- )
cel-shading-gadget-program delete-gl-program ;
: cel-shading-draw-setup ( gadget -- gadget )
GL_PROJECTION glMatrixMode
glLoadIdentity
cel-shading-frustum glFrustum
GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor glClear
GL_MODELVIEW glMatrixMode
glLoadIdentity
[ >r 0.0 0.0 r> cel-shading-gadget-distance neg glTranslatef ] keep
[ cel-shading-gadget-pitch 1.0 0.0 0.0 glRotatef ] keep
[ cel-shading-gadget-yaw 0.0 1.0 0.0 glRotatef ] keep
[ cel-shading-gadget-program [ "light_direction" glGetUniformLocation -25.0 45.0 80.0 glUniform3f ] keep
[ "color" glGetUniformLocation 0.6 0.5 0.5 1.0 glUniform4f ] keep
[ "ambient" glGetUniformLocation 0.2 0.2 0.2 0.2 glUniform4f ] keep
"diffuse" glGetUniformLocation 0.8 0.8 0.8 0.8 glUniform4f ] keep ;
M: cel-shading-gadget draw-gadget* ( gadget -- )
dup cel-shading-gadget-program [
cel-shading-draw-setup
0.0 -0.12 0.0 glTranslatef
cel-shading-gadget-model first3 draw-bunny
] with-gl-program ;
: reset-last-drag-rel ( -- )
{ 0 0 } last-drag-loc set ;
: last-drag-rel ( -- rel )
drag-loc [ last-drag-loc get v- ] keep last-drag-loc set ;
: drag-yaw-pitch ( -- yaw pitch )
last-drag-rel MOUSE-MOTION-SCALE v*n first2 ;
cel-shading-gadget H{
{ T{ key-down f f "LEFT" } [ KEY-ROTATE-STEP neg swap yaw-cel-shading-gadget ] }
{ T{ key-down f f "RIGHT" } [ KEY-ROTATE-STEP swap yaw-cel-shading-gadget ] }
{ T{ key-down f f "DOWN" } [ KEY-ROTATE-STEP neg swap pitch-cel-shading-gadget ] }
{ T{ key-down f f "UP" } [ KEY-ROTATE-STEP swap pitch-cel-shading-gadget ] }
{ T{ key-down f f "=" } [ KEY-DISTANCE-STEP neg swap zoom-cel-shading-gadget ] }
{ T{ key-down f f "-" } [ KEY-DISTANCE-STEP swap zoom-cel-shading-gadget ] }
{ T{ button-down f f 1 } [ drop reset-last-drag-rel ] }
{ T{ drag f 1 } [ drag-yaw-pitch rot [ pitch-cel-shading-gadget ] keep yaw-cel-shading-gadget ] }
{ T{ mouse-scroll } [ scroll-direction get second MOUSE-DISTANCE-SCALE * swap zoom-cel-shading-gadget ] }
} set-gestures
: cel-shading-window ( -- )
[ <cel-shading-gadget> "Cel Shading" open-window ] with-ui ;
MAIN: cel-shading-window

View File

@ -0,0 +1 @@
Stanford Bunny rendered with a cel-shading GLSL program

View File

@ -0,0 +1,3 @@
demos
opengl
glsl

View File

@ -85,7 +85,7 @@ HELP: run-detached
HELP: <process-stream> HELP: <process-stream>
{ $values { "obj" object } { "stream" "a bidirectional stream" } } { $values { "obj" object } { "stream" "a bidirectional stream" } }
{ $description "Launches a process and redirects its input and output via a paper of pipes which may be read and written as a stream." } { $description "Launches a process and redirects its input and output via a pair of pipes which may be read and written as a stream." }
{ $notes "Closing the stream will block until the process exits." } ; { $notes "Closing the stream will block until the process exits." } ;
{ run-process run-detached <process-stream> } related-words { run-process run-detached <process-stream> } related-words

View File

@ -1,21 +1,24 @@
! Copyright (C) 2004, 2007 Slava Pestov. ! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien bit-arrays generic assocs io kernel USING: alien generic assocs kernel kernel.private math
kernel.private math io.nonblocking sequences strings structs io.nonblocking sequences strings structs sbufs threads unix
sbufs threads unix vectors io.buffers io.backend vectors io.buffers io.backend io.streams.duplex math.parser
io.streams.duplex math.parser continuations system libc ; continuations system libc qualified namespaces ;
QUALIFIED: io
IN: io.unix.backend IN: io.unix.backend
! Multiplexer protocol
SYMBOL: unix-io-backend
HOOK: init-unix-io unix-io-backend ( -- )
HOOK: register-io-task unix-io-backend ( task -- )
HOOK: unregister-io-task unix-io-backend ( task -- )
HOOK: unix-io-multiplex unix-io-backend ( timeval -- )
TUPLE: unix-io ; TUPLE: unix-io ;
! We want namespaces::bind to shadow the bind system call from
! unix
USING: namespaces ;
! Global variables ! Global variables
SYMBOL: read-fdset
SYMBOL: read-tasks SYMBOL: read-tasks
SYMBOL: write-fdset
SYMBOL: write-tasks SYMBOL: write-tasks
! Some general stuff ! Some general stuff
@ -53,9 +56,9 @@ M: integer close-handle ( fd -- )
! port to finish I/O ! port to finish I/O
TUPLE: io-task port callbacks ; TUPLE: io-task port callbacks ;
: <io-task> ( port class -- task ) : <io-task> ( port continuation class -- task )
>r V{ } clone io-task construct-boa >r 1vector io-task construct-boa r> construct-delegate ;
{ set-delegate } r> construct ; inline inline
! Multiplexer ! Multiplexer
GENERIC: do-io-task ( task -- ? ) GENERIC: do-io-task ( task -- ? )
@ -63,58 +66,30 @@ GENERIC: task-container ( task -- vector )
: io-task-fd io-task-port port-handle ; : io-task-fd io-task-port port-handle ;
: add-io-task ( callback task -- ) : check-io-task ( task -- )
[ io-task-callbacks push ] keep dup io-task-fd swap task-container at [
dup io-task-fd over task-container 2dup at [
"Cannot perform multiple reads from the same port" throw "Cannot perform multiple reads from the same port" throw
] when set-at ; ] when ;
: add-io-task ( task -- )
dup check-io-task
dup register-io-task
dup io-task-fd over task-container set-at ;
: remove-io-task ( task -- ) : remove-io-task ( task -- )
dup io-task-fd swap task-container delete-at ; dup io-task-fd over task-container delete-at
unregister-io-task ;
: pop-callbacks ( task -- ) : pop-callbacks ( task -- )
dup io-task-callbacks swap remove-io-task dup remove-io-task
[ schedule-thread ] each ; io-task-callbacks [ schedule-thread ] each ;
: handle-fd ( task -- ) : handle-fd ( task -- )
dup io-task-port touch-port dup io-task-port touch-port
dup do-io-task [ pop-callbacks ] [ drop ] if ; dup do-io-task [ pop-callbacks ] [ drop ] if ;
: handle-fdset ( fdset tasks -- ) : handle-timeout ( task -- )
swap [ "Timeout" over io-task-port report-error pop-callbacks ;
swap dup io-task-port timeout? [
dup io-task-port "Timeout" swap report-error
nip pop-callbacks
] [
tuck io-task-fd swap nth
[ handle-fd ] [ drop ] if
] if drop
] curry assoc-each ;
: init-fdset ( fdset tasks -- )
swap dup clear-bits
[ >r drop t swap r> set-nth ] curry assoc-each ;
: read-fdset/tasks
read-fdset get-global read-tasks get-global ;
: write-fdset/tasks
write-fdset get-global write-tasks get-global ;
: init-fdsets ( -- read write except )
read-fdset/tasks dupd init-fdset
write-fdset/tasks dupd init-fdset
f ;
: (io-multiplex) ( ms -- )
>r FD_SETSIZE init-fdsets r> make-timeval select 0 < [
err_no ignorable-error? [ (io-error) ] unless
] when ;
M: unix-io io-multiplex ( ms -- )
(io-multiplex)
read-fdset/tasks handle-fdset
write-fdset/tasks handle-fdset ;
! Readers ! Readers
: reader-eof ( reader -- ) : reader-eof ( reader -- )
@ -137,17 +112,18 @@ M: unix-io io-multiplex ( ms -- )
TUPLE: read-task ; TUPLE: read-task ;
: <read-task> ( port -- task ) read-task <io-task> ; : <read-task> ( port continuation -- task )
read-task <io-task> ;
M: read-task do-io-task M: read-task do-io-task
io-task-port dup refill io-task-port dup refill
[ [ reader-eof ] [ drop ] if ] keep ; [ [ reader-eof ] [ drop ] if ] keep ;
M: read-task task-container drop read-tasks get-global ; M: read-task task-container
drop read-tasks get-global ;
M: input-port (wait-to-read) M: input-port (wait-to-read)
[ swap <read-task> add-io-task stop ] callcc0 [ <read-task> add-io-task stop ] callcc0 pending-error ;
pending-error ;
! Writers ! Writers
: write-step ( port -- ? ) : write-step ( port -- ? )
@ -156,35 +132,38 @@ M: input-port (wait-to-read)
TUPLE: write-task ; TUPLE: write-task ;
: <write-task> ( port -- task ) write-task <io-task> ; : <write-task> ( port continuation -- task )
write-task <io-task> ;
M: write-task do-io-task M: write-task do-io-task
io-task-port dup buffer-empty? over port-error or io-task-port dup buffer-empty? over port-error or
[ 0 swap buffer-reset t ] [ write-step ] if ; [ 0 swap buffer-reset t ] [ write-step ] if ;
M: write-task task-container drop write-tasks get-global ; M: write-task task-container
drop write-tasks get-global ;
: add-write-io-task ( callback task -- ) : add-write-io-task ( port continuation -- )
dup io-task-fd write-tasks get-global at over port-handle write-tasks get-global at
[ io-task-callbacks push ] [ add-io-task ] ?if ; [ io-task-callbacks push drop ]
[ <write-task> add-io-task ] if* ;
: (wait-to-write) ( port -- ) : (wait-to-write) ( port -- )
[ swap <write-task> add-write-io-task stop ] callcc0 drop ; [ add-write-io-task stop ] callcc0 drop ;
M: port port-flush ( port -- ) M: port port-flush ( port -- )
dup buffer-empty? [ drop ] [ (wait-to-write) ] if ; dup buffer-empty? [ drop ] [ (wait-to-write) ] if ;
USE: io M: unix-io io-multiplex ( ms -- )
unix-io-multiplex ;
M: unix-io init-io ( -- ) M: unix-io init-io ( -- )
#! Should only be called on startup. Calling this at any H{ } clone read-tasks set-global
#! other time can have unintended consequences. H{ } clone write-tasks set-global
global [ init-unix-io ;
H{ } clone read-tasks set
FD_SETSIZE 8 * <bit-array> read-fdset set
H{ } clone write-tasks set
FD_SETSIZE 8 * <bit-array> write-fdset set
] bind ;
M: unix-io init-stdio ( -- ) M: unix-io init-stdio ( -- )
0 1 handle>duplex-stream stdio set-global ; 0 1 handle>duplex-stream io:stdio set-global
2 <writer> io:stderr set-global ;
: multiplexer-error ( n -- )
0 < [ err_no ignorable-error? [ (io-error) ] unless ] when ;

View File

@ -0,0 +1,106 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types kernel io.nonblocking io.unix.backend
io.unix.sockets sequences assocs unix unix.kqueue math
namespaces classes combinators ;
IN: io.unix.backend.kqueue
TUPLE: unix-kqueue-io ;
! Global variables
SYMBOL: kqueue-fd
SYMBOL: kqueue-added
SYMBOL: kqueue-deleted
SYMBOL: kqueue-events
: max-events ( -- n )
#! We read up to 256 events at a time. This is an arbitrary
#! constant...
256 ; inline
M: unix-kqueue-io init-unix-io ( -- )
H{ } clone kqueue-added set-global
H{ } clone kqueue-deleted set-global
max-events "kevent" <c-array> kqueue-events set-global
kqueue dup io-error kqueue-fd set-global ;
M: unix-kqueue-io register-io-task ( task -- )
dup io-task-fd kqueue-added get-global key? [ drop ] [
dup io-task-fd kqueue-deleted get-global key? [
io-task-fd kqueue-deleted get-global delete-at
] [
dup io-task-fd kqueue-added get-global set-at
] if
] if ;
M: unix-kqueue-io unregister-io-task ( task -- )
dup io-task-fd kqueue-deleted get-global key? [ drop ] [
dup io-task-fd kqueue-added get-global key? [
io-task-fd kqueue-added get-global delete-at
] [
dup io-task-fd kqueue-deleted get-global set-at
] if
] if ;
: io-task-filter ( task -- n )
class {
{ read-task [ EVFILT_READ ] }
{ accept-task [ EVFILT_READ ] }
{ receive-task [ EVFILT_READ ] }
{ write-task [ EVFILT_WRITE ] }
{ connect-task [ EVFILT_WRITE ] }
{ send-task [ EVFILT_WRITE ] }
} case ;
: make-kevent ( task -- event )
"kevent" <c-object>
over io-task-fd over set-kevent-ident
swap io-task-filter over set-kevent-filter ;
: make-add-kevent ( task -- event )
make-kevent
EV_ADD over set-kevent-flags ;
: make-delete-kevent ( task -- event )
make-kevent
EV_DELETE over set-kevent-flags ;
: kqueue-additions ( -- kevents )
kqueue-added get-global
dup clear-assoc values
[ make-add-kevent ] map ;
: kqueue-deletions ( -- kevents )
kqueue-deleted get-global
dup clear-assoc values
[ make-delete-kevent ] map ;
: kqueue-changelist ( -- byte-array n )
kqueue-additions kqueue-deletions append
dup concat f like swap length ;
: kqueue-eventlist ( -- byte-array n )
kqueue-events get-global max-events ;
: do-kevent ( timespec -- n )
>r
kqueue-fd get-global
kqueue-changelist
kqueue-eventlist
r> kevent dup multiplexer-error ;
: kevent-task ( kevent -- task )
dup kevent-ident swap kevent-filter {
{ [ dup EVFILT_READ = ] [ read-tasks ] }
{ [ dup EVFILT_WRITE = ] [ write-tasks ] }
} cond nip get at ;
: handle-kevents ( n eventlist -- )
[ kevent-nth kevent-task handle-fd ] curry each ;
M: unix-kqueue-io unix-io-multiplex ( ms -- )
make-timespec
do-kevent
kqueue-events get-global handle-kevents ;
T{ unix-kqueue-io } unix-io-backend set-global

View File

@ -0,0 +1,52 @@
! Copyright (C) 2004, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax kernel io.nonblocking io.unix.backend
bit-arrays sequences assocs unix math namespaces ;
IN: io.unix.backend.select
TUPLE: unix-select-io ;
! Global variables
SYMBOL: read-fdset
SYMBOL: write-fdset
M: unix-select-io init-unix-io ( -- )
FD_SETSIZE 8 * <bit-array> read-fdset set-global
FD_SETSIZE 8 * <bit-array> write-fdset set-global ;
: handle-fdset ( fdset tasks -- )
swap [
swap dup io-task-port timeout? [
nip handle-timeout
] [
tuck io-task-fd swap nth
[ handle-fd ] [ drop ] if
] if drop
] curry assoc-each ;
: init-fdset ( fdset tasks -- )
swap dup clear-bits
[ >r drop t swap r> set-nth ] curry assoc-each ;
: read-fdset/tasks
read-fdset get-global read-tasks get-global ;
: write-fdset/tasks
write-fdset get-global write-tasks get-global ;
: init-fdsets ( -- read write except )
read-fdset/tasks dupd init-fdset
write-fdset/tasks dupd init-fdset
f ;
M: unix-select-io register-io-task ( task -- ) drop ;
M: unix-select-io unregister-io-task ( task -- ) drop ;
M: unix-select-io unix-io-multiplex ( timeval -- )
make-timeval >r FD_SETSIZE init-fdsets r>
select multiplexer-error
read-fdset/tasks handle-fdset
write-fdset/tasks handle-fdset ;
T{ unix-select-io } unix-io-backend set-global

View File

@ -33,7 +33,8 @@ M: unix-io addrinfo-error ( n -- )
TUPLE: connect-task ; TUPLE: connect-task ;
: <connect-task> ( port -- task ) connect-task <io-task> ; : <connect-task> ( port continuation -- task )
connect-task <io-task> ;
M: connect-task do-io-task M: connect-task do-io-task
io-task-port dup port-handle f 0 write io-task-port dup port-handle f 0 write
@ -42,7 +43,7 @@ M: connect-task do-io-task
M: connect-task task-container drop write-tasks get-global ; M: connect-task task-container drop write-tasks get-global ;
: wait-to-connect ( port -- ) : wait-to-connect ( port -- )
[ swap <connect-task> add-io-task stop ] callcc0 drop ; [ <connect-task> add-io-task stop ] callcc0 drop ;
M: unix-io (client) ( addrspec -- stream ) M: unix-io (client) ( addrspec -- stream )
dup make-sockaddr/size >r >r dup make-sockaddr/size >r >r
@ -66,7 +67,8 @@ USE: unix
TUPLE: accept-task ; TUPLE: accept-task ;
: <accept-task> ( port -- task ) accept-task <io-task> ; : <accept-task> ( port continuation -- task )
accept-task <io-task> ;
M: accept-task task-container drop read-tasks get ; M: accept-task task-container drop read-tasks get ;
@ -85,7 +87,7 @@ M: accept-task do-io-task
over 0 >= [ do-accept t ] [ 2drop defer-error ] if ; over 0 >= [ do-accept t ] [ 2drop defer-error ] if ;
: wait-to-accept ( server -- ) : wait-to-accept ( server -- )
[ swap <accept-task> add-io-task stop ] callcc0 drop ; [ <accept-task> add-io-task stop ] callcc0 drop ;
USE: io.sockets USE: io.sockets
@ -136,7 +138,8 @@ packet-size <byte-array> receive-buffer set-global
TUPLE: receive-task ; TUPLE: receive-task ;
: <receive-task> ( stream -- task ) receive-task <io-task> ; : <receive-task> ( stream continuation -- task )
receive-task <io-task> ;
M: receive-task do-io-task M: receive-task do-io-task
io-task-port io-task-port
@ -152,7 +155,7 @@ M: receive-task do-io-task
M: receive-task task-container drop read-tasks get ; M: receive-task task-container drop read-tasks get ;
: wait-receive ( stream -- ) : wait-receive ( stream -- )
[ swap <receive-task> add-io-task stop ] callcc0 drop ; [ <receive-task> add-io-task stop ] callcc0 drop ;
M: unix-io receive ( datagram -- packet addrspec ) M: unix-io receive ( datagram -- packet addrspec )
dup check-datagram-port dup check-datagram-port
@ -166,7 +169,7 @@ M: unix-io receive ( datagram -- packet addrspec )
TUPLE: send-task packet sockaddr len ; TUPLE: send-task packet sockaddr len ;
: <send-task> ( packet sockaddr len port -- task ) : <send-task> ( packet sockaddr len stream continuation -- task )
send-task <io-task> [ send-task <io-task> [
{ {
set-send-task-packet set-send-task-packet
@ -185,8 +188,7 @@ M: send-task do-io-task
M: send-task task-container drop write-tasks get ; M: send-task task-container drop write-tasks get ;
: wait-send ( packet sockaddr len stream -- ) : wait-send ( packet sockaddr len stream -- )
[ >r <send-task> r> swap add-io-task stop ] callcc0 [ <send-task> add-io-task stop ] callcc0 2drop 2drop ;
2drop 2drop ;
M: unix-io send ( packet addrspec datagram -- ) M: unix-io send ( packet addrspec datagram -- )
3dup check-datagram-send 3dup check-datagram-send

View File

@ -1,9 +1,12 @@
USE: io.unix.backend USING: io.unix.backend io.unix.files io.unix.sockets
USE: io.unix.files io.unix.launcher io.unix.mmap io.backend combinators namespaces
USE: io.unix.sockets system vocabs.loader ;
USE: io.unix.launcher
USE: io.unix.mmap {
USE: io.backend ! kqueue is a work in progress
USE: namespaces ! { [ macosx? ] [ "io.unix.backend.kqueue" ] }
! { [ bsd? ] [ "io.unix.backend.kqueue" ] }
{ [ unix? ] [ "io.unix.backend.select" ] }
} cond require
T{ unix-io } io-backend set-global T{ unix-io } io-backend set-global

View File

@ -1,5 +1,4 @@
USING: help.markup help.syntax ; USING: help.markup help.syntax ;
IN: multiline IN: multiline
HELP: STRING: HELP: STRING:

View File

@ -3,7 +3,9 @@
! This file is based on the gl.h that comes with xorg-x11 6.8.2 ! This file is based on the gl.h that comes with xorg-x11 6.8.2
USING: alien alien.syntax kernel sequences words ; USING: alien alien.syntax kernel parser sequences system words ;
<< windows? "opengl.gl.windows" "opengl.gl.unix" ? use+ >>
IN: opengl.gl IN: opengl.gl
TYPEDEF: uint GLenum TYPEDEF: uint GLenum
@ -1118,195 +1120,688 @@ FUNCTION: void glPushName ( GLuint name ) ;
FUNCTION: void glPopName ( ) ; FUNCTION: void glPopName ( ) ;
! OpenGL extension functions
! OpenGL 1.2 ! OpenGL 1.2
: GL_PACK_SKIP_IMAGES HEX: 806B ; inline
: GL_PACK_IMAGE_HEIGHT HEX: 806C ; inline
: GL_UNPACK_SKIP_IMAGES HEX: 806D ; inline
: GL_UNPACK_IMAGE_HEIGHT HEX: 806E ; inline
: GL_TEXTURE_3D HEX: 806F ; inline
: GL_PROXY_TEXTURE_3D HEX: 8070 ; inline
: GL_TEXTURE_DEPTH HEX: 8071 ; inline
: GL_TEXTURE_WRAP_R HEX: 8072 ; inline
: GL_MAX_3D_TEXTURE_SIZE HEX: 8073 ; inline
: GL_BGR HEX: 80E0 ; inline
: GL_BGRA HEX: 80E1 ; inline
: GL_UNSIGNED_BYTE_3_3_2 HEX: 8032 ; inline
: GL_UNSIGNED_BYTE_2_3_3_REV HEX: 8362 ; inline
: GL_UNSIGNED_SHORT_5_6_5 HEX: 8363 ; inline
: GL_UNSIGNED_SHORT_5_6_5_REV HEX: 8364 ; inline
: GL_UNSIGNED_SHORT_4_4_4_4 HEX: 8033 ; inline
: GL_UNSIGNED_SHORT_4_4_4_4_REV HEX: 8365 ; inline
: GL_UNSIGNED_SHORT_5_5_5_1 HEX: 8034 ; inline
: GL_UNSIGNED_SHORT_1_5_5_5_REV HEX: 8366 ; inline
: GL_UNSIGNED_INT_8_8_8_8 HEX: 8035 ; inline
: GL_UNSIGNED_INT_8_8_8_8_REV HEX: 8367 ; inline
: GL_UNSIGNED_INT_10_10_10_2 HEX: 8036 ; inline
: GL_UNSIGNED_INT_2_10_10_10_REV HEX: 8368 ; inline
: GL_RESCALE_NORMAL HEX: 803A ; inline
: GL_LIGHT_MODEL_COLOR_CONTROL HEX: 81F8 ; inline
: GL_SINGLE_COLOR HEX: 81F9 ; inline
: GL_SEPARATE_SPECULAR_COLOR HEX: 81FA ; inline
: GL_CLAMP_TO_EDGE HEX: 812F ; inline
: GL_TEXTURE_MIN_LOD HEX: 813A ; inline
: GL_TEXTURE_MAX_LOD HEX: 813B ; inline
: GL_TEXTURE_BASE_LEVEL HEX: 813C ; inline
: GL_TEXTURE_MAX_LEVEL HEX: 813D ; inline
: GL_MAX_ELEMENTS_VERTICES HEX: 80E8 ; inline
: GL_MAX_ELEMENTS_INDICES HEX: 80E9 ; inline
: GL_ALIASED_POINT_SIZE_RANGE HEX: 846D ; inline
: GL_ALIASED_LINE_WIDTH_RANGE HEX: 846E ; inline
: GL_SMOOTH_POINT_SIZE_RANGE HEX: 0B12 ; inline
: GL_SMOOTH_POINT_SIZE_GRANULARITY HEX: 0B13 ; inline
: GL_SMOOTH_LINE_WIDTH_RANGE HEX: 0B22 ; inline
: GL_SMOOTH_LINE_WIDTH_GRANULARITY HEX: 0B23 ; inline
: GL_UNSIGNED_BYTE_3_3_2 HEX: 8032 ; inline
: GL_UNSIGNED_SHORT_4_4_4_4 HEX: 8033 ; inline
: GL_UNSIGNED_SHORT_5_5_5_1 HEX: 8034 ; inline
: GL_UNSIGNED_INT_8_8_8_8 HEX: 8035 ; inline
: GL_UNSIGNED_INT_10_10_10_2 HEX: 8036 ; inline
: GL_RESCALE_NORMAL HEX: 803A ; inline
: GL_TEXTURE_BINDING_3D HEX: 806A ; inline
: GL_PACK_SKIP_IMAGES HEX: 806B ; inline
: GL_PACK_IMAGE_HEIGHT HEX: 806C ; inline
: GL_UNPACK_SKIP_IMAGES HEX: 806D ; inline
: GL_UNPACK_IMAGE_HEIGHT HEX: 806E ; inline
: GL_TEXTURE_3D HEX: 806F ; inline
: GL_PROXY_TEXTURE_3D HEX: 8070 ; inline
: GL_TEXTURE_DEPTH HEX: 8071 ; inline
: GL_TEXTURE_WRAP_R HEX: 8072 ; inline
: GL_MAX_3D_TEXTURE_SIZE HEX: 8073 ; inline
: GL_BGR HEX: 80E0 ; inline
: GL_BGRA HEX: 80E1 ; inline
: GL_MAX_ELEMENTS_VERTICES HEX: 80E8 ; inline
: GL_MAX_ELEMENTS_INDICES HEX: 80E9 ; inline
: GL_CLAMP_TO_EDGE HEX: 812F ; inline
: GL_TEXTURE_MIN_LOD HEX: 813A ; inline
: GL_TEXTURE_MAX_LOD HEX: 813B ; inline
: GL_TEXTURE_BASE_LEVEL HEX: 813C ; inline
: GL_TEXTURE_MAX_LEVEL HEX: 813D ; inline
: GL_LIGHT_MODEL_COLOR_CONTROL HEX: 81F8 ; inline
: GL_SINGLE_COLOR HEX: 81F9 ; inline
: GL_SEPARATE_SPECULAR_COLOR HEX: 81FA ; inline
: GL_UNSIGNED_BYTE_2_3_3_REV HEX: 8362 ; inline
: GL_UNSIGNED_SHORT_5_6_5 HEX: 8363 ; inline
: GL_UNSIGNED_SHORT_5_6_5_REV HEX: 8364 ; inline
: GL_UNSIGNED_SHORT_4_4_4_4_REV HEX: 8365 ; inline
: GL_UNSIGNED_SHORT_1_5_5_5_REV HEX: 8366 ; inline
: GL_UNSIGNED_INT_8_8_8_8_REV HEX: 8367 ; inline
: GL_UNSIGNED_INT_2_10_10_10_REV HEX: 8368 ; inline
: GL_ALIASED_POINT_SIZE_RANGE HEX: 846D ; inline
: GL_ALIASED_LINE_WIDTH_RANGE HEX: 846E ; inline
! Not present on Windows GL-FUNCTION: void glCopyTexSubImage3D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) ;
! FUNCTION: void glDrawRangeElements ( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLvoid* indices ) ; GL-FUNCTION: void glDrawRangeElements ( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLvoid* indices ) ;
GL-FUNCTION: void glTexImage3D ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid* pixels ) ;
GL-FUNCTION: void glTexSubImage3D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* pixels ) ;
! FUNCTION: void glTexImage3D ( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid* pixels ) ;
! FUNCTION: void glTexSubImage3D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid* pixels ) ;
! FUNCTION: void glCopyTexSubImage3D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ) ;
! TODO: the rest. looks fiddly
! OpenGL 1.3 ! OpenGL 1.3
: GL_ACTIVE_TEXTURE HEX: 84E0 ; inline
: GL_CLIENT_ACTIVE_TEXTURE HEX: 84E1 ; inline : GL_MULTISAMPLE HEX: 809D ; inline
: GL_MAX_TEXTURE_UNITS HEX: 84E2 ; inline : GL_SAMPLE_ALPHA_TO_COVERAGE HEX: 809E ; inline
: GL_TEXTURE0 HEX: 84C0 ; inline : GL_SAMPLE_ALPHA_TO_ONE HEX: 809F ; inline
: GL_TEXTURE1 HEX: 84C1 ; inline : GL_SAMPLE_COVERAGE HEX: 80A0 ; inline
: GL_TEXTURE2 HEX: 84C2 ; inline : GL_SAMPLE_BUFFERS HEX: 80A8 ; inline
: GL_TEXTURE3 HEX: 84C3 ; inline : GL_SAMPLES HEX: 80A9 ; inline
: GL_TEXTURE4 HEX: 84C4 ; inline : GL_SAMPLE_COVERAGE_VALUE HEX: 80AA ; inline
: GL_TEXTURE5 HEX: 84C5 ; inline : GL_SAMPLE_COVERAGE_INVERT HEX: 80AB ; inline
: GL_TEXTURE6 HEX: 84C6 ; inline : GL_CLAMP_TO_BORDER HEX: 812D ; inline
: GL_TEXTURE7 HEX: 84C7 ; inline : GL_TEXTURE0 HEX: 84C0 ; inline
: GL_TEXTURE8 HEX: 84C8 ; inline : GL_TEXTURE1 HEX: 84C1 ; inline
: GL_TEXTURE9 HEX: 84C9 ; inline : GL_TEXTURE2 HEX: 84C2 ; inline
: GL_TEXTURE10 HEX: 84CA ; inline : GL_TEXTURE3 HEX: 84C3 ; inline
: GL_TEXTURE11 HEX: 84CB ; inline : GL_TEXTURE4 HEX: 84C4 ; inline
: GL_TEXTURE12 HEX: 84CC ; inline : GL_TEXTURE5 HEX: 84C5 ; inline
: GL_TEXTURE13 HEX: 84CD ; inline : GL_TEXTURE6 HEX: 84C6 ; inline
: GL_TEXTURE14 HEX: 84CE ; inline : GL_TEXTURE7 HEX: 84C7 ; inline
: GL_TEXTURE15 HEX: 84CF ; inline : GL_TEXTURE8 HEX: 84C8 ; inline
: GL_TEXTURE16 HEX: 84D0 ; inline : GL_TEXTURE9 HEX: 84C9 ; inline
: GL_TEXTURE17 HEX: 84D1 ; inline : GL_TEXTURE10 HEX: 84CA ; inline
: GL_TEXTURE18 HEX: 84D2 ; inline : GL_TEXTURE11 HEX: 84CB ; inline
: GL_TEXTURE19 HEX: 84D3 ; inline : GL_TEXTURE12 HEX: 84CC ; inline
: GL_TEXTURE20 HEX: 84D4 ; inline : GL_TEXTURE13 HEX: 84CD ; inline
: GL_TEXTURE21 HEX: 84D5 ; inline : GL_TEXTURE14 HEX: 84CE ; inline
: GL_TEXTURE22 HEX: 84D6 ; inline : GL_TEXTURE15 HEX: 84CF ; inline
: GL_TEXTURE23 HEX: 84D7 ; inline : GL_TEXTURE16 HEX: 84D0 ; inline
: GL_TEXTURE24 HEX: 84D8 ; inline : GL_TEXTURE17 HEX: 84D1 ; inline
: GL_TEXTURE25 HEX: 84D9 ; inline : GL_TEXTURE18 HEX: 84D2 ; inline
: GL_TEXTURE26 HEX: 84DA ; inline : GL_TEXTURE19 HEX: 84D3 ; inline
: GL_TEXTURE27 HEX: 84DB ; inline : GL_TEXTURE20 HEX: 84D4 ; inline
: GL_TEXTURE28 HEX: 84DC ; inline : GL_TEXTURE21 HEX: 84D5 ; inline
: GL_TEXTURE29 HEX: 84DD ; inline : GL_TEXTURE22 HEX: 84D6 ; inline
: GL_TEXTURE30 HEX: 84DE ; inline : GL_TEXTURE23 HEX: 84D7 ; inline
: GL_TEXTURE31 HEX: 84DF ; inline : GL_TEXTURE24 HEX: 84D8 ; inline
: GL_NORMAL_MAP HEX: 8511 ; inline : GL_TEXTURE25 HEX: 84D9 ; inline
: GL_REFLECTION_MAP HEX: 8512 ; inline : GL_TEXTURE26 HEX: 84DA ; inline
: GL_TEXTURE_CUBE_MAP HEX: 8513 ; inline : GL_TEXTURE27 HEX: 84DB ; inline
: GL_TEXTURE_BINDING_CUBE_MAP HEX: 8514 ; inline : GL_TEXTURE28 HEX: 84DC ; inline
: GL_TEXTURE_CUBE_MAP_POSITIVE_X HEX: 8515 ; inline : GL_TEXTURE29 HEX: 84DD ; inline
: GL_TEXTURE_CUBE_MAP_NEGATIVE_X HEX: 8516 ; inline : GL_TEXTURE30 HEX: 84DE ; inline
: GL_TEXTURE_CUBE_MAP_POSITIVE_Y HEX: 8517 ; inline : GL_TEXTURE31 HEX: 84DF ; inline
: GL_TEXTURE_CUBE_MAP_NEGATIVE_Y HEX: 8518 ; inline : GL_ACTIVE_TEXTURE HEX: 84E0 ; inline
: GL_TEXTURE_CUBE_MAP_POSITIVE_Z HEX: 8519 ; inline : GL_CLIENT_ACTIVE_TEXTURE HEX: 84E1 ; inline
: GL_TEXTURE_CUBE_MAP_NEGATIVE_Z HEX: 851A ; inline : GL_MAX_TEXTURE_UNITS HEX: 84E2 ; inline
: GL_PROXY_TEXTURE_CUBE_MAP HEX: 851B ; inline : GL_TRANSPOSE_MODELVIEW_MATRIX HEX: 84E3 ; inline
: GL_MAX_CUBE_MAP_TEXTURE_SIZE HEX: 851C ; inline : GL_TRANSPOSE_PROJECTION_MATRIX HEX: 84E4 ; inline
: GL_COMBINE HEX: 8570 ; inline : GL_TRANSPOSE_TEXTURE_MATRIX HEX: 84E5 ; inline
: GL_COMBINE_RGB HEX: 8571 ; inline : GL_TRANSPOSE_COLOR_MATRIX HEX: 84E6 ; inline
: GL_COMBINE_ALPHA HEX: 8572 ; inline : GL_SUBTRACT HEX: 84E7 ; inline
: GL_RGB_SCALE HEX: 8573 ; inline : GL_COMPRESSED_ALPHA HEX: 84E9 ; inline
: GL_ADD_SIGNED HEX: 8574 ; inline : GL_COMPRESSED_LUMINANCE HEX: 84EA ; inline
: GL_INTERPOLATE HEX: 8575 ; inline : GL_COMPRESSED_LUMINANCE_ALPHA HEX: 84EB ; inline
: GL_CONSTANT HEX: 8576 ; inline : GL_COMPRESSED_INTENSITY HEX: 84EC ; inline
: GL_PRIMARY_COLOR HEX: 8577 ; inline : GL_COMPRESSED_RGB HEX: 84ED ; inline
: GL_PREVIOUS HEX: 8578 ; inline : GL_COMPRESSED_RGBA HEX: 84EE ; inline
: GL_SOURCE0_RGB HEX: 8580 ; inline : GL_TEXTURE_COMPRESSION_HINT HEX: 84EF ; inline
: GL_SOURCE1_RGB HEX: 8581 ; inline : GL_NORMAL_MAP HEX: 8511 ; inline
: GL_SOURCE2_RGB HEX: 8582 ; inline : GL_REFLECTION_MAP HEX: 8512 ; inline
: GL_SOURCE0_ALPHA HEX: 8588 ; inline : GL_TEXTURE_CUBE_MAP HEX: 8513 ; inline
: GL_SOURCE1_ALPHA HEX: 8589 ; inline : GL_TEXTURE_BINDING_CUBE_MAP HEX: 8514 ; inline
: GL_SOURCE2_ALPHA HEX: 858A ; inline : GL_TEXTURE_CUBE_MAP_POSITIVE_X HEX: 8515 ; inline
: GL_OPERAND0_RGB HEX: 8590 ; inline : GL_TEXTURE_CUBE_MAP_NEGATIVE_X HEX: 8516 ; inline
: GL_OPERAND1_RGB HEX: 8591 ; inline : GL_TEXTURE_CUBE_MAP_POSITIVE_Y HEX: 8517 ; inline
: GL_OPERAND2_RGB HEX: 8592 ; inline : GL_TEXTURE_CUBE_MAP_NEGATIVE_Y HEX: 8518 ; inline
: GL_OPERAND0_ALPHA HEX: 8598 ; inline : GL_TEXTURE_CUBE_MAP_POSITIVE_Z HEX: 8519 ; inline
: GL_OPERAND1_ALPHA HEX: 8599 ; inline : GL_TEXTURE_CUBE_MAP_NEGATIVE_Z HEX: 851A ; inline
: GL_OPERAND2_ALPHA HEX: 859A ; inline : GL_PROXY_TEXTURE_CUBE_MAP HEX: 851B ; inline
: GL_SUBTRACT HEX: 84E7 ; inline : GL_MAX_CUBE_MAP_TEXTURE_SIZE HEX: 851C ; inline
: GL_TRANSPOSE_MODELVIEW_MATRIX HEX: 84E3 ; inline : GL_COMBINE HEX: 8570 ; inline
: GL_TRANSPOSE_PROJECTION_MATRIX HEX: 84E4 ; inline : GL_COMBINE_RGB HEX: 8571 ; inline
: GL_TRANSPOSE_TEXTURE_MATRIX HEX: 84E5 ; inline : GL_COMBINE_ALPHA HEX: 8572 ; inline
: GL_TRANSPOSE_COLOR_MATRIX HEX: 84E6 ; inline : GL_RGB_SCALE HEX: 8573 ; inline
: GL_COMPRESSED_ALPHA HEX: 84E9 ; inline : GL_ADD_SIGNED HEX: 8574 ; inline
: GL_COMPRESSED_LUMINANCE HEX: 84EA ; inline : GL_INTERPOLATE HEX: 8575 ; inline
: GL_COMPRESSED_LUMINANCE_ALPHA HEX: 84EB ; inline : GL_CONSTANT HEX: 8576 ; inline
: GL_COMPRESSED_INTENSITY HEX: 84EC ; inline : GL_PRIMARY_COLOR HEX: 8577 ; inline
: GL_COMPRESSED_RGB HEX: 84ED ; inline : GL_PREVIOUS HEX: 8578 ; inline
: GL_COMPRESSED_RGBA HEX: 84EE ; inline : GL_SOURCE0_RGB HEX: 8580 ; inline
: GL_TEXTURE_COMPRESSION_HINT HEX: 84EF ; inline : GL_SOURCE1_RGB HEX: 8581 ; inline
: GL_TEXTURE_COMPRESSED_IMAGE_SIZE HEX: 86A0 ; inline : GL_SOURCE2_RGB HEX: 8582 ; inline
: GL_TEXTURE_COMPRESSED HEX: 86A1 ; inline : GL_SOURCE0_ALPHA HEX: 8588 ; inline
: GL_SOURCE1_ALPHA HEX: 8589 ; inline
: GL_SOURCE2_ALPHA HEX: 858A ; inline
: GL_OPERAND0_RGB HEX: 8590 ; inline
: GL_OPERAND1_RGB HEX: 8591 ; inline
: GL_OPERAND2_RGB HEX: 8592 ; inline
: GL_OPERAND0_ALPHA HEX: 8598 ; inline
: GL_OPERAND1_ALPHA HEX: 8599 ; inline
: GL_OPERAND2_ALPHA HEX: 859A ; inline
: GL_TEXTURE_COMPRESSED_IMAGE_SIZE HEX: 86A0 ; inline
: GL_TEXTURE_COMPRESSED HEX: 86A1 ; inline
: GL_NUM_COMPRESSED_TEXTURE_FORMATS HEX: 86A2 ; inline : GL_NUM_COMPRESSED_TEXTURE_FORMATS HEX: 86A2 ; inline
: GL_COMPRESSED_TEXTURE_FORMATS HEX: 86A3 ; inline : GL_COMPRESSED_TEXTURE_FORMATS HEX: 86A3 ; inline
: GL_DOT3_RGB HEX: 86AE ; inline : GL_DOT3_RGB HEX: 86AE ; inline
: GL_DOT3_RGBA HEX: 86AF ; inline : GL_DOT3_RGBA HEX: 86AF ; inline
: GL_CLAMP_TO_BORDER HEX: 812D ; inline : GL_MULTISAMPLE_BIT HEX: 20000000 ; inline
: GL_MULTISAMPLE HEX: 809D ; inline
: GL_SAMPLE_ALPHA_TO_COVERAGE HEX: 809E ; inline GL-FUNCTION: void glActiveTexture ( GLenum texture ) ;
: GL_SAMPLE_ALPHA_TO_ONE HEX: 809F ; inline GL-FUNCTION: void glClientActiveTexture ( GLenum texture ) ;
: GL_SAMPLE_COVERAGE HEX: 80A0 ; inline GL-FUNCTION: void glCompressedTexImage1D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, GLvoid* data ) ;
: GL_SAMPLE_BUFFERS HEX: 80A8 ; inline GL-FUNCTION: void glCompressedTexImage2D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLvoid* data ) ;
: GL_SAMPLES HEX: 80A9 ; inline GL-FUNCTION: void glCompressedTexImage3D ( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid* data ) ;
: GL_SAMPLE_COVERAGE_VALUE HEX: 80AA ; inline GL-FUNCTION: void glCompressedTexSubImage1D ( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, GLvoid* data ) ;
: GL_SAMPLE_COVERAGE_INVERT HEX: 80AB ; inline GL-FUNCTION: void glCompressedTexSubImage2D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLvoid* data ) ;
: GL_MULTISAMPLE_BIT HEX: 20000000 ; inline GL-FUNCTION: void glCompressedTexSubImage3D ( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLvoid* data ) ;
GL-FUNCTION: void glGetCompressedTexImage ( GLenum target, GLint lod, GLvoid* img ) ;
GL-FUNCTION: void glLoadTransposeMatrixd ( GLdouble m[16] ) ;
GL-FUNCTION: void glLoadTransposeMatrixf ( GLfloat m[16] ) ;
GL-FUNCTION: void glMultTransposeMatrixd ( GLdouble m[16] ) ;
GL-FUNCTION: void glMultTransposeMatrixf ( GLfloat m[16] ) ;
GL-FUNCTION: void glMultiTexCoord1d ( GLenum target, GLdouble s ) ;
GL-FUNCTION: void glMultiTexCoord1dv ( GLenum target, GLdouble* v ) ;
GL-FUNCTION: void glMultiTexCoord1f ( GLenum target, GLfloat s ) ;
GL-FUNCTION: void glMultiTexCoord1fv ( GLenum target, GLfloat* v ) ;
GL-FUNCTION: void glMultiTexCoord1i ( GLenum target, GLint s ) ;
GL-FUNCTION: void glMultiTexCoord1iv ( GLenum target, GLint* v ) ;
GL-FUNCTION: void glMultiTexCoord1s ( GLenum target, GLshort s ) ;
GL-FUNCTION: void glMultiTexCoord1sv ( GLenum target, GLshort* v ) ;
GL-FUNCTION: void glMultiTexCoord2d ( GLenum target, GLdouble s, GLdouble t ) ;
GL-FUNCTION: void glMultiTexCoord2dv ( GLenum target, GLdouble* v ) ;
GL-FUNCTION: void glMultiTexCoord2f ( GLenum target, GLfloat s, GLfloat t ) ;
GL-FUNCTION: void glMultiTexCoord2fv ( GLenum target, GLfloat* v ) ;
GL-FUNCTION: void glMultiTexCoord2i ( GLenum target, GLint s, GLint t ) ;
GL-FUNCTION: void glMultiTexCoord2iv ( GLenum target, GLint* v ) ;
GL-FUNCTION: void glMultiTexCoord2s ( GLenum target, GLshort s, GLshort t ) ;
GL-FUNCTION: void glMultiTexCoord2sv ( GLenum target, GLshort* v ) ;
GL-FUNCTION: void glMultiTexCoord3d ( GLenum target, GLdouble s, GLdouble t, GLdouble r ) ;
GL-FUNCTION: void glMultiTexCoord3dv ( GLenum target, GLdouble* v ) ;
GL-FUNCTION: void glMultiTexCoord3f ( GLenum target, GLfloat s, GLfloat t, GLfloat r ) ;
GL-FUNCTION: void glMultiTexCoord3fv ( GLenum target, GLfloat* v ) ;
GL-FUNCTION: void glMultiTexCoord3i ( GLenum target, GLint s, GLint t, GLint r ) ;
GL-FUNCTION: void glMultiTexCoord3iv ( GLenum target, GLint* v ) ;
GL-FUNCTION: void glMultiTexCoord3s ( GLenum target, GLshort s, GLshort t, GLshort r ) ;
GL-FUNCTION: void glMultiTexCoord3sv ( GLenum target, GLshort* v ) ;
GL-FUNCTION: void glMultiTexCoord4d ( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ) ;
GL-FUNCTION: void glMultiTexCoord4dv ( GLenum target, GLdouble* v ) ;
GL-FUNCTION: void glMultiTexCoord4f ( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ) ;
GL-FUNCTION: void glMultiTexCoord4fv ( GLenum target, GLfloat* v ) ;
GL-FUNCTION: void glMultiTexCoord4i ( GLenum target, GLint s, GLint t, GLint r, GLint q ) ;
GL-FUNCTION: void glMultiTexCoord4iv ( GLenum target, GLint* v ) ;
GL-FUNCTION: void glMultiTexCoord4s ( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ) ;
GL-FUNCTION: void glMultiTexCoord4sv ( GLenum target, GLshort* v ) ;
GL-FUNCTION: void glSampleCoverage ( GLclampf value, GLboolean invert ) ;
! OpenGL 1.4 ! OpenGL 1.4
: GL_POINT_SIZE_MIN HEX: 8126 ; inline
: GL_POINT_SIZE_MAX HEX: 8127 ; inline : GL_BLEND_DST_RGB HEX: 80C8 ; inline
: GL_POINT_FADE_THRESHOLD_SIZE HEX: 8128 ; inline : GL_BLEND_SRC_RGB HEX: 80C9 ; inline
: GL_POINT_DISTANCE_ATTENUATION HEX: 8129 ; inline : GL_BLEND_DST_ALPHA HEX: 80CA ; inline
: GL_FOG_COORDINATE_SOURCE HEX: 8450 ; inline : GL_BLEND_SRC_ALPHA HEX: 80CB ; inline
: GL_FOG_COORDINATE HEX: 8451 ; inline : GL_POINT_SIZE_MIN HEX: 8126 ; inline
: GL_FRAGMENT_DEPTH HEX: 8452 ; inline : GL_POINT_SIZE_MAX HEX: 8127 ; inline
: GL_CURRENT_FOG_COORDINATE HEX: 8453 ; inline : GL_POINT_FADE_THRESHOLD_SIZE HEX: 8128 ; inline
: GL_FOG_COORDINATE_ARRAY_TYPE HEX: 8454 ; inline : GL_POINT_DISTANCE_ATTENUATION HEX: 8129 ; inline
: GL_FOG_COORDINATE_ARRAY_STRIDE HEX: 8455 ; inline : GL_GENERATE_MIPMAP HEX: 8191 ; inline
: GL_FOG_COORDINATE_ARRAY_POINTER HEX: 8456 ; inline : GL_GENERATE_MIPMAP_HINT HEX: 8192 ; inline
: GL_FOG_COORDINATE_ARRAY HEX: 8457 ; inline : GL_DEPTH_COMPONENT16 HEX: 81A5 ; inline
: GL_COLOR_SUM HEX: 8458 ; inline : GL_DEPTH_COMPONENT24 HEX: 81A6 ; inline
: GL_CURRENT_SECONDARY_COLOR HEX: 8459 ; inline : GL_DEPTH_COMPONENT32 HEX: 81A7 ; inline
: GL_SECONDARY_COLOR_ARRAY_SIZE HEX: 845A ; inline : GL_MIRRORED_REPEAT HEX: 8370 ; inline
: GL_SECONDARY_COLOR_ARRAY_TYPE HEX: 845B ; inline : GL_FOG_COORDINATE_SOURCE HEX: 8450 ; inline
: GL_SECONDARY_COLOR_ARRAY_STRIDE HEX: 845C ; inline : GL_FOG_COORDINATE HEX: 8451 ; inline
: GL_SECONDARY_COLOR_ARRAY_POINTER HEX: 845D ; inline : GL_FRAGMENT_DEPTH HEX: 8452 ; inline
: GL_SECONDARY_COLOR_ARRAY HEX: 845E ; inline : GL_CURRENT_FOG_COORDINATE HEX: 8453 ; inline
: GL_INCR_WRAP HEX: 8507 ; inline : GL_FOG_COORDINATE_ARRAY_TYPE HEX: 8454 ; inline
: GL_DECR_WRAP HEX: 8508 ; inline : GL_FOG_COORDINATE_ARRAY_STRIDE HEX: 8455 ; inline
: GL_MAX_TEXTURE_LOD_BIAS HEX: 84FD ; inline : GL_FOG_COORDINATE_ARRAY_POINTER HEX: 8456 ; inline
: GL_TEXTURE_FILTER_CONTROL HEX: 8500 ; inline : GL_FOG_COORDINATE_ARRAY HEX: 8457 ; inline
: GL_TEXTURE_LOD_BIAS HEX: 8501 ; inline : GL_COLOR_SUM HEX: 8458 ; inline
: GL_GENERATE_MIPMAP HEX: 8191 ; inline : GL_CURRENT_SECONDARY_COLOR HEX: 8459 ; inline
: GL_GENERATE_MIPMAP_HINT HEX: 8192 ; inline : GL_SECONDARY_COLOR_ARRAY_SIZE HEX: 845A ; inline
: GL_BLEND_DST_RGB HEX: 80C8 ; inline : GL_SECONDARY_COLOR_ARRAY_TYPE HEX: 845B ; inline
: GL_BLEND_SRC_RGB HEX: 80C9 ; inline : GL_SECONDARY_COLOR_ARRAY_STRIDE HEX: 845C ; inline
: GL_BLEND_DST_ALPHA HEX: 80CA ; inline : GL_SECONDARY_COLOR_ARRAY_POINTER HEX: 845D ; inline
: GL_BLEND_SRC_ALPHA HEX: 80CB ; inline : GL_SECONDARY_COLOR_ARRAY HEX: 845E ; inline
: GL_MIRRORED_REPEAT HEX: 8370 ; inline : GL_MAX_TEXTURE_LOD_BIAS HEX: 84FD ; inline
: GL_DEPTH_COMPONENT16 HEX: 81A5 ; inline : GL_TEXTURE_FILTER_CONTROL HEX: 8500 ; inline
: GL_DEPTH_COMPONENT24 HEX: 81A6 ; inline : GL_TEXTURE_LOD_BIAS HEX: 8501 ; inline
: GL_DEPTH_COMPONENT32 HEX: 81A7 ; inline : GL_INCR_WRAP HEX: 8507 ; inline
: GL_TEXTURE_DEPTH_SIZE HEX: 884A ; inline : GL_DECR_WRAP HEX: 8508 ; inline
: GL_DEPTH_TEXTURE_MODE HEX: 884B ; inline : GL_TEXTURE_DEPTH_SIZE HEX: 884A ; inline
: GL_TEXTURE_COMPARE_MODE HEX: 884C ; inline : GL_DEPTH_TEXTURE_MODE HEX: 884B ; inline
: GL_TEXTURE_COMPARE_FUNC HEX: 884D ; inline : GL_TEXTURE_COMPARE_MODE HEX: 884C ; inline
: GL_COMPARE_R_TO_TEXTURE HEX: 884E ; inline : GL_TEXTURE_COMPARE_FUNC HEX: 884D ; inline
: GL_COMPARE_R_TO_TEXTURE HEX: 884E ; inline
GL-FUNCTION: void glBlendColor ( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) ;
GL-FUNCTION: void glBlendEquation ( GLenum mode ) ;
GL-FUNCTION: void glBlendFuncSeparate ( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha ) ;
GL-FUNCTION: void glFogCoordPointer ( GLenum type, GLsizei stride, GLvoid* pointer ) ;
GL-FUNCTION: void glFogCoordd ( GLdouble coord ) ;
GL-FUNCTION: void glFogCoorddv ( GLdouble* coord ) ;
GL-FUNCTION: void glFogCoordf ( GLfloat coord ) ;
GL-FUNCTION: void glFogCoordfv ( GLfloat* coord ) ;
GL-FUNCTION: void glMultiDrawArrays ( GLenum mode, GLint* first, GLsizei* count, GLsizei primcount ) ;
GL-FUNCTION: void glMultiDrawElements ( GLenum mode, GLsizei* count, GLenum type, GLvoid** indices, GLsizei primcount ) ;
GL-FUNCTION: void glPointParameterf ( GLenum pname, GLfloat param ) ;
GL-FUNCTION: void glPointParameterfv ( GLenum pname, GLfloat* params ) ;
GL-FUNCTION: void glSecondaryColor3b ( GLbyte red, GLbyte green, GLbyte blue ) ;
GL-FUNCTION: void glSecondaryColor3bv ( GLbyte* v ) ;
GL-FUNCTION: void glSecondaryColor3d ( GLdouble red, GLdouble green, GLdouble blue ) ;
GL-FUNCTION: void glSecondaryColor3dv ( GLdouble* v ) ;
GL-FUNCTION: void glSecondaryColor3f ( GLfloat red, GLfloat green, GLfloat blue ) ;
GL-FUNCTION: void glSecondaryColor3fv ( GLfloat* v ) ;
GL-FUNCTION: void glSecondaryColor3i ( GLint red, GLint green, GLint blue ) ;
GL-FUNCTION: void glSecondaryColor3iv ( GLint* v ) ;
GL-FUNCTION: void glSecondaryColor3s ( GLshort red, GLshort green, GLshort blue ) ;
GL-FUNCTION: void glSecondaryColor3sv ( GLshort* v ) ;
GL-FUNCTION: void glSecondaryColor3ub ( GLubyte red, GLubyte green, GLubyte blue ) ;
GL-FUNCTION: void glSecondaryColor3ubv ( GLubyte* v ) ;
GL-FUNCTION: void glSecondaryColor3ui ( GLuint red, GLuint green, GLuint blue ) ;
GL-FUNCTION: void glSecondaryColor3uiv ( GLuint* v ) ;
GL-FUNCTION: void glSecondaryColor3us ( GLushort red, GLushort green, GLushort blue ) ;
GL-FUNCTION: void glSecondaryColor3usv ( GLushort* v ) ;
GL-FUNCTION: void glSecondaryColorPointer ( GLint size, GLenum type, GLsizei stride, GLvoid* pointer ) ;
GL-FUNCTION: void glWindowPos2d ( GLdouble x, GLdouble y ) ;
GL-FUNCTION: void glWindowPos2dv ( GLdouble* p ) ;
GL-FUNCTION: void glWindowPos2f ( GLfloat x, GLfloat y ) ;
GL-FUNCTION: void glWindowPos2fv ( GLfloat* p ) ;
GL-FUNCTION: void glWindowPos2i ( GLint x, GLint y ) ;
GL-FUNCTION: void glWindowPos2iv ( GLint* p ) ;
GL-FUNCTION: void glWindowPos2s ( GLshort x, GLshort y ) ;
GL-FUNCTION: void glWindowPos2sv ( GLshort* p ) ;
GL-FUNCTION: void glWindowPos3d ( GLdouble x, GLdouble y, GLdouble z ) ;
GL-FUNCTION: void glWindowPos3dv ( GLdouble* p ) ;
GL-FUNCTION: void glWindowPos3f ( GLfloat x, GLfloat y, GLfloat z ) ;
GL-FUNCTION: void glWindowPos3fv ( GLfloat* p ) ;
GL-FUNCTION: void glWindowPos3i ( GLint x, GLint y, GLint z ) ;
GL-FUNCTION: void glWindowPos3iv ( GLint* p ) ;
GL-FUNCTION: void glWindowPos3s ( GLshort x, GLshort y, GLshort z ) ;
GL-FUNCTION: void glWindowPos3sv ( GLshort* p ) ;
! OpenGL 1.5
: GL_BUFFER_SIZE HEX: 8764 ; inline
: GL_BUFFER_USAGE HEX: 8765 ; inline
: GL_QUERY_COUNTER_BITS HEX: 8864 ; inline
: GL_CURRENT_QUERY HEX: 8865 ; inline
: GL_QUERY_RESULT HEX: 8866 ; inline
: GL_QUERY_RESULT_AVAILABLE HEX: 8867 ; inline
: GL_ARRAY_BUFFER HEX: 8892 ; inline
: GL_ELEMENT_ARRAY_BUFFER HEX: 8893 ; inline
: GL_ARRAY_BUFFER_BINDING HEX: 8894 ; inline
: GL_ELEMENT_ARRAY_BUFFER_BINDING HEX: 8895 ; inline
: GL_VERTEX_ARRAY_BUFFER_BINDING HEX: 8896 ; inline
: GL_NORMAL_ARRAY_BUFFER_BINDING HEX: 8897 ; inline
: GL_COLOR_ARRAY_BUFFER_BINDING HEX: 8898 ; inline
: GL_INDEX_ARRAY_BUFFER_BINDING HEX: 8899 ; inline
: GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING HEX: 889A ; inline
: GL_EDGE_FLAG_ARRAY_BUFFER_BINDING HEX: 889B ; inline
: GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING HEX: 889C ; inline
: GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING HEX: 889D ; inline
: GL_WEIGHT_ARRAY_BUFFER_BINDING HEX: 889E ; inline
: GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING HEX: 889F ; inline
: GL_READ_ONLY HEX: 88B8 ; inline
: GL_WRITE_ONLY HEX: 88B9 ; inline
: GL_READ_WRITE HEX: 88BA ; inline
: GL_BUFFER_ACCESS HEX: 88BB ; inline
: GL_BUFFER_MAPPED HEX: 88BC ; inline
: GL_BUFFER_MAP_POINTER HEX: 88BD ; inline
: GL_STREAM_DRAW HEX: 88E0 ; inline
: GL_STREAM_READ HEX: 88E1 ; inline
: GL_STREAM_COPY HEX: 88E2 ; inline
: GL_STATIC_DRAW HEX: 88E4 ; inline
: GL_STATIC_READ HEX: 88E5 ; inline
: GL_STATIC_COPY HEX: 88E6 ; inline
: GL_DYNAMIC_DRAW HEX: 88E8 ; inline
: GL_DYNAMIC_READ HEX: 88E9 ; inline
: GL_DYNAMIC_COPY HEX: 88EA ; inline
: GL_SAMPLES_PASSED HEX: 8914 ; inline
: GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE ; inline
: GL_FOG_COORD GL_FOG_COORDINATE ; inline
: GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY ; inline
: GL_SRC0_RGB GL_SOURCE0_RGB ; inline
: GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER ; inline
: GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE ; inline
: GL_SRC1_ALPHA GL_SOURCE1_ALPHA ; inline
: GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE ; inline
: GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE ; inline
: GL_SRC0_ALPHA GL_SOURCE0_ALPHA ; inline
: GL_SRC1_RGB GL_SOURCE1_RGB ; inline
: GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING ; inline
: GL_SRC2_ALPHA GL_SOURCE2_ALPHA ; inline
: GL_SRC2_RGB GL_SOURCE2_RGB ; inline
TYPEDEF: ptrdiff_t GLsizeiptr
TYPEDEF: ptrdiff_t GLintptr
GL-FUNCTION: void glBeginQuery ( GLenum target, GLuint id ) ;
GL-FUNCTION: void glBindBuffer ( GLenum target, GLuint buffer ) ;
GL-FUNCTION: void glBufferData ( GLenum target, GLsizeiptr size, GLvoid* data, GLenum usage ) ;
GL-FUNCTION: void glBufferSubData ( GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data ) ;
GL-FUNCTION: void glDeleteBuffers ( GLsizei n, GLuint* buffers ) ;
GL-FUNCTION: void glDeleteQueries ( GLsizei n, GLuint* ids ) ;
GL-FUNCTION: void glEndQuery ( GLenum target ) ;
GL-FUNCTION: void glGenBuffers ( GLsizei n, GLuint* buffers ) ;
GL-FUNCTION: void glGenQueries ( GLsizei n, GLuint* ids ) ;
GL-FUNCTION: void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint* params ) ;
GL-FUNCTION: void glGetBufferPointerv ( GLenum target, GLenum pname, GLvoid** params ) ;
GL-FUNCTION: void glGetBufferSubData ( GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data ) ;
GL-FUNCTION: void glGetQueryObjectiv ( GLuint id, GLenum pname, GLint* params ) ;
GL-FUNCTION: void glGetQueryObjectuiv ( GLuint id, GLenum pname, GLuint* params ) ;
GL-FUNCTION: void glGetQueryiv ( GLenum target, GLenum pname, GLint* params ) ;
GL-FUNCTION: GLboolean glIsBuffer ( GLuint buffer ) ;
GL-FUNCTION: GLboolean glIsQuery ( GLuint id ) ;
GL-FUNCTION: GLvoid* glMapBuffer ( GLenum target, GLenum access ) ;
GL-FUNCTION: GLboolean glUnmapBuffer ( GLenum target ) ;
! OpenGL 2.0
: GL_VERTEX_ATTRIB_ARRAY_ENABLED HEX: 8622 ; inline
: GL_VERTEX_ATTRIB_ARRAY_SIZE HEX: 8623 ; inline
: GL_VERTEX_ATTRIB_ARRAY_STRIDE HEX: 8624 ; inline
: GL_VERTEX_ATTRIB_ARRAY_TYPE HEX: 8625 ; inline
: GL_CURRENT_VERTEX_ATTRIB HEX: 8626 ; inline
: GL_VERTEX_PROGRAM_POINT_SIZE HEX: 8642 ; inline
: GL_VERTEX_PROGRAM_TWO_SIDE HEX: 8643 ; inline
: GL_VERTEX_ATTRIB_ARRAY_POINTER HEX: 8645 ; inline
: GL_STENCIL_BACK_FUNC HEX: 8800 ; inline
: GL_STENCIL_BACK_FAIL HEX: 8801 ; inline
: GL_STENCIL_BACK_PASS_DEPTH_FAIL HEX: 8802 ; inline
: GL_STENCIL_BACK_PASS_DEPTH_PASS HEX: 8803 ; inline
: GL_MAX_DRAW_BUFFERS HEX: 8824 ; inline
: GL_DRAW_BUFFER0 HEX: 8825 ; inline
: GL_DRAW_BUFFER1 HEX: 8826 ; inline
: GL_DRAW_BUFFER2 HEX: 8827 ; inline
: GL_DRAW_BUFFER3 HEX: 8828 ; inline
: GL_DRAW_BUFFER4 HEX: 8829 ; inline
: GL_DRAW_BUFFER5 HEX: 882A ; inline
: GL_DRAW_BUFFER6 HEX: 882B ; inline
: GL_DRAW_BUFFER7 HEX: 882C ; inline
: GL_DRAW_BUFFER8 HEX: 882D ; inline
: GL_DRAW_BUFFER9 HEX: 882E ; inline
: GL_DRAW_BUFFER10 HEX: 882F ; inline
: GL_DRAW_BUFFER11 HEX: 8830 ; inline
: GL_DRAW_BUFFER12 HEX: 8831 ; inline
: GL_DRAW_BUFFER13 HEX: 8832 ; inline
: GL_DRAW_BUFFER14 HEX: 8833 ; inline
: GL_DRAW_BUFFER15 HEX: 8834 ; inline
: GL_BLEND_EQUATION_ALPHA HEX: 883D ; inline
: GL_POINT_SPRITE HEX: 8861 ; inline
: GL_COORD_REPLACE HEX: 8862 ; inline
: GL_MAX_VERTEX_ATTRIBS HEX: 8869 ; inline
: GL_VERTEX_ATTRIB_ARRAY_NORMALIZED HEX: 886A ; inline
: GL_MAX_TEXTURE_COORDS HEX: 8871 ; inline
: GL_MAX_TEXTURE_IMAGE_UNITS HEX: 8872 ; inline
: GL_FRAGMENT_SHADER HEX: 8B30 ; inline
: GL_VERTEX_SHADER HEX: 8B31 ; inline
: GL_MAX_FRAGMENT_UNIFORM_COMPONENTS HEX: 8B49 ; inline
: GL_MAX_VERTEX_UNIFORM_COMPONENTS HEX: 8B4A ; inline
: GL_MAX_VARYING_FLOATS HEX: 8B4B ; inline
: GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS HEX: 8B4C ; inline
: GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS HEX: 8B4D ; inline
: GL_SHADER_TYPE HEX: 8B4F ; inline
: GL_FLOAT_VEC2 HEX: 8B50 ; inline
: GL_FLOAT_VEC3 HEX: 8B51 ; inline
: GL_FLOAT_VEC4 HEX: 8B52 ; inline
: GL_INT_VEC2 HEX: 8B53 ; inline
: GL_INT_VEC3 HEX: 8B54 ; inline
: GL_INT_VEC4 HEX: 8B55 ; inline
: GL_BOOL HEX: 8B56 ; inline
: GL_BOOL_VEC2 HEX: 8B57 ; inline
: GL_BOOL_VEC3 HEX: 8B58 ; inline
: GL_BOOL_VEC4 HEX: 8B59 ; inline
: GL_FLOAT_MAT2 HEX: 8B5A ; inline
: GL_FLOAT_MAT3 HEX: 8B5B ; inline
: GL_FLOAT_MAT4 HEX: 8B5C ; inline
: GL_SAMPLER_1D HEX: 8B5D ; inline
: GL_SAMPLER_2D HEX: 8B5E ; inline
: GL_SAMPLER_3D HEX: 8B5F ; inline
: GL_SAMPLER_CUBE HEX: 8B60 ; inline
: GL_SAMPLER_1D_SHADOW HEX: 8B61 ; inline
: GL_SAMPLER_2D_SHADOW HEX: 8B62 ; inline
: GL_DELETE_STATUS HEX: 8B80 ; inline
: GL_COMPILE_STATUS HEX: 8B81 ; inline
: GL_LINK_STATUS HEX: 8B82 ; inline
: GL_VALIDATE_STATUS HEX: 8B83 ; inline
: GL_INFO_LOG_LENGTH HEX: 8B84 ; inline
: GL_ATTACHED_SHADERS HEX: 8B85 ; inline
: GL_ACTIVE_UNIFORMS HEX: 8B86 ; inline
: GL_ACTIVE_UNIFORM_MAX_LENGTH HEX: 8B87 ; inline
: GL_SHADER_SOURCE_LENGTH HEX: 8B88 ; inline
: GL_ACTIVE_ATTRIBUTES HEX: 8B89 ; inline
: GL_ACTIVE_ATTRIBUTE_MAX_LENGTH HEX: 8B8A ; inline
: GL_FRAGMENT_SHADER_DERIVATIVE_HINT HEX: 8B8B ; inline
: GL_SHADING_LANGUAGE_VERSION HEX: 8B8C ; inline
: GL_CURRENT_PROGRAM HEX: 8B8D ; inline
: GL_POINT_SPRITE_COORD_ORIGIN HEX: 8CA0 ; inline
: GL_LOWER_LEFT HEX: 8CA1 ; inline
: GL_UPPER_LEFT HEX: 8CA2 ; inline
: GL_STENCIL_BACK_REF HEX: 8CA3 ; inline
: GL_STENCIL_BACK_VALUE_MASK HEX: 8CA4 ; inline
: GL_STENCIL_BACK_WRITEMASK HEX: 8CA5 ; inline
: GL_BLEND_EQUATION HEX: 8009 ; inline
: GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION ; inline
TYPEDEF: char GLchar
GL-FUNCTION: void glAttachShader ( GLuint program, GLuint shader ) ;
GL-FUNCTION: void glBindAttribLocation ( GLuint program, GLuint index, GLchar* name ) ;
GL-FUNCTION: void glBlendEquationSeparate ( GLenum modeRGB, GLenum modeAlpha ) ;
GL-FUNCTION: void glCompileShader ( GLuint shader ) ;
GL-FUNCTION: GLuint glCreateProgram ( ) ;
GL-FUNCTION: GLuint glCreateShader ( GLenum type ) ;
GL-FUNCTION: void glDeleteProgram ( GLuint program ) ;
GL-FUNCTION: void glDeleteShader ( GLuint shader ) ;
GL-FUNCTION: void glDetachShader ( GLuint program, GLuint shader ) ;
GL-FUNCTION: void glDisableVertexAttribArray ( GLuint index ) ;
GL-FUNCTION: void glDrawBuffers ( GLsizei n, GLenum* bufs ) ;
GL-FUNCTION: void glEnableVertexAttribArray ( GLuint index ) ;
GL-FUNCTION: void glGetActiveAttrib ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name ) ;
GL-FUNCTION: void glGetActiveUniform ( GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name ) ;
GL-FUNCTION: void glGetAttachedShaders ( GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders ) ;
GL-FUNCTION: GLint glGetAttribLocation ( GLuint program, GLchar* name ) ;
GL-FUNCTION: void glGetProgramInfoLog ( GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog ) ;
GL-FUNCTION: void glGetProgramiv ( GLuint program, GLenum pname, GLint* param ) ;
GL-FUNCTION: void glGetShaderInfoLog ( GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog ) ;
GL-FUNCTION: void glGetShaderSource ( GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source ) ;
GL-FUNCTION: void glGetShaderiv ( GLuint shader, GLenum pname, GLint* param ) ;
GL-FUNCTION: GLint glGetUniformLocation ( GLint programObj, GLchar* name ) ;
GL-FUNCTION: void glGetUniformfv ( GLuint program, GLint location, GLfloat* params ) ;
GL-FUNCTION: void glGetUniformiv ( GLuint program, GLint location, GLint* params ) ;
GL-FUNCTION: void glGetVertexAttribPointerv ( GLuint index, GLenum pname, GLvoid** pointer ) ;
GL-FUNCTION: void glGetVertexAttribdv ( GLuint index, GLenum pname, GLdouble* params ) ;
GL-FUNCTION: void glGetVertexAttribfv ( GLuint index, GLenum pname, GLfloat* params ) ;
GL-FUNCTION: void glGetVertexAttribiv ( GLuint index, GLenum pname, GLint* params ) ;
GL-FUNCTION: GLboolean glIsProgram ( GLuint program ) ;
GL-FUNCTION: GLboolean glIsShader ( GLuint shader ) ;
GL-FUNCTION: void glLinkProgram ( GLuint program ) ;
GL-FUNCTION: void glShaderSource ( GLuint shader, GLsizei count, GLchar** strings, GLint* lengths ) ;
GL-FUNCTION: void glStencilFuncSeparate ( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask ) ;
GL-FUNCTION: void glStencilMaskSeparate ( GLenum face, GLuint mask ) ;
GL-FUNCTION: void glStencilOpSeparate ( GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass ) ;
GL-FUNCTION: void glUniform1f ( GLint location, GLfloat v0 ) ;
GL-FUNCTION: void glUniform1fv ( GLint location, GLsizei count, GLfloat* value ) ;
GL-FUNCTION: void glUniform1i ( GLint location, GLint v0 ) ;
GL-FUNCTION: void glUniform1iv ( GLint location, GLsizei count, GLint* value ) ;
GL-FUNCTION: void glUniform2f ( GLint location, GLfloat v0, GLfloat v1 ) ;
GL-FUNCTION: void glUniform2fv ( GLint location, GLsizei count, GLfloat* value ) ;
GL-FUNCTION: void glUniform2i ( GLint location, GLint v0, GLint v1 ) ;
GL-FUNCTION: void glUniform2iv ( GLint location, GLsizei count, GLint* value ) ;
GL-FUNCTION: void glUniform3f ( GLint location, GLfloat v0, GLfloat v1, GLfloat v2 ) ;
GL-FUNCTION: void glUniform3fv ( GLint location, GLsizei count, GLfloat* value ) ;
GL-FUNCTION: void glUniform3i ( GLint location, GLint v0, GLint v1, GLint v2 ) ;
GL-FUNCTION: void glUniform3iv ( GLint location, GLsizei count, GLint* value ) ;
GL-FUNCTION: void glUniform4f ( GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) ;
GL-FUNCTION: void glUniform4fv ( GLint location, GLsizei count, GLfloat* value ) ;
GL-FUNCTION: void glUniform4i ( GLint location, GLint v0, GLint v1, GLint v2, GLint v3 ) ;
GL-FUNCTION: void glUniform4iv ( GLint location, GLsizei count, GLint* value ) ;
GL-FUNCTION: void glUniformMatrix2fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix3fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix4fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUseProgram ( GLuint program ) ;
GL-FUNCTION: void glValidateProgram ( GLuint program ) ;
GL-FUNCTION: void glVertexAttrib1d ( GLuint index, GLdouble x ) ;
GL-FUNCTION: void glVertexAttrib1dv ( GLuint index, GLdouble* v ) ;
GL-FUNCTION: void glVertexAttrib1f ( GLuint index, GLfloat x ) ;
GL-FUNCTION: void glVertexAttrib1fv ( GLuint index, GLfloat* v ) ;
GL-FUNCTION: void glVertexAttrib1s ( GLuint index, GLshort x ) ;
GL-FUNCTION: void glVertexAttrib1sv ( GLuint index, GLshort* v ) ;
GL-FUNCTION: void glVertexAttrib2d ( GLuint index, GLdouble x, GLdouble y ) ;
GL-FUNCTION: void glVertexAttrib2dv ( GLuint index, GLdouble* v ) ;
GL-FUNCTION: void glVertexAttrib2f ( GLuint index, GLfloat x, GLfloat y ) ;
GL-FUNCTION: void glVertexAttrib2fv ( GLuint index, GLfloat* v ) ;
GL-FUNCTION: void glVertexAttrib2s ( GLuint index, GLshort x, GLshort y ) ;
GL-FUNCTION: void glVertexAttrib2sv ( GLuint index, GLshort* v ) ;
GL-FUNCTION: void glVertexAttrib3d ( GLuint index, GLdouble x, GLdouble y, GLdouble z ) ;
GL-FUNCTION: void glVertexAttrib3dv ( GLuint index, GLdouble* v ) ;
GL-FUNCTION: void glVertexAttrib3f ( GLuint index, GLfloat x, GLfloat y, GLfloat z ) ;
GL-FUNCTION: void glVertexAttrib3fv ( GLuint index, GLfloat* v ) ;
GL-FUNCTION: void glVertexAttrib3s ( GLuint index, GLshort x, GLshort y, GLshort z ) ;
GL-FUNCTION: void glVertexAttrib3sv ( GLuint index, GLshort* v ) ;
GL-FUNCTION: void glVertexAttrib4Nbv ( GLuint index, GLbyte* v ) ;
GL-FUNCTION: void glVertexAttrib4Niv ( GLuint index, GLint* v ) ;
GL-FUNCTION: void glVertexAttrib4Nsv ( GLuint index, GLshort* v ) ;
GL-FUNCTION: void glVertexAttrib4Nub ( GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w ) ;
GL-FUNCTION: void glVertexAttrib4Nubv ( GLuint index, GLubyte* v ) ;
GL-FUNCTION: void glVertexAttrib4Nuiv ( GLuint index, GLuint* v ) ;
GL-FUNCTION: void glVertexAttrib4Nusv ( GLuint index, GLushort* v ) ;
GL-FUNCTION: void glVertexAttrib4bv ( GLuint index, GLbyte* v ) ;
GL-FUNCTION: void glVertexAttrib4d ( GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w ) ;
GL-FUNCTION: void glVertexAttrib4dv ( GLuint index, GLdouble* v ) ;
GL-FUNCTION: void glVertexAttrib4f ( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) ;
GL-FUNCTION: void glVertexAttrib4fv ( GLuint index, GLfloat* v ) ;
GL-FUNCTION: void glVertexAttrib4iv ( GLuint index, GLint* v ) ;
GL-FUNCTION: void glVertexAttrib4s ( GLuint index, GLshort x, GLshort y, GLshort z, GLshort w ) ;
GL-FUNCTION: void glVertexAttrib4sv ( GLuint index, GLshort* v ) ;
GL-FUNCTION: void glVertexAttrib4ubv ( GLuint index, GLubyte* v ) ;
GL-FUNCTION: void glVertexAttrib4uiv ( GLuint index, GLuint* v ) ;
GL-FUNCTION: void glVertexAttrib4usv ( GLuint index, GLushort* v ) ;
GL-FUNCTION: void glVertexAttribPointer ( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid* pointer ) ;
! OpenGL 2.1
: GL_CURRENT_RASTER_SECONDARY_COLOR HEX: 845F ; inline
: GL_PIXEL_PACK_BUFFER HEX: 88EB ; inline
: GL_PIXEL_UNPACK_BUFFER HEX: 88EC ; inline
: GL_PIXEL_PACK_BUFFER_BINDING HEX: 88ED ; inline
: GL_PIXEL_UNPACK_BUFFER_BINDING HEX: 88EF ; inline
: GL_SRGB HEX: 8C40 ; inline
: GL_SRGB8 HEX: 8C41 ; inline
: GL_SRGB_ALPHA HEX: 8C42 ; inline
: GL_SRGB8_ALPHA8 HEX: 8C43 ; inline
: GL_SLUMINANCE_ALPHA HEX: 8C44 ; inline
: GL_SLUMINANCE8_ALPHA8 HEX: 8C45 ; inline
: GL_SLUMINANCE HEX: 8C46 ; inline
: GL_SLUMINANCE8 HEX: 8C47 ; inline
: GL_COMPRESSED_SRGB HEX: 8C48 ; inline
: GL_COMPRESSED_SRGB_ALPHA HEX: 8C49 ; inline
: GL_COMPRESSED_SLUMINANCE HEX: 8C4A ; inline
: GL_COMPRESSED_SLUMINANCE_ALPHA HEX: 8C4B ; inline
GL-FUNCTION: void glUniformMatrix2x3fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix2x4fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix3x2fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix3x4fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix4x2fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
GL-FUNCTION: void glUniformMatrix4x3fv ( GLint location, GLsizei count, GLboolean transpose, GLfloat* value ) ;
! GL_EXT_framebuffer_object
: GL_INVALID_FRAMEBUFFER_OPERATION_EXT HEX: 0506 ; inline
: GL_MAX_RENDERBUFFER_SIZE_EXT HEX: 84E8 ; inline
: GL_FRAMEBUFFER_BINDING_EXT HEX: 8CA6 ; inline
: GL_RENDERBUFFER_BINDING_EXT HEX: 8CA7 ; inline
: GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT HEX: 8CD0 ; inline
: GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT HEX: 8CD1 ; inline
: GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT HEX: 8CD2 ; inline
: GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT HEX: 8CD3 ; inline
: GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT HEX: 8CD4 ; inline
: GL_FRAMEBUFFER_COMPLETE_EXT HEX: 8CD5 ; inline
: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT HEX: 8CD6 ; inline
: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT HEX: 8CD7 ; inline
: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT HEX: 8CD9 ; inline
: GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT HEX: 8CDA ; inline
: GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT HEX: 8CDB ; inline
: GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT HEX: 8CDC ; inline
: GL_FRAMEBUFFER_UNSUPPORTED_EXT HEX: 8CDD ; inline
: GL_MAX_COLOR_ATTACHMENTS_EXT HEX: 8CDF ; inline
: GL_COLOR_ATTACHMENT0_EXT HEX: 8CE0 ; inline
: GL_COLOR_ATTACHMENT1_EXT HEX: 8CE1 ; inline
: GL_COLOR_ATTACHMENT2_EXT HEX: 8CE2 ; inline
: GL_COLOR_ATTACHMENT3_EXT HEX: 8CE3 ; inline
: GL_COLOR_ATTACHMENT4_EXT HEX: 8CE4 ; inline
: GL_COLOR_ATTACHMENT5_EXT HEX: 8CE5 ; inline
: GL_COLOR_ATTACHMENT6_EXT HEX: 8CE6 ; inline
: GL_COLOR_ATTACHMENT7_EXT HEX: 8CE7 ; inline
: GL_COLOR_ATTACHMENT8_EXT HEX: 8CE8 ; inline
: GL_COLOR_ATTACHMENT9_EXT HEX: 8CE9 ; inline
: GL_COLOR_ATTACHMENT10_EXT HEX: 8CEA ; inline
: GL_COLOR_ATTACHMENT11_EXT HEX: 8CEB ; inline
: GL_COLOR_ATTACHMENT12_EXT HEX: 8CEC ; inline
: GL_COLOR_ATTACHMENT13_EXT HEX: 8CED ; inline
: GL_COLOR_ATTACHMENT14_EXT HEX: 8CEE ; inline
: GL_COLOR_ATTACHMENT15_EXT HEX: 8CEF ; inline
: GL_DEPTH_ATTACHMENT_EXT HEX: 8D00 ; inline
: GL_STENCIL_ATTACHMENT_EXT HEX: 8D20 ; inline
: GL_FRAMEBUFFER_EXT HEX: 8D40 ; inline
: GL_RENDERBUFFER_EXT HEX: 8D41 ; inline
: GL_RENDERBUFFER_WIDTH_EXT HEX: 8D42 ; inline
: GL_RENDERBUFFER_HEIGHT_EXT HEX: 8D43 ; inline
: GL_RENDERBUFFER_INTERNAL_FORMAT_EXT HEX: 8D44 ; inline
: GL_STENCIL_INDEX1_EXT HEX: 8D46 ; inline
: GL_STENCIL_INDEX4_EXT HEX: 8D47 ; inline
: GL_STENCIL_INDEX8_EXT HEX: 8D48 ; inline
: GL_STENCIL_INDEX16_EXT HEX: 8D49 ; inline
: GL_RENDERBUFFER_RED_SIZE_EXT HEX: 8D50 ; inline
: GL_RENDERBUFFER_GREEN_SIZE_EXT HEX: 8D51 ; inline
: GL_RENDERBUFFER_BLUE_SIZE_EXT HEX: 8D52 ; inline
: GL_RENDERBUFFER_ALPHA_SIZE_EXT HEX: 8D53 ; inline
: GL_RENDERBUFFER_DEPTH_SIZE_EXT HEX: 8D54 ; inline
: GL_RENDERBUFFER_STENCIL_SIZE_EXT HEX: 8D55 ; inline
GL-FUNCTION: void glBindFramebufferEXT ( GLenum target, GLuint framebuffer ) ;
GL-FUNCTION: void glBindRenderbufferEXT ( GLenum target, GLuint renderbuffer ) ;
GL-FUNCTION: GLenum glCheckFramebufferStatusEXT ( GLenum target ) ;
GL-FUNCTION: void glDeleteFramebuffersEXT ( GLsizei n, GLuint* framebuffers ) ;
GL-FUNCTION: void glDeleteRenderbuffersEXT ( GLsizei n, GLuint* renderbuffers ) ;
GL-FUNCTION: void glFramebufferRenderbufferEXT ( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer ) ;
GL-FUNCTION: void glFramebufferTexture1DEXT ( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) ;
GL-FUNCTION: void glFramebufferTexture2DEXT ( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level ) ;
GL-FUNCTION: void glFramebufferTexture3DEXT ( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset ) ;
GL-FUNCTION: void glGenFramebuffersEXT ( GLsizei n, GLuint* framebuffers ) ;
GL-FUNCTION: void glGenRenderbuffersEXT ( GLsizei n, GLuint* renderbuffers ) ;
GL-FUNCTION: void glGenerateMipmapEXT ( GLenum target ) ;
GL-FUNCTION: void glGetFramebufferAttachmentParameterivEXT ( GLenum target, GLenum attachment, GLenum pname, GLint* params ) ;
GL-FUNCTION: void glGetRenderbufferParameterivEXT ( GLenum target, GLenum pname, GLint* params ) ;
GL-FUNCTION: GLboolean glIsFramebufferEXT ( GLuint framebuffer ) ;
GL-FUNCTION: GLboolean glIsRenderbufferEXT ( GLuint renderbuffer ) ;
GL-FUNCTION: void glRenderbufferStorageEXT ( GLenum target, GLenum internalformat, GLsizei width, GLsizei height ) ;
! GL_ARB_texture_float
: GL_RGBA32F_ARB HEX: 8814 ; inline
: GL_RGB32F_ARB HEX: 8815 ; inline
: GL_ALPHA32F_ARB HEX: 8816 ; inline
: GL_INTENSITY32F_ARB HEX: 8817 ; inline
: GL_LUMINANCE32F_ARB HEX: 8818 ; inline
: GL_LUMINANCE_ALPHA32F_ARB HEX: 8819 ; inline
: GL_RGBA16F_ARB HEX: 881A ; inline
: GL_RGB16F_ARB HEX: 881B ; inline
: GL_ALPHA16F_ARB HEX: 881C ; inline
: GL_INTENSITY16F_ARB HEX: 881D ; inline
: GL_LUMINANCE16F_ARB HEX: 881E ; inline
: GL_LUMINANCE_ALPHA16F_ARB HEX: 881F ; inline
: GL_TEXTURE_RED_TYPE_ARB HEX: 8C10 ; inline
: GL_TEXTURE_GREEN_TYPE_ARB HEX: 8C11 ; inline
: GL_TEXTURE_BLUE_TYPE_ARB HEX: 8C12 ; inline
: GL_TEXTURE_ALPHA_TYPE_ARB HEX: 8C13 ; inline
: GL_TEXTURE_LUMINANCE_TYPE_ARB HEX: 8C14 ; inline
: GL_TEXTURE_INTENSITY_TYPE_ARB HEX: 8C15 ; inline
: GL_TEXTURE_DEPTH_TYPE_ARB HEX: 8C16 ; inline
: GL_UNSIGNED_NORMALIZED_ARB HEX: 8C17 ; inline

View File

@ -0,0 +1,5 @@
USING: alien.syntax kernel syntax words ;
IN: opengl.gl.unix
: GL-FUNCTION: POSTPONE: FUNCTION: ; parsing

View File

@ -0,0 +1,34 @@
USING: alien alien.syntax arrays assocs hashtables init kernel
libc math namespaces parser sequences syntax system vectors
windows.opengl32 ;
IN: opengl.gl.windows
<PRIVATE
SYMBOL: gl-function-number-counter
SYMBOL: gl-function-pointers
0 gl-function-number-counter set
[ 100 <hashtable> gl-function-pointers set ] "opengl.gl.windows init hook" add-init-hook
: gl-function-number ( -- n )
gl-function-number-counter get
dup 1+ gl-function-number-counter set ;
: gl-function-pointer ( name n -- funptr )
wglGetCurrentContext 2array dup gl-function-pointers get at
[ -rot 2drop ]
[ >r wglGetProcAddress dup r> gl-function-pointers get set-at ]
if* ;
PRIVATE>
: GL-FUNCTION:
"stdcall"
scan
scan
dup gl-function-number [ gl-function-pointer ] 2curry swap
";" parse-tokens [ "()" subseq? not ] subset
define-indirect
; parsing

View File

@ -92,6 +92,96 @@ HELP: with-translation
{ $values { "loc" "a pair of integers" } { "quot" quotation } } { $values { "loc" "a pair of integers" } { "quot" quotation } }
{ $description "Calls the quotation with a translation by " { $snippet "loc" } " pixels applied to the current " { $link GL_MODELVIEW } " matrix, restoring the matrix when the quotation is done." } ; { $description "Calls the quotation with a translation by " { $snippet "loc" } " pixels applied to the current " { $link GL_MODELVIEW } " matrix, restoring the matrix when the quotation is done." } ;
HELP: gl-shader
{ $class-description { $snippet "gl-shader" } " is a predicate class comprising values returned by OpenGL to represent shader objects. The following words are provided for creating and manipulating these objects:"
{ $list
{ { $link <gl-shader> } " - Compile GLSL code into a shader object" }
{ { $link gl-shader-ok? } " - Check whether a shader object compiled successfully" }
{ { $link check-gl-shader } " - Throw an error unless a shader object compiled successfully" }
{ { $link gl-shader-info-log } " - Retrieve the info log of messages generated by the GLSL compiler" }
{ { $link delete-gl-shader } " - Invalidate a shader object" }
}
"The derived predicate classes " { $link vertex-shader } " and " { $link fragment-shader } " are also defined for the two standard kinds of shader defined by the OpenGL specification." } ;
HELP: vertex-shader
{ $class-description { $snippet "vertex-shader" } " is the predicate class of " { $link gl-shader } " objects that refer to shaders of type " { $snippet "GL_VERTEX_SHADER" } ". In addition to the " { $snippet "gl-shader" } " words, the following vertex shader-specific functions are defined:"
{ $list
{ { $link <vertex-shader> } " - Compile GLSL code into a vertex shader object "}
}
} ;
HELP: fragment-shader
{ $class-description { $snippet "fragment-shader" } " is the predicate class of " { $link gl-shader } " objects that refer to shaders of type " { $snippet "GL_FRAGMENT_SHADER" } ". In addition to the " { $snippet "gl-shader" } " words, the following fragment shader-specific functions are defined:"
{ $list
{ { $link <fragment-shader> } " - Compile GLSL code into a fragment shader object "}
}
} ;
HELP: <gl-shader>
{ $values { "source" "The GLSL source code to compile" } { "kind" "The kind of shader to compile, such as " { $snippet "GL_VERTEX_SHADER" } " or " { $snippet "GL_FRAGMENT_SHADER" } } }
{ $description "Tries to compile the given GLSL source into a shader object. The returned object can be checked for validity by " { $link check-gl-shader } " or " { $link gl-shader-ok? } ". Errors and warnings generated by the GLSL compiler will be collected in the info log, available from " { $link gl-shader-info-log } ".\n\nWhen the shader object is no longer needed, it should be deleted using " { $link delete-gl-shader } " or else be attached to a " { $link gl-program } " object deleted using " { $link delete-gl-program } "." } ;
HELP: <vertex-shader>
{ $values { "source" "The GLSL source code to compile" } }
{ $description "Tries to compile the given GLSL source into a vertex shader object. Equivalent to " { $snippet "GL_VERTEX_SHADER <gl-shader>" } "." } ;
HELP: <fragment-shader>
{ $values { "source" "The GLSL source code to compile" } }
{ $description "Tries to compile the given GLSL source into a fragment shader object. Equivalent to " { $snippet "GL_FRAGMENT_SHADER <gl-shader>" } "." } ;
HELP: gl-shader-ok?
{ $values { "shader" "A " { $link gl-shader } " object" } }
{ $description "Returns a boolean value indicating whether the given shader object compiled successfully. Compilation errors and warnings are available in the shader's info log, which can be gotten using " { $link gl-shader-info-log } "." } ;
HELP: check-gl-shader
{ $values { "shader" "A " { $link gl-shader } " object" } }
{ $description "Throws an error containing the " { $link gl-shader-info-log } " for the shader object if it failed to compile. Otherwise, the shader object is left on the stack." } ;
HELP: delete-gl-shader
{ $values { "shader" "A " { $link gl-shader } " object" } }
{ $description "Deletes the shader object, invalidating it and releasing any resources allocated for it by the OpenGL implementation." } ;
HELP: gl-shader-info-log
{ $values { "shader" "A " { $link gl-shader } " object" } }
{ $description "Retrieves the info log for " { $snippet "shader" } ", including any errors or warnings generated in compiling the shader object." } ;
HELP: gl-program
{ $class-description { $snippet "gl-program" } " is a predicate class comprising values returned by OpenGL to represent proram objects. The following words are provided for creating and manipulating these objects:"
{ $list
{ { $link <gl-program> } " - Link a set of shaders into a GLSL program" }
{ { $link gl-program-ok? } " - Check whether a program object linked successfully" }
{ { $link check-gl-program } " - Throw an error unless a program object linked successfully" }
{ { $link gl-program-info-log } " - Retrieve the info log of messages generated by the GLSL linker" }
{ { $link gl-program-shaders } " - Retrieve the set of shader objects composing the GLSL linker" }
{ { $link delete-gl-program } " - Invalidate a program object and all its attached shaders" }
{ { $link with-gl-program } " - Use a program object" }
}
} ;
HELP: <gl-program>
{ $values { "shaders" "A sequence of " { $link gl-shader } " objects." } }
{ $description "Creates a new GLSL program object, attaches all the shader objects in the " { $snippet "shaders" } " sequence, and attempts to link them. The returned object can be checked for validity by " { $link check-gl-program } " or " { $link gl-program-ok? } ". Errors and warnings generated by the GLSL linker will be collected in the info log, available from " { $link gl-program-info-log } ".\n\nWhen the program object and its attached shaders are no longer needed, it should be deleted using " { $link delete-gl-program } "." } ;
HELP: gl-program-ok?
{ $values { "program" "A " { $link gl-program } " object" } }
{ $description "Returns a boolean value indicating whether the given program object linked successfully. Link errors and warnings are available in the program's info log, which can be gotten using " { $link gl-program-info-log } "." } ;
HELP: check-gl-program
{ $values { "program" "A " { $link gl-program } " object" } }
{ $description "Throws an error containing the " { $link gl-program-info-log } " for the program object if it failed to link. Otherwise, the program object is left on the stack." } ;
HELP: gl-program-info-log
{ $values { "program" "A " { $link gl-program } " object" } }
{ $description "Retrieves the info log for " { $snippet "program" } ", including any errors or warnings generated in linking the program object." } ;
HELP: delete-gl-program
{ $values { "program" "A " { $link gl-program } " object" } }
{ $description "Deletes the program object, invalidating it and releasing any resources allocated for it by the OpenGL implementation. Any attached " { $link gl-shader } "s are also deleted.\n\nIf the shader objects should be preserved, they should each be detached using " { $link detach-gl-program-shader } ". The program object can then be destroyed alone using " { $link delete-gl-program-only } "." } ;
HELP: with-gl-program
{ $values { "program" "A " { $link gl-program } " object" } { "quot" "A quotation" } }
{ $description "Enables " { $snippet "program" } " for all OpenGL calls made in " { $snippet "quot" } ". The fixed-function pipeline is restored at the end of " { $snippet "quot" } "." } ;
ARTICLE: "gl-utilities" "OpenGL utility words" ARTICLE: "gl-utilities" "OpenGL utility words"
"In addition to the full OpenGL API, the " { $vocab-link "opengl" } " vocabulary includes some utility words to give OpenGL a more Factor-like feel." "In addition to the full OpenGL API, the " { $vocab-link "opengl" } " vocabulary includes some utility words to give OpenGL a more Factor-like feel."
$nl $nl
@ -112,6 +202,10 @@ $nl
{ $subsection gl-rect } { $subsection gl-rect }
{ $subsection gl-fill-poly } { $subsection gl-fill-poly }
{ $subsection gl-poly } { $subsection gl-poly }
{ $subsection gl-gradient } ; { $subsection gl-gradient }
"Compiling, linking, and using GLSL programs:"
{ $subsection gl-shader }
{ $subsection gl-program }
;
ABOUT: "gl-utilities" ABOUT: "gl-utilities"

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005, 2007 Slava Pestov. ! Copyright (C) 2005, 2007 Slava Pestov.
! Portions copyright (C) 2007 Eduardo Cavazos. ! Portions copyright (C) 2007 Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types kernel math namespaces sequences USING: alien alien.c-types kernel libc math namespaces sequences
math.vectors math.constants math.functions opengl.gl opengl.glu math.vectors math.constants math.functions opengl.gl opengl.glu
combinators arrays ; combinators arrays ;
IN: opengl IN: opengl
@ -20,7 +20,7 @@ IN: opengl
: gl-error ( -- ) : gl-error ( -- )
glGetError dup zero? [ glGetError dup zero? [
"GL error: " dup gluErrorString append throw "GL error: " over gluErrorString append throw
] unless drop ; ] unless drop ;
: do-state ( what quot -- ) : do-state ( what quot -- )
@ -185,3 +185,100 @@ TUPLE: sprite loc dim dim2 dlist texture ;
glLoadIdentity glLoadIdentity
GL_MODELVIEW glMatrixMode GL_MODELVIEW glMatrixMode
glLoadIdentity ; glLoadIdentity ;
! Shaders
: c-true? ( int -- ? ) zero? not ; inline
: with-gl-shader-source-ptr ( string quot -- )
swap dup length 1+ [ tuck string>memory <void*> swap call ] with-malloc ; inline
: <gl-shader> ( source kind -- shader )
glCreateShader dup rot [ 1 swap f glShaderSource ] with-gl-shader-source-ptr
[ glCompileShader ] keep
gl-error ;
: (gl-shader?) ( object -- ? )
dup integer? [ glIsShader c-true? ] [ drop f ] if ;
: gl-shader-get-int ( shader enum -- value )
0 <int> [ glGetShaderiv ] keep *int ;
: gl-shader-ok? ( shader -- ? )
GL_COMPILE_STATUS gl-shader-get-int c-true? ;
: <vertex-shader> ( source -- vertex-shader )
GL_VERTEX_SHADER <gl-shader> ; inline
: (vertex-shader?) ( object -- ? )
dup (gl-shader?) [ GL_SHADER_TYPE gl-shader-get-int GL_VERTEX_SHADER = ] [ drop f ] if ;
: <fragment-shader> ( source -- fragment-shader )
GL_FRAGMENT_SHADER <gl-shader> ; inline
: (fragment-shader?) ( object -- ? )
dup (gl-shader?) [ GL_SHADER_TYPE gl-shader-get-int GL_FRAGMENT_SHADER = ] [ drop f ] if ;
: gl-shader-info-log-length ( shader -- log-length )
GL_INFO_LOG_LENGTH gl-shader-get-int ; inline
: gl-shader-info-log ( shader -- log )
dup gl-shader-info-log-length dup [ [ 0 <int> swap glGetShaderInfoLog ] keep alien>char-string ] with-malloc ;
: check-gl-shader ( shader -- shader* )
dup gl-shader-ok? [ dup gl-shader-info-log throw ] unless ;
: delete-gl-shader ( shader -- ) glDeleteShader ; inline
PREDICATE: integer gl-shader (gl-shader?) ;
PREDICATE: gl-shader vertex-shader (vertex-shader?) ;
PREDICATE: gl-shader fragment-shader (fragment-shader?) ;
! Programs
: <gl-program> ( shaders -- program )
glCreateProgram swap
[ dupd glAttachShader ] each
[ glLinkProgram ] keep
gl-error ;
: (gl-program?) ( object -- ? )
dup integer? [ glIsProgram c-true? ] [ drop f ] if ;
: gl-program-get-int ( program enum -- value )
0 <int> [ glGetProgramiv ] keep *int ;
: gl-program-ok? ( program -- ? )
GL_LINK_STATUS gl-program-get-int c-true? ;
: gl-program-info-log-length ( program -- log-length )
GL_INFO_LOG_LENGTH gl-program-get-int ; inline
: gl-program-info-log ( program -- log )
dup gl-program-info-log-length
dup [ [ 0 <int> swap glGetProgramInfoLog ] keep
alien>char-string ] with-malloc ;
: check-gl-program ( program -- program* )
dup gl-program-ok? [ dup gl-program-info-log throw ] unless ;
: gl-program-shaders-length ( program -- shaders-length )
GL_ATTACHED_SHADERS gl-program-get-int ; inline
: gl-program-shaders ( program -- shaders )
dup gl-program-shaders-length
[ dup "GLuint" <c-array> [ 0 <int> swap glGetAttachedShaders ] keep ] keep
c-uint-array> ;
: delete-gl-program-only ( program -- ) glDeleteProgram ; inline
: detach-gl-program-shader ( program shader -- ) glDetachShader ; inline
: delete-gl-program ( program -- )
dup gl-program-shaders [ 2dup detach-gl-program-shader delete-gl-shader ] each
delete-gl-program-only ;
: with-gl-program ( program quot -- )
swap glUseProgram call 0 glUseProgram ; inline
PREDICATE: integer gl-program (gl-program?) ;

View File

@ -1,6 +1,6 @@
! Copyright (c) 2007 Aaron Schaefer, Daniel Ehrenberg. ! Copyright (c) 2007 Aaron Schaefer, Daniel Ehrenberg.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays combinators.lib hashtables kernel math math.parser math.ranges USING: hashtables kernel math math.parser math.ranges project-euler.common
sequences sorting ; sequences sorting ;
IN: project-euler.004 IN: project-euler.004
@ -21,9 +21,6 @@ IN: project-euler.004
: palindrome? ( n -- ? ) : palindrome? ( n -- ? )
number>string dup reverse = ; number>string dup reverse = ;
: cartesian-product ( seq1 seq2 -- seq1xseq2 )
swap [ swap [ 2array ] map-with ] map-with concat ;
<PRIVATE <PRIVATE
: source-004 ( -- seq ) : source-004 ( -- seq )

View File

@ -0,0 +1,75 @@
! Copyright (c) 2007 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.primes project-euler.common sequences ;
IN: project-euler.027
! http://projecteuler.net/index.php?section=problems&id=27
! DESCRIPTION
! -----------
! Euler published the remarkable quadratic formula:
! n² + n + 41
! It turns out that the formula will produce 40 primes for the consecutive
! values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is
! divisible by 41, and certainly when n = 41, 41² + 41 + 41 is clearly
! divisible by 41.
! Using computers, the incredible formula n² - 79n + 1601 was discovered, which
! produces 80 primes for the consecutive values n = 0 to 79. The product of the
! coefficients, -79 and 1601, is -126479.
! Considering quadratics of the form:
! n² + an + b, where |a| < 1000 and |b| < 1000
! where |n| is the modulus/absolute value of n
! e.g. |11| = 11 and |-4| = 4
! Find the product of the coefficients, a and b, for the quadratic expression
! that produces the maximum number of primes for consecutive values of n,
! starting with n = 0.
! SOLUTION
! --------
! b must be prime since n = 0 must return a prime
! a + b + 1 must be prime since n = 1 must return a prime
! 1 - a + b must be prime as well, hence >= 2. Therefore:
! 1 - a + b >= 2
! b - a >= 1
! a < b
<PRIVATE
: source-027 ( -- seq )
1000 [ prime? ] subset [ dup [ neg ] map append ] keep
cartesian-product [ first2 < ] subset ;
: quadratic ( b a n -- m )
dup sq -rot * + + ;
: (consecutive-primes) ( b a n -- m )
3dup quadratic prime? [ 1+ (consecutive-primes) ] [ 2nip ] if ;
: consecutive-primes ( a b -- m )
swap 0 (consecutive-primes) ;
: max-consecutive ( seq -- elt n )
dup [ first2 consecutive-primes ] map dup supremum
over index [ swap nth ] curry 2apply ;
PRIVATE>
: euler027 ( -- answer )
source-027 max-consecutive drop product ;
! [ euler027 ] 100 ave-time
! 687 ms run / 23 ms GC ave time - 100 trials
! TODO: generalize max-consecutive/max-product (from #26) into a new word
MAIN: euler027

View File

@ -0,0 +1,46 @@
! Copyright (c) 2007 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators.lib kernel math math.ranges ;
IN: project-euler.028
! http://projecteuler.net/index.php?section=problems&id=28
! DESCRIPTION
! -----------
! Starting with the number 1 and moving to the right in a clockwise direction a
! 5 by 5 spiral is formed as follows:
! 21 22 23 24 25
! 20 7 8 9 10
! 19 6 1 2 11
! 18 5 4 3 12
! 17 16 15 14 13
! It can be verified that the sum of both diagonals is 101.
! What is the sum of both diagonals in a 1001 by 1001 spiral formed in the same way?
! SOLUTION
! --------
! For a square sized n by n, the sum of corners is 4n² - 6n + 6
<PRIVATE
: sum-corners ( n -- sum )
dup 1 = [ [ sq 4 * ] keep 6 * - 6 + ] unless ;
: sum-diags ( n -- sum )
1 swap 2 <range> [ sum-corners ] sigma ;
PRIVATE>
: euler028 ( -- answer )
1001 sum-diags ;
! [ euler028 ] 100 ave-time
! 0 ms run / 0 ms GC ave time - 100 trials
MAIN: euler028

View File

@ -0,0 +1,37 @@
! Copyright (c) 2007 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: hashtables kernel math.functions math.ranges project-euler.common
sequences ;
IN: project-euler.029
! http://projecteuler.net/index.php?section=problems&id=29
! DESCRIPTION
! -----------
! Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
! 2^2 = 4, 2^3 = 8, 2^4 = 16, 2^5 = 32
! 3^2 = 9, 3^3 = 27, 3^4 = 81, 3^5 = 243
! 4^2 = 16, 4^3 = 64, 4^4 = 256, 4^5 = 1024
! 5^2 = 25, 5^3 = 125, 5^4 = 625, 5^5 = 3125
! If they are then placed in numerical order, with any repeats removed, we get
! the following sequence of 15 distinct terms:
! 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
! How many distinct terms are in the sequence generated by a^b for 2 ≤ a ≤ 100
! and 2 ≤ b ≤ 100?
! SOLUTION
! --------
: euler029 ( -- answer )
2 100 [a,b] dup cartesian-product [ first2 ^ ] map prune length ;
! [ euler029 ] 100 ave-time
! 951 ms run / 12 ms GC ave time - 100 trials
MAIN: euler029

View File

@ -1,5 +1,5 @@
USING: kernel math math.functions math.miller-rabin math.parser USING: arrays combinators.lib kernel math math.functions math.miller-rabin
math.primes.factors math.ranges namespaces sequences ; math.parser math.primes.factors math.ranges namespaces sequences ;
IN: project-euler.common IN: project-euler.common
! A collection of words used by more than one Project Euler solution ! A collection of words used by more than one Project Euler solution
@ -7,6 +7,7 @@ IN: project-euler.common
! Problems using each public word ! Problems using each public word
! ------------------------------- ! -------------------------------
! cartesian-product - #4, #27
! collect-consecutive - #8, #11 ! collect-consecutive - #8, #11
! log10 - #25, #134 ! log10 - #25, #134
! max-path - #18, #67 ! max-path - #18, #67
@ -45,6 +46,9 @@ IN: project-euler.common
PRIVATE> PRIVATE>
: cartesian-product ( seq1 seq2 -- seq1xseq2 )
swap [ swap [ 2array ] map-with ] map-with concat ;
: collect-consecutive ( seq width -- seq ) : collect-consecutive ( seq width -- seq )
[ [
2dup count-shifts [ 2dup head shift-3rd , ] times 2dup count-shifts [ 2dup head shift-3rd , ] times

View File

@ -8,8 +8,9 @@ USING: definitions io io.files kernel math.parser sequences vocabs
project-euler.013 project-euler.014 project-euler.015 project-euler.016 project-euler.013 project-euler.014 project-euler.015 project-euler.016
project-euler.017 project-euler.018 project-euler.019 project-euler.020 project-euler.017 project-euler.018 project-euler.019 project-euler.020
project-euler.021 project-euler.022 project-euler.023 project-euler.024 project-euler.021 project-euler.022 project-euler.023 project-euler.024
project-euler.025 project-euler.026 project-euler.067 project-euler.134 project-euler.025 project-euler.026 project-euler.027 project-euler.028
project-euler.169 project-euler.173 project-euler.175 ; project-euler.029 project-euler.067 project-euler.134 project-euler.169
project-euler.173 project-euler.175 ;
IN: project-euler IN: project-euler
<PRIVATE <PRIVATE

View File

@ -10,4 +10,3 @@ C-STRUCT: timeval
"timeval" <c-object> "timeval" <c-object>
[ set-timeval-usec ] keep [ set-timeval-usec ] keep
[ set-timeval-sec ] keep ; [ set-timeval-sec ] keep ;

View File

@ -11,7 +11,7 @@ IN: tools.deploy.shaker
: show ( msg -- ) : show ( msg -- )
#! Use primitives directly so that we can print stuff even #! Use primitives directly so that we can print stuff even
#! after most of the image has been stripped away #! after most of the image has been stripped away
"\r\n" append stdout fwrite stdout fflush ; "\r\n" append stdout-handle fwrite stdout-handle fflush ;
: strip-init-hooks ( -- ) : strip-init-hooks ( -- )
"Stripping startup hooks" show "Stripping startup hooks" show

View File

@ -0,0 +1,73 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax ;
IN: unix.kqueue
FUNCTION: int kqueue ( ) ;
FUNCTION: int kevent ( int kq, kevent* changelist, int nchanges, kevent* eventlist, int nevents, timespec* timeout ) ;
C-STRUCT: kevent
{ "ulong" "ident" } ! identifier for this event
{ "short" "filter" } ! filter for event
{ "ushort" "flags" } ! action flags for kqueue
{ "uint" "fflags" } ! filter flag value
{ "long" "data" } ! filter data value
{ "void*" "udata" } ! opaque user data identifier
;
: EVFILT_READ -1 ; inline
: EVFILT_WRITE -2 ; inline
: EVFILT_AIO -3 ; inline ! attached to aio requests
: EVFILT_VNODE -4 ; inline ! attached to vnodes
: EVFILT_PROC -5 ; inline ! attached to struct proc
: EVFILT_SIGNAL -6 ; inline ! attached to struct proc
: EVFILT_TIMER -7 ; inline ! timers
: EVFILT_MACHPORT -8 ; inline ! Mach ports
: EVFILT_FS -9 ; inline ! Filesystem events
! actions
: EV_ADD HEX: 1 ; inline ! add event to kq (implies enable)
: EV_DELETE HEX: 2 ; inline ! delete event from kq
: EV_ENABLE HEX: 4 ; inline ! enable event
: EV_DISABLE HEX: 8 ; inline ! disable event (not reported)
! flags
: EV_ONESHOT HEX: 10 ; inline ! only report one occurrence
: EV_CLEAR HEX: 20 ; inline ! clear event state after reporting
: EV_SYSFLAGS HEX: f000 ; inline ! reserved by system
: EV_FLAG0 HEX: 1000 ; inline ! filter-specific flag
: EV_FLAG1 HEX: 2000 ; inline ! filter-specific flag
! returned values
: EV_EOF HEX: 8000 ; inline ! EOF detected
: EV_ERROR HEX: 4000 ; inline ! error, data contains errno
: EV_POLL EV_FLAG0 ; inline
: EV_OOBAND EV_FLAG1 ; inline
: NOTE_LOWAT HEX: 00000001 ; inline ! low water mark
: NOTE_DELETE HEX: 00000001 ; inline ! vnode was removed
: NOTE_WRITE HEX: 00000002 ; inline ! data contents changed
: NOTE_EXTEND HEX: 00000004 ; inline ! size increased
: NOTE_ATTRIB HEX: 00000008 ; inline ! attributes changed
: NOTE_LINK HEX: 00000010 ; inline ! link count changed
: NOTE_RENAME HEX: 00000020 ; inline ! vnode was renamed
: NOTE_REVOKE HEX: 00000040 ; inline ! vnode access was revoked
: NOTE_EXIT HEX: 80000000 ; inline ! process exited
: NOTE_FORK HEX: 40000000 ; inline ! process forked
: NOTE_EXEC HEX: 20000000 ; inline ! process exec'd
: NOTE_PCTRLMASK HEX: f0000000 ; inline ! mask for hint bits
: NOTE_PDATAMASK HEX: 000fffff ; inline ! mask for pid
: NOTE_SECONDS HEX: 00000001 ; inline ! data is seconds
: NOTE_USECONDS HEX: 00000002 ; inline ! data is microseconds
: NOTE_NSECONDS HEX: 00000004 ; inline ! data is nanoseconds
: NOTE_ABSOLUTE HEX: 00000008 ; inline ! absolute timeout
: NOTE_TRACK HEX: 00000001 ; inline ! follow across forks
: NOTE_TRACKERR HEX: 00000002 ; inline ! could not track child
: NOTE_CHILD HEX: 00000004 ; inline ! am a child process

View File

@ -41,6 +41,12 @@ C-STRUCT: timespec
{ "time_t" "sec" } { "time_t" "sec" }
{ "long" "nsec" } ; { "long" "nsec" } ;
: make-timespec ( ms -- timespec )
1000 /mod 1000000 *
"timespec" <c-object>
[ set-timespec-nsec ] keep
[ set-timespec-sec ] keep ;
! ! ! Unix constants ! ! ! Unix constants
! File type ! File type

4
extra/windows/opengl32/opengl32.factor Normal file → Executable file
View File

@ -1,8 +1,7 @@
! Copyright (C) 2005, 2006 Doug Coleman. ! Copyright (C) 2005, 2006 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax parser namespaces kernel USING: alien alien.c-types alien.syntax parser namespaces kernel
math windows.types windows.types init assocs sequences opengl.gl math windows.types windows.types init assocs sequences libc ;
libc ;
IN: windows.opengl32 IN: windows.opengl32
! PIXELFORMATDESCRIPTOR flags ! PIXELFORMATDESCRIPTOR flags
@ -100,4 +99,5 @@ LIBRARY: gl
FUNCTION: HGLRC wglCreateContext ( HDC hDC ) ; FUNCTION: HGLRC wglCreateContext ( HDC hDC ) ;
FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ; FUNCTION: BOOL wglDeleteContext ( HGLRC hRC ) ;
FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ; FUNCTION: BOOL wglMakeCurrent ( HDC hDC, HGLRC hglrc ) ;
FUNCTION: HGLRC wglGetCurrentContext ( ) ;
FUNCTION: void* wglGetProcAddress ( char* name ) ; FUNCTION: void* wglGetProcAddress ( char* name ) ;

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
puts factor_eval(STDIN.read)</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^E</string>
<key>name</key>
<string>Eval Selection/Line</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>8E01DDAF-959B-4237-ADB9-C133A4ACCE90</string>
</dict>
</plist>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
doc = STDIN.read
word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
factor_run(%Q(#{doc_using_statements(doc)} USE: help\n \\ #{word} help))</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>^H</string>
<key>name</key>
<string>Help for Word</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>BC5BE120-734B-40DF-8B6B-5D3243614B27</string>
</dict>
</plist>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
doc = STDIN.read
puts factor_eval(%Q(#{doc_using_statements(doc)} USE: inference\n [ #{ENV["TM_SELECTED_TEXT"]} ] infer.))</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>document</string>
<key>name</key>
<string>Infer Effect of Selection</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
</dict>
</plist>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
factor_run(%Q(USE: parser\n "#{ENV["TM_FILEPATH"]}" run-file))</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@r</string>
<key>name</key>
<string>Run File in Listener</string>
<key>output</key>
<string>discard</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>CAD3BB10-C480-4C0E-9518-94D61F7A0C0B</string>
</dict>
</plist>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
factor_run(STDIN.read)</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^~e</string>
<key>name</key>
<string>Run Selection/Line in Listener</string>
<key>output</key>
<string>discard</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>15A984BD-BC65-43E8-878A-267788C8DA70</string>
</dict>
</plist>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/tm_factor"
doc = STDIN.read
word = line_current_word(ENV["TM_CURRENT_LINE"], ENV["TM_LINE_INDEX"].to_i)
puts factor_eval(%Q(#{doc_using_statements(doc)} USE: prettyprint\n \\ #{word} see))</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>document</string>
<key>keyEquivalent</key>
<string>^h</string>
<key>name</key>
<string>See Word</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>
<string>source.factor</string>
<key>uuid</key>
<string>35484754-DBF9-4381-BB25-00CAB64DF4A1</string>
</dict>
</plist>

View File

@ -0,0 +1,38 @@
require 'osx/cocoa'
def _wait_for_return_value(pb)
origCount = pb.changeCount
sleep 0.125 while pb.changeCount == origCount
end
def perform_service(service, in_string, wait_for_return_value=false)
p = OSX::NSPasteboard.pasteboardWithUniqueName
p.declareTypes_owner([OSX::NSStringPboardType], nil)
p.setString_forType(in_string, OSX::NSStringPboardType)
raise "Unable to call service #{service}" unless OSX::NSPerformService(service, p)
_wait_for_return_value(p) if wait_for_return_value
p.stringForType(OSX::NSStringPboardType)
end
def textmate_front()
system %Q{osascript -e 'tell app "TextMate" to activate'};
end
def factor_run(code)
perform_service("Factor/Evaluate in Listener", code)
end
def factor_eval(code)
r = perform_service("Factor/Evaluate Selection", code, true)
textmate_front
r
end
def doc_using_statements(document)
document.scan(/\b(USING:\s[^;]*\s;|USE:\s+\S+|IN:\s\S+)/).join("\n") << "\n"
end
def line_current_word(line, point)
left = line.rindex(/\s|^/, point - 1) + 1; right = line.index(/\s|$/, point) - 1
line[left..right]
end

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>fileTypes</key> <key>fileTypes</key>
@ -240,6 +240,44 @@
</dict> </dict>
</array> </array>
</dict> </dict>
<dict>
<key>begin</key>
<string>&lt;"</string>
<key>end</key>
<string>"&gt;</string>
<key>name</key>
<string>string.quoted.double.multiline.factor</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#escaped_characters</string>
</dict>
</array>
</dict>
<dict>
<key>begin</key>
<string>(^|(?&lt;=\s))(STRING:)\s+(\S+)</string>
<key>captures</key>
<dict>
<key>2</key>
<dict>
<key>name</key>
<string>keyword.colon.factor</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>entity.name.heredoc.factor</string>
</dict>
</dict>
<key>contentName</key>
<string>string.unquoted.heredoc.factor</string>
<key>end</key>
<string>^;$</string>
<key>name</key>
<string>definition.word.heredoc.factor</string>
</dict>
<dict> <dict>
<key>match</key> <key>match</key>
<string>inline|foldable</string> <string>inline|foldable</string>
@ -254,9 +292,9 @@
</dict> </dict>
<dict> <dict>
<key>begin</key> <key>begin</key>
<string>\(\s</string> <string>\((?=\s)</string>
<key>end</key> <key>end</key>
<string>\s\)</string> <string>(^|(?&lt;=\s))\)</string>
<key>name</key> <key>name</key>
<string>comment.parens.factor</string> <string>comment.parens.factor</string>
</dict> </dict>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>fileTypes</key> <key>fileTypes</key>

View File

@ -1,9 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>name</key> <key>name</key>
<string>Factor</string> <string>Factor</string>
<key>ordering</key>
<array>
<string>3C9C9C2A-314A-475B-A4E4-A68BAAF3F36E</string>
<string>141517D7-73E0-4475-A481-71102575A175</string>
<string>CAD3BB10-C480-4C0E-9518-94D61F7A0C0B</string>
<string>15A984BD-BC65-43E8-878A-267788C8DA70</string>
<string>8E01DDAF-959B-4237-ADB9-C133A4ACCE90</string>
<string>35484754-DBF9-4381-BB25-00CAB64DF4A1</string>
<string>BC5BE120-734B-40DF-8B6B-5D3243614B27</string>
<string>B619FCC0-2DF2-4657-82A8-0E5676A10254</string>
</array>
<key>uuid</key> <key>uuid</key>
<string>8061D2F3-B603-411D-AFFE-61784A07906D</string> <string>8061D2F3-B603-411D-AFFE-61784A07906D</string>
</dict> </dict>

View File

@ -13,8 +13,9 @@ normal operation. */
void init_c_io(void) void init_c_io(void)
{ {
userenv[IN_ENV] = allot_alien(F,(CELL)stdin); userenv[STDIN_ENV] = allot_alien(F,(CELL)stdin);
userenv[OUT_ENV] = allot_alien(F,(CELL)stdout); userenv[STDOUT_ENV] = allot_alien(F,(CELL)stdout);
userenv[STDERR_ENV] = allot_alien(F,(CELL)stderr);
} }
void io_error(void) void io_error(void)

View File

@ -16,8 +16,8 @@ typedef enum {
OS_ENV, /* operating system name */ OS_ENV, /* operating system name */
ARGS_ENV = 10, /* command line arguments */ ARGS_ENV = 10, /* command line arguments */
IN_ENV, /* stdin FILE* handle */ STDIN_ENV, /* stdin FILE* handle */
OUT_ENV, /* stdout FILE* handle */ STDOUT_ENV, /* stdout FILE* handle */
IMAGE_ENV = 13, /* image path name */ IMAGE_ENV = 13, /* image path name */
EXECUTABLE_ENV, /* runtime executable path name */ EXECUTABLE_ENV, /* runtime executable path name */
@ -51,6 +51,9 @@ typedef enum {
STACK_TRACES_ENV = 36, STACK_TRACES_ENV = 36,
UNDEFINED_ENV = 37, /* default quotation for undefined words */ UNDEFINED_ENV = 37, /* default quotation for undefined words */
STDERR_ENV = 38, /* stderr FILE* handle */
STAGE2_ENV = 39 /* have we bootstrapped? */ STAGE2_ENV = 39 /* have we bootstrapped? */
} F_ENVTYPE; } F_ENVTYPE;