www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/19/01:32:55

From: "Roy Taylor" <rtaylor AT nextsteps DOT com>
To: <djgpp AT delorie DOT com>
Subject: Odd problem...
Date: Wed, 19 May 1999 00:31:36 -0500
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1162
MIME-Version: 1.0
Message-ID: <19990519053901232.AAA56.87@mike-s-toy>
Reply-To: djgpp AT delorie DOT com

I have run into a tricky problem while writing a polygon draw function.  It
seems to work fine in real mode under my MS compiler (but that won't cut it
in realtime graphics anymore...).  I am porting the code over, and I see
this bizarre bug bite me.  When I run the following code on my old
compiler, I get an output of "Point 0=(160,40)".  Simple enough.  But when
I compile in DJGPP, I get random ints popping up, usually not zero, but
rarely the same one twice.  If it is not too much trouble, could you try to
see any leaks in the code?  Thank you very much for your time and for
making the coolest compiler out today.


                                      Mike Taylor


typedef struct PointType
{
    int x,y;
} Point,*pPoint;

typedef struct HLineListType
{
    char Color;
    int YStart;
    int YEnd;
    int Start[200];
    int End[200];
} HLineList, *pHLineList;

typedef struct PolygonType
{
    pPoint Vert[10];
    char Color;
    char NumVerts;
}  Polygon, *pPolygon;

void DrawPoly(pPolygon Poly,pHLineList ClipList)
{
    printf("Point 0=(%i,%i)\n",Poly->Vert[0]->x,Poly->Vert[0]->y);
}

int main(void)
{
    int i;
    Polygon Hex;
    HLineList ScreenClip;
    Point p[6];
    p[0].x=160;p[0].y=40;
    Hex.Vert[0]=(pPoint)&p[0];
    Hex.NumVerts=6;Hex.Color=2;
    ScreenClip.YStart=0;ScreenClip.YEnd=200;
    for(i=0;i<=200;i++)
    {
        ScreenClip.Start[i]=0;ScreenClip.End[i]=320;
    }
    DrawPoly((pPolygon)&Hex,(pHLineList)&ScreenClip);
    return(0);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019