File: quickstart.txt

package info (click to toggle)
allegro4.4 2%3A4.4.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 20,756 kB
  • sloc: ansic: 164,458; asm: 17,620; cpp: 3,848; javascript: 3,053; objc: 1,687; sh: 1,107; python: 676; pascal: 179; makefile: 57; perl: 29; lisp: 1
file content (199 lines) | stat: -rw-r--r-- 6,239 bytes parent folder | download | duplicates (8)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
AllegroGL Quickstart
====================


AllegroGL web site:  http://allegrogl.sourceforge.net/
This document:       http://allegrogl.sourceforge.net/quickstart.txt


Introduction
~~~~~~~~~~~~

You should read the rest of the documentation for details. This guide
only contains minimal details on how to set up and use AllegroGL.


Requirements
~~~~~~~~~~~~

See readme.txt or the HTML docs for the proper list of requirements.


Installation
~~~~~~~~~~~~

From version 0.4.4 onwards, AllegroGL is an addon library for Allegro and the
usual way to build it is by following the allegro compilation procedure. It
will configure, build and install AllegroGL using default options (a shared
release library).
    
However, you if you need a custom compiled library, e.g. with debug symbols or
a statically linked one, you can build AllegroGL manually, passing custom build
options.

See readme.txt or the HTML docs for the full installation procedure. This
is just to get you quickly started, so a lot of details are skipped.

Unix: Unzip the AllegroGL archive, and run './configure' and `make' from the
	top directory.  That should build the library (in `lib') and example
	programs (in `examp').  Then run 'make install' to install the header
	files and the library.


Windows: Unzip the archive. First run 'fix msvc' or 'fix mingw32' depending on
	which compiler you will be using (You'll also need to run vcvars32.bat
	if you're building with MSVC). Then simply run 'make' followed by
	'make install' to build the library and install it.
	You can use the DEBUGMODE=1 switch if you need to the debug build of
	the library.


DOS: Unzip the archive files MesaLib-4.0.zip wherever you want.
	Unzip AllegroGL

	Go to the root directory of AllegroGL type 'fixdjgpp' (without
	quotes) followed by 'make MESADIR=xxxx' where 'xxx' is the path to the
	Mesa root directory. Finally type 'make install' to install the library


Mac OS X: Unzip the archive. First run './fix.sh macosx', then
	simply run 'make' and 'sudo make install'. The last step will
	require your root password.


Using AllegroGL:
~~~~~~~~~~~~~~~~

Unix: 	For the compilation process, all you need to do is
	#include <alleggl.h>.
	You'll need to link with -lagl (or -lagld), `allegro-config --libs`
	(or `allegro-config --libs debug`), -lGL and -lGLU

Windows: For the compilation process, all you need to do is
	#include <alleggl.h>.

	For MSVC: You'll need to link with agl.lib (or agld.lib),
	alleg.lib (or alld.lib), user32.lib, gdi32.lib, opengl32.lib,
	and glu32.lib (note: the link order is important).

	For Mingw: You'll need to link with -lagl (or -lagld), 
	-lalleg (or -lalld), -luser32 -lgdi32 -lopengl32 and -lglu32
	(note: the link order is important).

DOS:	For the compilation process, all you need to do is
	#include <alleggl.h>.
	You'll need to link with -lagl (or -lagld), 
	-lalleg (or -lalld), -lmesagl and -lmesaglu

Mac OS X: For the compilation process, all you need to do is
	#include <alleggl.h>.
	You'll need to link with -lagl (or -lagld), `allegro-config --libs`
	(or `allegro-config --libs debug`), -framework Carbon and
	-framework OpenGL.
	There is no support to build from Project Builder or XCode at the
	moment, sorry.


Tests/Examples
~~~~~~~~~~~~~~

You can try out any of the example programs in `examp'. Most of them
require mysha.pcx, which you can find in the Allegro example directory.

- test.c and tex.c Show a very simple OpenGL program.
- extextur.c       Shows how to load and display textures.
- exalleg.c        Shows how to use Allegro code with AllegroGL to
                   read/write to the screen.
- exmasked.c       Shows how to draw sprites that are masked using
                   OpenGL.
- extext.c         Shows how to use the extended text and font facilities
                   in AllegroGL.
- exalpfnt.c       Shows how to use FONTs that are alpha channel only, to
                   save on texture memory.
- excamera.c       Shows how to use a camera in OpenGL. It uses Allegro to
                   manage a quaternion.
- exgui.c          Demonstrates the use of the Allegro GUI routines with an
                   OpenGL back-end.
- exext.c          Shows how to use OpenGL extensions with AllegroGL.
- dialog.c         Demonstrates switching in between Allegro screen modes
                   and OpenGL. It can also serve as a test application for
                   resolution/color depths.
- dumbtest.c       Just tests various features of AllegroGL, like
                   mix-matching Allegro's rendering with OpenGL's.
- exmipmaps.c      Shows how to use a mipmap stack in AllegroGL for texture
                   filtering.
- fonttest.c       Shows various AllegroGL FONT rendering types.
- exblend.c        Shows how to use Allegro/AllegroGL API to do accelerated
                   blending of the bitmaps to the screen.


Example code:
~~~~~~~~~~~~~

#include <allegro.h>
#include <alleggl.h>

int main() {
	
	/* Initialize both Allegro and AllegroGL */
	if (allegro_init())
		return 1;

	if (install_allegro_gl())
		return 1;
	
	/* Tell Allegro we want to use the keyboard */
	install_keyboard();

	/* Suggest a good screen mode for OpenGL */
	allegro_gl_set(AGL_Z_DEPTH, 8);
	allegro_gl_set(AGL_COLOR_DEPTH, 16);
	allegro_gl_set(AGL_SUGGEST, AGL_Z_DEPTH | AGL_COLOR_DEPTH);

	/* Set the graphics mode */
	if (set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0)) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Unable to set graphic mode\n%s\n", allegro_error);
		return 1;
	}
	
	/* Clear the screen */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/* Set up the view frustum */
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glFrustum(-1.0, 1.0, -1.0, 1.0, 1, 60.0);

	/* Draw a quad using OpenGL */
	glBegin(GL_QUADS);
		glColor3ub(255, 255, 255);
		glVertex3f(-1, -1, -2);
		glVertex3f( 1, -1, -2);
		glVertex3f( 1,  1, -2);
		glVertex3f(-1,  1, -2);
	glEnd();
	
	/* Flip the backbuffer on screen */
	allegro_gl_flip();
	
	/* Wait for the user to press a key */
	readkey();
	
	/* Finished. */
	return 0;
}
END_OF_MAIN()







Contact information
~~~~~~~~~~~~~~~~~~~

Web page:     http://allegrogl.sourceforge.net/
Mailing list: allegrogl-general@lists.sourceforge.net