Change HTML4 entities to HTML5
< to < > to > & to &
This commit is contained in:
parent
56a4baa60e
commit
b8e7ce7165
105 changed files with 1117 additions and 1117 deletions
128
56-03.html
128
56-03.html
|
|
@ -50,10 +50,10 @@
|
|||
texture mapped onto it */
|
||||
#define DRAW_TEXTURED_POLYGON(PointList,NumPoints,TexVerts,TexMap) \
|
||||
Polygon.Length = NumPoints; Polygon.PointPtr = PointList; \
|
||||
DrawTexturedPolygon(&Polygon, TexVerts, TexMap);
|
||||
#define FIXED_TO_INT(FixedVal) ((int) (FixedVal >> 16))
|
||||
DrawTexturedPolygon(&Polygon, TexVerts, TexMap);
|
||||
#define FIXED_TO_INT(FixedVal) ((int) (FixedVal >> 16))
|
||||
#define ROUND_FIXED_TO_INT(FixedVal) \
|
||||
((int) ((FixedVal + DOUBLE_TO_FIXED(0.5)) >> 16))
|
||||
((int) ((FixedVal + DOUBLE_TO_FIXED(0.5)) >> 16))
|
||||
/* Retrieves specified pixel from specified image bitmap of specified width. */
|
||||
#define GET_IMAGE_PIXEL(TexMapBits, TexMapWidth, X, Y) \
|
||||
TexMapBits[(Y * TexMapWidth) + X]
|
||||
|
|
@ -97,10 +97,10 @@ extern void DrawTexturedPolygon(PointListHeader *, Point *, TextureMap *);
|
|||
“Convex” means that every horizontal line drawn through the polygon at any
|
||||
point would cross exactly two active edges (neither horizontal lines nor
|
||||
zero-length edges count as active edges; both are acceptable anywhere in
|
||||
the polygon), and that the right & left edges never cross. Nonconvex
|
||||
the polygon), and that the right & left edges never cross. Nonconvex
|
||||
polygons won’t be drawn properly. Can’t fail. */
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include “polygon.h”
|
||||
/* Describes the current location and stepping, in both the source and
|
||||
the destination, of an edge */
|
||||
|
|
@ -143,13 +143,13 @@ void DrawTexturedPolygon(PointListHeader * Polygon, Point * TexVerts,
|
|||
{
|
||||
int MinY, MaxY, MinVert, i;
|
||||
EdgeScan LeftEdge, RightEdge;
|
||||
NumVerts = Polygon->Length;
|
||||
VertexPtr = Polygon->PointPtr;
|
||||
NumVerts = Polygon->Length;
|
||||
VertexPtr = Polygon->PointPtr;
|
||||
TexVertsPtr = TexVerts;
|
||||
TexMapBits = TexMap->TexMapBits;
|
||||
TexMapWidth = TexMap->TexMapWidth;
|
||||
TexMapBits = TexMap->TexMapBits;
|
||||
TexMapWidth = TexMap->TexMapWidth;
|
||||
/* Nothing to draw if less than 3 vertices */
|
||||
if (NumVerts < 3) {
|
||||
if (NumVerts < 3) {
|
||||
return;
|
||||
}
|
||||
/* Scan through the destination polygon vertices and find the top of the
|
||||
|
|
@ -158,18 +158,18 @@ void DrawTexturedPolygon(PointListHeader * Polygon, Point * TexVerts,
|
|||
backface removal) */
|
||||
MinY = 32767;
|
||||
MaxY = -32768;
|
||||
for (i=0; i<NumVerts; i++) {
|
||||
if (VertexPtr[i].Y < MinY) {
|
||||
for (i=0; i<NumVerts; i++) {
|
||||
if (VertexPtr[i].Y < MinY) {
|
||||
MinY = VertexPtr[i].Y;
|
||||
MinVert = i;
|
||||
}
|
||||
if (VertexPtr[i].Y > MaxY) {
|
||||
if (VertexPtr[i].Y > MaxY) {
|
||||
MaxY = VertexPtr[i].Y;
|
||||
MaxVert = i;
|
||||
}
|
||||
}
|
||||
/* Reject flat (0-pixel-high) polygons */
|
||||
if (MinY >= MaxY) {
|
||||
if (MinY >= MaxY) {
|
||||
return;
|
||||
}
|
||||
/* The destination Y coordinate is not edge specific; it applies to
|
||||
|
|
@ -180,9 +180,9 @@ void DrawTexturedPolygon(PointListHeader * Polygon, Point * TexVerts,
|
|||
by one in Y, so calculate the corresponding destination X step for
|
||||
each edge, and then the corresponding source image X and Y steps */
|
||||
LeftEdge.Direction = -1; /* set up left edge first */
|
||||
SetUpEdge(&LeftEdge, MinVert);
|
||||
SetUpEdge(&LeftEdge, MinVert);
|
||||
RightEdge.Direction = 1; /* set up right edge */
|
||||
SetUpEdge(&RightEdge, MinVert);
|
||||
SetUpEdge(&RightEdge, MinVert);
|
||||
/* Step down destination edges one scan line at a time. At each scan
|
||||
line, find the corresponding edge points in the source image. Scan
|
||||
between the edge points in the source, drawing the corresponding
|
||||
|
|
@ -192,20 +192,20 @@ void DrawTexturedPolygon(PointListHeader * Polygon, Point * TexVerts,
|
|||
in clockwise order as seen from the viewpoint) */
|
||||
for (;;) {
|
||||
/* Done if off bottom of clip rectangle */
|
||||
if (DestY >= ClipMaxY) {
|
||||
if (DestY >= ClipMaxY) {
|
||||
return;
|
||||
}
|
||||
/* Draw only if inside Y bounds of clip rectangle */
|
||||
if (DestY >= ClipMinY) {
|
||||
if (DestY >= ClipMinY) {
|
||||
/* Draw the scan line between the two current edges */
|
||||
ScanOutLine(&LeftEdge, &RightEdge);
|
||||
ScanOutLine(&LeftEdge, &RightEdge);
|
||||
}
|
||||
/* Advance the source and destination polygon edges, ending if we’ve
|
||||
scanned all the way to the bottom of the polygon */
|
||||
if (!StepEdge(&LeftEdge)) {
|
||||
if (!StepEdge(&LeftEdge)) {
|
||||
break;
|
||||
}
|
||||
if (!StepEdge(&RightEdge)) {
|
||||
if (!StepEdge(&RightEdge)) {
|
||||
break;
|
||||
}
|
||||
DestY++;
|
||||
|
|
@ -218,28 +218,28 @@ int StepEdge(EdgeScan * Edge)
|
|||
{
|
||||
/* Count off the scan line we stepped last time; if this edge is
|
||||
finished, try to start another one */
|
||||
if (--Edge->RemainingScans == 0) {
|
||||
if (--Edge->RemainingScans == 0) {
|
||||
/* Set up the next edge; done if there is no next edge */
|
||||
if (SetUpEdge(Edge, Edge->CurrentEnd) == 0) {
|
||||
if (SetUpEdge(Edge, Edge->CurrentEnd) == 0) {
|
||||
return(0); /* no more edges; done drawing polygon */
|
||||
}
|
||||
return(1); /* all set to draw the new edge */
|
||||
}
|
||||
/* Step the current source edge */
|
||||
Edge->SourceX += Edge->SourceStepX;
|
||||
Edge->SourceY += Edge->SourceStepY;
|
||||
Edge->SourceX += Edge->SourceStepX;
|
||||
Edge->SourceY += Edge->SourceStepY;
|
||||
/* Step dest X with Bresenham-style variables, to get precise dest pixel
|
||||
placement and avoid gaps */
|
||||
Edge->DestX += Edge->DestXIntStep; /* whole pixel step */
|
||||
Edge->DestX += Edge->DestXIntStep; /* whole pixel step */
|
||||
/* Do error term stuff for fractional pixel X step handling */
|
||||
if ((Edge->DestXErrTerm += Edge->DestXAdjUp) > 0) {
|
||||
Edge->DestX += Edge->DestXDirection;
|
||||
Edge->DestXErrTerm -= Edge->DestXAdjDown;
|
||||
if ((Edge->DestXErrTerm += Edge->DestXAdjUp) > 0) {
|
||||
Edge->DestX += Edge->DestXDirection;
|
||||
Edge->DestXErrTerm -= Edge->DestXAdjDown;
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
/* Sets up an edge to be scanned; the edge starts at StartVert and proceeds
|
||||
in direction Edge->Direction through the vertex list. Edge->Direction must
|
||||
in direction Edge->Direction through the vertex list. Edge->Direction must
|
||||
be set prior to call; -1 to scan a left edge (backward through the vertex
|
||||
list), 1 to scan a right edge (forward through the vertex list).
|
||||
Automatically skips over 0-height edges. Returns 1 for success, or 0 if
|
||||
|
|
@ -255,41 +255,41 @@ int SetUpEdge(EdgeScan * Edge, int StartVert)
|
|||
}
|
||||
/* Advance to the next vertex, wrapping if we run off the start or end
|
||||
of the vertex list */
|
||||
NextVert = StartVert + Edge->Direction;
|
||||
if (NextVert >= NumVerts) {
|
||||
NextVert = StartVert + Edge->Direction;
|
||||
if (NextVert >= NumVerts) {
|
||||
NextVert = 0;
|
||||
} else if (NextVert < 0) {
|
||||
} else if (NextVert < 0) {
|
||||
NextVert = NumVerts - 1;
|
||||
}
|
||||
/* Calculate the variables for this edge and done if this is not a
|
||||
zero-height edge */
|
||||
if ((Edge->RemainingScans =
|
||||
if ((Edge->RemainingScans =
|
||||
VertexPtr[NextVert].Y - VertexPtr[StartVert].Y) != 0) {
|
||||
DestYHeight = INT_TO_FIXED(Edge->RemainingScans);
|
||||
Edge->CurrentEnd = NextVert;
|
||||
Edge->SourceX = INT_TO_FIXED(TexVertsPtr[StartVert].X);
|
||||
Edge->SourceY = INT_TO_FIXED(TexVertsPtr[StartVert].Y);
|
||||
Edge->SourceStepX = FixedDiv(INT_TO_FIXED(TexVertsPtr[NextVert].X) -
|
||||
Edge->SourceX, DestYHeight);
|
||||
Edge->SourceStepY = FixedDiv(INT_TO_FIXED(TexVertsPtr[NextVert].Y) -
|
||||
Edge->SourceY, DestYHeight);
|
||||
DestYHeight = INT_TO_FIXED(Edge->RemainingScans);
|
||||
Edge->CurrentEnd = NextVert;
|
||||
Edge->SourceX = INT_TO_FIXED(TexVertsPtr[StartVert].X);
|
||||
Edge->SourceY = INT_TO_FIXED(TexVertsPtr[StartVert].Y);
|
||||
Edge->SourceStepX = FixedDiv(INT_TO_FIXED(TexVertsPtr[NextVert].X) -
|
||||
Edge->SourceX, DestYHeight);
|
||||
Edge->SourceStepY = FixedDiv(INT_TO_FIXED(TexVertsPtr[NextVert].Y) -
|
||||
Edge->SourceY, DestYHeight);
|
||||
/* Set up Bresenham-style variables for dest X stepping */
|
||||
Edge->DestX = VertexPtr[StartVert].X;
|
||||
Edge->DestX = VertexPtr[StartVert].X;
|
||||
if ((DestXWidth =
|
||||
(VertexPtr[NextVert].X - VertexPtr[StartVert].X)) < 0) {
|
||||
(VertexPtr[NextVert].X - VertexPtr[StartVert].X)) < 0) {
|
||||
/* Set up for drawing right to left */
|
||||
Edge->DestXDirection = -1;
|
||||
Edge->DestXDirection = -1;
|
||||
DestXWidth = -DestXWidth;
|
||||
Edge->DestXErrTerm = 1 - Edge->RemainingScans;
|
||||
Edge->DestXIntStep = -(DestXWidth / Edge->RemainingScans);
|
||||
Edge->DestXErrTerm = 1 - Edge->RemainingScans;
|
||||
Edge->DestXIntStep = -(DestXWidth / Edge->RemainingScans);
|
||||
} else {
|
||||
/* Set up for drawing left to right */
|
||||
Edge->DestXDirection = 1;
|
||||
Edge->DestXErrTerm = 0;
|
||||
Edge->DestXIntStep = DestXWidth / Edge->RemainingScans;
|
||||
Edge->DestXDirection = 1;
|
||||
Edge->DestXErrTerm = 0;
|
||||
Edge->DestXIntStep = DestXWidth / Edge->RemainingScans;
|
||||
}
|
||||
Edge->DestXAdjUp = DestXWidth % Edge->RemainingScans;
|
||||
Edge->DestXAdjDown = Edge->RemainingScans;
|
||||
Edge->DestXAdjUp = DestXWidth % Edge->RemainingScans;
|
||||
Edge->DestXAdjDown = Edge->RemainingScans;
|
||||
return(1); /* success */
|
||||
}
|
||||
StartVert = NextVert; /* keep looking for a non-0-height edge */
|
||||
|
|
@ -298,17 +298,17 @@ int SetUpEdge(EdgeScan * Edge, int StartVert)
|
|||
/* Texture-map-draw the scan line between two edges. */
|
||||
void ScanOutLine(EdgeScan * LeftEdge, EdgeScan * RightEdge)
|
||||
{
|
||||
Fixedpoint SourceX = LeftEdge->SourceX;
|
||||
Fixedpoint SourceY = LeftEdge->SourceY;
|
||||
int DestX = LeftEdge->DestX;
|
||||
int DestXMax = RightEdge->DestX;
|
||||
Fixedpoint SourceX = LeftEdge->SourceX;
|
||||
Fixedpoint SourceY = LeftEdge->SourceY;
|
||||
int DestX = LeftEdge->DestX;
|
||||
int DestXMax = RightEdge->DestX;
|
||||
Fixedpoint DestWidth;
|
||||
Fixedpoint SourceXStep, SourceYStep;
|
||||
/* Nothing to do if fully X clipped */
|
||||
if ((DestXMax <= ClipMinX) || (DestX >= ClipMaxX)) {
|
||||
if ((DestXMax <= ClipMinX) || (DestX >= ClipMaxX)) {
|
||||
return;
|
||||
}
|
||||
if ((DestXMax - DestX) <= 0) {
|
||||
if ((DestXMax - DestX) <= 0) {
|
||||
return; /* nothing to draw */
|
||||
}
|
||||
/* Width of destination scan line, for scaling. Note: because this is an
|
||||
|
|
@ -321,21 +321,21 @@ void ScanOutLine(EdgeScan * LeftEdge, EdgeScan * RightEdge)
|
|||
DestWidth = INT_TO_FIXED(DestXMax - DestX);
|
||||
/* Calculate source steps that correspond to each dest X step (across
|
||||
the scan line) */
|
||||
SourceXStep = FixedDiv(RightEdge->SourceX - SourceX, DestWidth);
|
||||
SourceYStep = FixedDiv(RightEdge->SourceY - SourceY, DestWidth);
|
||||
SourceXStep = FixedDiv(RightEdge->SourceX - SourceX, DestWidth);
|
||||
SourceYStep = FixedDiv(RightEdge->SourceY - SourceY, DestWidth);
|
||||
/* Clip right edge if necessary */
|
||||
if (DestXMax > ClipMaxX) {
|
||||
if (DestXMax > ClipMaxX) {
|
||||
DestXMax = ClipMaxX;
|
||||
}
|
||||
/* Clip left edge if necssary */
|
||||
if (DestX < ClipMinX) {
|
||||
if (DestX < ClipMinX) {
|
||||
SourceX += SourceXStep * (ClipMinX - DestX);
|
||||
SourceY += SourceYStep * (ClipMinX - DestX);
|
||||
DestX = ClipMinX;
|
||||
}
|
||||
/* Scan across the destination scan line, updating the source image
|
||||
position accordingly */
|
||||
for (; DestX<DestXMax; DestX++) {
|
||||
for (; DestX<DestXMax; DestX++) {
|
||||
/* Get currently mapped pixel out of image and draw it to screen */
|
||||
WritePixelX(DestX, DestY,
|
||||
GET_IMAGE_PIXEL(TexMapBits, TexMapWidth,
|
||||
|
|
|
|||
Loading…
Reference in a new issue