sdl2 on Windows?

Whatever is on your mind, whether Lisp related or not.

sdl2 on Windows?

Postby gekkonier » Tue Feb 14, 2017 2:47 am

Hi!

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)
(sdl2-examples:basic-test)

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...
gekkonier
 
Posts: 17
Joined: Tue Jan 17, 2017 6:57 am

Re: sdl2 on Windows?

Postby gekkonier » Wed Feb 15, 2017 3:45 am

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.

:?
gekkonier
 
Posts: 17
Joined: Tue Jan 17, 2017 6:57 am

Re: sdl2 on Windows?

Postby gekkonier » Wed Feb 15, 2017 6:25 am

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.
gekkonier
 
Posts: 17
Joined: Tue Jan 17, 2017 6:57 am

Re: sdl2 on Windows?

Postby gekkonier » Thu Mar 23, 2017 6:44 am

I found out why that basic example on windows 64bit wont work:
https://github.com/lispgames/cl-sdl2/issues/23

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)
(sdl2test:main)


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}>:
  EXCEPTION_ACCESS_VIOLATION


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
         nil
         (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 <your.name@example.com>"
  :license "Specify license here"
  :depends-on (#:cl-opengl
               #:sdl2)
  :serial t
  :components ((:file "package")
               (:file "sdl2test")))
gekkonier
 
Posts: 17
Joined: Tue Jan 17, 2017 6:57 am


Return to The Lounge

Who is online

Users browsing this forum: No registered users and 1 guest

cron