Update of /cvsroot/super-tux/supertux/lib/video
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31982/lib/video
Modified Files:
drawing_context.cpp drawing_context.h
Log Message:
Added an alpha parameter for transformation and got rid of ugly alpha draw_font() parameter.
Index: drawing_context.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- drawing_context.cpp 24 Sep 2004 15:07:22 -0000 1.7
+++ drawing_context.cpp 24 Sep 2004 18:00:39 -0000 1.8
@@ -31,6 +31,7 @@
{
transform.draw_effect = NONE_EFFECT;
transform.zoom = 1;
+transform.alpha = 255;
}
DrawingContext::~DrawingContext()
@@ -52,6 +53,7 @@
request.drawing_effect = drawing_effect;
request.drawing_effect = transform.draw_effect | drawing_effect;
request.zoom = transform.zoom;
+ request.alpha = transform.alpha;
drawingrequests.push_back(request);
}
@@ -68,6 +70,7 @@
request.layer = layer;
request.pos = transform.apply(dest);
request.drawing_effect = drawing_effect;
+ request.alpha = transform.alpha;
SurfacePartRequest* surfacepartrequest = new SurfacePartRequest();
surfacepartrequest->size = size;
@@ -81,7 +84,7 @@
void
DrawingContext::draw_text(Font* font, const std::string& text,
const Vector& position, int allignment, int layer,
- Uint32 drawing_effect, int alpha)
+ Uint32 drawing_effect)
{
DrawingRequest request;
@@ -89,12 +92,12 @@
request.layer = layer;
request.pos = transform.apply(position);
request.drawing_effect = drawing_effect;
+ request.alpha = transform.alpha;
TextRequest* textrequest = new TextRequest;
textrequest->font = font;
textrequest->text = text;
textrequest->allignment = allignment;
- textrequest->alpha = alpha;
request.request_data = textrequest;
drawingrequests.push_back(request);
@@ -144,7 +147,7 @@
surfacepartrequest->surface->impl->draw_part(
surfacepartrequest->source.x, surfacepartrequest->source.y,
request.pos.x, request.pos.y,
- surfacepartrequest->size.x, surfacepartrequest->size.y, 255,
+ surfacepartrequest->size.x, surfacepartrequest->size.y, request.alpha,
request.drawing_effect);
delete surfacepartrequest;
@@ -201,7 +204,7 @@
{
TextRequest* textrequest = (TextRequest*) request.request_data;
- textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, textrequest->alpha);
+ textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, request.alpha);
delete textrequest;
}
@@ -295,9 +298,9 @@
if(i->zoom != 1.0)
surface->impl->draw_stretched(i->pos.x * i->zoom, i->pos.y * i->zoom,
(int)(surface->w * i->zoom), (int)(surface->h * i->zoom),
- 255, i->drawing_effect);
+ i->alpha, i->drawing_effect);
else
- surface->impl->draw(i->pos.x, i->pos.y, 255, i->drawing_effect);
+ surface->impl->draw(i->pos.x, i->pos.y, i->alpha, i->drawing_effect);
break;
}
case SURFACE_PART:
@@ -350,3 +353,9 @@
{
transform.zoom = zoom;
}
+
+void
+DrawingContext::set_alpha(int alpha)
+{
+ transform.alpha = alpha;
+}
Index: drawing_context.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- drawing_context.h 24 Sep 2004 15:07:22 -0000 1.8
+++ drawing_context.h 24 Sep 2004 18:00:46 -0000 1.9
@@ -68,7 +68,7 @@
/// Draws a text.
void draw_text(Font* font, const std::string& text, const Vector& position,
int allignment, int layer,
- Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
+ Uint32 drawing_effect = NONE_EFFECT);
/// Draws a color gradient onto the whole screen */
void draw_gradient(Color from, Color to, int layer);
/// Fills a rectangle.
@@ -93,6 +93,8 @@
void set_drawing_effect(int effect);
/// apply that zoom in the next draws */
void set_zooming(float zoom);
+ /// apply that alpha in the next draws */
+ void set_alpha(int alpha);
private:
class Transform
@@ -107,6 +109,7 @@
Uint32 draw_effect;
float zoom;
+ int alpha;
};
/// the transform stack
@@ -130,7 +133,6 @@
Font* font;
std::string text;
int allignment;
- int alpha;
};
struct GradientRequest
@@ -150,6 +152,7 @@
int layer;
Uint32 drawing_effect;
float zoom;
+ int alpha;
RequestType type;
Vector pos;
|