Original Post
Hello everybody iam completely new here and of course very happy to discover and learn with these superb Nehe's tutorials.
Iam programming in Scheme so its a bit different from C-style programs. By chance 6 tutorials got sources in Scheme thanks for that guys...
I tried to adapt the tutorial 6 to my style and only took the (load-gl-texture) from the source code of Brian.
I got a little problem with my (on-paint) function, i was trying to apply a texture to a cube so i call the (load-gl-texture) and after that i call the glBindTexture to select one but i cant make rotate my cube ... there is the code :
code][ /code] tags to preserve indentation.
[edited by - SiCrane on May 15, 2004 8:42:56 PM]
(define cube #f)
...
(define/override (on-size width height)
(with-gl-context
(lambda ()
(gl-viewport 0 0 width height)
(gl-matrix-mode 'projection)
(gl-load-identity)
(let ((h (/ height width)))
(gl-frustum -1.0 1.0 (- h) h 6.0 60.0))
(gl-matrix-mode 'modelview)
(gl-load-identity)
(gl-translate 0.0 0.0 -40.0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(glEnable GL_TEXTURE_2D)
(glShadeModel GL_SMOOTH)
"(gl-enable 'cull-face)"
"(gl-enable 'lighting)"
"(gl-enable 'light0)"
(gl-enable 'depth-test)
(glDepthFunc GL_LEQUAL)
(glHint GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST)
(set! cube (gl-gen-lists 1))
(gl-new-list cube 'compile)
(build-cube1) ; function builds a cube ...
(gl-end-list)
))
(refresh))
(define/override (on-paint) ; <=> DrawGLScene
(if (= rotation 360.0) ;TODO not incr infinitely
(set! rotation 0.0)
(set! rotation (+ 1.0 rotation)))
(with-gl-context
(lambda ()
(gl-load-texture) ; BIG PROBLEM HERE
(glClearColor 0.0 0.0 0.0 0.0)
(gl-clear 'color-buffer-bit 'depth-buffer-bit)
(glBindTexture GL_TEXTURE_2D (gl-uint-vector-ref *texture* 0))
(gl-push-matrix) ; on
(gl-rotate rotation 0.0 5.0 1.0)
(gl-call-list cube)
(gl-pop-matrix)
(swap-gl-buffers)
(glFlush)
)
)
(refresh)) ;<======== ?????
I know that doing the last refresh is paradoxal but its the only way to make my cube rotate ...
edit: Use the [