Did I convert this OpenGL code into Lispbuilder-OpenGL right

Discussion of Common Lisp

Did I convert this OpenGL code into Lispbuilder-OpenGL right

Postby joeish80829 » Sat Oct 26, 2013 5:02 am

here is the lispbuilder version


Code: Select all
(defparameter coords (make-array '(6 4 3) :initial-contents
       '( ( ( +1 -1 -1 ) ( -1 -1 -1 ) ( -1 +1 -1 ) ( +1 +1 -1 ) )
        ( ( +1 +1 -1 ) ( -1 +1 -1 ) ( -1 +1 +1 ) ( +1 +1 +1 ) )
        ( ( +1 -1 +1 ) ( +1 -1 -1 ) ( +1 +1 -1 ) ( +1 +1 +1 ) )
        ( ( -1 -1 -1 ) ( -1 -1 +1 ) ( -1 +1 +1 ) ( -1 +1 -1 ) )
        ( ( +1 -1 +1 ) ( -1 -1 +1 ) ( -1 -1 -1 ) ( +1 -1 -1 ) )
        ( ( -1 -1 +1 ) ( +1 -1 +1 ) ( +1 +1 +1 ) ( -1 +1 +1 ) ))))



(defun test ()
  (gl::glLoadIdentity)
  (gl::glRotatef (coerce 55 'single-float) (coerce 1 'single-float) (coerce 0 'single-float) (coerce 0 'single-float))
  (gl::glRotatef (coerce 45 'single-float) (coerce 0 'single-float) (coerce 1 'single-float) (coerce 0 'single-float))
  (gl::glRotatef (coerce 0 'single-float) (coerce 0 'single-float) (coerce 0 'single-float) (coerce 1 'single-float))
  ;; coords go here
  (dotimes (i 6)
    (gl::glColor3ub (* i 20) (+ (* i 10) 100) (* i 42))
    (gl::glBegin 7)
    (dotimes (j 4)
      (gl::glVertex3d (coerce (* 0.2 (aref coords i j 0)) 'double-float) (coerce (* 0.2 (aref coords i j 1)) 'double-float) (coerce (* 0.2 (aref coords i j 1)) 'double-float)))
    (gl::glEnd)
    (return (test))
    ))



Here is the Opengl code Im attempting to convert


void on_opengl(void* param)
{
glLoadIdentity();

glTranslated(0.0, 0.0, -1.0);

glRotatef( 55, 1, 0, 0 );
glRotatef( 45, 0, 1, 0 );
glRotatef( 0, 0, 0, 1 );

static const int coords[6][4][3] = {
{ { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
{ { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
{ { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
{ { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
{ { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
{ { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
};

for (int i = 0; i < 6; ++i) {
glColor3ub( i*20, 100+i*10, i*42 );
glBegin(GL_QUADS);
for (int j = 0; j < 4; ++j) {
glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], 0.2 * coords[i][j][2]);
}
glEnd();
}
}

Im new to OpenGl and lispbulder as well....if some one could maybe give this a once over and verify if i made any mistakes

I run at the repl and it just hangs

I get these kind of errors in inferior lisp
Code: Select all
; caught STYLE-WARNING:
;   undefined function: TRACK-PACKAGE
;
; compilation unit finished
;   Undefined function:
;     TRACK-PACKAGE
;   caught 1 STYLE-WARNING condition

; in: DEFUN SETUP-STREAM-INDIRECTION
;     (SWANK::PREFIXED-VAR '#:CURRENT SWANK::STREAM-VAR)
;
; caught STYLE-WARNING:
;   undefined function: PREFIXED-VAR
;
; compilation unit finished
;   Undefined function:
;     PREFIXED-VAR
;   caught 1 STYLE-WARNING condition
joeish80829
 
Posts: 153
Joined: Tue Sep 03, 2013 5:32 am

Return to Common Lisp

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 4 guests