[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video linedraw.c sprite.c
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src/video linedraw.c sprite.c |
Date: |
Thu, 20 Nov 2003 20:26:11 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/20 20:26:11
Modified files:
src/video : linedraw.c sprite.c
Log message:
fix clipping stuff
Patches:
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.44 stratagus/src/video/linedraw.c:1.45
--- stratagus/src/video/linedraw.c:1.44 Tue Nov 18 17:34:41 2003
+++ stratagus/src/video/linedraw.c Thu Nov 20 20:26:11 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: linedraw.c,v 1.44 2003/11/18 22:34:41 nehalmistry Exp $
+// $Id: linedraw.c,v 1.45 2003/11/21 01:26:11 nehalmistry Exp $
//@{
@@ -470,6 +470,8 @@
global void VideoDrawTransPixel(SDL_Color color, int x, int y, unsigned char
alpha)
{
+ // FIXME: trans?
+
int bpp;
int ofs;
unsigned int c;
@@ -485,17 +487,10 @@
global void VideoDrawPixelClip(SDL_Color color, int x, int y)
{
- int bpp;
- int ofs;
- unsigned int c;
-
- c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
- bpp = TheScreen->format->BytesPerPixel;
- ofs = TheScreen->pitch * y + x * bpp;
-
- SDL_LockSurface(TheScreen);
- memcpy(TheScreen->pixels + ofs, &c, bpp);
- SDL_UnlockSurface(TheScreen);
+ int w = 1;
+ int h = 1;
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoDrawPixel(color, x, y);
}
global void VideoDrawVLine(SDL_Color color, int x, int y, int height)
@@ -510,6 +505,7 @@
global void VideoDrawTransVLine(SDL_Color color, int x, int y,
int height, unsigned char alpha)
{
+ // FIXME: trans
int i;
for (i = 0; i < height; ++i) {
@@ -519,11 +515,9 @@
global void VideoDrawVLineClip(SDL_Color color, int x, int y, int height)
{
- int i;
-
- for (i = 0; i < height; ++i) {
- VideoDrawPixel(color, x, y + i);
- }
+ int w = 1;
+ CLIP_RECTANGLE(x, y, w, height);
+ VideoDrawVLine(color, x, y, height);
}
global void VideoDrawHLine(SDL_Color color, int x, int y, int width)
@@ -537,16 +531,15 @@
global void VideoDrawHLineClip(SDL_Color color, int x, int y, int width)
{
- int i;
-
- for (i = 0; i < width; ++i) {
- VideoDrawPixel(color, x + i, y);
- }
+ int h = 1;
+ CLIP_RECTANGLE(x, y, width, h);
+ VideoDrawHLine(color, x, y, width);
}
global void VideoDrawTransHLine(SDL_Color color, int x, int y,
int width, unsigned char alpha)
{
+ // FIXME: trans
int i;
for (i = 0; i < width; ++i) {
@@ -657,14 +650,43 @@
global void VideoDrawLineClip(SDL_Color color, int sx, int sy, int dx, int dy)
{
- // FIXME:
+ int w;
+ int h;
+
+ // FIXME: messy
+ if (dx > sx && dy > sy) {
+ w = dx - sx;
+ h = dy - sy;
+ CLIP_RECTANGLE(sx, sy, w, h);
+ dx = sx + w;
+ dy = sy + h;
+ } else if (dx > sx && dy < sy) {
+ w = dx - sx;
+ h = sy - dy;
+ CLIP_RECTANGLE(sx, dy, w, h);
+ dx = sx + w;
+ sy = dy + h;
+ } else if (dx < sx && dy > sy) {
+ w = sx - dx;
+ h = dy - sy;
+ CLIP_RECTANGLE(dx, sy, w, h);
+ sx = dx + w;
+ dy = sy + h;
+ } else if (dx < sx && dy < sy) {
+ w = sx - dx;
+ h = sy - dy;
+ CLIP_RECTANGLE(dx, dy, w, h);
+ sx = dx + w;
+ sy = dy + h;
+ }
+
VideoDrawLine(color, sx, sy, dx, dy);
}
global void VideoDrawTransLine(SDL_Color color, int sx, int sy,
int dx, int dy, unsigned char alpha)
{
- // FIXME:
+ // FIXME: trans
VideoDrawLine(color, sx, sy, dx, dy);
}
@@ -689,20 +711,8 @@
global void VideoDrawRectangleClip(SDL_Color color, int x, int y,
int w, int h)
{
- int i;
-
- // FIXME: should be able to optimize this
- // FIXME: do clipping
-
- for (i = 0; i <= w; ++i) {
- VideoDrawPixel(color, x + i, y);
- VideoDrawPixel(color, x + i, y + h);
- }
-
- for (i = 1; i < h; ++i) {
- VideoDrawPixel(color, x, y + i);
- VideoDrawPixel(color, x + w, y + i);
- }
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoDrawRectangle(color, x, y, w, h);
}
global void VideoDrawTransRectangle(SDL_Color color, int x, int y,
@@ -758,23 +768,16 @@
global void VideoFillRectangleClip(SDL_Color color, int x, int y,
int w, int h)
{
- // FIXME: do clipping
-
- SDL_Rect drect;
- Uint32 c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
-
- drect.x = x;
- drect.y = y;
- drect.w = w;
- drect.h = h;
-
- SDL_FillRect(TheScreen, &drect, c);
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoFillRectangle(color, x, y, w, h);
}
global void VideoFillTransRectangleClip(SDL_Color color, int x, int y,
int w, int h, unsigned char alpha)
{
-// DebugCheck(1);
+ // FIXME: trans
+ CLIP_RECTANGLE(x, y, w, h);
+ VideoFillRectangle(color, x, y, w, h);
}
global void VideoDrawCircleClip(SDL_Color color, int x, int y,
Index: stratagus/src/video/sprite.c
diff -u stratagus/src/video/sprite.c:1.41 stratagus/src/video/sprite.c:1.42
--- stratagus/src/video/sprite.c:1.41 Thu Nov 20 01:43:42 2003
+++ stratagus/src/video/sprite.c Thu Nov 20 20:26:11 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sprite.c,v 1.41 2003/11/20 06:43:42 nehalmistry Exp $
+// $Id: sprite.c,v 1.42 2003/11/21 01:26:11 nehalmistry Exp $
//@{
@@ -489,21 +489,10 @@
srect.x = (frame % (sprite->Surface->w / sprite->Width)) * sprite->Width;
srect.y = (frame / (sprite->Surface->w / sprite->Width)) * sprite->Height;
srect.w = sprite->Width;
+
srect.h = sprite->Height;
- // FIXME: is this right?
- if (x + srect.w > ClipX2) {
- srect.w = ClipX2 - x;
- }
- if (y + srect.h > ClipY2) {
- srect.h = ClipY2 - y;
- }
- if (x < ClipX1) {
- x = ClipX1;
- }
- if (y < ClipY1) {
- y = ClipY1;
- }
+ CLIP_RECTANGLE(x, y, srect.w, srect.h);
drect.x = x;
drect.y = y;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/video linedraw.c sprite.c,
Nehal Mistry <=