Skip to content

Commit

Permalink
ray4: deprecate old typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
hollasch committed Nov 3, 2024
1 parent 3cbbb14 commit b8485e4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 49 deletions.
48 changes: 24 additions & 24 deletions ray4/src/r4_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ ImageHeader iheader = { // Output Image Header
Vector4 Gx, Gy, Gz; // Ray-Grid Basis Vectors
Point4 Gorigin; // Ray-Grid Origin Point
int res[3] = {0,0,0}; // Full Output Image Resolution
ulong scanlsize; // Scanline Size
ulong slbuff_count; // Number of Lines in Scanline Buffer
long scanlsize; // Scanline Size
long slbuff_count; // Number of Lines in Scanline Buffer
char *scanbuff; // Scanline Buffer
time_t StartTime; // Timestamp

Expand Down Expand Up @@ -221,7 +221,7 @@ char *GetField (char *str, int &value) {
if ((*str < '0') || ('9' < *str))
return nullptr;

value = static_cast<ushort>(atoi(str));
value = atoi(str);

while (('0' <= *str) && (*str <= '9'))
++str;
Expand Down Expand Up @@ -253,7 +253,7 @@ char *GetRange (
if ((*str < '0') || ('9' < *str))
return nullptr;

val1 = val2 = static_cast<ushort>(atoi (str));
val1 = val2 = atoi(str);

while (('0' <= *str) && (*str <= '9'))
++str;
Expand All @@ -271,7 +271,7 @@ char *GetRange (
if ((*str < '0') || ('9' < *str))
return nullptr;

val2 = static_cast<ushort>(atoi (str));
val2 = atoi(str);
while (('0' <= *str) && (*str <= '9'))
++str;

Expand Down Expand Up @@ -504,20 +504,20 @@ void ProcessArgs (int argc, char *argv[]) {
// Integer Write Routines -- These routines write out values in big-endian format.
//==================================================================================================

void WriteInteger8(uchar value) {
void WriteUInteger8(uint8_t value) {
WriteBlock(&value, 1);
}

void WriteInteger16(ushort value) {
unsigned char block[2];
void WriteUInteger16(uint16_t value) {
uint8_t block[2];
block[0] = 0xff & (value >> 8);
block[1] = 0xff & value;

WriteBlock(block, 2);
}

void WriteInteger32(ulong value) {
unsigned char block[4];
void WriteUInteger32(uint32_t value) {
uint8_t block[4];
block[0] = 0xff & (value >> 24);
block[1] = 0xff & (value >> 16);
block[2] = 0xff & (value >> 8);
Expand All @@ -529,18 +529,18 @@ void WriteInteger32(ulong value) {
//__________________________________________________________________________________________________

void WriteHeader(const ImageHeader& header) {
WriteInteger32(header.magic);
WriteInteger8(header.version);
WriteInteger8(header.bitsperpixel);
WriteUInteger32(header.magic);
WriteUInteger8(header.version);
WriteUInteger8(header.bitsperpixel);

for (int i=0; i < 3; ++i)
WriteInteger16(header.aspect[i]);
WriteUInteger16(header.aspect[i]);

for (int i=0; i < 3; ++i)
WriteInteger16(header.start[i]);
WriteUInteger16(header.start[i]);

for (int i=0; i < 3; ++i)
WriteInteger16(header.end[i]);
WriteUInteger16(header.end[i]);
}

//__________________________________________________________________________________________________
Expand Down Expand Up @@ -604,7 +604,7 @@ void CalcRayGrid (void) {
void FireRays () {
// This is the main routine that fires the rays through the ray grid and into the 4D scene.

ulong scancount = 0; // Scanline Counter
long scancount = 0; // Scanline Counter
char *scanptr = scanbuff; // Scanline Buffer Pointer
bool eflag = true; // Even RGB Boundary Flag

Expand Down Expand Up @@ -647,20 +647,20 @@ void FireRays () {

if (iheader.bitsperpixel == 24) {

*scanptr++ = static_cast<uchar>(color.r);
*scanptr++ = static_cast<uchar>(color.g);
*scanptr++ = static_cast<uchar>(color.b);
*scanptr++ = static_cast<uint8_t>(color.r);
*scanptr++ = static_cast<uint8_t>(color.g);
*scanptr++ = static_cast<uint8_t>(color.b);

} else if (eflag) {

*scanptr++ = (static_cast<uchar>(color.r) & 0xF0) | (static_cast<uchar>(color.g) >> 4);
*scanptr = (static_cast<uchar>(color.b) & 0xF0);
*scanptr++ = (static_cast<uint8_t>(color.r) & 0xF0) | (static_cast<uint8_t>(color.g) >> 4);
*scanptr = (static_cast<uint8_t>(color.b) & 0xF0);
eflag = false;

} else {

*scanptr++ |= (static_cast<uchar>(color.r) >> 4);
*scanptr++ = (static_cast<uchar>(color.g) & 0xF0) | (static_cast<uchar>(color.b) >> 4);
*scanptr++ |= (static_cast<uint8_t>(color.r) >> 4);
*scanptr++ = (static_cast<uint8_t>(color.g) & 0xF0) | (static_cast<uint8_t>(color.b) >> 4);
eflag = true;
}
}
Expand Down
17 changes: 8 additions & 9 deletions ray4/src/r4_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Triangle DefTriangle = {

static AttrName *attrnamelist = nullptr; // Attribute Name List
static bool eofflag = false; // Non-Zero If EOF Input File
static ulong lcount = 1; // Input Line Counter
static long lcount = 1; // Input Line Counter
static Attributes *prevattr= &DefAttributes; // Previously Named Attribute
static char token[MAXTLEN+1]; // Input Token

Expand All @@ -183,7 +183,7 @@ void Error (const char *format, ...) {

va_start(args, format);

printf("Input Error [Line %lu]: ", lcount);
printf("Input Error [Line %l]: ", lcount);
vprintf(format, args);
print("\n");

Expand Down Expand Up @@ -221,7 +221,7 @@ char *GetToken (
}

char *ptr = buff; // Destination Buffer Pointer
ushort nn = 0; // Length of Destination String
int nn = 0; // Length of Destination String

// Skip past comments and whitespace.

Expand Down Expand Up @@ -411,7 +411,7 @@ void ReadReal (char *ctoken, double *num) {

//__________________________________________________________________________________________________

void ReadUint16 (char *itoken, ushort *num) {
void ReadUint16 (char *itoken, uint16_t *num) {
// This procedure reads in a 16-bit unsigned integer from the input stream and stores it in the
// location given in the parameter list.

Expand All @@ -420,7 +420,7 @@ void ReadUint16 (char *itoken, ushort *num) {
GetToken (inbuff, false);
if (CType(*inbuff) != NUM)
Error ("Missing integer argument for '%s'.", itoken);
*num = static_cast<ushort>(atoi (inbuff));
*num = static_cast<uint16_t>(atoi(inbuff));
}

//__________________________________________________________________________________________________
Expand Down Expand Up @@ -487,7 +487,7 @@ void ParseInput () {
break;

case VarType::UInt16:
ReadUint16 (token, reinterpret_cast<ushort*>(Globals[i].address));
ReadUint16 (token, reinterpret_cast<uint16_t*>(Globals[i].address));
break;

case VarType::Real:
Expand Down Expand Up @@ -553,7 +553,7 @@ Attributes *ReadAttributes () {
if (newattr->indexref <= 0.0)
Error ("Non-positive index of refraction.");
} else if (keyeq (token, "refle")) {
ushort scratch;
uint16_t scratch;
ReadUint16 (token, &scratch);
if (scratch == 1)
newattr->flags |= AT_REFLECT;
Expand Down Expand Up @@ -623,8 +623,7 @@ void DoAttributes () {

AttrName *newattrname; // New Attributes Alias Node
if (anptr) {
printf ("Warning: Attributes \"%s\" redefined at line %lu.\n",
token, lcount);
printf ("Warning: Attributes \"%s\" redefined at line %l.\n", token, lcount);
newattrname = anptr;
} else {
newattrname = NEW (AttrName, 1);
Expand Down
2 changes: 1 addition & 1 deletion ray4/src/r4_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Color black { 0, 0, 0 }; // Used to zero out colors.
void RayTrace (
const Ray4 &rayIn, // Trace Ray
Color &color, // Resulting Color
ulong level) // Raytrace Level
int level) // Raytrace Level
{
// This routine is the heart of the raytracer; it takes the ray, determines which objects are
// hit, picks the closest one, determines the appropriate shade at the surface, and then may or
Expand Down
23 changes: 8 additions & 15 deletions ray4/src/ray4.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@



// Basic Type Definitions

using uchar = unsigned char;
using ulong = unsigned long;
using ushort = unsigned short;


// Constant Definitions

const double epsilon = 1.0e-15; // Very Small Number (Effectively Zero)
Expand Down Expand Up @@ -99,10 +92,10 @@ inline double lerp (double a, double b, double t) {
// Structure Definitions

struct Stats {
ulong Ncast; // Number of Rays Cast
ulong Nreflect; // Number of Reflection Rays Cast
ulong Nrefract; // Number of Refraction Rays Cast
ulong maxlevel; // Maximum Ray Tree Level
long Ncast; // Number of Rays Cast
long Nreflect; // Number of Reflection Rays Cast
long Nrefract; // Number of Refraction Rays Cast
long maxlevel; // Maximum Ray Tree Level
};

enum class LightType { Point, Directional };
Expand Down Expand Up @@ -168,7 +161,7 @@ struct TetPar { // Tetrahedron/Parallelepiped Common Fields
Point4 vert[4]; // Vertices
Vector4 vec1,vec2,vec3; // Vectors from Vertex 0 to Vertices 1,2,3
Vector4 normal; // Hyperplane Normal Vector
uchar ax1, ax2, ax3; // Non-Dominant Normal Vector Axes
uint8_t ax1, ax2, ax3; // Non-Dominant Normal Vector Axes
double planeConst; // Hyperplane Constant
double CramerDiv; // Cramer's-Rule Divisor for Barycentric Coords
};
Expand Down Expand Up @@ -205,7 +198,7 @@ void MyFree (void*);
void OpenInput (void);
void OpenOutput (void);
void ParseInput (void);
void RayTrace (const Ray4&, Color&, ulong);
void RayTrace (const Ray4&, Color&, int);
int ReadChar (void);
void UnreadChar (int);
void WriteBlock (void *block, int size);
Expand All @@ -220,7 +213,7 @@ void WriteBlock (void *block, int size);
double global_indexref = 1.00; // Global Index Refraction
char *infile = nullptr; // Input File Name
Light *lightlist = nullptr; // Light-Source List
ushort maxdepth = 0; // Maximum Recursion Depth
int maxdepth = 0; // Maximum Recursion Depth
ObjInfo *objlist = nullptr; // Object List
char *outfile = nullptr; // Output File Name
Stats stats = { 0, 0, 0, 0 }; // Status Information
Expand All @@ -236,7 +229,7 @@ void WriteBlock (void *block, int size);
extern double global_indexref;
extern char *infile;
extern Light *lightlist;
extern ushort maxdepth;
extern int maxdepth;
extern ObjInfo *objlist;
extern char *outfile;
extern Stats stats;
Expand Down

0 comments on commit b8485e4

Please sign in to comment.