new build target 'vcproj' - generate Visual C++ Studio project files; fix GCC warnings in intersect_packet()
--- a/SConstruct Sun May 31 16:53:05 2009 +0200
+++ b/SConstruct Sun May 31 23:06:03 2009 +0200
@@ -24,6 +24,8 @@
no-download = (libs, demos, local-models)
- everything but docs and downloadable models
+ vcproj - generate project files for Visual C++ Studio
+
Default target is no-download.
Options:
@@ -235,7 +237,8 @@
# configure libpng
-if conf.CheckLibWithHeader('zlib', 'zlib.h', 'C') and conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
+conf.CheckLibWithHeader('zlib', 'zlib.h', 'C')
+if conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
conf.Define('HAVE_PNG')
env = conf.Finish()
@@ -301,11 +304,11 @@
Export('env pyenv sdlenv have_sdl cc')
lib = SConscript('src/SConscript', build_dir='build/lib', duplicate=0,
exports={'buildmodule':False})
-pymodule = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,
+(pymodule, modvcproj) = SConscript('src/SConscript', build_dir='build/pymodule', duplicate=0,
exports={'buildmodule':True})
-SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='lib')
-SConscript('demos/SConscript', exports='pymodule')
+ccdemvcproj = SConscript('ccdemos/SConscript', build_dir='build/ccdemos', duplicate=0, exports='lib')
+demosvcproj = SConscript('demos/SConscript', exports='pymodule')
SConscript('tests/SConscript', build_dir='build/tests', duplicate=0, exports='lib')
SConscript('models/SConscript')
@@ -318,3 +321,11 @@
env.Alias('all', ['no-docs', 'docs'])
env.Alias('pyrit', 'no-download')
Default('pyrit')
+
+vcsol = env.MSVSSolution(
+ target = 'pyrit' + env['MSVSSOLUTIONSUFFIX'],
+ projects = [modvcproj, ccdemvcproj, demosvcproj],
+ variant = 'Release')
+
+env.Depends(vcsol, [modvcproj, ccdemvcproj, demosvcproj]);
+env.Alias('vcproj', vcsol)
--- a/ccdemos/SConscript Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/SConscript Sun May 31 23:06:03 2009 +0200
@@ -3,12 +3,32 @@
myenv.Append(LIBPATH=['#build/lib'])
myenv.Prepend(LIBS=['pyrit'])
+demos = [
+ 'realtime.cc', 'realtime_bunny.cc', 'realtime_dragon.cc',
+ 'spheres_shadow.cc', 'textures.cc']
+
+includes = ['common_sdl.h', 'common_ply.h']
+
l = []
if have_sdl:
- l.append( myenv.Program(['realtime.cc']) )
- l.append( myenv.Program(['realtime_bunny.cc']) )
- l.append( myenv.Program(['realtime_dragon.cc']) )
- l.append( myenv.Program(['spheres_shadow.cc']) )
- l.append( myenv.Program(['textures.cc']) )
+ for src in demos:
+ l.append( myenv.Program(src) )
env.Alias('cc-demos', l)
+
+# MS Visual Studio Project
+vcprojsrcs = []
+for src in demos:
+ vcprojsrcs += ['ccdemos/' + src]
+vcprojincs = []
+for inc in includes:
+ vcprojincs += ['ccdemos/' + inc]
+vcproj = env.MSVSProject(
+ auto_build_solution=0,
+ target = '#pyrit_ccdemos' + env['MSVSPROJECTSUFFIX'],
+ srcs = vcprojsrcs,
+ incs = vcprojincs,
+ buildtarget = 'cc-demos',
+ variant = 'Release')
+
+Return('vcproj')
--- a/ccdemos/common_ply.h Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/common_ply.h Sun May 31 23:06:03 2009 +0200
@@ -1,6 +1,8 @@
#include <iostream>
#include <fstream>
#include <iomanip>
+#include "raytracer.h"
+#include "mempool.h"
void load_ply(Raytracer &rt, const char *filename, Material *mat, const Vector &scale, const Vector &transp)
{
--- a/ccdemos/common_sdl.h Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/common_sdl.h Sun May 31 23:06:03 2009 +0200
@@ -1,4 +1,5 @@
#include <SDL.h>
+#include "raytracer.h"
Uint32 fp10s_acc = 0;
Uint32 fp10s_acc_samples = 0;
--- a/ccdemos/realtime.cc Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/realtime.cc Sun May 31 23:06:03 2009 +0200
@@ -1,10 +1,8 @@
#include <stdlib.h>
-#include "raytracer.h"
+#include "common_sdl.h"
#include "kdtree.h"
-#include "common_sdl.h"
-
int main(int argc, char **argv)
{
Raytracer rt;
--- a/ccdemos/realtime_bunny.cc Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/realtime_bunny.cc Sun May 31 23:06:03 2009 +0200
@@ -1,8 +1,6 @@
-#include "raytracer.h"
-#include "kdtree.h"
-
#include "common_sdl.h"
#include "common_ply.h"
+#include "kdtree.h"
int main(int argc, char **argv)
{
--- a/ccdemos/realtime_dragon.cc Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/realtime_dragon.cc Sun May 31 23:06:03 2009 +0200
@@ -1,10 +1,8 @@
-#include "raytracer.h"
+#include "common_sdl.h"
+#include "common_ply.h"
#include "kdtree.h"
#include "serialize.h"
-#include "common_sdl.h"
-#include "common_ply.h"
-
int main(int argc, char **argv)
{
Raytracer rt;
--- a/ccdemos/spheres_shadow.cc Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/spheres_shadow.cc Sun May 31 23:06:03 2009 +0200
@@ -1,8 +1,6 @@
-#include "raytracer.h"
+#include "common_sdl.h"
#include "octree.h"
-#include "common_sdl.h"
-
Camera cam;
Light light(Vector(-2.0f, 10.0f, -2.0f), Colour(0.9f, 0.9f, 0.9f));
--- a/ccdemos/textures.cc Sun May 31 16:53:05 2009 +0200
+++ b/ccdemos/textures.cc Sun May 31 23:06:03 2009 +0200
@@ -1,8 +1,6 @@
-#include "raytracer.h"
+#include "common_sdl.h"
#include "kdtree.h"
-#include "common_sdl.h"
-
Camera cam(Vector(0.0f,6.0f,6.0f), Vector(0.0f,2.0f,-7.0f), Vector(0.0f,0.0f,-1.0f));
Light light(Vector(-2.0f, 10.0f, -2.0f), Colour(0.9f, 0.9f, 0.9f));
--- a/demos/SConscript Sun May 31 16:53:05 2009 +0200
+++ b/demos/SConscript Sun May 31 23:06:03 2009 +0200
@@ -18,3 +18,16 @@
l.append( env.Copy('#build/demos/'+str(pymodule[0]).split(os.sep)[-1], str(pymodule[0])) )
env.Alias('python-demos', l)
+
+# MS Visual Studio Project
+vcprojmisc = []
+for file in files:
+ vcprojmisc += ['demos/' + file]
+vcproj = env.MSVSProject(
+ auto_build_solution=0,
+ target = '#pyrit_demos' + env['MSVSPROJECTSUFFIX'],
+ misc = vcprojmisc,
+ buildtarget = 'python-demos',
+ variant = 'Release')
+
+Return('vcproj')
--- a/include/common.h Sun May 31 16:53:05 2009 +0200
+++ b/include/common.h Sun May 31 23:06:03 2009 +0200
@@ -38,6 +38,24 @@
using namespace std;
+#ifndef MSVC
+# include <stdint.h>
+#else
+#ifndef _SDL_config_win32_h
+/* these stdint.h typedefs are not available in MSVC
+ * but are defined in SDL_config_win32.h */
+typedef __int8 int8_t;
+typedef __int16 int16_t;
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int8 uint8_t;
+typedef unsigned __int16 uint16_t;
+typedef unsigned __int32 uint32_t;
+typedef unsigned __int64 uint64_t;
+#endif
+#endif
+
+
#ifdef PYRIT_DOUBLE
# define Float double
# define Eps DBL_EPSILON
--- a/include/mempool.h Sun May 31 16:53:05 2009 +0200
+++ b/include/mempool.h Sun May 31 23:06:03 2009 +0200
@@ -30,6 +30,8 @@
#include "common.h"
+#include <string.h>
+
/**
* Memory pool template
*/
--- a/include/shapes.h Sun May 31 16:53:05 2009 +0200
+++ b/include/shapes.h Sun May 31 23:06:03 2009 +0200
@@ -69,12 +69,17 @@
#ifndef NO_SIMD
virtual mfloat4 intersect_packet(const RayPacket &rays, mfloat4 &dists) const
{
- mfloat4 results;
- ((int*)&results)[0] = intersect(rays[0], ((float*)&dists)[0]) ? -1 : 0;
- ((int*)&results)[1] = intersect(rays[1], ((float*)&dists)[1]) ? -1 : 0;
- ((int*)&results)[2] = intersect(rays[2], ((float*)&dists)[2]) ? -1 : 0;
- ((int*)&results)[3] = intersect(rays[3], ((float*)&dists)[3]) ? -1 : 0;
- return results;
+ union {
+ mfloat4 mresults;
+ int32_t results[4];
+ };
+ union {
+ mfloat4 m;
+ float arr[4];
+ } d = { dists };
+ for (int i = 0; i < 4; i++)
+ results[i] = intersect(rays[i], d.arr[i]) ? -1 : 0;
+ return mresults;
};
#endif
--- a/src/SConscript Sun May 31 16:53:05 2009 +0200
+++ b/src/SConscript Sun May 31 23:06:03 2009 +0200
@@ -4,6 +4,13 @@
'common.cc', 'raytracer.cc', 'sampler.cc', 'scene.cc',
'shapes.cc', 'material.cc', 'pixmap.cc', 'serialize.cc',
'container.cc', 'kdtree.cc', 'octree.cc']
+
+includes = [
+ 'common.h', 'container.h', 'kdtree.h', 'material.h',
+ 'matrix.h', 'mempool.h', 'octree.h', 'pixmap.h',
+ 'quaternion.h', 'raytracer.h', 'raytracermodule.h',
+ 'sampler.h', 'scene.h', 'serialize.h', 'shapes.h',
+ 'simd.h', 'vector.h']
if buildmodule:
shared_objs = []
@@ -25,7 +32,23 @@
pyenv.AddPostAction(pymodule, 'mt /nologo /manifest ${TARGET}.manifest /outputresource:$TARGET;2')
env.Alias('shared-objs', shared_objs)
env.Alias('python-module', pymodule)
- Return('pymodule')
+
+ # MS Visual Studio Project
+ vcprojsrcs = []
+ for src in sources+['raytracermodule.cc']:
+ vcprojsrcs += ['src/' + src]
+ vcprojincs = []
+ for inc in includes:
+ vcprojincs += ['include/' + inc]
+ vcproj = env.MSVSProject(
+ auto_build_solution=0,
+ target = '#pyrit_module' + env['MSVSPROJECTSUFFIX'],
+ srcs = vcprojsrcs,
+ incs = vcprojincs,
+ buildtarget = 'python-module',
+ variant = 'Release')
+
+ Return(('pymodule', 'vcproj'))
else:
objs = []
for src in sources:
--- a/src/raytracer.cc Sun May 31 16:53:05 2009 +0200
+++ b/src/raytracer.cc Sun May 31 23:06:03 2009 +0200
@@ -27,6 +27,7 @@
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <assert.h>
#include "raytracer.h"
@@ -478,7 +479,7 @@
for (;;)
{
my_count = 0;
- while ( more_samples = sampler->nextSample(&sample_queue[my_pos++]) )
+ while ( (more_samples = sampler->nextSample(&sample_queue[my_pos++])) != 0 )
{
my_count++;
if (my_pos >= sample_queue_size)