I've been stuck on this for the last two weeks and I'm feeling frustrated. Hopefully someone here can help.<br>I'm using cl-opengl with sbcl on an Ubuntu box. Everything been working well but I've run into trouble with vertex (and other) arrays. I'm trying to create a vertex, normal, tex-coord, and edge array format. I keep getting an error when I try to bind the vertex array. <br>
<br>Undefined function: CL-OPENGL::TEX-COORD-POINTER<br><br>I've looked and there is a tex-coord-pointer defined in cl-opengl! <br>
<br>Anyway, here is my code below (Just the one object, if you want the rest I can send it). Thanks in advance for your time.<br><br><br>(in-package #:qix)<br><br>(gl:define-gl-array-format vnte<br> (gl:vertex :type :float :components (x y z))<br>
(gl:normal :type :float :components (nx ny nz))<br> (gl:tex-coord :type :float :components (tx ty))<br> (gl:edge-flag :type :float :components (e)))<br><br>(defclass 3d-model (display-list) <br> ((vertex-array<br> :accessor vertex-array<br>
:initarg vertex-array<br> :initform nil)<br> (size)))<br><br><br>(defclass 3d-square (3d-model) <br> ((top<br> :initarg :top<br> :initform nil<br> :accessor top)<br> (left<br> :initarg :left<br> :initform nil<br>
:accessor left) <br> (width<br> :initarg :width<br> :initform nil<br> :accessor width)<br> (height<br> :accessor height<br> :initarg :height<br> :accessor height)<br> (x-size<br> :accessor x-size<br>
:initarg :x-size<br> :initform 10)<br> (y-size<br> :accessor y-size<br> :initarg :y-size<br> :initform 10)))<br><br>(defmethod initialize-instance :after ((this 3d-square) &rest args)<br> (print "starting init!")<br>
(with-accessors ((vertex-array vertex-array)<br> (width width)<br> (height height) <br> (x-size x-size) <br> (y-size y-size) <br> (top top) <br> (left left)) this<br>
(setf (slot-value this 'size) (* x-size y-size))<br> (let ((dx (/ width x-size)) <br> (dy (/ height y-size))<br> (tdx (/ x-size)) <br> (tdy (/ y-size)))<br> (setf vertex-array (gl:alloc-gl-array 'vnte (slot-value this 'size)))<br>
(loop for i from 0 to (- x-size 1)<br> do (loop for j from 0 to (- y-size 1) <br> do (let ((startx (+ left (* i dx))) <br> (starty (- top (* j dy)))<br> (endx (+ left (* i dx) dx))<br>
(endy (- top (* j dy) dy))<br> (tex-startx (* i tdx)) <br> (tex-starty (* j tdy))<br> (tex-endx (+ (* i tdx) tdx))<br> (tex-endy (+ (* j tdy) tdy))<br> (offset (+ (* i y-size 6 3) (* j 6 3))))<br>
<br> ; first triangle<br> (setf (gl:glaref vertex-array offset 'x) (float startx))<br> (setf (gl:glaref vertex-array offset 'y) (float starty))<br> (setf (gl:glaref vertex-array offset 'z) (float 0))<br>
(setf (gl:glaref vertex-array (+ offset 1) 'x) (float endx))<br> (setf (gl:glaref vertex-array (+ offset 1) 'y) (float starty))<br> (setf (gl:glaref vertex-array (+ offset 1) 'z) (float 0))<br>
(setf (gl:glaref vertex-array (+ offset 2) 'x) (float startx))<br> (setf (gl:glaref vertex-array (+ offset 2) 'y) (float endy))<br> (setf (gl:glaref vertex-array (+ offset 2) 'z) (float 0))<br>
; second triangle<br> (setf (gl:glaref vertex-array (+ offset 3) 'x) (float startx))<br> (setf (gl:glaref vertex-array (+ offset 3) 'y) (float endy))<br> (setf (gl:glaref vertex-array (+ offset 3) 'z) (float 0))<br>
(setf (gl:glaref vertex-array (+ offset 4) 'x) (float endx))<br> (setf (gl:glaref vertex-array (+ offset 4) 'y) (float starty))<br> (setf (gl:glaref vertex-array (+ offset 4) 'z) (float 0))<br>
(setf (gl:glaref vertex-array (+ offset 5) 'x) (float endx))<br> (setf (gl:glaref vertex-array (+ offset 5) 'y) (float endy))<br> (setf (gl:glaref vertex-array (+ offset 5) 'z) (float 0))<br>
<br> ; first triangle normals<br> (setf (gl:glaref vertex-array offset 'nx) (float 0))<br> (setf (gl:glaref vertex-array offset 'ny) (float 0))<br> (setf (gl:glaref vertex-array offset 'nz) (float 1))<br>
(setf (gl:glaref vertex-array (+ offset 1) 'nx) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 1) 'ny) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 1) 'nz) (float 1))<br>
(setf (gl:glaref vertex-array (+ offset 2) 'nx) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 2) 'ny) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 2) 'nz) (float 1))<br>
;second triangle...<br> (setf (gl:glaref vertex-array (+ offset 3) 'nx) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 3) 'ny) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 3) 'nz) (float 1))<br>
(setf (gl:glaref vertex-array (+ offset 4) 'nx) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 4) 'ny) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 4) 'nz) (float 1))<br>
(setf (gl:glaref vertex-array (+ offset 5) 'nx) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 5) 'ny) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 5) 'nz) (float 1))<br>
<br> ; first triangle texture<br> (setf (gl:glaref vertex-array offset 'tx) (float tex-startx))<br> (setf (gl:glaref vertex-array offset 'ty) (float tex-starty))<br> (setf (gl:glaref vertex-array (+ offset 1) 'tx) (float tex-endx))<br>
(setf (gl:glaref vertex-array (+ offset 1) 'ty) (float tex-starty))<br> (setf (gl:glaref vertex-array (+ offset 2) 'tx) (float tex-startx))<br> (setf (gl:glaref vertex-array (+ offset 2) 'ty) (float tex-endy))<br>
; second triangle texture<br> (setf (gl:glaref vertex-array (+ offset 3) 'tx) (float tex-startx))<br> (setf (gl:glaref vertex-array (+ offset 3) 'ty) (float tex-endy))<br>
(setf (gl:glaref vertex-array (+ offset 4) 'tx) (float tex-endx))<br> (setf (gl:glaref vertex-array (+ offset 4) 'ty) (float tex-starty))<br> (setf (gl:glaref vertex-array (+ offset 5) 'tx) (float tex-endx))<br>
(setf (gl:glaref vertex-array (+ offset 1) 'ty) (float tex-endy))<br> ; First triangle edges<br> (setf (gl:glaref vertex-array offset 'e) (float (if (zerop i) 1 0)))<br> (setf (gl:glaref vertex-array (+ offset 1) 'e) (float 0))<br>
(setf (gl:glaref vertex-array (+ offset 2) 'e) (float (if (zerop j) 1 0)))<br> ;Seconde Triangle Edges<br> (setf (gl:glaref vertex-array (+ offset 3) 'e) (float 0))<br> (setf (gl:glaref vertex-array (+ offset 4) 'e) (float (if <br>
(eql j (- y-size 1)) <br> 1 0)))<br> (setf (gl:glaref vertex-array (+ offset 5) 'e) (float (if <br> (eql i (- x-size 1)) <br>
1 0)))))))))<br><br><br><br>(defmethod render ((this 3d-square))<br> ;;enable the correct arrays<br> (gl:enable-client-state :vertex-array)<br> (gl:enable-client-state :edge-flag-array)<br>
(gl:enable-client-state :normal-array)<br> (gl:enable-client-state :texture-coord-array)<br> (print "two")<br> (gl:bind-gl-vertex-array (vertex-array this))<br> (format t "size = ~a~%" (slot-value this 'size))<br>
(%gl:draw-arrays :triangles 0 (slot-value this 'size))) <br>