From e7595adabac15fd3a523327bf8c42655f989f9c2 Mon Sep 17 00:00:00 2001 From: pixel Date: Mon, 19 May 2003 18:17:55 +0000 Subject: EOD --- lib/shape.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'lib') 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); } -- cgit v1.2.3