Skip to content
Permalink
Browse files

Add Code::Blocks project file for Windows, update scripts

There's one central SETUP_dev_win.sh script, which lets you
choose whether you want to develop using Code::Blocks for Windows,
or using Visual Studio, and downloads the respective SDK files.
Also the script copies the relevant project file to the root dir.
  • Loading branch information...
anrieff committed Jun 2, 2018
1 parent d30340e commit 5bb52e29b5eca8e622d5220c4b5cdfc0803faf9d
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="fray" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/fray" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/fray" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O3" />
<Add option="-ffast-math" />
<Add option="-march=native" />
<Add option="-fno-rtti" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add directory="SDK/SDL-1.2.15/include" />
<Add directory="SDK/OpenEXR-mingw/include/OpenEXR" />
</Compiler>
<Linker>
<Add library="mingw32" />
<Add library="SDLmain" />
<Add library="SDL.dll" />
<Add library="user32" />
<Add library="gdi32" />
<Add library="winmm" />
<Add library="dxguid" />
<Add library="IlmImf" />
<Add library="Imath" />
<Add library="Iex" />
<Add library="Half" />
<Add library="IlmThread" />
<Add library="zlibstatic" />
<Add directory="SDK/SDL-1.2.15/lib" />
<Add directory="SDK/OpenEXR-mingw/lib" />
</Linker>
<Unit filename="src/bbox.h" />
<Unit filename="src/bitmap.cpp" />
<Unit filename="src/bitmap.h" />
<Unit filename="src/camera.cpp" />
<Unit filename="src/camera.h" />
<Unit filename="src/color.h" />
<Unit filename="src/constants.h" />
<Unit filename="src/cxxptl-sdl.cpp" />
<Unit filename="src/cxxptl-sdl.h" />
<Unit filename="src/environment.cpp" />
<Unit filename="src/environment.h" />
<Unit filename="src/geometry.cpp" />
<Unit filename="src/geometry.h" />
<Unit filename="src/heightfield.cpp" />
<Unit filename="src/heightfield.h" />
<Unit filename="src/lights.cpp" />
<Unit filename="src/lights.h" />
<Unit filename="src/main.cpp" />
<Unit filename="src/matrix.cpp" />
<Unit filename="src/matrix.h" />
<Unit filename="src/mesh.cpp" />
<Unit filename="src/mesh.h" />
<Unit filename="src/random_generator.cpp" />
<Unit filename="src/random_generator.h" />
<Unit filename="src/scene.cpp" />
<Unit filename="src/scene.h" />
<Unit filename="src/sdl.cpp" />
<Unit filename="src/sdl.h" />
<Unit filename="src/shading.cpp" />
<Unit filename="src/shading.h" />
<Unit filename="src/triangle.cpp" />
<Unit filename="src/triangle.h" />
<Unit filename="src/util.cpp" />
<Unit filename="src/util.h" />
<Unit filename="src/vector.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
@@ -0,0 +1,52 @@
#!/bin/bash

# Usage: SETUP_dev.sh <vc|cb>"

compiler="$1"

if [ ! -f "sdl_win.sh" ]; then
echo "Invalid directory, you should run this from within scripts/"
exit 2
fi

if [ ! "x$compiler" == "xvc" -a ! "x$compiler" == "xcb" ]; then
echo "Choose your compiler/IDE:"
echo ""
echo " 1) Microsoft Visual Studio 2017"
echo " 2) Code::Blocks 17.12"
echo ""
echo -n "? "
read choice
if [ "x$choice" == "x1" ]; then
compiler="vc"
elif [ "x$choice" == "x2" ]; then
compiler="cb"
else
echo "Invalid choice"
exit 1
fi
fi
echo "Compiler is $compiler"

PROJ="../projfiles"

if [ $compiler == "vc" ]; then
./sdl_win.sh
./openexr_win.sh
./zlib_win.sh

echo ">> Copying project files..."
cp $PROJ/fray.vcxproj* ..

echo ">> All set up! Open fray.vcxproj (in the root project dir) and happy hacking!"
fi

if [ $compiler == "cb" ]; then
./sdl_win_cb.sh
./openexr_win_cb.sh

