I found 'alpha.ss' a helpful example<br><br><br>Stephen<br><br><br>#lang scheme/gui<br>;; By Brendan Burns<br>;; on Jaunty install the libgl1-mesa-dev package or make the symbolic links yourself<br>;; /usr/lib$ sudo ln -s libGL.so.1 libGL.so<br>
;; /usr/lib$ sudo ln -s libGLU.so.1 libGLU.so<br><br>;; Standard requires<br>(require<br> sgl/gl<br> "gl-frame.ss")<br><br>;; texture<br>;; This needs to be here and not in gl-init because of some weirdness in the<br>
;; threading on windows causes the window to attempt to be drawn prior to the<br>; texture being fully loaded.<br>(define *texture* (image->gl-vector (get-file "Choose image for texture" #f "../../icons" "sk" "jpg" null '(("Image" "*.jpg")))))<br>
<br>;; Init function<br>(define (my-gl-init)<br> (let ((res *texture*))<br> ;; Same texture, three smoothing styles...<br> (init-textures 3)<br> (unless (gl-load-texture (list-ref res 2) (list-ref res 0) (list-ref res 1)<br>
GL_NEAREST GL_NEAREST 0)<br> (error "Couldn't load texture"))<br> (unless (gl-load-texture (list-ref res 2) (list-ref res 0) (list-ref res 1)<br> GL_LINEAR GL_LINEAR 1)<br>
(error "Couldn't load texture"))<br> (unless (gl-load-texture (list-ref res 2) (list-ref res 0) (list-ref res 1)<br> GL_LINEAR GL_LINEAR_MIPMAP_NEAREST 2)<br> (error "Couldn't load texture"))<br>
<br> ;; Set-up alpha blending 50% transparency<br> (glColor4d 1 1 1 0.5)<br> (glBlendFunc GL_SRC_ALPHA GL_ONE)<br> (glEnable GL_BLEND)<br> <br> ;; Standard Init<br> (glEnable GL_TEXTURE_2D)<br> (glShadeModel GL_SMOOTH)<br>
(glClearColor 0.0 0.0 0.0 0.5)<br> (glClearDepth 1)<br> (glEnable GL_DEPTH_TEST)<br> (glDepthFunc GL_LEQUAL)<br> (glHint GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST)<br> <br> ;; default light<br> (glEnable GL_LIGHT0)<br>
(glEnable GL_LIGHTING)))<br><br>;; Our user interaction variables<br>(define *xrot* 0)<br>(define *yrot* 0)<br>(define *zrot* 0)<br>(define *z* -5)<br>(define *blend* #f)<br>(define *tex* 0)<br><br>;; Our main function that does the drawing<br>
(define (my-gl-draw)<br> ;; erase the background<br> (glClear (+ GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT))<br> ;; turn blending on/off<br> (if *blend* (glEnable GL_BLEND) (glDisable GL_BLEND))<br> <br> ;; draw cube.<br>
(glLoadIdentity)<br> (glTranslated 0 0 *z*)<br> (glRotated *xrot* 1 0 0) <br> (glRotated *yrot* 0 1 0)<br> (glRotated *zrot* 0 0 1)<br> (glBindTexture GL_TEXTURE_2D (get-texture *tex*))<br> (glBegin GL_QUADS)<br>
; front<br> (glNormal3d 0 0 1)<br> (glTexCoord2i 0 0) <br> (glVertex3i -1 -1 1)<br> (glTexCoord2i 1 0)<br> (glVertex3i 1 -1 1)<br> (glTexCoord2i 1 1)<br> (glVertex3i 1 1 1)<br> (glTexCoord2i 0 1)<br> (glVertex3i -1 1 1)<br>
; back<br> (glNormal3d 0 0 -1)<br> (glTexCoord2i 1 0) <br> (glVertex3i -1 -1 -1)<br> (glTexCoord2i 1 1)<br> (glVertex3i 1 -1 -1)<br> (glTexCoord2i 0 1)<br> (glVertex3i 1 1 -1)<br> (glTexCoord2i 0 0)<br> (glVertex3i -1 1 -1)<br>
; top<br> (glNormal3d 0 1 0)<br> (glTexCoord2i 0 1) <br> (glVertex3i -1 1 -1)<br> (glTexCoord2i 0 0)<br> (glVertex3i 1 1 -1)<br> (glTexCoord2i 1 0)<br> (glVertex3i 1 1 1)<br> (glTexCoord2i 1 1)<br> (glVertex3i -1 1 1)<br>
; bottom<br> (glNormal3d 0 -1 0)<br> (glTexCoord2i 1 1) <br> (glVertex3i -1 -1 -1)<br> (glTexCoord2i 0 1)<br> (glVertex3i -1 -1 1)<br> (glTexCoord2i 0 0)<br> (glVertex3i 1 -1 1)<br> (glTexCoord2i 1 0)<br> (glVertex3i 1 -1 -1)<br>
; right<br> (glNormal3d 1 0 0)<br> (glTexCoord2i 1 0) <br> (glVertex3i 1 -1 -1)<br> (glTexCoord2i 1 1)<br> (glVertex3i 1 -1 1)<br> (glTexCoord2i 0 1)<br> (glVertex3i 1 1 1)<br> (glTexCoord2i 0 0)<br> (glVertex3i 1 1 -1)<br>
;left<br> (glNormal3d -1 0 0)<br> (glTexCoord2i 0 0) <br> (glVertex3i -1 -1 -1)<br> (glTexCoord2i 1 0)<br> (glVertex3i -1 1 -1)<br> (glTexCoord2i 1 1)<br> (glVertex3i -1 1 1)<br> (glTexCoord2i 0 1)<br> (glVertex3i -1 -1 1)<br>
<br> (glEnd)<br> (set! *xrot* (+ *xrot* 0.3))<br> (set! *yrot* (+ *yrot* 0.2))<br> (set! *zrot* (+ *zrot* 0.4))<br> <br> (glFlush))<br><br>;; Move forward<br>(add-key-mapping #\i (lambda () (set! *z* (+ *z* 0.3))))<br>
;; Move backward<br>(add-key-mapping #\k (lambda () (set! *z* (- *z* 0.3))))<br>;; Turn blending on/off<br>(add-key-mapping #\b (lambda () (set! *blend* (not *blend*))))<br>;; Cycle textures<br>(add-key-mapping #\t (lambda () (set! *tex* (modulo (+ *tex* 1) 3))))<br>
<br>;; Set the init function<br>(set-gl-init-fn my-gl-init)<br>;; Set the draw function<br>(set-gl-draw-fn my-gl-draw)<br>(gl-run)<br><br><br><div class="gmail_quote">On Mon, Jan 18, 2010 at 7:50 PM, Eduardo Bellani <span dir="ltr"><<a href="mailto:ebellani@gmail.com">ebellani@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">> First, some of the GLUT functions are implemented in the sgl library.<br>
> Search for glu on the C style API page.<br>
><br>
> It seems like you're main problem is starting up a canvas and getting<br>
> a GL-context.<br>
><br>
> Attached is a short example with your code based on my gl-world package.<br>
><br>
> Jay<br>
</div>Thanks man!<br>
<br>
Now I do have a working canvas, at least.<br>
<br>
Do you have any clue as to why<br>
it does not visible draw anything? From what I'm seeing, the C and the scheme<br>
versions are somewhat equivalent, except for the resize and all the GLUT calls.<br>
<font color="#888888"><br>
<br>
--<br>
</font><div><div></div><div class="h5">Eduardo Bellani<br>
<br>
<a href="http://www.cnxs.com.br" target="_blank">www.cnxs.com.br</a><br>
<br>
More is not better (or worse) than less, just different.<br>
– The paradigm paradox.<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><br>--<br>Stephen De Gabrielle<br><a href="mailto:stephen.degabrielle@acm.org">stephen.degabrielle@acm.org</a><br>Telephone +44 (0)20 85670911<br>Mobile +44 (0)79 85189045<br>
<a href="http://www.degabrielle.name/stephen">http://www.degabrielle.name/stephen</a><br><br>