gpu.render: factor out and make public a "bind-uniforms" word for binding a uniform-tuple to a program-instance independent of a render-set

db4
Joe Groff 2009-10-18 18:31:38 -05:00
parent 2a156795c5
commit 08768d0e2f
2 changed files with 16 additions and 8 deletions

View File

@ -226,6 +226,11 @@ HELP: render-set
} }
{ $notes "User-created framebuffers require OpenGL 3.0 or one of the " { $snippet "GL_EXT_framebuffer_object" } " or " { $snippet "GL_ARB_framebuffer_object" } " extensions. Disabling rasterization requires OpenGL 3.0 or the " { $snippet "GL_EXT_transform_feedback" } " extension. Named output-attachment values are available in GLSL 1.30 or later, and GLSL 1.20 and earlier using the " { $snippet "GL_EXT_gpu_shader4" } " extension. Transform feedback requires OpenGL 3.0 or one of the " { $snippet "GL_EXT_transform_feedback" } " or " { $snippet "GL_ARB_transform_feedback" } " extensions." } ;
HELP: bind-uniforms
{ $values { "program-instance" program-instance } { "uniforms" uniform-tuple } }
{ $description "Binds the uniform shader parameters for " { $snippet "program-instance" } " using values from the given uniform tuple." }
{ $notes "The " { $link render } " word uses this word. Calling this word directly is only necessary if uniform parameters need to be bound independently of a " { $snippet "render" } " operation." } ;
{ render render-set } related-words
HELP: texture-uniform

View File

@ -168,12 +168,12 @@ M: multi-index-elements render-vertex-indexes
: (bind-texture-unit) ( texture texture-unit -- )
swap [ GL_TEXTURE0 + glActiveTexture ] [ bind-texture drop ] bi* ; inline
GENERIC: bind-uniform-textures ( program-instance uniform-tuple -- )
GENERIC: bind-uniforms ( program-instance uniform-tuple -- )
GENERIC: (bind-uniform-textures) ( program-instance uniform-tuple -- )
GENERIC: (bind-uniforms) ( program-instance uniform-tuple -- )
M: uniform-tuple bind-uniform-textures
M: uniform-tuple (bind-uniform-textures)
2drop ;
M: uniform-tuple bind-uniforms
M: uniform-tuple (bind-uniforms)
2drop ;
: uniform-slot-type ( uniform -- type )
@ -363,7 +363,7 @@ DEFER: [bind-uniform-tuple]
:: [bind-uniforms] ( superclass uniforms -- quot )
superclass "uniform-tuple-texture-units" word-prop 0 or :> first-texture-unit
superclass \ bind-uniforms method :> next-method
superclass \ (bind-uniforms) method :> next-method
first-texture-unit uniforms "" [bind-uniform-tuple] nip :> bind-quot
{ 2dup next-method } bind-quot [ ] append-as ;
@ -371,10 +371,10 @@ DEFER: [bind-uniform-tuple]
: define-uniform-tuple-methods ( class superclass uniforms -- )
[
2drop
[ \ bind-uniform-textures create-method-in ]
[ \ (bind-uniform-textures) create-method-in ]
[ [bind-uniform-textures] ] bi define
] [
[ \ bind-uniforms create-method-in ] 2dip
[ \ (bind-uniforms) create-method-in ] 2dip
[bind-uniforms] define
] 3bi ;
@ -481,12 +481,15 @@ TUPLE: render-set
: 3<render-set> ( x y z quot-assoc -- render-set )
render-set swap 3make-tuple ; inline
: bind-uniforms ( program-instance uniforms -- )
[ (bind-uniform-textures) ] [ (bind-uniforms) ] 2bi ; inline
: render ( render-set -- )
{
[ vertex-array>> program-instance>> handle>> glUseProgram ]
[
[ vertex-array>> program-instance>> ] [ uniforms>> ] bi
[ bind-uniform-textures ] [ bind-uniforms ] 2bi
bind-uniforms
]
[
framebuffer>>