[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] What should (POINTER VOID) be in opengl?
From: |
Matthew Welland |
Subject: |
[Chicken-users] What should (POINTER VOID) be in opengl? |
Date: |
Mon, 19 Jun 2006 21:54:09 -0700 |
User-agent: |
KMail/1.8.3 |
I'm trying to get tesselation to work and getting nowhere fast. My callbacks
are not being called and I suspect I'm off target in more than one place.
Anyhow for starters, what would I put for (POINTER VOID) in the following:
[procedure] (glu:TessBeginPolygon (POINTER GLUTESSELATOR) (POINTER VOID))
Here is the complete code I am trying to get to work, you can see I tried #f
and at least the code runs but the callbacks never get called:
###################
(use srfi-1 utils gl glu glut srfi-4)
(define leftFirst gl:TRUE)
(define *args* (argv))
;; /* Initialize alpha blending function.
;; */
(define (init)
(gl:Enable gl:BLEND)
(gl:BlendFunc gl:SRC_ALPHA gl:ONE_MINUS_SRC_ALPHA)
(gl:ShadeModel gl:FLAT)
(gl:ClearColor 0.0 0.0 0.0 0.0))
(define (drawLeftTriangle)
;; /* draw yellow triangle on LHS of screen */
(gl:Begin gl:TRIANGLES)
(gl:Color4f 1.0 1.0 0.0 0.75)
(gl:Vertex3f 0.1 0.9 0.0)
(gl:Vertex3f 0.1 0.1 0.0)
(gl:Vertex3f 0.7 0.5 0.0)
(gl:End))
(define (drawRightTriangle)
;; /* draw cyan triangle on RHS of screen */
(gl:Begin gl:TRIANGLES)
(gl:Color4f 0.0 1.0 1.0 0.75)
(gl:Vertex3f 0.9 0.9 0.0)
(gl:Vertex3f 0.3 0.5 0.0)
(gl:Vertex3f 0.9 0.1 0.0)
(gl:End))
;;
;; The simplest possible tesselation code...
;;
(define startList 1)
;; required callback routines
;;
(define (tcbBegin prim)
(printf "tcbBegin ~A\n" prim)
(gl:Begin prim))
(define (tbbVertex data)
(printf "tbbVertex ~A\n" data)
(gl:Vertex2dv data))
(define (tcbEnd)
(printf "tcbEnd\n")
(gl:End))
(define (errorCallback errorCode)
(let ((estring (glu:ErrorString errorCode)))
(printf (current-error-port) "Tessellation Error: ~A\n" estring)
(exit 0)))
;; I assume that self-intersecting primitives would usually require a more
;; complex process than merely copying the data!?
;;
(define (tcbCombine) ;; c d w)
(let ((nv (list->f64vector '(0 0 0))))
;; (f64vector-set! nv 0 (f64vector-ref c 0))
;; (f64vector-set! nv 1 (f64vector-ref c 1))
;; (f64vector-set! nv 2 (f64vector-ref c 2))
nv))
;; Create the polygon using a tesselator
;;
(define (createTessPolygon)
(gl:ClearColor 0.0 0.0 0.0 0.0)
(let ((tobj (glu:NewTess)))
(print "createTessPolygon")
(gl:NewList startList gl:COMPILE)
(glu:TessCallback tobj glu:TESS_BEGIN tcbBegin)
(glu:TessCallback tobj glu:TESS_VERTEX tbbVertex)
(glu:TessCallback tobj glu:TESS_END tcbEnd)
(glu:TessCallback tobj glu:TESS_ERROR errorCallback)
(glu:TessCallback tobj glu:TESS_COMBINE tcbCombine)
(gl:ShadeModel gl:FLAT)
(glu:TessBeginPolygon tobj #f)
(glu:TessBeginContour tobj)
(glu:TessVertex tobj (f64vector 0.9 0.9 0.0) #f)
(glu:TessVertex tobj (f64vector 0.3 0.5 0.0) #f)
(glu:TessVertex tobj (f64vector 0.9 0.1 0.0) #f)
(glu:TessEndContour tobj)
(glu:TessEndPolygon tobj)
(gl:EndList)))
(define (drawTessPolygon)
(print "drawTessPolygon")
(gl:Clear gl:COLOR_BUFFER_BIT)
(gl:Color4f 1.0 1.0 1.0 0.75)
(gl:PushMatrix)
(gl:CallList startList)
(gl:PopMatrix)
(gl:Flush))
;;
;; end tesselation code (except for the call below in display)
;;
(define (display)
(gl:Clear gl:COLOR_BUFFER_BIT)
(if leftFirst
(begin
(drawTessPolygon)
(gl:CallList 1))
(begin
(drawRightTriangle)
(drawLeftTriangle)))
(gl:Flush))
(define (reshape w h)
(gl:Viewport 0 0 w h)
(gl:MatrixMode gl:PROJECTION)
(gl:LoadIdentity)
(if (<= w h)
(glu:Ortho2D 0.0 1.0 0.0 (* 1.0 (/ h w)))
(glu:Ortho2D 0.0 (* 1.0 (/ w h)) 0.0 1.0)))
;; /* ARGSUSED1 */
(define (keyboard key x y)
(case key
((#\t #\T)
(set! leftFirst (not leftFirst))
(glut:PostRedisplay))
((#\q) ;; /* Escape key */ ** Changed to "q"
(exit 0))))
;; * Open window with initial window size, title bar,
;; * RGBA display mode, and handle input events.
(print "Use t to toggle drawing order of polygons and q to exit")
(glut:InitDisplayMode (+ glut:SINGLE glut:RGB))
(glut:InitWindowSize 200 200)
(glut:CreateWindow (list-ref *args* 0))
(init)
(createTessPolygon)
(glut:ReshapeFunc reshape)
(glut:KeyboardFunc keyboard)
(glut:DisplayFunc display)
(glut:MainLoop)
--
- [Chicken-users] What should (POINTER VOID) be in opengl?,
Matthew Welland <=