]> gitweb.factorcode.org Git - factor.git/commitdiff
opengl.shaders: docs + removing an unused word
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 31 Jan 2018 00:23:11 +0000 (01:23 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 31 Jan 2018 00:23:11 +0000 (01:23 +0100)
basis/opengl/shaders/shaders-docs.factor
basis/opengl/shaders/shaders.factor

index 87185a43b1b1f73de351f66946d4db59f4d8618d..710ca8e76d6079e9c6248a0204a665cf38922117 100644 (file)
@@ -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 } "." } ;
index 231011c521a7d57c0b15a0e92bc521013e0d3e03..4e6b0a7bb2c79fb2bc4c2c7d7897ab8cf386c61b 100644 (file)
@@ -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) ;