[SDL] [DEMO] Minimal world engine, updated

Matthijs Hollemans matthijs at allyoursoftware.com
Fri Jan 24 05:41:00 PST 2003

From: "Daniel Phillips"

> I cleaned up a number of issues with the world engine demo.


> I'd appreciate some more feedback/complaints about build
> problems at this point, and could somebody please try compiling
> this on Windows, and tell me how badly my C code breaks VCC.


First some small things that are typical for porting "gcc" SDL
programs to VisualC++. Change the includes from <SDL/SDL.h> to
"SDL.h" and <GL/...> to "SDL_opengl.h". There are some other header
file differences, such as a missing M_PI (or any kind of pi), and
redefinition of the min and max macros. VisualC++ also does not
permit the usage of "inline" in .c files, nor does it like the LL
suffix (cast to __int64 instead). These are all very small fixes.

The compiler also issues a bunch of warnings: There are about a
hundred places where doubles are truncated (in declarations) or
converted (in expressions) to float, and several signed/unsigned

However, in about 50 places in the code you do this: return
(vec3){x[0], x[1], x[2]}; In other words, you initialize a vec3
object on-the-fly. In VisualC++ this is only allowed when declaring
the variable, like this: vec3 v = { ... }; Everywhere else you
should set the struct fields separately, i.e. v.x = ...; v.y = ...;
etc. I did not feel like fixing all of this, so I gave up. If you
don't mind changing these on-the-fly initializations to "proper"
declarations, I can give it another shot.

Hope it helps,
Matthijs Hollemans

More information about the SDL mailing list