graphics 1.0.0b6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +88 -0
- data/Manifest.txt +2 -0
- data/Rakefile +7 -8
- data/examples/boid.rb +44 -63
- data/examples/bounce.rb +4 -4
- data/examples/canvas.rb +17 -16
- data/examples/collision.rb +1 -1
- data/examples/demo.rb +1 -1
- data/examples/editor.rb +1 -1
- data/examples/fluid.rb +6 -6
- data/examples/fluid2.rb +22 -9
- data/examples/gol.rb +1 -1
- data/examples/gol2.rb +14 -22
- data/examples/math.rb +1 -1
- data/examples/pi_polygon.rb +8 -3
- data/examples/radar.rb +3 -3
- data/examples/rainbow_fluid.rb +4 -3
- data/examples/tank.rb +7 -3
- data/examples/tank2.rb +3 -3
- data/examples/targeting.rb +3 -3
- data/examples/vants.rb +13 -4
- data/examples/walker.rb +1 -1
- data/examples/walker2.rb +1 -1
- data/examples/zombies.rb +13 -7
- data/ext/sdl/extconf.rb +12 -20
- data/ext/sdl/sdl.c +619 -360
- data/ext/sdl/sge/Makefile +36 -11
- data/ext/sdl/sge/Makefile.conf +15 -9
- data/ext/sdl/sge/sge_bm_text.cpp +7 -6
- data/ext/sdl/sge/sge_collision.cpp +3 -1
- data/ext/sdl/sge/sge_config.h +0 -2
- data/ext/sdl/sge/sge_internal.h +0 -8
- data/ext/sdl/sge/sge_primitives.cpp +0 -11
- data/ext/sdl/sge/sge_primitives.h +0 -3
- data/ext/sdl/sge/sge_rotation.cpp +1 -1
- data/ext/sdl/sge/sge_shape.cpp +18 -9
- data/ext/sdl/sge/sge_surface.cpp +10 -4
- data/ext/sdl/sge/sge_textpp.cpp +17 -13
- data/graphics_setup.sh +43 -13
- data/lib/graphics.rb +1 -1
- data/lib/graphics/body.rb +8 -0
- data/lib/graphics/decorators.rb +15 -3
- data/lib/graphics/extensions.rb +1 -1
- data/lib/graphics/rainbows.rb +17 -25
- data/lib/graphics/simulation.rb +265 -106
- data/lib/graphics/v.rb +8 -1
- data/resources/sounds/attribution.txt +2 -0
- data/resources/sounds/bullet.wav +0 -0
- data/test/test_graphics.rb +232 -107
- metadata +37 -43
- metadata.gz.sig +1 -2
data/ext/sdl/sge/Makefile
CHANGED
@@ -8,24 +8,49 @@ LIBS =$(SGE_LIBS)
|
|
8
8
|
SGE_VER = 030809
|
9
9
|
API_VER = 0
|
10
10
|
|
11
|
+
UNAME = $(shell uname)
|
12
|
+
ARCH = $(shell uname -m)
|
13
|
+
ifeq ($(UNAME), Darwin)
|
14
|
+
LIBNAME = libSGE2.dylib
|
15
|
+
LIBNAMEAPI = libSGE2.$(API_VER).dylib
|
16
|
+
LIBNAMEVER = libSGE2.$(API_VER).$(SGE_VER).dylib
|
17
|
+
LIBDIR = lib
|
18
|
+
LIBFLAG = -install_name
|
19
|
+
else
|
20
|
+
LIBNAME = libSGE2.so
|
21
|
+
LIBNAMEAPI = libSGE2.so.$(API_VER)
|
22
|
+
LIBNAMEVER = libSGE2.so.$(API_VER).$(SGE_VER)
|
23
|
+
LIBFLAG = -soname
|
24
|
+
ifeq ($(FORCE32), y)
|
25
|
+
LIBDIR = lib
|
26
|
+
else
|
27
|
+
ifeq ($(ARCH), x86_64)
|
28
|
+
LIBDIR = lib64
|
29
|
+
else
|
30
|
+
LIBDIR = lib
|
31
|
+
endif
|
32
|
+
endif
|
33
|
+
endif
|
34
|
+
|
35
|
+
|
11
36
|
OBJECTS=sge_surface.o sge_primitives.o sge_tt_text.o sge_bm_text.o sge_misc.o sge_textpp.o sge_blib.o sge_rotation.o sge_collision.o sge_shape.o
|
12
37
|
|
13
38
|
all: config $(OBJECTS)
|
14
|
-
@ar rsc
|
39
|
+
@ar rsc libSGE2.a $(OBJECTS)
|
15
40
|
|
16
41
|
$(OBJECTS): %.o:%.cpp %.h #Each object depends on thier .cpp and .h file
|
17
42
|
$(CXX) $(CFLAGS) -c $<
|
18
43
|
|
19
44
|
shared: all
|
20
|
-
$(CXX) $(CFLAGS) -Wl
|
45
|
+
$(CXX) $(CFLAGS) -Wl,$(LIBFLAG),$(LIBNAMEAPI) -fpic -fPIC -shared -o $(LIBNAME) $(OBJECTS) $(LIBS)
|
21
46
|
|
22
47
|
shared-strip: shared
|
23
|
-
@strip
|
48
|
+
@strip $(LIBNAME)
|
24
49
|
|
25
50
|
# Building a dll... I have no idea how to do this, but it should be something like below.
|
26
51
|
dll: config $(OBJECTS)
|
27
52
|
dlltool --output-def SGE.def $(OBJECTS)
|
28
|
-
dllwrap --driver-name $(CXX) -o SGE.dll --def SGE.def --output-lib
|
53
|
+
dllwrap --driver-name $(CXX) -o SGE.dll --def SGE.def --output-lib libSGE2.a --dllname SGE.dll $(OBJECTS) $(LIBS)
|
29
54
|
|
30
55
|
dll-strip: dll
|
31
56
|
@strip SGE.dll
|
@@ -73,11 +98,11 @@ endif
|
|
73
98
|
install: shared
|
74
99
|
@mkdir -p $(PREFIX_H)
|
75
100
|
install -c -m 644 sge*.h $(PREFIX_H)
|
76
|
-
@mkdir -p $(PREFIX)
|
77
|
-
install -c -m 644
|
78
|
-
install -c
|
79
|
-
@cd $(PREFIX)
|
80
|
-
ln -sf
|
81
|
-
ln -sf
|
101
|
+
@mkdir -p $(PREFIX)/$(LIBDIR)
|
102
|
+
install -c -m 644 libSGE2.a $(PREFIX)/$(LIBDIR)
|
103
|
+
install -c $(LIBNAME) $(PREFIX)/$(LIBDIR)/$(LIBNAMEVER)
|
104
|
+
@cd $(PREFIX)/$(LIBDIR);\
|
105
|
+
ln -sf $(LIBNAMEVER) $(LIBNAMEAPI);\
|
106
|
+
ln -sf $(LIBNAMEAPI) $(LIBNAME)
|
82
107
|
@echo "** Headerfiles installed in $(PREFIX_H)"
|
83
|
-
@echo "** Library files installed in $(PREFIX)
|
108
|
+
@echo "** Library files installed in $(PREFIX)/$(LIBDIR)"
|
data/ext/sdl/sge/Makefile.conf
CHANGED
@@ -3,36 +3,42 @@
|
|
3
3
|
# Comment/uncomment the following line to disable/enable build options
|
4
4
|
# (See README for more info)
|
5
5
|
C_COMP = y
|
6
|
-
|
7
|
-
|
6
|
+
USE_FT = n
|
7
|
+
USE_IMG = n
|
8
8
|
#QUIET = y
|
9
9
|
|
10
|
+
# Use this to build 32-bit libs on 64-bit Linux systems
|
11
|
+
FORCE32 = n
|
10
12
|
|
11
13
|
# Compilers (C and C++)
|
12
14
|
CC=gcc
|
13
15
|
CXX=g++
|
16
|
+
ifeq ($(FORCE32), y)
|
17
|
+
CC += -m32
|
18
|
+
CXX += -m32
|
19
|
+
endif
|
14
20
|
|
15
21
|
# Make sure sdl-config is available
|
16
|
-
HAVE_SDL =$(shell if (
|
22
|
+
HAVE_SDL =$(shell if (sdl2-config --version) < /dev/null > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
|
17
23
|
ifeq ($(HAVE_SDL),n)
|
18
24
|
$(error ERROR: Can't find SDL! Make sure that you have SDL (http://www.libsdl.org/) and its development files installed)
|
19
25
|
endif
|
20
26
|
|
21
27
|
# Where should SGE be installed?
|
22
|
-
PREFIX =$(shell
|
28
|
+
PREFIX =$(shell sdl2-config --prefix)
|
23
29
|
|
24
30
|
# Where should the headerfiles be installed?
|
25
|
-
PREFIX_H =$(shell
|
31
|
+
PREFIX_H =$(shell sdl2-config --prefix)/include/SDL2
|
26
32
|
|
27
33
|
# Flags passed to the compiler
|
28
34
|
CFLAGS =-Wall -O3 -ffast-math
|
29
|
-
SGE_CFLAGS =$(shell
|
35
|
+
SGE_CFLAGS =$(shell sdl2-config --cflags)
|
30
36
|
# Uncomment to make some more optimizations
|
31
37
|
#CFLAGS =-Wall -O9 -ffast-math -march=i686
|
32
38
|
|
33
39
|
|
34
40
|
# Libs config
|
35
|
-
SGE_LIBS =$(shell
|
41
|
+
SGE_LIBS =$(shell sdl2-config --libs) -lstdc++
|
36
42
|
|
37
43
|
|
38
44
|
# Is freetype-config available?
|
@@ -49,7 +55,7 @@ endif
|
|
49
55
|
|
50
56
|
|
51
57
|
# Is SDL_image available?
|
52
|
-
HAVE_IMG =$(shell if test -e "`
|
58
|
+
HAVE_IMG =$(shell if test -e "`sdl2-config --prefix`/include/SDL2/SDL_image.h" >/dev/null 2>&1; then echo "y"; else echo "n"; fi;)
|
53
59
|
|
54
60
|
ifneq ($(USE_IMG),y)
|
55
61
|
ifneq ($(USE_IMG),n)
|
@@ -58,6 +64,6 @@ ifneq ($(USE_IMG),y)
|
|
58
64
|
endif
|
59
65
|
|
60
66
|
ifeq ($(USE_IMG),y)
|
61
|
-
SGE_LIBS +=-
|
67
|
+
SGE_LIBS +=-lSDL2_image
|
62
68
|
endif
|
63
69
|
|
data/ext/sdl/sge/sge_bm_text.cpp
CHANGED
@@ -51,12 +51,13 @@ sge_bmpFont* sge_BF_CreateFont(SDL_Surface *surface, Uint8 flags)
|
|
51
51
|
font = new(nothrow) sge_bmpFont; if(font==NULL){SDL_SetError("SGE - Out of memory");return NULL;}
|
52
52
|
|
53
53
|
if(!(flags&SGE_BFNOCONVERT) && !(flags&SGE_BFSFONT)){ /* Get a converted copy */
|
54
|
-
|
54
|
+
SDL_assert(0 && "sge_BF_CreateFont");
|
55
|
+
/*font->FontSurface = SDL_DisplayFormat(surface);*/
|
55
56
|
if(font->FontSurface==NULL){SDL_SetError("SGE - Out of memory");return NULL;}
|
56
57
|
|
57
58
|
if(flags&SGE_BFPALETTE){ //We want an 8bit surface
|
58
59
|
SDL_Surface *tmp;
|
59
|
-
tmp =
|
60
|
+
tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, surface->w, surface->h, 8, 0, 0, 0, 0);
|
60
61
|
if(tmp==NULL){SDL_SetError("SGE - Out of memory");SDL_FreeSurface(font->FontSurface);return NULL;}
|
61
62
|
|
62
63
|
//Set the palette
|
@@ -64,7 +65,7 @@ sge_bmpFont* sge_BF_CreateFont(SDL_Surface *surface, Uint8 flags)
|
|
64
65
|
c[0].r=0; c[1].r=255;
|
65
66
|
c[0].g=0; c[1].g=255;
|
66
67
|
c[0].b=0; c[1].b=255;
|
67
|
-
|
68
|
+
SDL_SetPaletteColors(tmp->format->palette, c, 0, 2);
|
68
69
|
|
69
70
|
if (SDL_MUSTLOCK(font->FontSurface) && _sge_lock)
|
70
71
|
if (SDL_LockSurface(font->FontSurface) < 0){
|
@@ -154,7 +155,7 @@ sge_bmpFont* sge_BF_CreateFont(SDL_Surface *surface, Uint8 flags)
|
|
154
155
|
if(flags&SGE_BFTRANSP || flags&SGE_BFSFONT)
|
155
156
|
#if SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= \
|
156
157
|
SDL_VERSIONNUM(1, 1, 4)
|
157
|
-
SDL_SetColorKey(font->FontSurface,
|
158
|
+
SDL_SetColorKey(font->FontSurface,SDL_TRUE, font->bcolor); //Some versions of SDL have a bug with SDL_RLEACCEL
|
158
159
|
#else
|
159
160
|
SDL_SetColorKey(font->FontSurface,SDL_SRCCOLORKEY|SDL_RLEACCEL, font->bcolor);
|
160
161
|
#endif
|
@@ -383,7 +384,7 @@ void sge_BF_SetColor(sge_bmpFont *font, Uint8 R, Uint8 G, Uint8 B)
|
|
383
384
|
c[0].r=0; c[1].r=R;
|
384
385
|
c[0].g=0; c[1].g=G;
|
385
386
|
c[0].b=0; c[1].b=B;
|
386
|
-
|
387
|
+
SDL_SetPaletteColors(font->FontSurface->format->palette, c, 0, 2);
|
387
388
|
}
|
388
389
|
}
|
389
390
|
|
@@ -393,7 +394,7 @@ void sge_BF_SetColor(sge_bmpFont *font, Uint8 R, Uint8 G, Uint8 B)
|
|
393
394
|
//==================================================================================
|
394
395
|
void sge_BF_SetAlpha(sge_bmpFont *font, Uint8 alpha)
|
395
396
|
{
|
396
|
-
|
397
|
+
SDL_SetSurfaceAlphaMod(font->FontSurface, alpha);
|
397
398
|
}
|
398
399
|
|
399
400
|
|
@@ -40,6 +40,7 @@ sge_cdata *sge_make_cmap(SDL_Surface *img)
|
|
40
40
|
Uint8 *map;
|
41
41
|
Sint16 x,y;
|
42
42
|
Sint32 offs;
|
43
|
+
Uint32 key;
|
43
44
|
int i;
|
44
45
|
|
45
46
|
cdata=new(nothrow) sge_cdata;
|
@@ -56,7 +57,8 @@ sge_cdata *sge_make_cmap(SDL_Surface *img)
|
|
56
57
|
for(y=0; y < img->h; y++){
|
57
58
|
for(x=0; x < img->w; x++){
|
58
59
|
if(i>7){i=0;map++;}
|
59
|
-
|
60
|
+
SDL_GetColorKey(img, &key);
|
61
|
+
if(sge_GetPixel(img, Sint16(x),Sint16(y))!=key){
|
60
62
|
*map=*map|sge_mask[i];
|
61
63
|
}
|
62
64
|
i++;
|
data/ext/sdl/sge/sge_config.h
CHANGED
data/ext/sdl/sge/sge_internal.h
CHANGED
@@ -2514,14 +2514,3 @@ void sge_AABezier(SDL_Surface *surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16
|
|
2514
2514
|
sge_AABezierAlpha(surface,x1,y1,x2,y2,x3,y3,x4,y4,level, SDL_MapRGB(surface->format,R,G,B),255);
|
2515
2515
|
}
|
2516
2516
|
|
2517
|
-
//==================================================================================
|
2518
|
-
// Added by zenspider:
|
2519
|
-
//==================================================================================
|
2520
|
-
|
2521
|
-
void sge_FastFilledRect(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color) {
|
2522
|
-
for (Sint16 y = y1; y <= y2; y++) {
|
2523
|
-
_HLine(Surface, x1, x2, y, color);
|
2524
|
-
}
|
2525
|
-
|
2526
|
-
sge_UpdateRect(Surface, x1, y1, x2, y2);
|
2527
|
-
}
|
@@ -105,9 +105,6 @@ DECLSPEC void sge_Bezier(SDL_Surface *surface, Sint16 x1, Sint16 y1, Sint16 x2,
|
|
105
105
|
DECLSPEC void sge_BezierAlpha(SDL_Surface *surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,Sint16 x3, Sint16 y3, Sint16 x4, Sint16 y4, int level, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha);
|
106
106
|
DECLSPEC void sge_AABezier(SDL_Surface *surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,Sint16 x3, Sint16 y3, Sint16 x4, Sint16 y4, int level, Uint8 R, Uint8 G, Uint8 B);
|
107
107
|
DECLSPEC void sge_AABezierAlpha(SDL_Surface *surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,Sint16 x3, Sint16 y3, Sint16 x4, Sint16 y4, int level, Uint8 R, Uint8 G, Uint8 B, Uint8 alpha);
|
108
|
-
|
109
|
-
// Added by zenspider
|
110
|
-
DECLSPEC void sge_FastFilledRect(SDL_Surface *Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
111
108
|
#endif /* sge_C_ONLY */
|
112
109
|
|
113
110
|
|
@@ -645,7 +645,7 @@ SDL_Surface *sge_rotate_scaled_surface(SDL_Surface *src, int angle, double scale
|
|
645
645
|
|
646
646
|
/* Create the destination surface*/
|
647
647
|
int max = int( sqrt( (src->h*src->h/2 + src->w*src->w/2) *scale + 1 ) );
|
648
|
-
dest=
|
648
|
+
dest=SDL_CreateRGBSurface(SDL_SWSURFACE, max, max, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask );
|
649
649
|
if(!dest){SDL_SetError("SGE - Out of memory");return NULL;}
|
650
650
|
sge_ClearSurface(dest,bcol);
|
651
651
|
|
data/ext/sdl/sge/sge_shape.cpp
CHANGED
@@ -27,6 +27,11 @@
|
|
27
27
|
|
28
28
|
using namespace std;
|
29
29
|
|
30
|
+
template <typename T>
|
31
|
+
T absDiff(T a, T b)
|
32
|
+
{
|
33
|
+
return (a > b) ? (a - b) : (b - a);
|
34
|
+
}
|
30
35
|
|
31
36
|
sge_screen *the_screen=NULL; //The pointer to the active screen class (or NULL)
|
32
37
|
|
@@ -37,10 +42,12 @@ sge_screen::sge_screen(SDL_Surface *screen)
|
|
37
42
|
{
|
38
43
|
sge_screen::screen=screen; //Our screen pointer
|
39
44
|
|
40
|
-
|
45
|
+
SDL_assert(0 && "sge_screen");
|
46
|
+
/* Test some flags
|
41
47
|
HW=(((screen->flags) & SDL_HWSURFACE) != 0);
|
42
48
|
DB=(((screen->flags) & SDL_DOUBLEBUF) != 0);
|
43
49
|
FS=(((screen->flags) & SDL_FULLSCREEN) != 0);
|
50
|
+
*/
|
44
51
|
|
45
52
|
/* Test the resolution of SDL_Delay() */
|
46
53
|
//sge_CalibrateDelay();
|
@@ -144,14 +151,16 @@ void sge_screen::update(void)
|
|
144
151
|
r[j++]=*i;
|
145
152
|
}
|
146
153
|
|
147
|
-
|
154
|
+
SDL_assert(0 && "sge_screen::update");
|
155
|
+
//SDL_UpdateRects(screen,rects.size(), r); //Let SDL update the rectangles
|
148
156
|
|
149
157
|
delete[] r;
|
150
158
|
|
151
159
|
rects.clear(); //Empty the list
|
152
160
|
}
|
153
161
|
else if(DB) //double-buffered
|
154
|
-
|
162
|
+
SDL_assert(0 && "sge_screen::update");
|
163
|
+
//SDL_Flip(screen);
|
155
164
|
}
|
156
165
|
|
157
166
|
|
@@ -214,14 +223,14 @@ int sge_surface::get_warp(SDL_Rect rec, SDL_Rect &r1, SDL_Rect &r2, SDL_Rect &r3
|
|
214
223
|
if(rec.x<border.x){
|
215
224
|
r1.w = border.x - rec.x;
|
216
225
|
r1.x = border.x + border.w - r1.w;
|
217
|
-
r2.w =
|
226
|
+
r2.w = absDiff(rec.w, r1.w); //SDL_Rect w/h is unsigned
|
218
227
|
r2.x = border.x;
|
219
228
|
rects=2;
|
220
229
|
}else if(rec.x+rec.w > border.x + border.w){
|
221
230
|
r1.x = rec.x;
|
222
231
|
r1.w = border.x + border.w - rec.x;
|
223
232
|
r2.x = border.x;
|
224
|
-
r2.w =
|
233
|
+
r2.w = absDiff(rec.w, r1.w);
|
225
234
|
rects=2;
|
226
235
|
}
|
227
236
|
|
@@ -232,13 +241,13 @@ int sge_surface::get_warp(SDL_Rect rec, SDL_Rect &r1, SDL_Rect &r2, SDL_Rect &r3
|
|
232
241
|
if(rects==0){
|
233
242
|
r1.h = border.y - rec.y;
|
234
243
|
r1.y = border.y + border.h - r1.h;
|
235
|
-
r2.h =
|
244
|
+
r2.h = absDiff(rec.h, r1.h);
|
236
245
|
r2.y = border.y;
|
237
246
|
rects=2;
|
238
247
|
}else{
|
239
248
|
r2.h = r1.h= border.y - rec.y;
|
240
249
|
r2.y = r1.y= border.y + border.h - r1.h;
|
241
|
-
r4.h = r3.h=
|
250
|
+
r4.h = r3.h= absDiff(rec.h, r1.h);
|
242
251
|
r4.y = r3.y= border.y;
|
243
252
|
rects=4;
|
244
253
|
}
|
@@ -247,13 +256,13 @@ int sge_surface::get_warp(SDL_Rect rec, SDL_Rect &r1, SDL_Rect &r2, SDL_Rect &r3
|
|
247
256
|
r1.y = rec.y;
|
248
257
|
r1.h = border.y + border.h - rec.y;
|
249
258
|
r2.y = border.y;
|
250
|
-
r2.h =
|
259
|
+
r2.h = absDiff(rec.h, r1.h);
|
251
260
|
rects=2;
|
252
261
|
}else{
|
253
262
|
r2.y = r1.y = rec.y;
|
254
263
|
r2.h = r1.h = border.y + border.h - rec.y;
|
255
264
|
r4.y = r3.y = border.y;
|
256
|
-
r4.h = r3.h =
|
265
|
+
r4.h = r3.h = absDiff(rec.h, r1.h);
|
257
266
|
rects=4;
|
258
267
|
}
|
259
268
|
}
|
data/ext/sdl/sge/sge_surface.cpp
CHANGED
@@ -87,6 +87,8 @@ Uint8 sge_getLock(void)
|
|
87
87
|
//==================================================================================
|
88
88
|
void sge_UpdateRect(SDL_Surface *screen, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
|
89
89
|
{
|
90
|
+
SDL_assert(0 && "sge_UpdateRect");
|
91
|
+
/*
|
90
92
|
if(_sge_update!=1 || screen != SDL_GetVideoSurface()){return;}
|
91
93
|
|
92
94
|
if(x>=screen->w || y>=screen->h){return;}
|
@@ -103,6 +105,7 @@ void sge_UpdateRect(SDL_Surface *screen, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
|
|
103
105
|
if(b+y > screen->h){b=screen->h-y;}
|
104
106
|
|
105
107
|
SDL_UpdateRect(screen,x,y,a,b);
|
108
|
+
*/
|
106
109
|
}
|
107
110
|
|
108
111
|
|
@@ -592,8 +595,11 @@ void sge_ClearSurface(SDL_Surface *Surface, Uint32 color)
|
|
592
595
|
|
593
596
|
SDL_FillRect(Surface,NULL, color);
|
594
597
|
|
598
|
+
SDL_assert(0 && "sge_ClearSurface");
|
599
|
+
/*
|
595
600
|
if(_sge_update!=1){return;}
|
596
601
|
SDL_UpdateRect(Surface, 0,0,0,0);
|
602
|
+
*/
|
597
603
|
}
|
598
604
|
|
599
605
|
|
@@ -659,10 +665,10 @@ int sge_BlitTransparent(SDL_Surface *Src, SDL_Surface *Dest, Sint16 SrcX, Sint16
|
|
659
665
|
#endif
|
660
666
|
|
661
667
|
/* Set the color to be transparent */
|
662
|
-
SDL_SetColorKey(Src,
|
668
|
+
SDL_SetColorKey(Src, SDL_TRUE, Clear);
|
663
669
|
|
664
670
|
/* Set the alpha value */
|
665
|
-
|
671
|
+
SDL_SetSurfaceAlphaMod(Src, Alpha);
|
666
672
|
|
667
673
|
/* Blit */
|
668
674
|
ret=SDL_BlitSurface(Src, &src, Dest, &dest);
|
@@ -676,8 +682,8 @@ int sge_BlitTransparent(SDL_Surface *Src, SDL_Surface *Dest, Sint16 SrcX, Sint16
|
|
676
682
|
#endif
|
677
683
|
|
678
684
|
/* Set normal levels */
|
679
|
-
|
680
|
-
SDL_SetColorKey(Src,
|
685
|
+
SDL_SetSurfaceAlphaMod(Src,0);
|
686
|
+
SDL_SetColorKey(Src,SDL_TRUE,0);
|
681
687
|
|
682
688
|
return ret;
|
683
689
|
}
|
data/ext/sdl/sge/sge_textpp.cpp
CHANGED
@@ -310,8 +310,10 @@ bool sge_TextEditor::check(SDL_Event* event)
|
|
310
310
|
return move_start();
|
311
311
|
else if(event->key.keysym.sym==SDLK_END)
|
312
312
|
return move_end();
|
313
|
+
/*
|
313
314
|
else if(event->key.keysym.unicode!=0)
|
314
315
|
return insert(event->key.keysym.unicode);
|
316
|
+
*/
|
315
317
|
|
316
318
|
return false;
|
317
319
|
}
|
@@ -415,10 +417,10 @@ bool sge_text::update_textSurface(bool force)
|
|
415
417
|
if(!text_surface)
|
416
418
|
return false;
|
417
419
|
|
418
|
-
SDL_SetColorKey(text_surface,
|
420
|
+
SDL_SetColorKey(text_surface,SDL_TRUE,SDL_MapRGB(text_surface->format,background.r,background.g,background.b));
|
419
421
|
|
420
422
|
if( alpha_level != SDL_ALPHA_OPAQUE )
|
421
|
-
|
423
|
+
SDL_SetSurfaceAlphaMod(text_surface, alpha_level);
|
422
424
|
|
423
425
|
set_textSurface(text_surface);
|
424
426
|
}else
|
@@ -453,7 +455,7 @@ bool sge_text::update_textSurface(bool force)
|
|
453
455
|
c[1].r=bm_font->FontSurface->format->palette->colors[1].r;
|
454
456
|
c[1].g=bm_font->FontSurface->format->palette->colors[1].g;
|
455
457
|
c[1].b=bm_font->FontSurface->format->palette->colors[1].b;
|
456
|
-
|
458
|
+
SDL_SetPaletteColors(text_surface->format->palette, c, 0, 2);
|
457
459
|
bcol = 0;
|
458
460
|
}else{
|
459
461
|
//Use the same background color as the font surface
|
@@ -465,10 +467,10 @@ bool sge_text::update_textSurface(bool force)
|
|
465
467
|
|
466
468
|
sge_BF_textout(text_surface, bm_font, (char*)(text.c_str()), 0, 0);
|
467
469
|
|
468
|
-
SDL_SetColorKey(text_surface,
|
470
|
+
SDL_SetColorKey(text_surface,SDL_TRUE, bcol);
|
469
471
|
|
470
472
|
if( alpha_level != SDL_ALPHA_OPAQUE )
|
471
|
-
|
473
|
+
SDL_SetSurfaceAlphaMod(text_surface, alpha_level);
|
472
474
|
|
473
475
|
set_textSurface(text_surface);
|
474
476
|
}else
|
@@ -519,9 +521,9 @@ SDL_Rect sge_text::render_text(SDL_Surface *surface, Sint16 x, Sint16 y)
|
|
519
521
|
if(!tmp)
|
520
522
|
return ret;
|
521
523
|
|
522
|
-
SDL_SetColorKey(tmp,
|
524
|
+
SDL_SetColorKey(tmp,SDL_TRUE,SDL_MapRGB(tmp->format,background.r,background.g,background.b));
|
523
525
|
if( alpha_level != SDL_ALPHA_OPAQUE )
|
524
|
-
|
526
|
+
SDL_SetSurfaceAlphaMod(tmp, alpha_level);
|
525
527
|
|
526
528
|
sge_Blit(tmp, surface, 0, 0, x, y, tmp->w, tmp->h);
|
527
529
|
ret.x=x; ret.y=y; ret.w=tmp->w; ret.h=tmp->h;
|
@@ -534,7 +536,7 @@ SDL_Rect sge_text::render_text(SDL_Surface *surface, Sint16 x, Sint16 y)
|
|
534
536
|
string text=get_string(sCursor);
|
535
537
|
|
536
538
|
if( alpha_level != SDL_ALPHA_OPAQUE && !bm_font->FontSurface->format->Amask)
|
537
|
-
|
539
|
+
SDL_SetSurfaceAlphaMod(bm_font->FontSurface, alpha_level);
|
538
540
|
|
539
541
|
return sge_BF_textout(surface, bm_font, (char*)(text.c_str()), x, y);
|
540
542
|
}else{
|
@@ -705,17 +707,19 @@ int sge_text_input(sge_TextSurface *tc, Uint8 flags)
|
|
705
707
|
bool is_ttf = tc->get_bg(&bg); /* No bc color indicates bitmap font */
|
706
708
|
|
707
709
|
if( flags&SGE_FLAG1 || !is_ttf ){ /* Keep background? */
|
708
|
-
|
710
|
+
SDL_assert(0 && "sge_text_input");
|
711
|
+
//buffer = SDL_DisplayFormat(screen);
|
709
712
|
if(buffer==NULL){
|
710
713
|
SDL_SetError("SGE - Out of memory");return -3;
|
711
714
|
}
|
712
715
|
}
|
713
716
|
|
714
717
|
/* Enable keyrepeat */
|
715
|
-
if(!(flags&SGE_FLAG3))
|
716
|
-
|
718
|
+
//if(!(flags&SGE_FLAG3))
|
719
|
+
// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL+50);
|
717
720
|
|
718
|
-
|
721
|
+
SDL_assert(0 && "sge_text_input");
|
722
|
+
//int uflag = SDL_EnableUNICODE(1);
|
719
723
|
|
720
724
|
Sint16 x = tc->get_xpos();
|
721
725
|
Sint16 y = tc->get_ypos();
|
@@ -773,7 +777,7 @@ int sge_text_input(sge_TextSurface *tc, Uint8 flags)
|
|
773
777
|
|
774
778
|
_sge_update = update;
|
775
779
|
|
776
|
-
SDL_EnableUNICODE(uflag); //Restore unicode setting
|
780
|
+
//SDL_EnableUNICODE(uflag); //Restore unicode setting
|
777
781
|
|
778
782
|
if( quit < 0 )
|
779
783
|
return quit;
|