Changeset 30955 in project
 Timestamp:
 06/04/14 01:58:45 (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/openglglew
r30953 r30955 92 92 Prints the given {{MATRIX}} to {{(currentoutputport)}}. 93 93 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> (mat4identity #!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 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 {{#t}}, {{A}} and {{B}} must be f32vectors and the returned value will be an f32vector located in nongarbage 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> (mat4identity [RESULT])</procedure> 99 100 Return an identity matrix. If {{RESULT}} is {{#t}}, the returned value will be an f32vector located in nongarbage 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. 101 101 102 102 <procedure> (translate X Y Z MATRIX)</procedure> … … 144 144 Flip (mirror) {{MATRIX}} along the zaxis. 145 145 146 <procedure> (translatescale 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> (translaterotatescale2d X Y Z ANGLE SCALE #!optional RESULT)</procedure>151 152 Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated around the zaxis 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> (translaterotatescale 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 viewfrustum 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> (lookat EYEX EYEY EYEZ X Y Z UPX UPY UPZ #!optional RESULT)</procedure>179 180 Create a âlookatâ style camera matrix. The camera is positioned at {{(EYEX, EYEY, EYEZ)}}, pointing towards {{(X, Y, Z)}}. {{(UPX, UPY, UPZ)}} 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> (camerainverse 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> (translatescale X Y Z SCALE [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 {{#t}}, the returned value will be an f32vector located in nongarbage 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> (translaterotatescale2d X Y Z ANGLE SCALE [RESULT])</procedure> 151 152 Efficiently create a matrix translated by {{X}}, {{Y}}, and {{Z}}, rotated around the zaxis 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 nongarbage 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> (translaterotatescale X Y Z RX RY RZ ANGLE SCALE [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 {{#t}}, the returned value will be an f32vector located in nongarbage 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 160 Transpose {{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 nongarbage 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 164 Invert {{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 nongarbage 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 168 Create 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 nongarbage 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 172 Create 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 nongarbage 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 176 Create a viewfrustum 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 nongarbage 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> (lookat EYEX EYEY EYEZ X Y Z UPX UPY UPZ [RESULT])</procedure> 179 180 Create a âlookatâ style camera matrix. The camera is positioned at {{(EYEX, EYEY, EYEZ)}}, pointing towards {{(X, Y, Z)}}. {{(UPX, UPY, UPZ)}} 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 nongarbage 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> (camerainverse CAMERA [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 {{#t}}, {{CAMERA}} must be an f32vector and the returned value will be an f32vector located in nongarbage 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. 185 185 186 186 <procedure> (crossproduct AX AY AZ BX BY BZ)</procedure> … … 208 208 glutils provides functions for creating VAOs, and loading PLY files. 209 209 210 <procedure> (makevao VERTEXDATA INDEXDATA ATTRIBUTES #!optional USAGE)</procedure>211 212 {{makevao}} generalizes the typically repetitious code used to initialize vertex attribute objects. It deals with the case of having packed vertex data ({{VERTEXDATA}}) and a vector of indices ({{INDEXDATA}}) 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>gltype}}. {{N}} is the number of elements for the giv ien attribute. The keyword {{normalize?:}} accepts a boolean argument which instructs OpenGL to normalize the attribute or not. Defaults to {{#f}}.210 <procedure> (makevao VERTEXDATA INDEXDATA ATTRIBUTES [USAGE])</procedure> 211 212 {{makevao}} generalizes the typically repetitious code used to initialize vertex attribute objects. It deals with the case of having packed vertex data ({{VERTEXDATA}}) and a vector of indices ({{INDEXDATA}}) for those vertexes. This data may be passed as any sort of (srfi4) 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>gltype}}. {{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}}. 215 215 216 216 The optional {{USAGE}} must be one of {{+streamdata+}}, {{+streamread+}}, {{streamcopy}}, {{+staticdata+}}, {{+staticread+}}, {{staticcopy}}, {{+dynamicdata+}}, {{+dynamicread+}}, {{dynamiccopy}}. Defaults to {{+staticdraw+}}. … … 220 220 <procedure> (loadply FILE BUFFERSPEC)</procedure> 221 221 222 Loads a [[http://paulbourke.net/dataformats/ply/PLY]] file. {{FILE}} is a path that may be pointing to a gziped PLY file. {{BUFFERSPEC}} 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 {{BUFFERSPEC}} and a list of the elements that are in the PLY file in the form of:222 Loads a [[http://paulbourke.net/dataformats/ply/PLY]] file. {{FILE}} is a path that may be pointing to a gziped PLY file. {{BUFFERSPEC}} 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 {{BUFFERSPEC}} and a list of the elements that are in the PLY file in the form of: 223 223 224 224 (elementname nelements (propertyname propertytype)) … … 232 232 (loadply "example.ply.gz" '((vertex: (x y z r g b)) (face: vertex_index))) 233 233 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> (loadplyvao FILE #!key VERTEXFACE)</procedure>234 This 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> (loadplyvao FILE vertex: VERTEX face: FACE)</procedure> 237 237 238 238 Similar to {{loadply}}, but returns a number of values: 239 239 240 240 * A vertex array ID as generated by {{makevao}}. 241 * A blobrepresenting the vertex data of the model242 * A blobrepresenting the index data of the model241 * A u8vector representing the vertex data of the model 242 * A u8vector representing the index data of the model 243 243 * The number of vertices of the model 244 244 * The GL enum value of the type of primitive used for the model (e.g. {{+triangles+}}) … … 265 265 * {{float:}} {{float32:}} 266 266 * {{double:}} {{float64:}} 267 268 269 ===== Vectors (srfi4) 270 glutils reexports a version of [[http://api.callcc.org/doc/srfi4srfi4]] that gives preference to vectors being created in nongarbage 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 srfi4 functions not mentioned below are reexported without changes. 271 272 The {{NNNvector}} and {{list>NNNvector}} constructors have been modified so that they return vectors in nongarbage collected memory. 273 274 The {{makeNNNvector}} constructors act as their srfi4 counterparts, except they now return vectors in nongarbage collected memory by default. 267 275 268 276 … … 344 352 (program (gl:makeprogram (list *vertex* *fragment*))) 345 353 346 (vao (makevao (f32vector>blob vertexdata) (u16vector>blob indexdata)354 (vao (makevao vertexdata indexdata 347 355 `((,(gl:getattriblocation (program) "vertex") float: 2) 348 356 (,(gl:getattriblocation (program) "color") float: 3)))) … … 359 367 === Version history 360 368 369 ==== Version 0.5.0 370 3 June 2014 371 372 * {{makevao}} accepts vectors and blobs 373 * {{loadply}} returns u8vectors rather than blobs 374 * glutils exports a nongarbage collected by default version of srfi4 375 * glmath can create nongarbage collected matrices 376 377 361 378 ==== Version 0.4.4 362 379 2 June 2014 … … 416 433 === Licence 417 434 BSD 435
Note: See TracChangeset
for help on using the changeset viewer.