summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2003-05-19 18:17:55 +0000
committerpixel <pixel>2003-05-19 18:17:55 +0000
commite7595adabac15fd3a523327bf8c42655f989f9c2 (patch)
treec0b65d51b6a25382848b138a1983f7951324a1fc /lib
parent3dfc16e096855b5e713fb1223511302de218f45a (diff)
EOD
Diffstat (limited to 'lib')
-rw-r--r--lib/shape.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/shape.cc b/lib/shape.cc
index a626155..fcca584 100644
--- a/lib/shape.cc
+++ b/lib/shape.cc
@@ -45,7 +45,8 @@ mogltk::fill::~fill() {
}
void mogltk::fill::walk(fillwalker * w) {
- header->walk(w);
+ if (header)
+ header->walk(w);
}
void mogltk::fill::swalk(segwalker * s) {
@@ -144,8 +145,8 @@ mogltk::texture * mogltk::fill::Talloc() {
int x; int y;
- for (x = 1; x < (maxX - minX); x <<= 1);
- for (y = 1; y < (maxY - minY); y <<= 1);
+ for (x = 1; x <= (maxX - minX); x <<= 1);
+ for (y = 1; y <= (maxY - minY); y <<= 1);
cached = new texture(x, y, true);
return cached;
@@ -157,8 +158,8 @@ mogltk::texture * mogltk::fill::STalloc() {
int x; int y;
- for (x = 1; x < (maxX - minX); x <<= 1);
- for (y = 1; y < (maxY - minY); y <<= 1);
+ for (x = 1; x <= (maxX - minX); x <<= 1);
+ for (y = 1; y <= (maxY - minY); y <<= 1);
scached = new texture(x, y, true);
return scached;
@@ -456,6 +457,7 @@ void mogltk::shape::bsubline_4(int x1, int y1, int x2, int y2, ColorP c) {
void mogltk::shape::line(int x1, int y1, int x2, int y2, ColorP c) {
if ((x1 == x2) && (y1 == y2)) {
+ printm(M_INFO, "Line is a pixel...\n");
pixel(x1, y1, c);
return;
}
@@ -489,6 +491,11 @@ void mogltk::shape::pixel(int x, int y, ColorP c) {
int bpp = surf->format->BytesPerPixel;
Uint8 *p = (Uint8 *)surf->pixels + y * surf->pitch + x * bpp;
Uint32 pixel = c.toSDL(surf->format);
+
+ if ((x < 0) || (y < 0) || (x >= surf->w) || (y >= surf->h)) {
+ printm(M_INFO, "Pixel culling, out of bounds.\n");
+ return;
+ }
switch(bpp) {
case 1:
@@ -621,7 +628,7 @@ void mogltk::filldrawer::step(int x, int y) {
if (oldx == -1) {
oldx = x;
} else {
-// s->hline(oldx, x, y, c);
+/* s->hline(oldx, x, y, c); */
Uint32 * p = t->GetPixels();
int i,
first = t->GetWidth() * (y - f->GetMinY()) + oldx - f->GetMinX(),
@@ -629,6 +636,13 @@ void mogltk::filldrawer::step(int x, int y) {
SDL_PixelFormat * format = t->GetFormat();
for (i = first; i <= last; i++) {
+ if (i > (t->GetWidth() * t->GetHeight())) {
+ printm(M_ERROR, "Big problem here. i = %i and W, H = %i, %i\n", i, t->GetWidth(), t->GetHeight());
+ printm(M_ERROR, "Initially, wanted to draw hline(%i, %i, %i)\n", oldx, x, y);
+ printm(M_ERROR, "With MinX = %i and MinY = %i --> hline(%i, %i, %i)\n", f->GetMinX(), f->GetMinY(), oldx - f->GetMinX(), x - f->GetMinX(), y - f->GetMinY());
+ printm(M_ERROR, "For info, MaxX = %i and MaxY = %i\n", f->GetMaxX(), f->GetMaxY());
+ exit(-1);
+ }
p[i] = c.toSDL(format);
}