gpu.shaders: change around vertex-array construction a bit. rename <vertex-array> to <multi-vertex-array> and buffer>vertex-array to <vertex-array*> . add new <vertex-array> that takes a single buffer and reads it with the program's linked vertex-format
parent
910f1b603c
commit
ce11431fdb
|
@ -163,7 +163,7 @@ CONSTANT: bunny-model-url "http://factorcode.org/bun_zipper.ply"
|
|||
|
||||
: 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 ;
|
||||
|
@ -180,7 +180,7 @@ CONSTANT: bunny-model-url "http://factorcode.org/bun_zipper.ply"
|
|||
|
||||
: <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 }
|
||||
|
@ -207,7 +207,7 @@ CONSTANT: bunny-model-url "http://factorcode.org/bun_zipper.ply"
|
|||
: <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 }
|
||||
|
|
|
@ -19,10 +19,11 @@ HELP: <shader-instance>
|
|||
|
||||
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" }
|
||||
|
@ -66,14 +67,21 @@ HELP: attribute-index
|
|||
}
|
||||
{ $description "Returns the numeric index of the vertex attribute named " { $snippet "attribute-name" } " in " { $snippet "program-instance" } "." } ;
|
||||
|
||||
HELP: <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 }
|
||||
{ "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 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*> } "." } ;
|
||||
|
||||
{ vertex-array <multi-vertex-array> <vertex-array*> } related-words
|
||||
HELP: <vertex-array*>
|
||||
{ $values
|
||||
{ "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 } " 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> <vertex-array*> } related-words
|
||||
|
||||
HELP: compile-shader-error
|
||||
{ $class-description "An error compiling the source for a " { $link shader } "."
|
||||
|
|
|
@ -326,19 +326,28 @@ TUPLE: vertex-array < gpu-object
|
|||
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
|
||||
: ?>buffer-ptr ( buffer/ptr -- buffer-ptr )
|
||||
dup buffer-ptr? [ 0 <buffer-ptr> ] unless ; inline
|
||||
: ?>buffer ( buffer/ptr -- buffer )
|
||||
dup buffer? [ buffer>> ] unless ; 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
|
||||
:: <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 ;
|
||||
|
@ -424,7 +433,7 @@ TUPLE: feedback-format
|
|||
|
||||
: 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>
|
||||
|
|
|
@ -62,4 +62,4 @@ CONSTANT: window-vertexes
|
|||
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
|
||||
|
|
|
@ -130,7 +130,7 @@ TUPLE: vbo
|
|||
[
|
||||
[
|
||||
[ vertex-buffer>> obj-program <program-instance> ]
|
||||
[ vertex-format>> ] bi buffer>vertex-array
|
||||
[ vertex-format>> ] bi <vertex-array*>
|
||||
] map >>vertex-arrays drop
|
||||
]
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue