From 31d9ab8f10ae92242c1df98c6a98044365402699 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 13 Aug 2012 23:07:37 -0400 Subject: [PATCH] initial build system working to compile from cygwin in Windows with SFML-1.6 --- .gitignore | 1 + Makefile | 6 +++++ SConstruct | 63 ++++++++++++++++++++++++++++++++++++++++++++ src/client/Client.cc | 45 +++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 SConstruct create mode 100644 src/client/Client.cc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba077a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d90b934 --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ + +all: + @scons + +clean: + @scons -c diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..04aeede --- /dev/null +++ b/SConstruct @@ -0,0 +1,63 @@ +# vim:filetype=python + +import os + +client_name = 'treacherous-terrain' +server_name = client_name + '-server' + +# determine our build platform +platform = 'windows' if os.path.exists('/bin/cygwin1.dll') else 'unix' + +# common environment settings +#SFML_VERSION = '2.0-rc' +SFML_VERSION = '1.6' +BIN_DIR = 'bin' +CXX = 'g++' +CPPFLAGS = [] +CXXFLAGS = ['-Wall', '-O2'] +LINKFLAGS = [] +LIBPATH = [] +LIBS_client = ['sfml-network', 'sfml-system', 'sfml-window'] +LIBS_server = ['sfml-network'] +libs_to_copy = [] + +if platform == 'windows': + # Windows-specific environment settings + CXX = 'i686-pc-mingw32-g++' + MINGW_DIR = '/usr/i686-pc-mingw32/sys-root/mingw/bin' + SFML_PATH = '/c/apps/SFML-%s' % SFML_VERSION + if 'SFML_PATH' in os.environ: + SFML_PATH = os.environ['SFML_PATH'] + CPPFLAGS.append('-I%s/include' % SFML_PATH) + LIBPATH.append('%s/lib' % SFML_PATH) + LINKFLAGS.append('-static-libstdc++') + LIBS_client.append('mingw32') + LIBS_server.append('mingw32') + libs_to_copy.append('%s/libgcc_s_dw2-1.dll' % MINGW_DIR) + +# our sources +sources_client = [Glob('src/common/*.cc'), Glob('src/client/*.cc')] +sources_server = [Glob('src/common/*.cc'), Glob('src/server/*.cc')] + +# create the scons environments +env_client = Environment( + CXX = CXX, + CPPFLAGS = CPPFLAGS, + CXXFLAGS = CXXFLAGS, + LINKFLAGS = LINKFLAGS, + LIBPATH = LIBPATH, + LIBS = LIBS_client) +env_server = Environment( + CXX = CXX, + CPPFLAGS = CPPFLAGS, + CXXFLAGS = CXXFLAGS, + LINKFLAGS = LINKFLAGS, + LIBPATH = LIBPATH, + LIBS = LIBS_server) + +for lib_path in libs_to_copy: + installed_libs = env_client.Install(BIN_DIR, lib_path) + env_client.Depends('%s/%s' % (BIN_DIR, client_name), installed_libs) +env_client.Program('%s/%s' % (BIN_DIR, client_name), sources_client) +# turn this back on when we have any server sources present +#env_server.Program('%s/%s' % (BIN_DIR, server_name), sources_server) diff --git a/src/client/Client.cc b/src/client/Client.cc new file mode 100644 index 0000000..4ae2035 --- /dev/null +++ b/src/client/Client.cc @@ -0,0 +1,45 @@ + +#include +#include + +int main(int argc, char *argv[]) +{ + bool fullscreen = false; + for (;;) + { + int c = getopt_long(argc, argv, "f", NULL, NULL); + if (c == -1) + break; + switch (c) + { + case 'f': + fullscreen = true; + break; + } + } + sf::VideoMode mode = fullscreen + ? sf::VideoMode::GetDesktopMode() + : sf::VideoMode(800, 600, 32); + long style = fullscreen + ? sf::Style::Fullscreen + : sf::Style::Resize | sf::Style::Close; + sf::Window window(mode, "Treacherous Terrain", style); + + while (window.IsOpened()) + { + sf::Event event; + while (window.GetEvent(event)) + { + if (event.Type == sf::Event::Closed) + window.Close(); + + if ( (event.Type == sf::Event::KeyPressed) + && (event.Key.Code == sf::Key::Escape) ) + window.Close(); + } + + window.Display(); + } + + return 0; +}