opengl.shaders: docs + removing an unused word
parent
5709e0b621
commit
713543644d
|
@ -1,7 +1,27 @@
|
|||
USING: help.markup help.syntax io kernel math quotations
|
||||
opengl.gl multiline assocs strings ;
|
||||
USING: help.markup help.syntax kernel quotations sequences strings ;
|
||||
IN: opengl.shaders
|
||||
|
||||
HELP: (gl-program)
|
||||
{ $values
|
||||
{ "shaders" sequence }
|
||||
{ "quot" quotation }
|
||||
} { $description
|
||||
"Creates a gl program and attaches the shaders to it. Then applies the quotation to the program and finally links it."
|
||||
}
|
||||
{ $errors "Throws a gl error if linking the program fails." } ;
|
||||
|
||||
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" } } { "shader" "a new " { $link gl-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" } { "vertex-shader" "a new " { $link vertex-shader } } }
|
||||
{ $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" } { "fragment-shader" "a new " { $link fragment-shader } } }
|
||||
{ $description "Tries to compile the given GLSL source into a fragment shader object. Equivalent to " { $snippet "GL_FRAGMENT_SHADER <gl-shader>" } "." } ;
|
||||
|
||||
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
|
||||
|
@ -27,18 +47,6 @@ HELP: fragment-shader
|
|||
}
|
||||
} ;
|
||||
|
||||
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" } } { "shader" "a new " { $link gl-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" } { "vertex-shader" "a new " { $link vertex-shader } } }
|
||||
{ $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" } { "fragment-shader" "a new " { $link fragment-shader } } }
|
||||
{ $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" } { "?" boolean } }
|
||||
{ $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 } "." } ;
|
||||
|
|
|
@ -62,16 +62,15 @@ PREDICATE: fragment-shader < gl-shader (fragment-shader?) ;
|
|||
|
||||
! Programs
|
||||
|
||||
: attach-shaders ( program shaders -- )
|
||||
[ glAttachShader ] with each ;
|
||||
|
||||
: (gl-program) ( shaders quot: ( gl-program -- ) -- program )
|
||||
glCreateProgram
|
||||
[
|
||||
[ swap [ glAttachShader ] with each ]
|
||||
[ swap call ] bi-curry bi*
|
||||
rot dupd attach-shaders swap call
|
||||
] [ glLinkProgram ] [ ] tri gl-error ; inline
|
||||
|
||||
: <mrt-gl-program> ( shaders frag-data-locations -- program )
|
||||
[ [ first2 swap glBindFragDataLocation ] with each ] curry (gl-program) ;
|
||||
|
||||
: <gl-program> ( shaders -- program )
|
||||
[ drop ] (gl-program) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue