Changeset 37378 in project


Ignore:
Timestamp:
03/15/19 13:09:56 (2 months ago)
Author:
kooda
Message:

Document gl-utils for CHICKEN 5

File:
1 copied

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/gl-utils

    r37369 r37378  
    88* gl-utils-mesh: Convenient vertex array interface for creation, modification, and use
    99* gl-utils-ply: [[http://paulbourke.net/dataformats/ply/|PLY]] file loading
    10 * gl-utils-srfi-4: OpenGL-safe numeric vectors
    11 
    12 gl-utils is known to work on Linux, Mac OS X, Windows, and with OpenGL ES. gl-utils will automatically compile with ES support on ARM hardware, or when {{gles}} is defined during compilation (e.g. {{chicken-install -D gles}}).
     10
     11gl-utils is known to work on Linux, Mac OS X, Windows, and with OpenGL ES.
    1312
    1413
    1514=== Requirements
     15* srfi-1
    1616* z3
    1717* matchable
    1818* miscmacros
    1919* srfi-42
    20 * opengl-glew
     20* srfi-99
     21* epoxy
    2122* gl-math
    22 * make
    2323
    2424
     
    316316
    317317
    318 ==== gl-utils-srfi-4
    319 '''This module has been deprecated. With gl-utils-mesh and gl-utils-bytevector, this functionality is better served by directly using srfi-4. This module may still be accessed by explicitly using gl-utils-srfi-4 for the time-being, but it will be removed in the future.'''
    320 
    321 gl-utils-srfi-4 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.
    322 
    323 The {{NNNvector}} and {{list->NNNvector}} constructors have been modified so that they return vectors in non-garbage collected memory. They will still be freed when no longer used.
    324 
    325 The {{make-NNNvector}} constructors act as their srfi-4 counterparts, except they return vectors in non-garbage collected memory by default. They will still be freed when non longer used.
    326 
    327 
    328318=== Examples
    329319This example depends on the [[http://wiki.call-cc.org/eggref/4/opengl-glew|opengl-glew]] egg, the [[http://wiki.call-cc.org/eggref/4/glfw3|glfw3]] egg for window and context creation, and the [[http://wiki.call-cc.org/eggref/4/gl-math|gl-math]] egg for matrix math.
     
    332322
    333323<enscript highlight="scheme">   
    334 (import chicken scheme)
    335 (use (prefix glfw3 glfw:) (prefix opengl-glew gl:) gl-math gl-utils)
     324;; This example illustrates drawing a basic mesh
     325
     326(import
     327  scheme
     328  (chicken base)
     329  (chicken bitwise)
     330  (prefix glfw3 #:glfw)
     331  (prefix epoxy #:gl)
     332  gl-math
     333  gl-utils)
    336334
    337335(define *vertex*
    338336#<<END
    339 #version 330
    340 in vec2 position;
    341 in vec3 color;
    342 out vec3 c;
     337#version 120
     338attribute vec2 position;
     339attribute vec3 color;
     340varying vec3 c;
    343341uniform mat4 MVP;
    344342
     
    352350(define *fragment*
    353351#<<END
    354 #version 330
    355 in vec3 c;
    356 out vec4 fragColor;
     352#version 120
     353varying vec3 c;
    357354void main(){
    358   fragColor = vec4(c, 1.0);
     355  gl_FragColor = vec4(c, 1.0);
    359356}
    360357END
     
    365362                                       (color #:unsigned-byte 3
    366363                                              normalized: #t))
    367                           initial-elements: ((position . (-1 -1
    368                                                            1 -1
    369                                                            1  1
    370                                                            -1  1))
     364                          initial-elements: ((position . (-1.0 -1.0
     365                                                           1.0 -1.0
     366                                                           1.0  1.0
     367                                                           -1.0  1.0))
    371368                                             (color . (255 0   0
    372369                                                       0   255 0
     
    396393                            (m* view-matrix model-matrix)))
    397394  (gl:bind-vertex-array (mesh-vao rect))
    398   (gl:draw-elements-base-vertex (mode->gl (mesh-mode rect))
    399                                 (mesh-n-indices rect)
    400                                 (type->gl (mesh-index-type rect))
    401                                 #f 0)
     395  (gl:draw-elements (mode->gl (mesh-mode rect))
     396                    (mesh-n-indices rect)
     397                    (type->gl (mesh-index-type rect))
     398                    #f)
    402399
    403400  (check-error)
    404401  (gl:bind-vertex-array 0))
    405402
    406 (glfw:with-window (640 480 "Example" resizable: #f
    407                        context-version-major: 3
    408                        context-version-minor: 3)
    409   (gl:init)
    410 
    411   (print (gl:is-supported? "GL_ARB_framebuffer_object"))
    412 
     403(glfw:key-callback
     404 (lambda (window key scancode action mods)
     405   (cond
     406    ((and (eq? key glfw:+key-escape+) (eq? action glfw:+press+))
     407     (glfw:set-window-should-close window #t)))))
     408
     409(glfw:with-window (640 480 "Example" resizable: #f)
    413410  (set! *vertex* (make-shader gl:+vertex-shader+ *vertex*))
    414411  (set! *fragment* (make-shader gl:+fragment-shader+ *fragment*))
    415412  (program (make-program (list *vertex* *fragment*)))
    416 
    417413  (mesh-make-vao! rect `((position . ,(gl:get-attrib-location
    418414                                       (program) "position"))
     
    423419    (gl:clear (bitwise-ior gl:+color-buffer-bit+ gl:+depth-buffer-bit+))
    424420    (render)
    425     (glfw:poll-events) ; Because of the context version, initializing GLEW results in a harmless invalid enum
     421    (glfw:poll-events)
    426422    (unless (glfw:window-should-close (glfw:window))
    427423      (loop))))
     
    431427=== Version history
    432428
     429==== Version 0.8.0
     43015 March 2019
     431
     432* Maintenance given to [[/users/kooda|Kooda]]
     433* Port to CHICKEN 5
     434* Removed deprecated module gl-utils-srfi-4
     435
     436
    433437==== Version 0.7.0
    43443824 April 2016
     
    480484
    481485=== Source repository
    482 Source available on [[https://github.com/AlexCharlton/gl-utils|GitHub]].
    483 
    484 Bug reports and patches welcome! Bugs can be reported via GitHub or to alex.n.charlton at gmail.
    485 
    486 
    487 === Author
     486Source available [[https://www.upyum.com/cgit.cgi/gl-utils/|here]].
     487
     488Bug reports and patches welcome! Bugs can be reported to kooda@upyum.com
     489
     490
     491=== Authors
    488492Alex Charlton
     493
     494Adrien (Kooda) Ramos
    489495
    490496
    491497=== License
    492498BSD
     499
Note: See TracChangeset for help on using the changeset viewer.