Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Definitions

Name: Anonymous 2010-11-16 4:30

So DrRackert let's me make definitions in the top window, but then it calls these constants, like if I do a simple

(define a 10)

If I try to re-define or set! a 15 then the interpret gets angry and says that a is a constant

How do I define something that can change values?

Name: Anonymous 2010-11-16 11:21

Well here is the exact code:

#lang racket/gui
(require (lib "gl.ss" "sgl")
         (lib "gl-vectors.ss" "sgl")
)
(define (resize w h)
  (glViewport 0 0 w h)
  #t
)
(define (draw-opengl)
  (glClearColor 0.0 0.0 0.0 0.0)
  (glClear GL_COLOR_BUFFER_BIT)
  (glColor3d 1.0 1.0 1.0)
  (glMatrixMode GL_PROJECTION)
  (glLoadIdentity)
  (glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)
  (glMatrixMode GL_MODELVIEW)
  (glLoadIdentity)
  (glBegin GL_QUADS)
  (glVertex3d 0.25 0.25 0.0)
  (glVertex3d 0.75 0.25 0.0)
  (glVertex3d 0.75 0.75 0.0)
  (glVertex3d 0.25 0.75 0.0)
  (glEnd)
)
(define my-canvas%
  (class* canvas% ()
    (inherit with-gl-context swap-gl-buffers)
   (define/override (on-paint)
      (with-gl-context
        (lambda ()
          (draw-opengl)
          (swap-gl-buffers)
        )
      )
    )
    (define/override (on-size width height)
      (with-gl-context
        (lambda ()
          (resize width height)
        )
      )
    )
    (super-instantiate () (style '(gl)))
  )
)
(define win (new frame% (label "OpenGl Test") (min-width 200) (min-height
200)))
(define gl  (new my-canvas% (parent win)))
(send win show #t)


My intention is to change 200 for the height and width to a variable, then use the interpreter to change the variable. If I define height2 and width2, it calls them constants.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List