[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video cursor.c linedraw.c
From: |
Nehal Mistry |
Subject: |
[Stratagus-CVS] stratagus/src/video cursor.c linedraw.c |
Date: |
Mon, 17 Nov 2003 15:33:20 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Nehal Mistry <address@hidden> 03/11/17 15:33:19
Modified files:
src/video : cursor.c linedraw.c
Log message:
implemented VideoDrawPixel VideoDrawRectangle VideoDrawRectangleClip
VideoFillRectangle VideoFillRectangleClip
Patches:
Index: stratagus/src/video/cursor.c
diff -u stratagus/src/video/cursor.c:1.77 stratagus/src/video/cursor.c:1.78
--- stratagus/src/video/cursor.c:1.77 Mon Nov 17 14:14:44 2003
+++ stratagus/src/video/cursor.c Mon Nov 17 15:33:17 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: cursor.c,v 1.77 2003/11/17 19:14:44 nehalmistry Exp $
+// $Id: cursor.c,v 1.78 2003/11/17 20:33:17 nehalmistry Exp $
//@{
@@ -516,6 +516,8 @@
SDL_Rect drect;
SDL_Rect srect;
+ printf("call LOAD\n");
+
srect.x = 0;
srect.y = 0;
srect.w = w;
@@ -524,7 +526,8 @@
drect.x = x;
drect.y = y;
- SDL_BlitSurface(OldCursorImage, NULL, TheScreen, &drect);
+ SDL_BlitSurface(OldCursorImage, &srect, TheScreen, &drect);
+ InvalidateArea(x, y, w, h);
}
local void SaveCursorBackground(int x, int y, int w, int h)
@@ -532,15 +535,16 @@
SDL_Rect srect;
SDL_Rect drect;
- srect.x = 0;
- srect.y = 0;
+ printf("call SAVE\n");
+ srect.x = x;
+ srect.y = y;
srect.w = w;
srect.h = h;
- drect.x = x;
- drect.y = y;
+ drect.x = 0;
+ drect.y = 0;
- SDL_BlitSurface(TheScreen, &srect, OldCursorImage, NULL);
+ SDL_BlitSurface(TheScreen, &srect, OldCursorImage, &drect);
}
#else
/**
@@ -1242,7 +1246,7 @@
int i;
CLprintf(file, "\n;;; -----------------------------------------\n");
- CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.77 2003/11/17
19:14:44 nehalmistry Exp $\n\n");
+ CLprintf(file, ";;; MODULE: cursors $Id: cursor.c,v 1.78 2003/11/17
20:33:17 nehalmistry Exp $\n\n");
for (i = 0; Cursors[i].OType; ++i) {
CLprintf(file, "(define-cursor '%s '%s\n",
Index: stratagus/src/video/linedraw.c
diff -u stratagus/src/video/linedraw.c:1.40 stratagus/src/video/linedraw.c:1.41
--- stratagus/src/video/linedraw.c:1.40 Mon Nov 17 14:14:46 2003
+++ stratagus/src/video/linedraw.c Mon Nov 17 15:33:17 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: linedraw.c,v 1.40 2003/11/17 19:14:46 nehalmistry Exp $
+// $Id: linedraw.c,v 1.41 2003/11/17 20:33:17 nehalmistry Exp $
//@{
@@ -37,12 +37,14 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "stratagus.h"
#include "video.h"
#include "intern_video.h"
+
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
@@ -452,8 +454,19 @@
global void VideoDrawPixel(SDL_Color color, int x, int y)
{
- DebugCheck(1);
+ 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);
}
+
global void VideoDrawTransPixel(SDL_Color color, int x, int y, unsigned char
alpha)
{
DebugCheck(1);
@@ -505,53 +518,44 @@
{
DebugCheck(1);
}
+
global void VideoDrawRectangle(SDL_Color color, int x, int y,
int w, int h)
{
- DebugCheck(1);
+ int i;
+
+ // FIXME: should be able to optimize this
+
+ 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);
+
+ }
}
+
global void VideoDrawRectangleClip(SDL_Color color, int x, int y,
int w, int h)
{
-/*
int i;
-// int j;
-// int bpp;
- Uint32 c;
- SDL_Rect drect;
- SDL_Surface* rec;
+ // FIXME: should be able to optimize this
+ // FIXME: do clipping
- rec = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMASK, GMASK, BMASK,
AMASK);
- c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
-
- SDL_LockSurface(rec);
- for (i = 0; i < w; ++i) {
-// ((Uint32*)(rec->pixels))[(x + i)] = c;
-// ((Uint32*)(rec->pixels))[(x + i) + (y) * rec->w] = c;
+ for (i = 0; i <= w; ++i) {
+ VideoDrawPixel(color, x + i, y);
+ VideoDrawPixel(color, x + i, y + h);
}
- SDL_UnlockSurface(rec);
- drect.x = x;
- drect.y = y;
+ for (i = 1; i < h; ++i) {
+ VideoDrawPixel(color, x, y + i);
+ VideoDrawPixel(color, x + w, y + i);
- SDL_BlitSurface(rec, NULL, TheScreen, &drect);
-// SDL_FreeSurface(rec);
-*/
-/*
- c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
- bpp = TheScreen->format->BytesPerPixel;
-*/
-/*
- for (i = 0; i < h; ++i) {
- // FIXME: why w*2?
- for (j = 0; j < w*2; ++j) {
- ((char*)(TheScreen->pixels))[(x + j) + (y + i) * TheScreen->pitch]
=
- c;
- }
}
-*/
-// Invalidate();
}
global void VideoDrawTransRectangle(SDL_Color color, int x, int y,
@@ -563,8 +567,6 @@
global void VideoFillRectangle(SDL_Color color, int x, int y,
int w, int h)
{
-// int i;
-// int j;
SDL_Rect drect;
Uint32 c = SDL_MapRGB(TheScreen->format, color.r, color.g, color.b);
@@ -574,27 +576,22 @@
drect.h = h;
SDL_FillRect(TheScreen, &drect, c);
-/*
- VideoLockScreen();
-
- for (i = 0; i < h; ++i) {
- // FIXME: why w*2?
- for (j = 0; j < w*2; ++j) {
- ((char*)(TheScreen->pixels))[(x + j) + (y + i) * TheScreen->pitch]
=
- c;
-//c = 0;
- }
- }
-
- VideoUnlockScreen();
- Invalidate();
-*/
}
global void VideoFillTransRectangle(SDL_Color color, int x, int y,
int w, int h, unsigned char alpha)
{
- DebugCheck(1);
+ // 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);
}
global void VideoFillRectangleClip(SDL_Color color, int x, int y,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/video cursor.c linedraw.c,
Nehal Mistry <=