echo ">> Copying project files..."
cp $PROJ/CodeBlocks-win.cbp ../fray.cbp

echo ">> All set up! Open fray.cbp (in the root project dir) and happy hacking!"
fi
@@ -0,0 +1,27 @@
#!/bin/sh

if [ -z $BASH_SOURCE ]; then
echo "ERROR \$BASH_SOURCE is required"
exit 1
fi

BASH_DIR=$(dirname $BASH_SOURCE)
SDK_DIR=$BASH_DIR/../SDK

if [ ! -d $SDK_DIR ]; then
mkdir $SDK_DIR
fi

echo ">> Downloading OpenEXR 2.2.1 into $SDK_DIR"
curl -L "http://raytracing-bg.net/lib/openexr-devel-mingw32.zip" --output $SDK_DIR/openexr.zip

if [ $? -ne 0 ]; then
echo ">> ERROR: cURL failed to download OpenEXR archive"
else

echo ">> Extracting OpenEXR sdk in $SDK_DIR/OpenEXR"
# unzip doesn't handle relative paths well
unzip -q -u $SDK_DIR/openexr.zip -d $SDK_DIR

rm $SDK_DIR/openexr.zip
fi
@@ -26,4 +26,8 @@ else
mv -T $SDK_DIR/SDL-1.2.15 $SDK_DIR/SDL

rm $SDK_DIR/sdl.zip

echo ">> Moving header files"
mkdir $SDK_DIR/SDL/include/SDL
mv $SDK_DIR/SDL/include/*.h $SDK_DIR/SDL/include/SDL
fi
@@ -0,0 +1,33 @@
#!/bin/sh

if [ -z $BASH_SOURCE ]; then
echo "ERROR \$BASH_SOURCE is required"
exit 1
fi

BASH_DIR=$(dirname $BASH_SOURCE)
SDK_DIR=$BASH_DIR/../SDK

if [ ! -d $SDK_DIR ]; then
mkdir $SDK_DIR
fi

echo ">> Downloading SDL 1.2 into $SDK_DIR"
curl http://libsdl.org/release/SDL-devel-1.2.15-mingw32.tar.gz --output $SDK_DIR/sdl.tar.gz

if [ $? -ne 0 ]; then
echo ">> ERROR: cURL failed to download SDL archive"
else

echo ">> Extracting SDL SDK in $SDK_DIR/SDL"
# unzip doesn't handle relative paths well
pushd .
cd $SDK_DIR
tar xzf sdl.tar.gz
popd

rm $SDK_DIR/sdl.tar.gz

echo ">> Copying SDL.dll"
cp $SDK_DIR/SDL-1.2.15/bin/SDL.dll ..
fi
@@ -24,11 +24,7 @@
#include "cxxptl-sdl.h"
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif // _WIN32

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@@ -22,13 +22,8 @@
* @Brief SDL port of the CXXPTL library
*/
#pragma once
#ifdef _WIN32
#include <SDL_thread.h>
#include <SDL_mutex.h>
#else
#include <SDL/SDL_thread.h>
#include <SDL/SDL_mutex.h>
#endif

/**
* @File cxxptl_sdl.h
@@ -21,16 +21,11 @@
* @File main.cpp
* @Brief Raytracer main file
*/
#ifdef _WIN32
#include <SDL.h>
#include <SDL_events.h>
#ifdef main
#undef main
#endif // main
#else
# undef main
#endif
#include <SDL/SDL.h>
#include <SDL/SDL_events.h>
#endif // _WIN32
#include <math.h>
#include <string.h>
#include <vector>
@@ -42,11 +42,7 @@
***************************************************************************/

#include <math.h>
#ifdef _WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif // _WIN32
#include "random_generator.h"
#include "constants.h"

@@ -21,11 +21,7 @@
* @File sdl.cpp
* @Brief Implements the interface to SDL (mainly drawing to screen functions)
*/
#ifndef _WIN32
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif // _WIN32
#include <stdio.h>
#include "sdl.h"
#include "bitmap.h"

0 comments on commit 5bb52e2

Please sign in to comment.
You can’t perform that action at this time.