vydd/sketch

Attempting to render images results in a garbled mess.

SkiHatDuckie opened this issue · 5 comments

When trying to load and render any PNG image, the image comes out as a garbled mess. I have, quite literally, 1 week of experience with common lisp, so my understanding of why this is happening is a bit limited.

Minimal-ish example:

(asdf:load-system :cffi)

(cffi:define-foreign-library libffi  ; Required for loading sketch.
  (t (:default "libffi-7")))

(cffi:use-foreign-library libffi)

(ql:quickload :sketch)

(defpackage :stickies (:use :cl :sketch))
(in-package :stickies)

...

(defsketch app 
    ((title "Stickies") (width 600) (height 400)
    (save-icon (load-resource "..\\assets\\StickiesSaveIcon.png")))
  (image save-icon 0 0))

(defun main ()
  (make-instance 'app))

(main)

The image I'm trying to draw to the screen:
saveIconTemp
What I'm getting:
saveIconRenderResult
My operating system is Windows 10, and I've been using SBCL 2.2.10.

It draws fine for me, but the colour comes out as red instead of purple.

icon

I execute all the code in the REPL, and load sketch with quicklisp.

(ql:quickload 'sketch)
To load "sketch":
  Load 1 ASDF system:
    sketch
; Loading "sketch"
.........
(SKETCH)
CL-USER> (in-package sketch)
#<PACKAGE "SKETCH">
SKETCH> (defsketch app
            ((title "Stickies")
             (width 600)
             (height 400)
             (save-icon (load-resource "/path/to/icon.png")))
          (image save-icon 0 0))
#<STANDARD-CLASS SKETCH::APP>
SKETCH> (make-instance 'app)
#<APP {100492DEE3}>
SKETCH> 

Linux Mint, a probably recent version of SBCL.

I tried running your code in the REPL myself, but got the same mess as before.

I'm starting to wonder if this has something to do with the external dependencies.
I tried running the following in the REPL:

* (ql:quickload :sdl2-ttf-examples) 
To load "sdl2-ttf-examples":
  Load 1 ASDF system:
    sdl2-ttf-examples
; Loading "sdl2-ttf-examples"
..
(:SDL2-TTF-EXAMPLES)
* (ttf-examples:gl-example)

And I got this:
openGLContext
But when I tried (ttf-examples:basic-example), it renders perfectly fine!
BasicFontExample
So now I'm wondering if this has something to do with OpenGL (using NVIDIA version 4.6) (???)

Hello! These results seem similar to #32 and #51. Have you tried the latest version of sketch (cloning this repo)?
P.S. These issues were fixed with #55

Everything works now! Thank you.
goddammit2
Now I just feel stupid, because I actually remember stumbling upon #55 earlier on into figuring this out, but I guess I looked at the date it was merged and then just assumed that it was already a part of the quicklisp release.

Ah, I also remember that issue, but I didn't realise it had been fixed.