I have been tasked with solving a problem that is outside of my domain of knowledge and I was hoping I could get some troubleshooting advice from someone more experienced with openGL (I have very little experience with openGL). We are working on a cross platform application that is implemented in a common lisp implementation called ccl. In this application we have a need to display some 3D objects that display text. On the mac, all of the text displays fine but on the PC instead of displaying the text it displays some other texture. At first I thought that maybe the wrong texture was just being referenced so I tried changing the texture number but none of the textures in the list appeared to be the text (or if it was the texture was distorted and did not look like text). I know this problem is very vague and I am not looking for someone to post a solution, but I was wondering if people could suggest places I might look to try and get a handle on this issue.
Here is the method that ends up creating the texture from a file (sorry the code is written in lisp using cocoa/cocotron) also when I added the print statements to print the pixels wide and pixels high both turned out to be powers of 2 (512):
(defun CREATE-IMAGE-FROM-FILE (Filename &key Verbose Forced-Depth (Flip-Vertical t)) "
in: Filename string-or-pathname, &key Verbose boolean, Forced-Depth int,
out: Pixels byte-vector,
Width Height Forced-Depth int; Has-Alpha boolean.
Create an image buffer from <Filename>
- File must be 32 bit ARGB compatible, e.g., .png with mask or 24 bit RGB."
(print "CREATE IMAGE FROM FILE")
(print Filename)
(when Verbose (format t "CREATE-IMAGE-FROM-FILE: ~A~%" Filename))
(let* ((Image-Representation (#/retain (ns-image-rep-from-file (native-string (namestring (translate-logical-pathname Filename)))))))
;; should massage data: GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV for best performance
;; http://developer.apple.com/documentation/graphicsimaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html
(when (%null-ptr-p Image-Representation)
(format t "~%missing texture ~S" Filename)
(return-from create-image-from-file))
;; do the OpenGL vertical image flip
(when Flip-Vertical
(flip-vertical-buffer
(#/bitmapData Image-Representation)
(* (#/bytesPerRow Image-Representation) (#/pixelsHigh Image-Representation))
(#/bytesPerRow Image-Representation)))
(print (#/pixelsWide Image-Representation))
(print (#/pixelsHigh Image-Representation))
(values
(#/bitmapData Image-Representation)
(#/pixelsWide Image-Representation)
(#/pixelsHigh Image-Representation)
(#/bitsPerPixel Image-Representation)
(#/hasAlpha Image-Representation)
(#/bitmapFormat Image-Representation))))
(defmethod DISPLAY-VERTEX-ARRAYS ((Self string-shape))
(glEnable gl_texture_2d)
(cond
;; Color!
((color-vector Self)
(glcolor3ubv (color-vector Self))
(gltexenvi gl_texture_env gl_texture_env_mode gl_blend))
;; Black
(t
(gltexenvi gl_texture_env gl_texture_env_mode gl_modulate)))
(glbindtexture gl_texture_2d (texture (font Self)))
(glInterleavedArrays GL_T2F_V3F (va-stride Self) (vertex-arrays Self))
(glDrawArrays gl_quads 0 (va-elements-count Self))
(gltexenvi gl_texture_env gl_texture_env_mode gl_modulate)
(glDisable gl_texture_2d)
;; if color was use better reset to white?
(when (color-vector Self) (glColor3f 1.0 1.0 1.0)))