From 2b9f068e7ee4c0d249c715f9eb5a3c2c8a11e6f8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 26 Mar 2008 18:10:17 +0000 Subject: win32 updates --- INSTALL | 2 +- MODELS | 10 ++++++---- configure.in | 23 +++++++++++++++++++---- osirion.kdevelop.pcs | Bin 524876 -> 523363 bytes osirion.kdevses | 22 +++++----------------- src/Makefile.am | 8 +++++--- src/client/client.cc | 2 +- src/client/client.h | 2 +- src/client/video.cc | 3 +-- src/core/application.cc | 5 +++++ src/core/netclient.h | 4 ++++ src/core/netconnection.cc | 6 +++++- src/core/netconnection.h | 4 ++++ src/core/netserver.cc | 19 ++++++++++++++++--- src/core/netserver.h | 4 ++++ src/filesystem/filesystem.cc | 6 +++++- src/osirion.cc | 2 +- src/render/gl.h | 4 ++++ src/sys/sys.cc | 18 ++++++++++-------- 19 files changed, 97 insertions(+), 47 deletions(-) diff --git a/INSTALL b/INSTALL index 285747f..be3f08c 100644 --- a/INSTALL +++ b/INSTALL @@ -13,7 +13,7 @@ Installation In theory, it should compile on any POSIX-compatible platform supported by SDL, but at the time of writing only linux is - supported. + supported. Support for the win32 platform is under development. I have succesfully compiled it on the following platforms: linux-x86_64, gcc 4.1.2, SDL 1.2.11 diff --git a/MODELS b/MODELS index 00d5a31..6f84ff1 100644 --- a/MODELS +++ b/MODELS @@ -82,8 +82,8 @@ Clip Detail brushes As with other engines, Osirion supports the use of detail brushes, but - witha twist: detail brushes will only be rendered if the model - is close enough to the camera. When it is further away, only structural + with a twist: detail brushes will only be rendered if the model + is close enough to the camera. When it is further away, only structural brushes will be rendered. This means that any objects that could only been seen from close by @@ -112,8 +112,10 @@ Textures Entities Add an info_engine entity to add an engine exhaust to a ship model. - An engine always points to the rear (negative Z-axis). Engines - will only be rendered if the model is close enough. + An engine exhaust always points to the rear (negative X-axis). + Engines will only be rendered if the model is close enough. + + target_turret and target_cannon are not yet implemented. Lights diff --git a/configure.in b/configure.in index 13d7060..1b03846 100644 --- a/configure.in +++ b/configure.in @@ -62,6 +62,21 @@ AC_DEFUN([KDE_FIND_PATH], fi ]) +AC_MSG_CHECKING([host type]) +case "$host" in + *-*-mingw*) + HOST_LIBS="-lws2_32" + HOST_GL_LIBS="-lopengl32 -lglu32" + AC_MSG_RESULT(win32) + ;; + *) + HOST_LIBS="" + HOST_GL_LIBS="-lGL -lGLU" + AC_MSG_RESULT(generic unix) + ;; +esac +AC_SUBST(HOST_LIBS) + AC_MSG_CHECKING(whether to abort on compiler warnings) WARN_CFLAGS="" AC_ARG_ENABLE(warn, @@ -98,17 +113,15 @@ AC_CHECK_HEADER(GL/glext.h, [#include ] ) -AC_CHECK_LIB(GL, glVertex3f, - GL_LIBS="$GL_LIBS -lGL -lGLU" -) +GL_LIBS="$HOST_GL_LIBS" AC_SUBST(GL_LIBS) AC_SUBST(GL_CFLAGS) AC_MSG_CHECKING([looking for SDL]) KDE_FIND_PATH(sdl-config, LIBSDL_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [ - AC_MSG_WARN([Could not find libsdl anywhere, check http://www.sdl.org]) + AC_MSG_WARN([Could not find libSDL, check http://www.sdl.org]) ]) if test -n "$LIBSDL_CONFIG"; then @@ -178,6 +191,8 @@ The Osirion Project $VERSION Configuration summary: platform ........... $host flags .............. $CXXFLAGS + libraries .......... $HOST_LIBS + opengl ............. $GL_LIBS Installation directories: prefix ............. $PACKAGE_PREFIX diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs index 6fb0f8e..053b777 100644 Binary files a/osirion.kdevelop.pcs and b/osirion.kdevelop.pcs differ diff --git a/osirion.kdevses b/osirion.kdevses index 303a055..9b9e01d 100644 --- a/osirion.kdevses +++ b/osirion.kdevses @@ -1,25 +1,13 @@ - - - + + + - - + + - - - - - - - - - - - - diff --git a/src/Makefile.am b/src/Makefile.am index 90ddbed..bdb46ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,11 +8,13 @@ bin_PROGRAMS = osiriond osirion # dedicated server osiriond_SOURCES = osiriond.cc osiriond_LDADD = $(top_builddir)/src/game/libgame.la \ - $(top_builddir)/src/core/libcore.la $(top_builddir)/src/server/libserver.la + $(top_builddir)/src/core/libcore.la $(top_builddir)/src/server/libserver.la \ + $(HOST_LIBS) # client osirion_SOURCES = osirion.cc osirion_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS) $(GLUT_CFLAGS) osirion_LDADD = $(top_builddir)/src/game/libgame.la \ - $(top_builddir)/src/core/libcore.la $(top_builddir)/src/client/libclient.la -osirion_LDFLAGS = $(GL_LIBS) $(LIBSDL_LIBS) + $(top_builddir)/src/core/libcore.la $(top_builddir)/src/client/libclient.la \ + $(HOST_LIBS) $(GL_LIBS) +osirion_LDFLAGS = $(LIBSDL_LIBS) diff --git a/src/client/client.cc b/src/client/client.cc index 99bd41f..b09618e 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -60,7 +60,7 @@ void func_r_restart(std::stringstream &args) //--- public ------------------------------------------------------ -void main(int count, char **arguments) +void client_main(int count, char **arguments) { std::cout << core::name() << " " << core::version() << std::endl; diff --git a/src/client/client.h b/src/client/client.h index 2113202..b1a50df 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -11,7 +11,7 @@ namespace client { /// the client main loop -void main(int count, char **arguments); +void client_main(int count, char **arguments); } diff --git a/src/client/video.cc b/src/client/video.cc index a7a74d5..e41f774 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -215,7 +215,7 @@ void screenshot() unsigned char *rgb_data = (unsigned char *) malloc(video::width * video::height * 3); // read OpenGL pixels into the buffer - //glReadBuffer(GL_FRONT); + //glReadBuffer(GL_BACK); glReadPixels(0, 0, (GLsizei) video::width, (GLsizei) video::height, GL_RGB, GL_UNSIGNED_BYTE, (void *) rgb_data); // either OpenGL actually returns BGR, or TGA wants BGR @@ -233,7 +233,6 @@ void screenshot() // close file ofs.close(); - con_print << "Wrote " << shortname << std::endl; } diff --git a/src/core/application.cc b/src/core/application.cc index d1dbcc0..485bac2 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -98,6 +98,7 @@ void func_name(std::string const &args) { extern "C" void signal_handler(int signum) { +#ifndef _WIN32 switch (signum) { case SIGHUP: case SIGINT: @@ -117,6 +118,7 @@ extern "C" void signal_handler(int signum) application()->quit(1); break; } +#endif } // --------------- Application ----------------------------- @@ -134,10 +136,13 @@ Application::Application() application_time = 0; application_game = 0; +#ifndef _WIN32 sys::signal(SIGHUP, signal_handler); sys::signal(SIGINT, signal_handler); sys::signal(SIGQUIT, signal_handler); sys::signal(SIGTERM, signal_handler); +#endif + } Application::~Application() diff --git a/src/core/netclient.h b/src/core/netclient.h index 49f509c..7176260 100644 --- a/src/core/netclient.h +++ b/src/core/netclient.h @@ -10,12 +10,16 @@ #include #include +#ifndef _WIN32 #include #include #include #include #include +#else +#include +#endif #include #include diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index b640595..18ae3bc 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -74,8 +74,12 @@ void NetConnection::connect(std::string const &to_host, int to_port) connection_error = false; FD_ZERO(&clientset); +#ifdef _WIN32 + FD_SET((unsigned int) fd(), &clientset); +#else FD_SET(fd(), &clientset); - +#endif + connection_timeout = application()->time(); connection_keepalive = application()->time(); diff --git a/src/core/netconnection.h b/src/core/netconnection.h index 08536de..3cc28db 100644 --- a/src/core/netconnection.h +++ b/src/core/netconnection.h @@ -10,6 +10,7 @@ #include #include +#ifndef _WIN32 #include #include #include @@ -19,6 +20,9 @@ #include #include +#else +#include +#endif #include #include diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 3b17a65..e3e01a3 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -7,12 +7,16 @@ #include #include +#ifndef _WIN32 #include #include #include #include #include +#else +#include +#endif #include #include @@ -25,6 +29,10 @@ #include "core/func.h" #include "core/core.h" +#ifdef _WIN32 + typedef int socklen_t; +#endif + namespace core { @@ -43,7 +51,8 @@ NetServer::NetServer(std::string const host, unsigned int const port) //perror("socket"); return; } - + + /* // set socket options socklen_t yes = 1; if (::setsockopt(netserver_fd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(socklen_t)) == -1) { @@ -51,6 +60,7 @@ NetServer::NetServer(std::string const host, unsigned int const port) //perror("setsockopt"); return; } + */ // Get the local adress to bind to netserver_addr.sin_family = AF_INET; @@ -77,8 +87,11 @@ NetServer::NetServer(std::string const host, unsigned int const port) // add the listening socket to the file descriptor set FD_ZERO(&serverset); +#ifdef _WIN32 + FD_SET((unsigned int) netserver_fd, &serverset); +#else FD_SET(netserver_fd, &serverset); - +#endif netserver_error = false; } @@ -173,7 +186,7 @@ void NetServer::receive() while (nb && FD_ISSET(fd(), &readset)) { // receive incoming data - struct sockaddr_in client_addr; + struct sockaddr_in client_addr; socklen_t client_addr_len = sizeof(client_addr); memset(recbuf, '\0', sizeof(recbuf)); ssize_t bytes_received = ::recvfrom(fd(), recbuf, FRAMESIZE-1, 0, (struct sockaddr *)&client_addr, &client_addr_len); diff --git a/src/core/netserver.h b/src/core/netserver.h index de923b9..5850b29 100644 --- a/src/core/netserver.h +++ b/src/core/netserver.h @@ -7,7 +7,11 @@ #ifndef __INCLUDED_CORE_NETSERVER_H__ #define __INCLUDED_CORE_NETSERVER_H__ +#ifndef _WIN32 #include +#else +#include +#endif #include #include diff --git a/src/filesystem/filesystem.cc b/src/filesystem/filesystem.cc index f34ac42..130aeb7 100644 --- a/src/filesystem/filesystem.cc +++ b/src/filesystem/filesystem.cc @@ -32,9 +32,13 @@ void init() moddir = ""; // FIXME win32 +#ifndef _WIN32 homedir = getenv("HOME"); homedir = homedir + "/.osirion/"; - +#else + homedir = "./home/"; +#endif + sys::mkdir(homedir); sys::mkdir(homedir+basedir); diff --git a/src/osirion.cc b/src/osirion.cc index 6fa2eb3..2f0a5eb 100644 --- a/src/osirion.cc +++ b/src/osirion.cc @@ -12,7 +12,7 @@ int main(int count, char **arguments) // preload the game module core::Module::load(new game::Game()); - client::main(count, arguments); + client::client_main(count, arguments); // unload the game module core::Module::unload(); diff --git a/src/render/gl.h b/src/render/gl.h index d5d6418..9153435 100644 --- a/src/render/gl.h +++ b/src/render/gl.h @@ -12,6 +12,10 @@ #include "math/vector3f.h" #include "math/color.h" +#ifdef _WIN32 +#define GL_RESCALE_NORMAL 0x803A +#endif + namespace render { /// wrapper namespace for OpenGL operations diff --git a/src/sys/sys.cc b/src/sys/sys.cc index a9958f4..4c3f38f 100644 --- a/src/sys/sys.cc +++ b/src/sys/sys.cc @@ -4,13 +4,10 @@ the terms of the GNU General Public License version 2 */ -// project headers -#include "sys/sys.h" -// system headers #ifdef _WIN32 -#include +#include #else @@ -21,15 +18,17 @@ #include #endif + #include +#include "sys/sys.h" + namespace sys { void mkdir(const char *path) { #ifdef _WIN32 - ::mkdir(path); - return true; + mkdir(path); #else ::mkdir(path, 0777); #endif @@ -60,14 +59,16 @@ unsigned long time() ::localtime_r(&epochtime, &localtime); return ((unsigned long) (localtime.tm_sec + localtime.tm_min*60 + localtime.tm_hour*3600)); #else - retrun 0; + return 0; #endif } void sleep(float seconds) { #ifndef _WIN32 - ::usleep((useconds_t) (seconds * 1000000.0) ); + ::usleep((useconds_t) (seconds * 1000000.0f) ); +#else + Sleep((DWORD) (seconds*1000.0f)); #endif } @@ -76,3 +77,4 @@ void quit(int status) { } } + -- cgit v1.2.3