--- a/README Tue Jul 26 17:41:36 2016 +0200
+++ b/README Tue Jul 26 18:19:37 2016 +0200
@@ -27,8 +27,7 @@
Python 2.4 or newer for Python module and demos
SDL for interactive C++ demos
-It should build with these compilers: GCC, IntelC, MSVC
-GCC is default in Linux, MSVC is default in Windows.
+It should build with these compilers: GCC, Clang, IntelC
Downloading model files
@@ -45,9 +44,6 @@
Threads are used to render rays paralelly. Arbitrary number
of threads can be used.
-For Windows, get Pthreads library here:
-http://sources.redhat.com/pthreads-win32/
-
Python Demos
------------
--- a/SConstruct Tue Jul 26 17:41:36 2016 +0200
+++ b/SConstruct Tue Jul 26 18:19:37 2016 +0200
@@ -39,12 +39,7 @@
Decider('MD5-timestamp')
SConsignFile('build/.sconsign.dblite')
-if sys.platform == 'win32':
- tools = ['mingw']
-else:
- tools = ['default']
-
-env = Environment(tools = tools, CPPPATH = ['.','#include','#build/include'])
+env = Environment(tools = ['default'], CPPPATH = ['.','#include','#build/include'])
vars = Variables(files=['build/.varscache'])
vars.AddVariables(
@@ -54,17 +49,8 @@
BoolVariable('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
('ldflags', 'add additional linker flags', ""),
BoolVariable('profile', "enable gcc's profiling support (-pg)", False),
+ BoolVariable('intelc', 'use Intel C++ Compiler, if available', False),
)
-if env['PLATFORM'] == 'win32':
- vars.AddVariables(
- BoolVariable('mingw', 'use Mingw and GCC compiler, if available', False),
- ('pythonpath', 'path to Python installation',
- 'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
- )
-else:
- vars.AddVariables(
- BoolVariable('intelc', 'use Intel C++ Compiler, if available', False),
- )
vars.Update(env)
@@ -84,8 +70,6 @@
platform = 'linux'
elif env['PLATFORM'] == 'posix':
platform = 'posix'
- elif env['PLATFORM'] == 'win32':
- platform = 'win32'
context.Result(platform)
return True
@@ -116,19 +100,6 @@
context.Result(False)
return gcc
-def CheckMSVC(context):
- global msvc, msvcversion
- context.Message('Checking for MSVC compiler... ')
- testenv = Environment()
- msvc = "msvc" in testenv['TOOLS']
- if msvc:
- msvcversion = testenv['MSVS_VERSION']
- context.Result(msvcversion)
- else:
- msvcversion = ''
- context.Result(False)
- return msvc
-
def CheckCPUFlags(context):
global cpu, cpuflags_gcc, cpuflags_intelc
context.Message('Checking CPU arch and flags... ')
@@ -144,25 +115,19 @@
conf = Configure(env, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
clean=False, help=False,
custom_tests = {
- 'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags,
- 'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC, 'CheckMSVC' : CheckMSVC})
+ 'CheckPlatform' : CheckPlatform,
+ 'CheckCPUFlags' : CheckCPUFlags,
+ 'CheckIntelC' : CheckIntelC,
+ 'CheckGCC' : CheckGCC,
+ })
conf.CheckPlatform()
conf.CheckGCC()
-if platform == 'win32':
- conf.CheckMSVC()
- intelc = False
-else:
- conf.CheckIntelC()
- msvc=False
+conf.CheckIntelC()
if intelc and (not gcc or conf.env['intelc']):
Tool('intelc').generate(conf.env)
cc = 'intelc'
-elif msvc and (not gcc or not conf.env['mingw']):
- Tool('default').generate(conf.env)
- conf.Define("MSVC")
- cc = 'msvc'
elif gcc:
cc = 'gcc'
else:
@@ -171,19 +136,11 @@
if cc == 'intelc' or cc == 'gcc':
conf.CheckCPUFlags()
-if platform == 'win32' and cc == 'gcc':
- conf.env.Append(LIBPATH=["C:/mingw/lib", "C:/msys/mingw/lib"])
- conf.env.Append(CPPPATH=["C:/mingw/include", "C:/msys/mingw/include"])
-
add_flags = ''
if cc == 'gcc':
add_flags += cpuflags_gcc + ' -ffast-math '
if cc == 'intelc':
add_flags += cpuflags_intelc + ' '
-if cc == 'msvc':
- add_flags += '/fp:fast '
- if conf.env['simd']:
- add_flags += '/arch:SSE '
if conf.env['force_flags']:
add_flags = conf.env['flags'] + ' '
@@ -203,8 +160,6 @@
# Other useful flags:
# -Wunsafe-loop-optimizations -Wpointer-arith -Wcast-align -Wconversion
# -Wmissing-noreturn -Winline -Wdisabled-optimization
-elif cc == 'msvc':
- conf.env.Append(CCFLAGS="/Ox /Ob2 /GS- /Gy /GF /GR- /Zp16 /MD /EHsc /vmb " + add_flags)
else:
print "No supported compiler found."
Exit(1)
@@ -220,20 +175,7 @@
# configure pthread
-pthread = True
-if platform == 'win32':
- if cc == 'msvc':
- if not conf.CheckLib('pthreadVC2'):
- pthread = False
- elif cc == 'gcc':
- if not conf.CheckLib('pthreadGC2'):
- pthread = False
-else:
- conf.env.Append(CCFLAGS="-pthread ")
-
-if not pthread:
- print 'Error: Cannot build without pthread.'
- Exit(1)
+conf.env.Append(CCFLAGS="-pthread ")
# configure libpng
@@ -247,23 +189,10 @@
# configure Python
pyenv = env.Clone()
have_python = True
-if platform == 'win32':
- pythonver = '%c%c' % (sys.version[0], sys.version[2])
- pythonlib = 'python'+pythonver
- pythonpath = [env['pythonpath']]
- pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath])
- pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath])
- pyenv.Replace(SHLIBSUFFIX='.pyd')
- conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
- clean=False, help=False)
- if not conf.CheckLib(pythonlib):
- have_python = False
- pyenv = conf.Finish()
-else:
- try:
- pyenv.ParseConfig('python-config --includes --libs')
- except:
- have_python = False
+try:
+ pyenv.ParseConfig('python-config --includes --libs')
+except:
+ have_python = False
if not have_python:
print "Error: Python is required."
@@ -271,15 +200,11 @@
# configure SDL
sdlenv = env.Clone()
-if cc == 'msvc':
- sdlenv.Append(LIBS=['SDL', 'SDLmain'])
- sdlenv.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS")
-else:
- try:
- sdlenv.ParseConfig('sdl-config --cflags')
- sdlenv.ParseConfig('sdl-config --libs')
- except:
- pass
+try:
+ sdlenv.ParseConfig('sdl-config --cflags')
+ sdlenv.ParseConfig('sdl-config --libs')
+except:
+ pass
def CheckSDL(context):
global have_sdl
@@ -304,16 +229,10 @@
Export('env pyenv sdlenv have_sdl cc')
lib = SConscript('src/SConscript', variant_dir='build/lib', duplicate=0,
exports={'buildmodule':False})
-if cc == 'msvc':
- (pymodule, modvcproj) = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
- exports={'buildmodule':True})
- ccdemvcproj = SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
- demosvcproj = SConscript('demos/SConscript', exports='pymodule')
-else:
- pymodule = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
- exports={'buildmodule':True})
- SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
- SConscript('demos/SConscript', exports='pymodule')
+pymodule = SConscript('src/SConscript', variant_dir='build/pymodule', duplicate=0,
+ exports={'buildmodule':True})
+SConscript('ccdemos/SConscript', variant_dir='build/ccdemos', duplicate=0, exports='lib')
+SConscript('demos/SConscript', exports='pymodule')
SConscript('tests/SConscript', variant_dir='build/tests', duplicate=0, exports='lib')
SConscript('models/SConscript')
@@ -327,12 +246,3 @@
env.Alias('all', ['no-docs', 'docs'])
env.Alias('pyrit', 'no-download')
Default('pyrit')
-
-if cc == 'msvc':
- 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 Tue Jul 26 17:41:36 2016 +0200
+++ b/ccdemos/SConscript Tue Jul 26 18:19:37 2016 +0200
@@ -15,21 +15,3 @@
l.append( myenv.Program(src) )
env.Alias('cc-demos', l)
-
-if cc == 'msvc':
- # 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/demos/SConscript Tue Jul 26 17:41:36 2016 +0200
+++ b/demos/SConscript Tue Jul 26 18:19:37 2016 +0200
@@ -18,17 +18,3 @@
l.append( env.Copy('#build/demos/'+str(pymodule[0]).split(os.sep)[-1], str(pymodule[0])) )
env.Alias('python-demos', l)
-
-if cc == 'msvc':
- # 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 Tue Jul 26 17:41:36 2016 +0200
+++ b/include/common.h Tue Jul 26 18:19:37 2016 +0200
@@ -34,27 +34,11 @@
#include <math.h>
#include <float.h>
#include <pthread.h>
+#include <stdint.h>
#include <string>
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
@@ -68,14 +52,7 @@
# define PI (float)M_PI
#endif
-// enable M_* constants in MSVC
-#define _USE_MATH_DEFINES
-
-#ifdef MSVC
-#define NORETURN __declspec(noreturn)
-#else
#define NORETURN __attribute__((noreturn))
-#endif
/**
* verbosity level
--- a/src/SConscript Tue Jul 26 17:41:36 2016 +0200
+++ b/src/SConscript Tue Jul 26 18:19:37 2016 +0200
@@ -20,36 +20,13 @@
ccflags = '$CCFLAGS -Wno-write-strings'
else:
ccflags = '$CCFLAGS'
- if cc == 'msvc':
- linkflags = '$LINKFLAGS /export:initpyrit'
- else:
- linkflags = '$LINKFLAGS'
+ linkflags = '$LINKFLAGS'
pymodule = pyenv.SharedLibrary('pyrit',
['raytracermodule.cc']+shared_objs,
SHLIBPREFIX = '', CCFLAGS = ccflags,
LINKFLAGS=linkflags)
- if cc == 'msvc':
- pyenv.AddPostAction(pymodule, 'mt /nologo /manifest ${TARGET}.manifest /outputresource:$TARGET;2')
env.Alias('shared-objs', shared_objs)
env.Alias('python-module', pymodule)
-
- if cc == 'msvc':
- # 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'))
-
Return('pymodule')
else:
objs = []
--- a/src/kdtree.cc Tue Jul 26 17:41:36 2016 +0200
+++ b/src/kdtree.cc Tue Jul 26 18:19:37 2016 +0200
@@ -107,8 +107,8 @@
bounds.w()*bounds.d() + bounds.h()*bounds.d());
Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost
- vector<ShapeBound>::iterator edge, splitedge = edges[0].end();
int axis = 0;
+ vector<ShapeBound>::iterator edge, splitedge = edges[axis].end();
for (int ax = 0; ax < 3; ax++)
{
int lnum = 0, rnum = (int)shapes->size();
@@ -138,9 +138,6 @@
}
}
- // we actually need to compare with edges[0].end(), but
- // MSVC does not allow comparison of iterators from differen instances of vector
- // it's OK this way, because axis will be zero if no good split was found
if (splitedge == edges[axis].end())
{
node->setLeaf();
@@ -556,7 +553,6 @@
void KdTree::recursive_load(istream &st, KdNode *node)
{
string s;
- istringstream is;
getline(st, s, ',');
trim(s);