: fill-bunny-state ( bunny-state -- )
dup [ vertexes>> ] [ indexes>> ] bi <bunny-buffers>
- [ bunny-program <program-instance> bunny-vertex buffer>vertex-array >>vertex-array ]
+ [ bunny-program <program-instance> <vertex-array> >>vertex-array ]
[ 0 <buffer-ptr> ]
[ uint-indexes <index-elements> >>index-elements ] tri*
drop ;
: <sobel-state> ( window-vertex-buffer -- sobel-state )
sobel-state new
- swap sobel-program <program-instance> window-vertex buffer>vertex-array >>vertex-array
+ swap sobel-program <program-instance> <vertex-array> >>vertex-array
RGBA half-components T{ texture-parameters
{ wrap clamp-texcoord-to-edge }
: <loading-state> ( window-vertex-buffer -- loading-state )
loading-state new
swap
- loading-program <program-instance> window-vertex buffer>vertex-array >>vertex-array
+ loading-program <program-instance> <vertex-array> >>vertex-array
RGBA ubyte-components T{ texture-parameters
{ wrap clamp-texcoord-to-edge }
HELP: <multi-vertex-array>
{ $values
- { "program-instance" program-instance } { "vertex-formats" "a list of " { $link buffer-ptr } "/" { $link vertex-format } " pairs" }
+ { "vertex-formats" "a list of " { $link buffer-ptr } "/" { $link vertex-format } " pairs" }
+ { "program-instance" program-instance }
{ "vertex-array" vertex-array }
}
-{ $description "Creates a new " { $link vertex-array } " to feed data to " { $snippet "program-instance" } " from the set of " { $link buffer } "s specified in " { $snippet "vertex-formats" } "." } ;
+{ $description "Creates a new " { $link vertex-array } " to feed data to " { $snippet "program-instance" } " from the set of " { $link buffer } "s specified in " { $snippet "vertex-formats" } ". The first element of each pair in " { $snippet "vertex-formats" } " can be either a " { $link buffer-ptr } " or a " { $link buffer } "; in the latter case, vertex data in the associated format is read from the beginning of the buffer." } ;
HELP: feedback-format:
{ $syntax "feedback-format: vertex-format" }
}
{ $description "Returns the numeric index of the vertex attribute named " { $snippet "attribute-name" } " in " { $snippet "program-instance" } "." } ;
+HELP: <vertex-array>
+{ $values
+ { "vertex-buffer" "a " { $link buffer } " or " { $link buffer-ptr } } { "program-instance" program-instance }
+ { "vertex-array" vertex-array }
+}
+{ $description "Creates a new " { $link vertex-array } " from the entire contents of a single " { $link buffer } " for use with a " { $link program-instance } ". The data in " { $snippet "buffer" } " is taken in the first " { $link vertex-format } " specified in the program instance's originating " { $link POSTPONE: GLSL-PROGRAM: } " definition. If the program has no associated vertex formats, an error will be thrown. To specify a different vertex format, use " { $link <vertex-array*> } "." } ;
+
HELP: <vertex-array*>
{ $values
- { "vertex-buffer" buffer } { "program-instance" program-instance } { "format" vertex-format }
+ { "vertex-buffer" "a " { $link buffer } " or " { $link buffer-ptr } } { "program-instance" program-instance } { "format" vertex-format }
{ "vertex-array" vertex-array }
}
-{ $description "Creates a new " { $link vertex-array } " from the entire contents of a single " { $link buffer } " in a single " { $link vertex-format } " for use with " { $snippet "program-instance" } "." } ;
+{ $description "Creates a new " { $link vertex-array } " from the entire contents of a single " { $link buffer } " for use with a " { $link program-instance } ". The data in " { $snippet "buffer" } " is taken in the specified " { $link vertex-format } "." } ;
-{ vertex-array <multi-vertex-array> <vertex-array*> } related-words
+{ vertex-array <multi-vertex-array> <vertex-array> <vertex-array*> } related-words
HELP: compile-shader-error
{ $class-description "An error compiling the source for a " { $link shader } "."
M: vertex-array dispose
[ [ delete-vertex-array ] when* f ] change-handle drop ;
-: <vertex-array> ( program-instance vertex-formats -- vertex-array )
- gen-vertex-array
- [ glBindVertexArray [ first2 bind-vertex-format ] with each ]
- [ -rot [ first buffer>> ] map vertex-array boa ] 3bi
- window-resource ; inline
-
-TYPED: buffer>vertex-array ( vertex-buffer: buffer
- program-instance: program-instance
- format: vertex-format
- --
- vertex-array: vertex-array )
- [ swap ] dip
- [ 0 <buffer-ptr> ] dip 2array 1array <vertex-array> ; inline
+: ?>buffer-ptr ( buffer/ptr -- buffer-ptr )
+ dup buffer-ptr? [ 0 <buffer-ptr> ] unless ; inline
+: ?>buffer ( buffer/ptr -- buffer )
+ dup buffer? [ buffer>> ] unless ; inline
+
+:: <multi-vertex-array> ( vertex-formats program-instance -- vertex-array )
+ gen-vertex-array :> handle
+ handle glBindVertexArray
+
+ vertex-formats [ program-instance swap first2 [ ?>buffer-ptr ] dip bind-vertex-format ] each
+ handle program-instance vertex-formats [ first ?>buffer ] map
+ vertex-array boa window-resource ; inline
+
+:: <vertex-array*> ( vertex-buffer program-instance format -- vertex-array )
+ gen-vertex-array :> handle
+ handle glBindVertexArray
+ program-instance vertex-buffer ?>buffer-ptr format bind-vertex-format
+ handle program-instance vertex-buffer ?>buffer 1array
+ vertex-array boa window-resource ; inline
+
+: <vertex-array> ( vertex-buffer program-instance -- vertex-array )
+ dup program>> vertex-formats>> first <vertex-array*> ; inline
TYPED: vertex-array-buffer ( vertex-array: vertex-array -- vertex-buffer: buffer )
vertex-buffers>> first ;
: shaders-and-formats ( words -- shaders vertex-formats feedback-format )
[ [ ?shader ] map sift ]
- [ [ vertex-format? ] filter ]
+ [ [ vertex-format-attributes ] filter ]
[ [ feedback-format? ] filter validate-feedback-format ] tri ;
PRIVATE>
byte-array>buffer ; inline
: <window-vertex-array> ( program-instance -- vertex-array )
- [ <window-vertex-buffer> ] dip window-vertex buffer>vertex-array ; inline
+ [ <window-vertex-buffer> ] dip window-vertex <vertex-array*> ; inline
[
[
[ vertex-buffer>> obj-program <program-instance> ]
- [ vertex-format>> ] bi buffer>vertex-array
+ [ vertex-format>> ] bi <vertex-array*>
] map >>vertex-arrays drop
]
[