Changeset 30955 in project


Ignore:
Timestamp:
06/04/14 01:58:45 (6 years ago)
Author:
acharlton
Message:

Update to version 0.5.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/opengl-glew

    r30953 r30955  
    9292Prints the given {{MATRIX}} to {{(current-output-port)}}.
    9393
    94 <procedure> (m* A B #!optional RESULT)</procedure>
    95 
    96 Multiply matrix {{A}} by matrix {{B}}. If the matrix {{RESULT}} is given, it will be modified to contain the results of the multiplication. If {{RESULT}} is not provided, {{A}} and {{B}} must be f32vectors and the returned value will be an f32vector.
    97 
    98 <procedure> (mat4-identity #!optional RESULT)</procedure>
    99 
    100 Return an identity matrix. If {{RESULT}} is not provided, the returned value will be an f32vector.
     94<procedure> (m* A B [RESULT])</procedure>
     95
     96Multiply matrix {{A}} by matrix {{B}}. If the matrix {{RESULT}} is given, it will be modified to contain the results of the multiplication. If {{RESULT}} is {{#t}}, {{A}} and {{B}} must be f32vectors and the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, {{A}} and {{B}} must be f32vectors and the returned value will be an f32vector located in normal garbage collected memory.
     97
     98<procedure> (mat4-identity [RESULT])</procedure>
     99
     100Return an identity matrix. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
    101101
    102102<procedure> (translate X Y Z MATRIX)</procedure>
     
    144144Flip (mirror) {{MATRIX}} along the z-axis.
    145145
    146 <procedure> (translate-scale X Y Z SCALE #!optional RESULT)</procedure>
    147 
    148 Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}} then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    149 
    150 <procedure> (translate-rotate-scale-2d X Y Z ANGLE SCALE #!optional RESULT)</procedure>
    151 
    152 Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated around the z-axis by {{ANGLE}} radians, then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    153 
    154 <procedure> (translate-rotate-scale X Y Z RX RY RZ ANGLE SCALE #!optional RESULT)</procedure>
    155 
    156 Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated {{ANGLE}} radians around the axis defined by {{(RX, RY, RZ)}}, then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    157 
    158 <procedure> (transpose MATRIX #!optional RESULT)</procedure>
    159 
    160 Transpose {{MATRIX}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    161 
    162 <procedure> (inverse MATRIX #!optional RESULT)</procedure>
    163 
    164 Invert {{MATRIX}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    165 
    166 <procedure> (ortho WIDTH HEIGHT NEAR FAR #!optional RESULT)</procedure>
    167 
    168 Create an orthographic projection matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    169 
    170 <procedure> (perspective WIDTH HEIGHT NEAR FAR ANGLE #!optional RESULT)</procedure>
    171 
    172 Create an perspective projection matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    173 
    174 <procedure> (frustum LEFT RIGHT BOTTOM TOP NEAR FAR #!optional RESULT)</procedure>
    175 
    176 Create a view-frustum matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    177 
    178 <procedure> (look-at EYE-X EYE-Y EYE-Z X Y Z UP-X UP-Y UP-Z #!optional RESULT)</procedure>
    179 
    180 Create a “look-at” style camera matrix. The camera is positioned at {{(EYE-X, EYE-Y, EYE-Z)}}, pointing towards {{(X, Y, Z)}}. {{(UP-X, UP-Y, UP-Z)}} defines the camera’s up vector. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
    181 
    182 <procedure> (camera-inverse CAMERA #!optional RESULT)</procedure>
    183 
    184 Invert {{CAMERA}} in an efficient fashion. This allows the camera to be constructed in an intuitive fashion by translating and rotating before inverting in order to position the scene properly. This function is far faster than the general {{inverse}} function, but the matrix {{CAMERA}} must only be a matrix representing a translation and a rotation (no scaling). If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is not provided, the returned value will be an f32vector.
     146<procedure> (translate-scale X Y Z SCALE [RESULT])</procedure>
     147
     148Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}} then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     149
     150<procedure> (translate-rotate-scale-2d X Y Z ANGLE SCALE [RESULT])</procedure>
     151
     152Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated around the z-axis by {{ANGLE}} radians, then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     153
     154<procedure> (translate-rotate-scale X Y Z RX RY RZ ANGLE SCALE [RESULT])</procedure>
     155
     156Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated {{ANGLE}} radians around the axis defined by {{(RX, RY, RZ)}}, then scaled by {{SCALE}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     157
     158<procedure> (transpose MATRIX [RESULT])</procedure>
     159
     160Transpose {{MATRIX}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, {{MATRIX}} must be an f32vector and the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, {{MATRIX}} must be an f32vector and the returned value will be an f32vector located in normal garbage collected memory.
     161
     162<procedure> (inverse MATRIX [RESULT])</procedure>
     163
     164Invert {{MATRIX}}. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, {{MATRIX}} must be an f32vector and the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, {{MATRIX}} must be an f32vector and the returned value will be an f32vector located in normal garbage collected memory.
     165
     166<procedure> (ortho WIDTH HEIGHT NEAR FAR [RESULT])</procedure>
     167
     168Create an orthographic projection matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     169
     170<procedure> (perspective WIDTH HEIGHT NEAR FAR ANGLE [RESULT])</procedure>
     171
     172Create an perspective projection matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     173
     174<procedure> (frustum LEFT RIGHT BOTTOM TOP NEAR FAR [RESULT])</procedure>
     175
     176Create a view-frustum matrix. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     177
     178<procedure> (look-at EYE-X EYE-Y EYE-Z X Y Z UP-X UP-Y UP-Z [RESULT])</procedure>
     179
     180Create a “look-at” style camera matrix. The camera is positioned at {{(EYE-X, EYE-Y, EYE-Z)}}, pointing towards {{(X, Y, Z)}}. {{(UP-X, UP-Y, UP-Z)}} defines the camera’s up vector. If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, the returned value will be an f32vector located in normal garbage collected memory.
     181
     182<procedure> (camera-inverse CAMERA [RESULT])</procedure>
     183
     184Invert {{CAMERA}} in an efficient fashion. This allows the camera to be constructed in an intuitive fashion by translating and rotating before inverting in order to position the scene properly. This function is far faster than the general {{inverse}} function, but the matrix {{CAMERA}} must only be a matrix representing a translation and a rotation (no scaling). If the matrix {{RESULT}} is given, it will be modified to contain the result. If {{RESULT}} is {{#t}}, {{CAMERA}} must be an f32vector and the returned value will be an f32vector located in non-garbage collected memory (the memory will still be freed when there are no more references to the matrix). If {{RESULT}} is not provided, {{CAMERA}} must be an f32vector and the returned value will be an f32vector located in normal garbage collected memory.
    185185
    186186<procedure> (cross-product AX AY AZ BX BY BZ)</procedure>
     
    208208gl-utils provides functions for creating VAOs, and loading PLY files.
    209209
    210 <procedure> (make-vao VERTEX-DATA INDEX-DATA ATTRIBUTES #!optional USAGE)</procedure>
    211 
    212 {{make-vao}} generalizes the typically repetitious code used to initialize vertex attribute objects. It deals with the case of having packed vertex data ({{VERTEX-DATA}}) and a vector of indices ({{INDEX-DATA}}) for those vertexes.
    213 
    214 {{ATTRIBUTES}} is the list of data necessary for the vertex attributes, in the form of {{((LOCATION TYPE N [normalize?: NORMALIZE?]) ...)}}. {{LOCATION}} is the attribute location, {{TYPE}} is the type of data corresponding to the given attribute, given as a keyword. For possible types, see {{type->gl-type}}. {{N}} is the number of elements for the givien attribute. The keyword {{normalize?:}} accepts a boolean argument which instructs OpenGL to normalize the attribute or not. Defaults to {{#f}}.
     210<procedure> (make-vao VERTEX-DATA INDEX-DATA ATTRIBUTES [USAGE])</procedure>
     211
     212{{make-vao}} generalizes the typically repetitious code used to initialize vertex attribute objects. It deals with the case of having packed vertex data ({{VERTEX-DATA}}) and a vector of indices ({{INDEX-DATA}}) for those vertexes. This data may be passed as any sort of (srfi-4) vector or a blob.
     213
     214{{ATTRIBUTES}} is the list of data necessary for the vertex attributes, in the form of {{((LOCATION TYPE N [normalize?: NORMALIZE?]) ...)}}. {{LOCATION}} is the attribute location, {{TYPE}} is the type of data corresponding to the given attribute, given as a keyword. For possible types, see {{type->gl-type}}. {{N}} is the number of elements for the given attribute. The keyword {{normalize?:}} accepts a boolean argument which instructs OpenGL to normalize the attribute or not. Defaults to {{#f}}.
    215215
    216216The optional {{USAGE}} must be one of {{+stream-data+}}, {{+stream-read+}}, {{stream-copy}}, {{+static-data+}}, {{+static-read+}}, {{static-copy}}, {{+dynamic-data+}}, {{+dynamic-read+}}, {{dynamic-copy}}. Defaults to {{+static-draw+}}.
     
    220220<procedure> (load-ply FILE BUFFER-SPEC)</procedure>
    221221
    222 Loads a [[http://paulbourke.net/dataformats/ply/|PLY]] file. {{FILE}} is a path that may be pointing to a gziped PLY file. {{BUFFER-SPEC}} is a list in the form {{((NAME VARS) ...)}} where {{NAME}} is the name of an element in the PLY file and {{VARS}} is either a list of property names or, in the case of a property list, a single name. Two values are returned: a list of blobs which correspond to the buffers named in {{BUFFER-SPEC}} and a list of the elements that are in the PLY file in the form of:
     222Loads a [[http://paulbourke.net/dataformats/ply/|PLY]] file. {{FILE}} is a path that may be pointing to a gziped PLY file. {{BUFFER-SPEC}} is a list in the form {{((NAME VARS) ...)}} where {{NAME}} is the name of an element in the PLY file and {{VARS}} is either a list of property names or, in the case of a property list, a single name. Two values are returned: a list of u8vectors which correspond to the buffers named in {{BUFFER-SPEC}} and a list of the elements that are in the PLY file in the form of:
    223223
    224224    (element-name n-elements (property-name property-type))
     
    232232    (load-ply "example.ply.gz" '((vertex: (x y z r g b)) (face: vertex_index)))
    233233
    234 This buffer spec would result in a list of two blobs being returned: one with the packed elements corresponding to properties {{x}}, {{y}}, {{z}}, {{r}}, {{g}}, and {{b}} (with the corresponding property types), and the second containing the vertex indices.
    235 
    236 <procedure> (load-ply-vao FILE #!key VERTEX FACE)</procedure>
     234This buffer spec would result in a list of two u8vectors being returned: one with the packed elements corresponding to properties {{x}}, {{y}}, {{z}}, {{r}}, {{g}}, and {{b}} (with the corresponding property types), and the second containing the vertex indices.
     235
     236<procedure> (load-ply-vao FILE vertex: VERTEX face: FACE)</procedure>
    237237
    238238Similar to {{load-ply}}, but returns a number of values:
    239239
    240240* A vertex array ID as generated by {{make-vao}}.
    241 * A blob representing the vertex data of the model
    242 * A blob representing the index data of the model
     241* A u8vector representing the vertex data of the model
     242* A u8vector representing the index data of the model
    243243* The number of vertices of the model
    244244* The GL enum value of the type of primitive used for the model (e.g. {{+triangles+}})
     
    265265* {{float:}} {{float32:}}
    266266* {{double:}} {{float64:}}
     267
     268
     269===== Vectors (srfi-4)
     270gl-utils reexports a version of [[http://api.call-cc.org/doc/srfi-4|srfi-4]] that gives preference to vectors being created in non-garbage collected memory. This is useful for use with OpenGL, since it is often desirable to pass vectors to OpenGL that will remain in one place. All srfi-4 functions not mentioned below are reexported without changes.
     271
     272The {{NNNvector}} and {{list->NNNvector}} constructors have been modified so that they return vectors in non-garbage collected memory.
     273
     274The {{make-NNNvector}} constructors act as their srfi-4 counterparts, except they now return vectors in non-garbage collected memory by default.
    267275
    268276
     
    344352  (program (gl:make-program (list *vertex* *fragment*)))
    345353
    346   (vao (make-vao (f32vector->blob vertex-data) (u16vector->blob index-data)
     354  (vao (make-vao vertex-data index-data
    347355                 `((,(gl:get-attrib-location (program) "vertex") float: 2)
    348356                   (,(gl:get-attrib-location (program) "color") float: 3))))
     
    359367=== Version history
    360368
     369==== Version 0.5.0
     3703 June 2014
     371
     372* {{make-vao}} accepts vectors and blobs
     373* {{load-ply}} returns u8vectors rather than blobs
     374* gl-utils exports a non-garbage collected by default version of srfi-4
     375* gl-math can create non-garbage collected matrices
     376
     377
    361378==== Version 0.4.4
    3623792 June 2014
     
    416433=== Licence
    417434BSD
     435
Note: See TracChangeset for help on using the changeset viewer.