[ODE] MacOS CFM Carbon Port

Frank C. pox at planetquake.com
Mon Jul 29 21:38:01 2002


Updating the Mac CW project to use the CVS source went smoothly... Commits 
required for the Mac targets described below:

The contents of this archive: 
<http://www3.sympatico.ca/frankco/Mac_CFMCarbon.zip> need to be extracted 
into "contrib/" (it should expand as a single directory named 
"Mac_CFMCarbon" with a bunch of stuff within). The following changes need 
to be made to 2 source files:

----
ode/src/timer.cpp
Carbon compatible getClockCount function is required (after "#if !defined(
PENTIUM) && !defined(WIN32)"):
----

#ifndef macintosh

#include <sys/time.h>
#include <unistd.h>

static inline void getClockCount (unsigned long cc[2])
{
   struct timeval tv;
   gettimeofday (&tv,0);
   cc[0] = tv.tv_usec;
   cc[1] = tv.tv_sec;
}

#else // macintosh

#include <MacTypes.h>
#include <Timer.h>

static inline void getClockCount (unsigned long cc[2])
{
	UnsignedWide ms;
	Microseconds(&ms);
	cc[1] = ms.lo / 1000000;
	cc[0] = ms.lo - ( cc[1] * 1000000 );
}

#endif


----
drawstuff/src/drawstuff.cpp
Need Mac paths in dsStartGraphics:
----

#ifndef macintosh

void dsStartGraphics (int width, int height, dsFunctions *fn)
{
   char *prefix = DEFAULT_PATH_TO_TEXTURES;
   if (fn->version >= 2 && fn->path_to_textures) prefix = 
fn->path_to_textures;
   char *s = (char*) alloca (strlen(prefix) + 20);

   strcpy (s,prefix);
   strcat (s,"/sky.ppm");
   sky_texture = new Texture (s);

   strcpy (s,prefix);
   strcat (s,"/ground.ppm");
   ground_texture = new Texture (s);

   strcpy (s,prefix);
   strcat (s,"/wood.ppm");
   wood_texture = new Texture (s);
}

#else // macintosh

void dsStartGraphics (int width, int height, dsFunctions *fn)
{
   // All examples build into the same dir
   char *prefix = "::::drawstuff:textures";
   char *s = (char*) alloca (strlen(prefix) + 20);

   strcpy (s,prefix);
   strcat (s,":sky.ppm");
   sky_texture = new Texture (s);

   strcpy (s,prefix);
   strcat (s,":ground.ppm");
   ground_texture = new Texture (s);

   strcpy (s,prefix);
   strcat (s,":wood.ppm");
   wood_texture = new Texture (s);
}

#endif


That's it! - Let me know if the zip file is OK (I can send a tar/gz 
archive if you prefer).

Frank.
--