Page 1 of 1

sdl2 on Windows?

Posted: Tue Feb 14, 2017 2:47 am
by gekkonier

I tried to play a bit with sdl2 on Windows.
I tried sbcl 64 bit, ccl 32 and 64 bit, but with no success.

Steps to reproduce:

-) Store the correct dll (32 bit or 64bit from SDL2 project) inside your path.

-) then:
(ql:quickload :sdl2)
(ql:quickload :cl-opengl)
(asdf:load-system :sdl2/examples)

A window should open, as in Linux, but nothing happens, no error message, nothing. It wont open a window nor gives control back to the repl. You need to crash the lisp enironment to stop it.

On Linux it was no problem at all, and glfw3 works on windows like a charm, so I assume that my setup understands opengl.
But I would like to use audio too, so glfw3 is not an option unfortunately.

Has anyone of you a working Installation with sdl2 on windows and can give me hints how it could work?
If not: is there a companion audio library to glfw3 I could try? I need to play music in the background and parallel to it some sound effects.

And why has everything that has something to do with programming must always be a pain if you want to use it cross platform? But thats another question...

Re: sdl2 on Windows?

Posted: Wed Feb 15, 2017 3:45 am
by gekkonier
I tried cl-openal on ccl 32bit, with alut.dll and openal32.dll.
Results in lisp crash.

I think game programming with common lisp on windows is something nobody tried to do.
Maybe I should search for other options beside lisp dialects. I got through pain with gambit and chicken, there it's the same, everyone seems to use linux, and all code is tailored to it. Maybe racket... lets see.


Re: sdl2 on Windows?

Posted: Wed Feb 15, 2017 6:25 am
by gekkonier
Okay, I think i will use now a 32 bit implementation with lispbuilder-sdl.
Althought it's 32bit and sdl 1, it will do now for me, I doing nothing fancy...

I got the missing dlls from the xelf project.
Tests with CCL 32bit seemed to work.

Re: sdl2 on Windows?

Posted: Thu Mar 23, 2017 6:44 am
by gekkonier
I found out why that basic example on windows 64bit wont work:

Anyway, I managed to do something in sdl2 (code on the bottom of this post).

If I start a sbcl repl, and do the following:

Code: Select all

(ql:quickload 'sdl2test)
a colored window appears and disappears later, as I would expect.

Then I tried to create an executable out of it.

I did an

Code: Select all

(sb-ext:save-lisp-and-die "test.exe" :toplevel 'sdl2test:main :executable t)
It writes out the test.exe and quits, as it should.
But after calling test.exe I got an access violation:

Code: Select all

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "SDL2 Main Thread" RUNNING {10047EA353}>:
Can anyone help?

Here are the files mentioned above:

Code: Select all

;;;; sdl2test.lisp

(in-package #:sdl2test)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)

(defun main(&key (delay 2000))
  (sdl2:with-init (:video)
    (sdl2:with-window (window :title "sdl2test" :w *screen-width* :h *screen-height*)
      (let ((screen-surface (sdl2:get-window-surface window)))
	(sdl2:fill-rect screen-surface
			(sdl2:map-rgb (sdl2:surface-format screen-surface) 255 0 255))
	(sdl2:update-window window)
	(sdl2:delay delay)))))

Code: Select all

;;;; package.lisp

(defpackage #:sdl2test
  (:use #:cl)
  (:export :main))
;;;; sdl2test.asd

Code: Select all

(asdf:defsystem #:sdl2test
  :description "Describe sdl2test here"
  :author "Your Name <>"
  :license "Specify license here"
  :depends-on (#:cl-opengl
  :serial t
  :components ((:file "package")
               (:file "sdl2test")))