-
Notifications
You must be signed in to change notification settings - Fork 2
/
Readme
executable file
·159 lines (123 loc) · 6.21 KB
/
Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
ESDL by Dan Gudmundsson
Currently located at http://esdl.sourceforge.net
What is it?
===========
Esdl is library for accessing SDL (Simple DirectMedia Layer)
and OpenGL through Erlang.
Simple DirectMedia Layer is a cross-platform multimedia library
designed to provide fast access to the graphics framebuffer and audio
device. It also do event handling from mouse, keyboards and joysticks.
It is also possible to use TrueType fonts through SDL_ttf
(www.libsdl.org/projects/SDL_ttf/) and images through SDL_image
(www.libsdl.org/projects/SDL_image/). More information can be
found at libsdl.org
OpenGL is a cross-platform standard for 3D rendering and
3D hardware acceleration. More information can be found at
www.opengl.org
Compilation and Installation
=============================
You need erlang (www.erlang.org). This release has only been
tested on R13B, but R12B and possibly even older releases
will probably also work.
You need libsdl (www.libsdl.org) (the development package) version > 1.2.5
You need opengl (with glu-1.2 (full version) libraries from your
hardware manufacturer or a software version from www.mesa3d.org.
And optionally you'll need:
* SDL_ttf (www.libsdl.org/projects/SDL_ttf/) version > 2.0.7
* SDL_image (www.libsdl.org/projects/SDL_image/) version > 1.2.4
Precompiled versions are available for Windows.
For Unix-like systems (including MacOS X):
Untar the esdl-VERSION.src.tar.gz file and type 'make; make install'
or put it anywhere and add the path in your ~/.erlang (C:/windows/.erlang)
file.
You might need to modify the c_src/Makefile (or c_src/Makefile.macosx)
to point out the correct paths to header files and libraries.
On MacOS X, the top-level Makefile will automatically use
c_src/Makefile.macosx, but if you run make in the c_src direcotory,
you need to run make as 'make -f Makefile.macosx'.
To sucessfully build esdl you need complete GLU version 1.2 or later,
many Linux system has a mesa-glu which don't have the correct tesselation
routines. Download the prebuilt sgi-version from www.mesa3d.org and click
on SGI-GLU link to find a rpm. Optionally you'll also need SDL_ttf
for the font support and SDL_image for the image support.
Note: SDL_ttf and SDL_image are disabled by default, since they
depend on libraries not in the plain vanilla SDL packages.
By making them optional one can compile and run esdl without
having to bother about getting hold of the SDL_ttf and
SDL_image libraries. Enable them in the Makefile:
ENABLE_SDL_TTF = yes
ENABLE_SDL_IMAGE = yes
Install sdl so that the os can find the dynamic libraries:
On windows: put the .dll's somewhere in your path or in $ESDL_PATH/priv
(in the precompiled version (maybe old) SDL.dll is included)
On unix: put the .so libs somewhere in your LD_LIBRARY_PATH
Testing esdl can be done by building the tests in the test directory and
running the test programs, example:
cd test
erl -pa ../ebin (werl on windows)
Erlang (BEAM) emulator version 5.1.1 [threads:0]
Eshell V5.1.1 (abort with ^G)
1> testsprite:go(). %% Escape quits
2> testgl:go().
3> erldemo:go().
4> testaudio:go().
5> testjoy:go().
6> test_ttf:go("/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 20).
7> test_glfont:go("/usr/share/fonts/truetype/freefont/FreeSans.ttf").
8> test_glimg:go().
Note: Using esdl on nvidia cards and their drivers requires that erlang
was built with threads.
That is when building erlang do ./configure -enable-threads
otherwise Erlang will crash with segfault
Performance & Quality?
======================
Is not as fast as in 'C' obviously, but the opengl part is pretty
fast if you have an opengl accelerated 3d card.
The sdl_video performance is not that fast mainly due to that most
of the sdl functions is synchronous (i.e. has return values which
erlang must wait for).
This code is almost untested, i.e it contains a lot of bugs.
What is done and what are the main differences with the 'C' libraries?
======================================================================
In general I have tried to follow the libraries as much as possible,
usually the only changes are the return values, in 'C' you use arguments
to do multiple returns which erlang won't allow instead a tuple is returned
containing the values.
The SDL functions have been split into several erlang modules
(with corresponding header files).
General SDL functions, such as SDL_Init, are in the sdl.erl module.
Most of the video related functions are in the sdl_video.erl module.
The event functions are sliced into the following modules:
sdl_event.erl, sdl_active.erl, sdl_keyboard.erl, sdl_mouse.erl.
sdl_audio.erl handles some of the audio functions, the audio part needs
more work.
The cdrom, threads and time functions are not implemented.
sdl_ttf.erl takes care of the TrueType fonts.
sdl_img.erl loads images onto SDL surfaces. None of the SDL_RWops
functions (which are the greater part of the API) are implemented.
The existing support will suffice in most cases though (e.g. loading
images from file).
Opengl is defined in the gl.erl module, everything in opengl-1.4 is
implemented, note that it depends on the dirvers which functions are
available. Most of glu functions are implemented except most of the
functions that require a function pointer.
Extra functions:
================
Most of the SDL_video functions requires a pointer to a
video_surface structure, to be able to handle these structures
the following functions has been added:
sdl_video:getSurface/1, sdl_video:getPixelFormat/1,
sdl_video:getPalette/1, sdl_video:getPixels/2
Some of the Opengl functions also requires pointers to memory
areas, the sdl_util module contains functions to handle these.
sdl_util:malloc/2, sdl_util:free/1, sdl_util:read/2, sdl_util:readBin/2,
sdl_util:write/2.
What's need to be done and what do I want you to do?
====================================================
Someone with some experience with audio programming can take a look at the
audio part which needs some work.
The other sdl packages such as sdl_image, sdl_mixer and sdl_mpeg.
If you make something funny or good looking applications, it would be fun
if you let me know and gave me some credit.
Regards
/Dan (d g u d @ e r i x. e r i c s s o n. s e)