From 71ef1f41c57e041a7f7960158f1cd782ce1ed996 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Tue, 17 Oct 2006 02:36:45 -0400 Subject: [PATCH] *** empty log message *** --- macosx/.cdtproject | 61 ++ macosx/.gitignore | 12 + macosx/.project | 90 ++ macosx/Makefile.linux | 22 + macosx/Makefile.macosx | 21 + macosx/configure | 54 ++ macosx/doc/OpenArena User's Manual.doc | Bin 0 -> 52736 bytes macosx/doc/OpenArena User's Manual.htm | 1096 +++++++++++++++++++++++ macosx/doc/OpenArena User's Manual.html | 1096 +++++++++++++++++++++++ macosx/heading.txt | 28 + macosx/license.txt | 1 + macosx/oa.nsi | 205 +++++ macosx/oa.sln | 41 + macosx/oa.vcproj | 520 +++++++++++ macosx/src/.gitignore | 3 + macosx/src/EventManager.cpp | 76 ++ macosx/src/EventManager.h | 38 + macosx/src/Makefile.linux | 99 ++ macosx/src/Makefile.macosx | 109 +++ macosx/src/Object.cpp | 17 + macosx/src/Object.h | 15 + macosx/src/ctrls.cpp | 224 +++++ macosx/src/ctrls.h | 76 ++ macosx/src/keys.cpp | 572 ++++++++++++ macosx/src/keys.h | 220 +++++ macosx/src/level.cpp | 956 ++++++++++++++++++++ macosx/src/level.h | 143 +++ macosx/src/linux.cpp | 254 ++++++ macosx/src/macosx.cpp | 318 +++++++ macosx/src/main.h | 135 +++ macosx/src/mygl.cpp | 85 ++ macosx/src/mygl.h | 113 +++ macosx/src/player.h | 57 ++ macosx/src/strmanip.cpp | 320 +++++++ macosx/src/strmanip.h | 239 +++++ macosx/src/tga.h | 101 +++ macosx/src/window.cpp | 515 +++++++++++ macosx/src/window.h | 125 +++ macosx/src/worlddefs.h | 31 + macosx/src/x11.cpp | 408 +++++++++ macosx/src/x11.h | 40 + 41 files changed, 8536 insertions(+) create mode 100644 macosx/.cdtproject create mode 100644 macosx/.gitignore create mode 100644 macosx/.project create mode 100644 macosx/Makefile.linux create mode 100644 macosx/Makefile.macosx create mode 100755 macosx/configure create mode 100644 macosx/doc/OpenArena User's Manual.doc create mode 100644 macosx/doc/OpenArena User's Manual.htm create mode 100644 macosx/doc/OpenArena User's Manual.html create mode 100644 macosx/heading.txt create mode 100644 macosx/license.txt create mode 100644 macosx/oa.nsi create mode 100644 macosx/oa.sln create mode 100644 macosx/oa.vcproj create mode 100644 macosx/src/.gitignore create mode 100644 macosx/src/EventManager.cpp create mode 100644 macosx/src/EventManager.h create mode 100644 macosx/src/Makefile.linux create mode 100644 macosx/src/Makefile.macosx create mode 100644 macosx/src/Object.cpp create mode 100644 macosx/src/Object.h create mode 100644 macosx/src/ctrls.cpp create mode 100644 macosx/src/ctrls.h create mode 100644 macosx/src/keys.cpp create mode 100644 macosx/src/keys.h create mode 100644 macosx/src/level.cpp create mode 100644 macosx/src/level.h create mode 100644 macosx/src/linux.cpp create mode 100644 macosx/src/macosx.cpp create mode 100644 macosx/src/main.h create mode 100644 macosx/src/mygl.cpp create mode 100644 macosx/src/mygl.h create mode 100644 macosx/src/player.h create mode 100644 macosx/src/strmanip.cpp create mode 100644 macosx/src/strmanip.h create mode 100644 macosx/src/tga.h create mode 100644 macosx/src/window.cpp create mode 100644 macosx/src/window.h create mode 100644 macosx/src/worlddefs.h create mode 100644 macosx/src/x11.cpp create mode 100644 macosx/src/x11.h diff --git a/macosx/.cdtproject b/macosx/.cdtproject new file mode 100644 index 0000000..6fb810a --- /dev/null +++ b/macosx/.cdtproject @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/.gitignore b/macosx/.gitignore new file mode 100644 index 0000000..13e1820 --- /dev/null +++ b/macosx/.gitignore @@ -0,0 +1,12 @@ +Debug +oa.ncb +Release +OpenArena-0.1.2-alpha.exe +vc70.idb +OpenArena +openarena +oa.exe +UpgradeLog.XML +Makefile +oa.vcproj.ARES.tomhicks.user +.settings diff --git a/macosx/.project b/macosx/.project new file mode 100644 index 0000000..ca30c56 --- /dev/null +++ b/macosx/.project @@ -0,0 +1,90 @@ + + + openarena + + + + + + org.eclipse.cdt.make.core.makeBuilder + clean,full,incremental, + + + org.eclipse.cdt.make.core.build.arguments + -k + + + org.eclipse.cdt.core.errorOutputParser + org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.environment + + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.build.target.inc + all + + + org.eclipse.cdt.make.core.enabledIncrementalBuild + true + + + org.eclipse.cdt.make.core.build.location + + + + org.eclipse.cdt.make.core.build.target.clean + clean + + + org.eclipse.cdt.make.core.build.command + make + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.build.target.full + clean all + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + org.eclipse.cdt.make.core.build.target.auto + all + + + org.eclipse.cdt.make.core.stopOnError + false + + + + + org.eclipse.cdt.make.core.ScannerConfigBuilder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.make.core.makeNature + org.eclipse.cdt.make.core.ScannerConfigNature + + diff --git a/macosx/Makefile.linux b/macosx/Makefile.linux new file mode 100644 index 0000000..c7e04e8 --- /dev/null +++ b/macosx/Makefile.linux @@ -0,0 +1,22 @@ +EXECUTABLES = OpenArena/OA +LIBRARIES = +BUILDROOT = /usr/local +PREFIX = + +.Phony: all clean install + +all: + $(MAKE) -C src all + +clean: + $(MAKE) -C src clean + +install: + +install-devel: + +install-doc: + + + + diff --git a/macosx/Makefile.macosx b/macosx/Makefile.macosx new file mode 100644 index 0000000..044cbc7 --- /dev/null +++ b/macosx/Makefile.macosx @@ -0,0 +1,21 @@ +EXECUTABLES = OpenArena/OA +LIBRARIES = +BUILDROOT = /usr/local +PREFIX = +.Phony: all clean install + +all: + $(MAKE) -C src all + +clean: + $(MAKE) -C src clean + +install: + +install-devel: + +install-doc: + + + + diff --git a/macosx/configure b/macosx/configure new file mode 100755 index 0000000..65c0d90 --- /dev/null +++ b/macosx/configure @@ -0,0 +1,54 @@ +#Symlink Makefiles +case `uname -s` in +Darwin) + ln -sf Makefile.macosx Makefile + ln -sf Makefile.macosx src/Makefile + + #this should be set as a default if no option is specified and set via options otherwise + USE_AGL=1 + ;; +Linux) + ln -sf Makefile.linux Makefile + ln -sf Makefile.linux src/Makefile + + #this should be set as a default if no option is specified and set via options otherwise + USE_GLX=1 + HAVE_XF86VIDMODE=1 + ;; +esac + +#Generate config.h +CONFIGFILE="src/config.h" + +#Write Header +echo "#ifndef CONFIG_H +#define CONFIG_H +" > $CONFIGFILE + +#Check for GLX ie X11 +if [ $USE_GLX ]; then + echo "#define USE_GLX" >> $CONFIGFILE + if [ $HAVE_XF86VIDMODE ]; then + echo "#define HAVE_XF86VIDMODE" >> $CONFIGFILE + fi +fi + +#Check for AGL +if [ $USE_AGL ]; then + echo "#define USE_AGL" >> $CONFIGFILE +fi + +#Check for CGL +if [ $USE_CGL ]; then + echo "#define USE_CGL" >> $CONFIGFILE +fi + +#Check for WGL +if [ $USE_WGL ]; then + echo "#define USE_WGL" >> $CONFIGFILE +fi + +#Write Footer +echo " +#endif +" >> $CONFIGFILE diff --git a/macosx/doc/OpenArena User's Manual.doc b/macosx/doc/OpenArena User's Manual.doc new file mode 100644 index 0000000000000000000000000000000000000000..09ac164f4632e870256b6aa3c29bc1b83c22ec0b GIT binary patch literal 52736 zcmeI53!GI|+5h(pAPh2!2xwln2!aX&3@B=9+yn+;AQ-?43TMvQGjrg~Ipeu73|3Mq zYHE3@^es!&GP{|n^;*4^rj}j){&`K!GR^x1^O|N+$@~4SwfDIU=bRZZ%=GN}d}m+Q zUbknh^{i*Dz4ktv{{J42UGtrN9(THJ$2)z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rkl^{%DMZ$D4)lT&Q`Q|wx~ z)K}czj}mx`0S)SQo2*xH<*{?Ge(i4y+6I5)(gDulqi^}0YFioysbjgH5At~lXv}ge zQ01N50Tt-n4^rWefqH`1foUvf0G?Irhq7n-$~+&{xcpeonVxdyuxEP8X=1NIncmY? zoDud+J2^4-idXFmHEW*z=6->73FGg}QttdvJj0L4t|8I72QR$9>&11fIGgwZmrG?W84e<*lS9|6vz4*%JKYYIGIQ#TGH+^e$m|gUbQoo z>&{2VBv6q+MFJHGR3uQ5z`sHQrN;jn+g3mD{~oxiZr{O|U%~i)?B8yj$+dpnu4zo} zg2wL}!?uCO>>Z#vfGdF|F3v_^3eC9zSnB261R7`G1{&Mn4jS9v1H)kxXfEI(P}q9z zsx$>-evQ-Tc%evJCZ6W!CKe_WkxV!pO~l>B=}aV=(DQ$dpQrhI%{S;=bAsBRIe4In zpTm;-14x+i#I(9oW`04Rvr^KOBxSWJnvQuU5_x8GnfwUG@-FAPd=$vjRM5GOmCqFm z8)mMUGq0iX#Kq>C@;i;|`j*$n*eje9m?_l$SpS@zIhVW-1eV}X4%_p2(((APe*Gky z@Y$tSf3c4l+q~9NEtLi> zZqQzv_Qle`vdmtmAqZz5=Li$tVSc#5^`9xV8HaLQT1S{?hrYNcl=3tqIB9C}J; z_i%!*ZOh+4T9WoO^&Z1fgUzMK-oJz;9P)oqFZ@eq={xp4f9c$YJ(^X53R}uTdu`em zla=(K4ZAmM=xsO|(xULx9(xL3?h0RB-n zyQO|MruaKNR$6#7Vb7$eR2%`p^Lys+i?(furC&e?3hw<$X{ivNT4Et ziUcYWs7TYTwENBc< z2O6VST4LBG^h{O7{#-P`^jvjg(~u!8aB z-*20o>kahYr{^f*m)=s|wQZZiZLgfHOMd)Sw0y1Z?4U*K7Z0{~8-n( + + + + + + + +OpenArena User’s Manual v0 + + + + + + + +
+ +

OpenArena User’s Manual v0.1.0

+ +

 

+ +

Table +of Contents

+ +

 

+ +

1.         Introduction

+ +

            a.         What This Is

+ +

            b.         What This Is Not

+ +

            c.         Version History

+ +

2.         Legal Stuff

+ +

            a.         Legal Notices

+ +

            b.         Copyright Information

+ +

            c.         Suggested Proper Uses

+ +

3.         How To Use the SDK

+ +

4.         Us

+ +

            a.         Contact Information / Who Did What

+ +

            b.         Why I Started This Project

+ +

5.         Files

+ +

            a.         Format of the .map file

+ +

            b.         Format of the .cfg file

+ +

6.         Notes on +the Source Code

+ +

            a.         Mistakes I Plan To Do Something +About

+ +

            b.         Mistakes I Plan To Do Nothing +About

+ +

7.         Changes to +this manual

+ +

            a.         Versions

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

1.         Introduction

+ +

 

+ +

1.a.      What This Is

+ +

            OpenArena +is a 3D rendering engine.  It is suitable +for any type of game, but can be used for anything that requires 3D Rendering.

+ +

 

+ +

1.b.      What This Is Not

+ +

            OpenArena +is not a game in itself.  I PLAN +to distribute some sample games as well.  +OpenArena is not opensource +software.  It is available under the QTPL +a copy of which is attached.

+ +

 

+ +

1.c.      Version History

+ +

            0.0.1-alpha

+ +

                        First Version

+ +

                        Loads a map from a file +and then renders from the origin.

+ +

            0.0.2-alpha

+ +

                        Beginning +of movement code.

+ +

            0.0.3-alpha

+ +

                        Added +prelim texture support.

+ +

            0.0.4-alpha

+ +

                        Better movement code.

+ +

            0.0.4.1-alpha

+ +

                        More movement code +(mouse look) still haven't gotten strafing done yet.

+ +

            0.0.5-alpha

+ +

                        Added support for +control config files for controls implemented so far.

+ +

            0.0.6-alpha

+ +

                        If only I could +remember.

+ +

            0.0.7-alpha

+ +

                        Added the ability for +map files to specify textures to load and which textures go with which +triangle.

+ +

            0.0.8-alpha

+ +

                        Added +the ability to load lighting information for an infinite amount of lights from +a .lit file.

+ +

            0.0.9-alpha

+ +

                        Fixed +control loading.

+ +

                        Modified default +tom4.map file to add 2 more sectors(rooms) to test +multiple sectors.  Until now we had never +tested a map with more than one sector.

+ +

            0.0.10-alpha

+ +

                        Completely +overhauled control loading. (technically a +little faster now)

+ +

                        Added +strafing.

+ +

                        Added mouselook, movespeed, turnspeed, and mousespeed (sensativity) to the config file

+ +

                        Changed +textures in the sample maps.

+ +

            0.0.11-alpha

+ +

                        Added support for +setting the screen resolution in the config file.

+ +

                        Added togglemouselook and quickmouselook +keys.

+ +

            0.0.12-alpha

+ +

                        Moved +all code from the CONTROLS class into the LEVEL class.

+ +

                        Moved +the LoadBMP function into the LEVEL class.

+ +

                        Moved +the texutre array into the LEVEL class.

+ +

                        Added left right and +middle mouse buttons as viable config keys (mouse1 +left, mouse2 right, mouse3 middle)

+ +

            0.0.13-alpha

+ +

                        Added maxfps param to config files.

+ +

                        Added colordepth param to config files.

+ +

                        Added fullscreen param to config files.

+ +

                        Added map param to config files.

+ +

                        Added nextLevel to LEVEL class.  This should allow to have a series of maps be +determined from some other config file later on ie. a maplist +file.

+ +

            0.0.14-alpha

+ +

                        Changed textures to targa files for now only 24 and 32 bit uncompressed images +are supported but more variety will come as will the return of bitmaps.

+ +

            0.0.14.1-alpha
+                        Added support for +compressed targa files.

+ +

            0.0.15-alpha

+ +

                        Added first command line +switch "+set" with it's first parameter +game.  This changes the directory oa loads data from (will make it also look in the oa folder later and add xgame +that only looks in this folder).

+ +

            0.0.16-alpha

+ +

                        Added support for .bmp +textures.

+ +

            0.0.17-alpha

+ +

                        Minor internal tweaking +can’t remember exactly what though.

+ +

            0.0.18-alpha

+ +

                        Major tweaking to +movement and rendering although there isn’t apparently any discernable changes +while running but greatly improved code readability.

+ +

            0.1.0-alpha

+ +

                        Complete rewrite of ingame controls.

+ +

Complete rewrite of level +loading code.

+ +

Complete rewrite of config loading code.

+ +

New map file format.

+ +

New cfg +file format.

+ +

Added support for saving a +map file.

+ +

Added support for saving a cfg file.

+ +

Removed lit file.

+ +

Removed ent file.

+ +

Temporarily removed support +for lights (they will be back soon).

+ +

(coming soon)

+ +

                        Added support for .md3 +models.

+ +

                        Compression some type of +package system probably zip or rar.

+ +

                        Camera/World +Collision.

+ +

                        A test +weapon.

+ +

                        A test +target ie. Bot with +no AI just change color or something when hit.

+ +

                        3D sound and other +sounds

+ +

                        More/real background +music

+ +

 

+ +

2.         Legal Stuff

+ +

 

+ +

2.a.      Legal Notices

+ +

            This software is provided without any warranty of any kind not even +that of merchantability or fitness for a particular purpose.  I take no responsibility for any damages to +anyone or anything resulting from the use or possession of this software.

+ +

 

+ +

2.b.      Copyright Information

+ +

            This program can be distributed +under the GNU GPL with the following exception. I want to make this multiplayer +compatible later on.  So any +modifications that have anything to do with encryption or netcode +don't have to be opensource as long as a copy of the +source is sent to me to peruse and possibly add to the program (with applicable +credit given).  Other than that OA will +be open source hence the name.  +Alternatively you can redistribute OA under the QTPL.

+ +

            If you would like to modify the +source code all I want you to do is make the new source available including +giving me a copy either by e-mail headhunter45@hotmail.com but I have the inbox +protector on so make sure the subject line has OpenArena +in it preferably even just OpenArena as a subject +this is only necessary the first time or two you e-mail me so I can add you to +my address book.

+ +

            The following textures are used with +permission from Texture Station at http://www.nepthys.com/textures moon2.bmp, ground.bmp, nightSky.bmp.  The names have been changed.

+ +

            Some of the audio loops used to +create the background music came, royalty free, from http://www.beatmode.com and Creative Power.

+ +

 

+ +

2.c.      Suggested Uses

+ +

            Make the next greatest first person +shooter.

+ +

Make a really cool RPG.

+ +

 

+ +

3.         How To Use +The SDK

+ +

            I.          Take +my code.

+ +

II.         Modify +it if necessary.

+ +

III.       Create +your own media ie textures, music, maps.

+ +

IV.       Distribute.

+ +

V.        Repeat.

+ +

 

+ +

4.         Us

+ +

 

+ +

4.a.      Contact Information / Who Did What

+ +

            G2k, headhunter45@hotmail.com +put OpenArena in the subject or I'll never see your +message.

+ +

 

+ +

4.b.      Why I Started This Project

+ +

            I got bored one weekend and couldn't +find my quake3™ cd.

+ +

 

+ +

5.         Files

+ +

 

+ +

5.a.      Format of the .map file

+ +

 

+ +

“//” denotes a C++ style comment in this +description, but there are no comments in the .map file at all.

+ +

Blank lines and organization are for readability +purposes only.

+ +

 

+ +

1          //Gravity +not implemented yet

+ +

4          //Number +of triangles in the map

+ +

 

+ +

//First triangle

+ +

1          //Texture +for the first triangle

+ +

//Verticies of this triangle  u and v are +texture coordinates

+ +

// x        +y       z       u      +v

+ +

-10.0  -1.0  +-10.0   0.0  0.0

+ +

-10.0  -1.0   +10.0   2  0.0

+ +

-10.0  10.0   +10.0   +2  1.1

+ +

//The normal for this triangle in x, y, z format +will take out later

+ +

1.0 0.0 0.0

+ +

 

+ +

//Second triangle

+ +

1

+ +

-10.0  -1.0  +-10.0   0.0  0.0

+ +

-10.0  10.0  +-10.0   0.0  1.1

+ +

-10.0  10.0   +10.0   +2  1.1

+ +

1.0 0.0 0.0

+ +

 

+ +

//Third triangle

+ +

1

+ +

 10.0  -1.0  -10.0   +0.0  0.0

+ +

 10.0  -1.0   10.0   +2  0.0

+ +

 10.0  10.0   10.0   2  1.1

+ +

-1.0 0.0 0.0

+ +

 

+ +

//Fourth Triangle

+ +

1

+ +

 10.0  -1.0  -10.0   +0.0  0.0

+ +

 10.0  10.0  -10.0   +0.0  1.1

+ +

 10.0  10.0   10.0   2  1.1

+ +

-1.0 0.0 0.0

+ +

 

+ +

3          //Number +of textures

+ +

groundc.tga      //Texture filenames all in the gamedir/textures folder.  Bmp and tga +textures are allowed.

+ +

moonc.tga

+ +

nightSkyc.tga

+ +

 

+ +

bgm2.mp3        //Background +music file cda1 specifies the first cd-audio track in +the first cd-rom drive cda2 the second and so on.

+ +

 

+ +

5.b.      Format of the .cfg file

+ +

            <command> <param 1> <param 2> … <param n>

+ +

            One command per line separated by any amount of whitespace.  WARNING!  +The parser treats newlines as whitespace but does not require a newline +to separate a command.  This may change +so stick with this format.  The parser +does not like syntax errors.

+ + + +

           

+ +

6.         Notes On +The Source Code

+ +

 

+ +

6.a.      Mistakes I Plan To Do Something About

+ +

            Almost nothing is properly +commented. (I’m working on this … slowly … kinda)

+ +

            Really really bad organization and nonuniform +nameing conventions.  (This is getting better though.)

+ +

 

+ +

6.b.      Mistakes I Plan To Do Nothing About

+ +

None so far.

+ +

 

+ +

7.         Changes to this file

+ +

 

+ +

7.a.      Versions

+ +

 

+ +

            v0.0.1

+ +

                        Origional +Version

+ +

            v0.0.2

+ +

                        Reorganized a few things

+ +

            v0.0.3

+ +

                        Updated contact +information and added an update for OpenArena +v0.0.18-alpha

+ +

            v0.1.0

+ +

                        Made version numbers of +this file match OpenArena release versions.

+ +

                        Updated file description +sections.

+ +

                        Made +section headings bold.

+ +

                        Removed sections 5.b and +5.c and renamed 5.d to 5.b because those files are no longer used.

+ +

 

+ +

 

+ +

 

+ +

           

+ +
+ + + + diff --git a/macosx/doc/OpenArena User's Manual.html b/macosx/doc/OpenArena User's Manual.html new file mode 100644 index 0000000..c1cdc1c --- /dev/null +++ b/macosx/doc/OpenArena User's Manual.html @@ -0,0 +1,1096 @@ + + + + + + + + +OpenArena User’s Manual v0 + + + + + + + +
+ +

OpenArena User’s Manual v0.1.0

+ +

 

+ +

Table +of Contents

+ +

 

+ +

1.         Introduction

+ +

            a.         What This Is

+ +

            b.         What This Is Not

+ +

            c.         Version History

+ +

2.         Legal Stuff

+ +

            a.         Legal Notices

+ +

            b.         Copyright Information

+ +

            c.         Suggested Proper Uses

+ +

3.         How To Use the SDK

+ +

4.         Us

+ +

            a.         Contact Information / Who Did What

+ +

            b.         Why I Started This Project

+ +

5.         Files

+ +

            a.         Format of the .map file

+ +

            b.         Format of the .cfg file

+ +

6.         Notes on +the Source Code

+ +

            a.         Mistakes I Plan To Do Something +About

+ +

            b.         Mistakes I Plan To Do Nothing +About

+ +

7.         Changes to +this manual

+ +

            a.         Versions

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

1.         Introduction

+ +

 

+ +

1.a.      What This Is

+ +

            OpenArena +is a 3D rendering engine.  It is suitable +for any type of game, but can be used for anything that requires 3D Rendering.

+ +

 

+ +

1.b.      What This Is Not

+ +

            OpenArena +is not a game in itself.  I PLAN +to distribute some sample games as well.  +OpenArena is not opensource +software.  It is available under the QTPL +a copy of which is attached.

+ +

 

+ +

1.c.      Version History

+ +

            0.0.1-alpha

+ +

                        First Version

+ +

                        Loads a map from a file +and then renders from the origin.

+ +

            0.0.2-alpha

+ +

                        Beginning +of movement code.

+ +

            0.0.3-alpha

+ +

                        Added +prelim texture support.

+ +

            0.0.4-alpha

+ +

                        Better movement code.

+ +

            0.0.4.1-alpha

+ +

                        More movement code +(mouse look) still haven't gotten strafing done yet.

+ +

            0.0.5-alpha

+ +

                        Added support for +control config files for controls implemented so far.

+ +

            0.0.6-alpha

+ +

                        If only I could +remember.

+ +

            0.0.7-alpha

+ +

                        Added the ability for +map files to specify textures to load and which textures go with which +triangle.

+ +

            0.0.8-alpha

+ +

                        Added +the ability to load lighting information for an infinite amount of lights from +a .lit file.

+ +

            0.0.9-alpha

+ +

                        Fixed +control loading.

+ +

                        Modified default +tom4.map file to add 2 more sectors(rooms) to test +multiple sectors.  Until now we had never +tested a map with more than one sector.

+ +

            0.0.10-alpha

+ +

                        Completely +overhauled control loading. (technically a +little faster now)

+ +

                        Added +strafing.

+ +

                        Added mouselook, movespeed, turnspeed, and mousespeed (sensativity) to the config file

+ +

                        Changed +textures in the sample maps.

+ +

            0.0.11-alpha

+ +

                        Added support for +setting the screen resolution in the config file.

+ +

                        Added togglemouselook and quickmouselook +keys.

+ +

            0.0.12-alpha

+ +

                        Moved +all code from the CONTROLS class into the LEVEL class.

+ +

                        Moved +the LoadBMP function into the LEVEL class.

+ +

                        Moved +the texutre array into the LEVEL class.

+ +

                        Added left right and +middle mouse buttons as viable config keys (mouse1 +left, mouse2 right, mouse3 middle)

+ +

            0.0.13-alpha

+ +

                        Added maxfps param to config files.

+ +

                        Added colordepth param to config files.

+ +

                        Added fullscreen param to config files.

+ +

                        Added map param to config files.

+ +

                        Added nextLevel to LEVEL class.  This should allow to have a series of maps be +determined from some other config file later on ie. a maplist +file.

+ +

            0.0.14-alpha

+ +

                        Changed textures to targa files for now only 24 and 32 bit uncompressed images +are supported but more variety will come as will the return of bitmaps.

+ +

            0.0.14.1-alpha
+                        Added support for +compressed targa files.

+ +

            0.0.15-alpha

+ +

                        Added first command line +switch "+set" with it's first parameter +game.  This changes the directory oa loads data from (will make it also look in the oa folder later and add xgame +that only looks in this folder).

+ +

            0.0.16-alpha

+ +

                        Added support for .bmp +textures.

+ +

            0.0.17-alpha

+ +

                        Minor internal tweaking +can’t remember exactly what though.

+ +

            0.0.18-alpha

+ +

                        Major tweaking to +movement and rendering although there isn’t apparently any discernable changes +while running but greatly improved code readability.

+ +

            0.1.0-alpha

+ +

                        Complete rewrite of ingame controls.

+ +

Complete rewrite of level +loading code.

+ +

Complete rewrite of config loading code.

+ +

New map file format.

+ +

New cfg +file format.

+ +

Added support for saving a +map file.

+ +

Added support for saving a cfg file.

+ +

Removed lit file.

+ +

Removed ent file.

+ +

Temporarily removed support +for lights (they will be back soon).

+ +

(coming soon)

+ +

                        Added support for .md3 +models.

+ +

                        Compression some type of +package system probably zip or rar.

+ +

                        Camera/World +Collision.

+ +

                        A test +weapon.

+ +

                        A test +target ie. Bot with +no AI just change color or something when hit.

+ +

                        3D sound and other +sounds

+ +

                        More/real background +music

+ +

 

+ +

2.         Legal Stuff

+ +

 

+ +

2.a.      Legal Notices

+ +

            This software is provided without any warranty of any kind not even +that of merchantability or fitness for a particular purpose.  I take no responsibility for any damages to +anyone or anything resulting from the use or possession of this software.

+ +

 

+ +

2.b.      Copyright Information

+ +

            This program can be distributed +under the GNU GPL with the following exception. I want to make this multiplayer +compatible later on.  So any +modifications that have anything to do with encryption or netcode +don't have to be opensource as long as a copy of the +source is sent to me to peruse and possibly add to the program (with applicable +credit given).  Other than that OA will +be open source hence the name.  +Alternatively you can redistribute OA under the QTPL.

+ +

            If you would like to modify the +source code all I want you to do is make the new source available including +giving me a copy either by e-mail headhunter45@hotmail.com but I have the inbox +protector on so make sure the subject line has OpenArena +in it preferably even just OpenArena as a subject +this is only necessary the first time or two you e-mail me so I can add you to +my address book.

+ +

            The following textures are used with +permission from Texture Station at http://www.nepthys.com/textures moon2.bmp, ground.bmp, nightSky.bmp.  The names have been changed.

+ +

            Some of the audio loops used to +create the background music came, royalty free, from http://www.beatmode.com and Creative Power.

+ +

 

+ +

2.c.      Suggested Uses

+ +

            Make the next greatest first person +shooter.

+ +

Make a really cool RPG.

+ +

 

+ +

3.         How To Use +The SDK

+ +

            I.          Take +my code.

+ +

II.         Modify +it if necessary.

+ +

III.       Create +your own media ie textures, music, maps.

+ +

IV.       Distribute.

+ +

V.        Repeat.

+ +

 

+ +

4.         Us

+ +

 

+ +

4.a.      Contact Information / Who Did What

+ +

            G2k, headhunter45@hotmail.com +put OpenArena in the subject or I'll never see your +message.

+ +

 

+ +

4.b.      Why I Started This Project

+ +

            I got bored one weekend and couldn't +find my quake3™ cd.

+ +

 

+ +

5.         Files

+ +

 

+ +

5.a.      Format of the .map file

+ +

 

+ +

“//” denotes a C++ style comment in this +description, but there are no comments in the .map file at all.

+ +

Blank lines and organization are for readability +purposes only.

+ +

 

+ +

1          //Gravity +not implemented yet

+ +

4          //Number +of triangles in the map

+ +

 

+ +

//First triangle

+ +

1          //Texture +for the first triangle

+ +

//Verticies of this triangle  u and v are +texture coordinates

+ +

// x        +y       z       u      +v

+ +

-10.0  -1.0  +-10.0   0.0  0.0

+ +

-10.0  -1.0   +10.0   2  0.0

+ +

-10.0  10.0   +10.0   +2  1.1

+ +

//The normal for this triangle in x, y, z format +will take out later

+ +

1.0 0.0 0.0

+ +

 

+ +

//Second triangle

+ +

1

+ +

-10.0  -1.0  +-10.0   0.0  0.0

+ +

-10.0  10.0  +-10.0   0.0  1.1

+ +

-10.0  10.0   +10.0   +2  1.1

+ +

1.0 0.0 0.0

+ +

 

+ +

//Third triangle

+ +

1

+ +

 10.0  -1.0  -10.0   +0.0  0.0

+ +

 10.0  -1.0   10.0   +2  0.0

+ +

 10.0  10.0   10.0   2  1.1

+ +

-1.0 0.0 0.0

+ +

 

+ +

//Fourth Triangle

+ +

1

+ +

 10.0  -1.0  -10.0   +0.0  0.0

+ +

 10.0  10.0  -10.0   +0.0  1.1

+ +

 10.0  10.0   10.0   2  1.1

+ +

-1.0 0.0 0.0

+ +

 

+ +

3          //Number +of textures

+ +

groundc.tga      //Texture filenames all in the gamedir/textures folder.  Bmp and tga +textures are allowed.

+ +

moonc.tga

+ +

nightSkyc.tga

+ +

 

+ +

bgm2.mp3        //Background +music file cda1 specifies the first cd-audio track in +the first cd-rom drive cda2 the second and so on.

+ +

 

+ +

5.b.      Format of the .cfg file

+ +

            <command> <param 1> <param 2> … <param n>

+ +

            One command per line separated by any amount of whitespace.  WARNING!  +The parser treats newlines as whitespace but does not require a newline +to separate a command.  This may change +so stick with this format.  The parser +does not like syntax errors.

+ + + +

           

+ +

6.         Notes On +The Source Code

+ +

 

+ +

6.a.      Mistakes I Plan To Do Something About

+ +

            Almost nothing is properly +commented. (I’m working on this … slowly … kinda)

+ +

            Really really bad organization and nonuniform +nameing conventions.  (This is getting better though.)

+ +

 

+ +

6.b.      Mistakes I Plan To Do Nothing About

+ +

None so far.

+ +

 

+ +

7.         Changes to this file

+ +

 

+ +

7.a.      Versions

+ +

 

+ +

            v0.0.1

+ +

                        Origional +Version

+ +

            v0.0.2

+ +

                        Reorganized a few things

+ +

            v0.0.3

+ +

                        Updated contact +information and added an update for OpenArena +v0.0.18-alpha

+ +

            v0.1.0

+ +

                        Made version numbers of +this file match OpenArena release versions.

+ +

                        Updated file description +sections.

+ +

                        Made +section headings bold.

+ +

                        Removed sections 5.b and +5.c and renamed 5.d to 5.b because those files are no longer used.

+ +

 

+ +

 

+ +

 

+ +

           

+ +
+ + + + diff --git a/macosx/heading.txt b/macosx/heading.txt new file mode 100644 index 0000000..e811d18 --- /dev/null +++ b/macosx/heading.txt @@ -0,0 +1,28 @@ +/******************************************************************************* +00000000011111111112222222222333333333344444444445555555555666666666677777777778 +12345678901234567890123456789012345678901234567890123456789012345678901234567890 +*******************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: +// Author: Tom Hicks +// Creation: 09-01-2003 +// LastEdit: 09-01-2003 +// Editors: None +// +// Purpose: +// +// Summary of Methods: +// Global +// -function name +// description +// blahClass +// -function name +// description +// +// Summary of Properties: +// blahClass +// -property name +// description +// +//////////////////////////////////////////////////////////////////////////////// diff --git a/macosx/license.txt b/macosx/license.txt new file mode 100644 index 0000000..ff22d35 --- /dev/null +++ b/macosx/license.txt @@ -0,0 +1 @@ +This program can be distributed under either the GPL or the QTPL. Copies of which will soon be added to this distribution. diff --git a/macosx/oa.nsi b/macosx/oa.nsi new file mode 100644 index 0000000..76ebe88 --- /dev/null +++ b/macosx/oa.nsi @@ -0,0 +1,205 @@ +; This script is based on example2.nsi + +;-------------------------------- + +; The name of the installer +Name "OpenArena" + +; The installer icon +Icon "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue-full.ico" + +; The uninstaller icon +UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue-full.ico" + + +; The file to write +OutFile "OpenArena-0.1.2-alpha.exe" + +; The default installation directory +InstallDir "$PROGRAMFILES\HHPS\OpenArena-0.1.2-alpha" + +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM SOFTWARE\HHPS\OpenArena-0.1.2-alpha "Install_Dir" + +; The text to prompt the user to enter a directory +ComponentText "This will install OpenArena on your computer. Select which options you want installed." + +; The text to prompt the user to enter a directory +DirText "Choose a directory to install in to:" + +;-------------------------------- + +; Main section docs and libs +Section - "Base (required)" + + SectionIn RO + + ;Dynamic libraries + CreateDirectory $INSTDIR + SetOutPath $INSTDIR + File ".\OpenArena\bass.dll" + WriteUninstaller "uninstall.exe" + + ;Documentation + CreateDirectory "$INSTDIR\doc" + SetOutPath "$INSTDIR\doc" + File ".\doc\*.doc" + File ".\doc\*.html" + + ; Write the installation path into the registry + WriteRegStr HKLM SOFTWARE\HHPS\OpenArena-0.1.2-alpha "Install_Dir" "$INSTDIR" + + ; Write the uninstall keys for Windows + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenArena v0.1.2-alpha" "DisplayName" "OpenArena v0.1.2-alpha (remove only)" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenArena v0.1.2-alpha" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteUninstaller "uninstall.exe" + CreateDirectory "$SMPROGRAMS\HHPS\OpenArena" + SetOutPath $INSTDIR\OpenArena + CreateShortCut "$SMPROGRAMS\HHPS\OpenArena\Readme v0.1.2-alpha.lnk" "$INSTDIR\doc\OpenArena User's Manual.html" + +SectionEnd + +; Source Files required to create and compile a game using the OpenArena SDK +Section "SDK" + + CreateDirectory "$INSTDIR\sources" + SetOutPath "$INSTDIR\sources" + File ".\*.txt" + File ".\*.nsi" + File ".\oa.*" + File ".*" + File "Makefile" + + CreateDirectory "$INSTDIR\sources\lib" + SetOutPath "$INSTDIR\sources\lib" + File ".\lib\bass.lib" + + CreateDirectory "$INSTDIR\sources\include" + SetOutPath "$INSTDIR\sources\include" + File ".\include\*.h" + + CreateDirectory "$INSTDIR\sources\src" + SetOutPath "$INSTDIR\sources\src" + File ".\src\*.cpp" + File ".\Makefile" + + CreateDirectory "$INSTDIR\sources\OpenArena" + SetOutPath "$INSTDIR\sources\OpenArena" + File ".\OpenArena\bass.dll" + + CreateDirectory "$INSTDIR\sources\OpenArena\oa" + CreateDirectory "$INSTDIR\sources\OpenArena\oa\config" + SetOutPath "$INSTDIR\sources\OpenArena\oa\config" + File ".\OpenArena\oa\config\my.cfg" + + CreateDirectory "$INSTDIR\sources\OpenArena\oa\maps" + SetOutPath "$INSTDIR\sources\OpenArena\oa\maps" + File ".\OpenArena\oa\maps\intro.map" + + CreateDirectory "$INSTDIR\sources\OpenArena\oa\music\bgm" + ;SetOutPath "$INSTDIR\sources\OpenArena\oa\music\bgm" + ;File ".\OpenArena\oa\music\bgm\*.mp3" + + CreateDirectory "$INSTDIR\sources\OpenArena\oa\textures" + SetOutPath "$INSTDIR\sources\OpenArena\oa\textures" + File ".\OpenArena\oa\textures\*.bmp" + File ".\OpenArena\oa\textures\*.tga" + CreateDirectory "$INSTDIR\sources\OpenArena\oa\textures\menu" + SetOutPath "$INSTDIR\sources\OpenArena\oa\textures\menu" + File ".\OpenArena\oa\textures\menu\*.bmp" + File ".\OpenArena\oa\textures\menu\*.tga" + + CreateDirectory "$INSTDIR\sources\ModelConverter" + SetOutPath "$INSTDIR\sources\ModelConverter" + File ".\ModelConverter\*.cs" + File ".\ModelConverter\*.ico" + File ".\ModelConverter\*.csproj" + File ".\ModelConverter\*.csproj.user" + + CreateShortCut "$SMPROGRAMS\HHPS\OpenArena\OpenArena SDK v0.1.2-alpha.lnk" "$INSTDIR\sources\oa.sln" + +SectionEnd + +Section "Media" + + CreateDirectory "$INSTDIR" + SetOutPath "$INSTDIR" + File ".\OpenArena\oa.exe" + + CreateDirectory "$INSTDIR\oa" + CreateDirectory "$INSTDIR\oa\config" + SetOutPath "$INSTDIR\oa\config" + File ".\OpenArena\oa\config\my.cfg" + + CreateDirectory "$INSTDIR\oa\maps" + SetOutPath $INSTDIR\oa\maps + File ".\OpenArena\oa\maps\intro.map" + File ".\OpenArena\oa\maps\oamap1.map" + + CreateDirectory "$INSTDIR\oa\music" + CreateDirectory "$INSTDIR\oa\music\bgm" + SetOutPath $INSTDIR\oa\music\bgm + File ".\OpenArena\oa\music\bgm\*.mp3" + + CreateDirectory "$INSTDIR\oa\textures" + SetOutPath $INSTDIR\oa\textures + File ".\OpenArena\oa\textures\*.tga" + File ".\OpenArena\oa\textures\*.bmp" + + CreateDirectory "$INSTDIR\oa\textures\menu" + SetOutPath $INSTDIR\oa\textures\menu + File ".\OpenArena\oa\textures\menu\*.bmp" + File ".\OpenArena\oa\textures\menu\*.tga" + + SetOutPath $INSTDIR + CreateShortCut "$SMPROGRAMS\HHPS\OpenArena\OpenArena v0.1.2-alpha.lnk" "$INSTDIR\oa.exe" + +SectionEnd + +;-------------------------------- +; Uninstaller + +UninstallText "This will uninstall OpenArena. Hit next to continue." +; Uninstall section + +Section "Uninstall" + + ; remove registry keys + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenArena v0.1.2-alpha" + DeleteRegKey HKLM SOFTWARE\HHPS\OpenArena-0.1.2-alpha + + ; remove files and uninstaller + Delete /REBOOTOK "$INSTDIR\oa" + Delete /REBOOTOK "$INSTDIR\sources" + Delete /REBOOTOK "$INSTDIR\doc" + Delete /REBOOTOK "$INSTDIR\*.exe" + Delete /REBOOTOK "$INSTDIR\*.dll" + + ;Delete /REBOOTOK $INSTDIR\lib\* + ;Delete /REBOOTOK $INSTDIR\src\*.* + ;Delete /REBOOTOK $INSTDIR\bass.dll + ;Delete /REBOOTOK $INSTDIR\heading.txt + ;Delete /REBOOTOK $INSTDIR\license.txt + ;Delete /REBOOTOK $INSTDIR\oa.ncb + ;Delete /REBOOTOK $INSTDIR\oa.sln + ;Delete /REBOOTOK $INSTDIR\oa.sou + ;Delete /REBOOTOK $INSTDIR\oa.vcproj + ;Delete /REBOOTOK "$INSTDIR\OpenArena User's Manual.doc" + ;Delete /REBOOTOK "$INSTDIR\OpenArena User's Manual.html" + + Delete /REBOOTOK $INSTDIR\uninstall.exe + + ; remove shortcuts, if any + Delete /REBOOTOK "$SMPROGRAMS\HHPS\OpenArena\Readme v0.1.2-alpha.lnk" + Delete /REBOOTOK "$SMPROGRAMS\HHPS\OpenArena\OpenArena SDK v0.1.2-alpha.lnk" + Delete /REBOOTOK "$SMPROGRAMS\HHPS\OpenArena\OpenArena v0.1.2-alpha.lnk" + + ; remove directories used + RMDIR /r $INSTDIR\include + RMDIR /r $INSTDIR\lib + RMDIR /r $INSTDIR\OpenArena + RMDIR /r $INSTDIR\src + RMDIR /r "$INSTDIR" + +SectionEnd \ No newline at end of file diff --git a/macosx/oa.sln b/macosx/oa.sln new file mode 100644 index 0000000..bee1fb4 --- /dev/null +++ b/macosx/oa.sln @@ -0,0 +1,41 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "oa", "oa.vcproj", "{6F5D0FF6-A032-4356-932E-865B601E0DD4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelConverter", "ModelConverter\ModelConverter.csproj", "{4327B7E9-B631-479B-8419-BCE37C986360}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Debug|Win32.ActiveCfg = Debug|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Debug|Win32.Build.0 = Debug|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Release|Any CPU.ActiveCfg = Release|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Release|Mixed Platforms.Build.0 = Release|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Release|Win32.ActiveCfg = Release|Win32 + {6F5D0FF6-A032-4356-932E-865B601E0DD4}.Release|Win32.Build.0 = Release|Win32 + {4327B7E9-B631-479B-8419-BCE37C986360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Debug|Win32.ActiveCfg = Debug|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Release|Any CPU.Build.0 = Release|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {4327B7E9-B631-479B-8419-BCE37C986360}.Release|Win32.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/macosx/oa.vcproj b/macosx/oa.vcproj new file mode 100644 index 0000000..5423215 --- /dev/null +++ b/macosx/oa.vcproj @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macosx/src/.gitignore b/macosx/src/.gitignore new file mode 100644 index 0000000..2bd1165 --- /dev/null +++ b/macosx/src/.gitignore @@ -0,0 +1,3 @@ +*.o +Makefile +config.h diff --git a/macosx/src/EventManager.cpp b/macosx/src/EventManager.cpp new file mode 100644 index 0000000..21ce992 --- /dev/null +++ b/macosx/src/EventManager.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +/** + * @file EventManager.cpp + * @breif Implementation of the EventManager class + * This file along with EventManager.h implement the EventManager + * class. The EventManager class collects and redistributes events + * in a fashion similar to AWT's EventListeners. + * + * @see EventManager.h + */ +#include "EventManager.h" +#include +#include + +namespace OpenArena +{ + EventManager::EventManager() + { + } + + + void EventManager::SendEvent(Events::Event* event) + { + unsigned int index; + + for(index=0; index < eventHandlers.Length(); index++) + { + Events::Event::EventHandler* handler = eventHandlers[index]; + if(handler->Handles(event->GetEventType())) + { + handler->HandleEvent(event); + } + } + + delete event; + } + + /* + void EventManager::SendEvent(Events::Event event) + { + unsigned int index; + + for(index=0; index < eventHandlers.Length(); index++) + { + Events::Event::EventHandler* handler = eventHandlers[index]; + if(handler->Handles(event.GetEventType())) + { + handler->HandleEvent(event); + } + } + } + */ + + void EventManager::RegisterEventHandler(Events::Event::EventHandler* eventHandler) + { + eventHandlers.Insert(eventHandler); + } +}; diff --git a/macosx/src/EventManager.h b/macosx/src/EventManager.h new file mode 100644 index 0000000..e1329c7 --- /dev/null +++ b/macosx/src/EventManager.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __OpenArena_EventMangaer_h__ +#define __OpenArena_EventMangaer_h__ + +#include "Events/Event.h" +#include "list.h" + +namespace OpenArena +{ + class EventManager + { + public: + EventManager(); + void SendEvent(Events::Event* event); + void RegisterEventHandler(Events::Event::EventHandler* eventHandler); + private: + list eventHandlers; + }; +} +#endif /*__OpenArena_EventMangaer_h__*/ diff --git a/macosx/src/Makefile.linux b/macosx/src/Makefile.linux new file mode 100644 index 0000000..728f178 --- /dev/null +++ b/macosx/src/Makefile.linux @@ -0,0 +1,99 @@ +#Dependencies soooo need to be fixed/finished +CPP = g++ -g +INCLUDES = -I/usr/X11R6/include +LD = g++ +OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o player.o +OBJECTS += strmanip.o tga.o vector.o window.o keys.o main.o x11.o EventManager.o Events/DrawEvent.o +OBJECTS += Events/Event.o Object.o Events/KeyPressEvent.o Events/KeyReleaseEvent.o +LIBS = -L/usr/X11R6/lib -lGL -lGLU -lXxf86vm +LIBRARIES = +SO_LIBS = +SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so +CPPFLAGS = -DHAVE_CONFIG_H +LDFLAGS = $(LIBS) + +.Phony: all clean install + +all: ../OpenArena + +clean: + rm -f *.o + rm -f ../OpenArena + +install: + +#Executables +../OpenArena: $(OBJECTS) + $(LD) $(LDFLAGS) -o ../OpenArena $(OBJECTS) + +#Dynamic Libraries +oa_game.so: + +oa_audio.so: + +oa_net.so: + +oa_video.so: + +oa_input.so: + +#Object Files +Events/Event.o: Events/Event.cpp Events/Event.h Object.h + $(CPP) $(CPPFLAGS) -c $(INCLUDE_DIRS) -o Events/Event.o Events/Event.cpp + +Object.o: Object.cpp Object.h + $(CPP) $(CPPFLAGS) -c $(INCLUDE_DIRS) -o Object.o Object.cpp + +Events/KeyPressEvent.o: Events/KeyPressEvent.cpp Events/KeyPressEvent.h Events/Event.h + $(CPP) $(CPPFLAGS) -c $(INCLUDE_DIRS) -o Events/KeyPressEvent.o Events/KeyPressEvent.cpp + +Events/KeyReleaseEvent.o: Events/KeyReleaseEvent.cpp Events/KeyReleaseEvent.h Events/Event.h + $(CPP) $(CPPFLAGS) -c $(INCLUDE_DIRS) -o Events/KeyReleaseEvent.o Events/KeyReleaseEvent.cpp + +Events/DrawEvent.o: Events/DrawEvent.cpp Events/DrawEvent.h Events/Event.h + $(CPP) $(CPPFLAGS) -c $(INCLUDE_DIRS) -o Events/DrawEvent.o Events/DrawEvent.cpp + +screen.o: screen.cpp screen.h config.h + $(CPP) $(CPPFLAGS) -c -o screen.o screen.cpp + +bmp.o: bmp.cpp bmp.h mygl.h datatypes.h texture.h config.h + $(CPP) $(CPPFLAGS) -c -o bmp.o bmp.cpp + +camera.o: camera.cpp camera.h vector.h mygl.h screen.h config.h + $(CPP) $(CPPFLAGS) -c -o camera.o camera.cpp + +ctrls.o: ctrls.cpp ctrls.h keys.h datatypes.h list.h config.h + $(CPP) $(CPPFLAGS) -c -o ctrls.o ctrls.cpp + +level.o: level.cpp level.h version.h config.h + $(CPP) $(CPPFLAGS) -c -o level.o level.cpp + +mygl.o: mygl.cpp mygl.h config.h + $(CPP) $(CPPFLAGS) -c -o mygl.o mygl.cpp + +myglFont.o: myglFont.cpp myglFont.h config.h + $(CPP) $(CPPFLAGS) -c -o myglFont.o myglFont.cpp + +myglTexture.o: myglTexture.cpp myglTexture.h config.h + $(CPP) $(CPPFLAGS) -c -o myglTexture.o myglTexture.cpp + +player.o: player.cpp player.h config.h + $(CPP) $(CPPFLAGS) -c -o player.o player.cpp + +strmanip.o: strmanip.cpp strmanip.h config.h + $(CPP) $(CPPFLAGS) -c -o strmanip.o strmanip.cpp + +tga.o: tga.cpp tga.h config.h + $(CPP) $(CPPFLAGS) -c -o tga.o tga.cpp + +vector.o: vector.cpp vector.h config.h + $(CPP) $(CPPFLAGS) -c -o vector.o vector.cpp + +window.o: window.cpp window.h config.h + $(CPP) $(CPPFLAGS) -c -o window.o window.cpp + +keys.o: keys.cpp keys.h config.h + $(CPP) $(CPPFLAGS) -c -o keys.o keys.cpp + +main.o: linux.cpp main.h config.h + $(CPP) $(CPPFLAGS) -c -o main.o linux.cpp diff --git a/macosx/src/Makefile.macosx b/macosx/src/Makefile.macosx new file mode 100644 index 0000000..26cd1d4 --- /dev/null +++ b/macosx/src/Makefile.macosx @@ -0,0 +1,109 @@ +#Dependencies soooo need to be fixed/finished +CPP = g++ -g +INCLUDES = +LD = g++ +X11INCLUDEDIR = /usr/X11R6/include +X11LIBDIR = /usr/X11R6/lib +INCLUDE_DIRS = -I$(X11INCLUDEDIR) -DHAVE_CONFIG_H +LIBRARY_DIRS = -L$(X11LIBDIR) +OBJECTS = screen.o bmp.o camera.o ctrls.o level.o mygl.o myglFont.o myglTexture.o player.o +OBJECTS += strmanip.o tga.o vector.o window.o keys.o main.o x11.o EventManager.o Events/DrawEvent.o +OBJECTS += Events/Event.o Object.o Events/KeyPressEvent.o Events/KeyReleaseEvent.o +LIBS = $(LIBRARY_DIRS) -lGL -lGLU -lXxf86vm -lX11 +LIBRARIES = +SO_LIBS = +SO_LIBRARIES = oa_game.so oa_audio.so oa_net.so oa_video.so oa_input.so +CPPFLAGS = $(INCLUDE_DIRS) +LDFLAGS = $(LIBS) -bind_at_load -framework OpenGL -framework AGL -framework Carbon +.Phony: all clean install + +all: ../OpenArena + +clean: + rm -f *.o + if [ -f ../OpenArena ]; then rm ../OpenArena; fi + rm -f */*.o + +install: + +#Executables +../OpenArena: $(OBJECTS) + $(LD) $(LDFLAGS) $(INCLUDE_DIRS) -o ../OpenArena $(OBJECTS) + +#Dynamic Libraries +oa_game.so: + +oa_audio.so: + +oa_net.so: + +oa_video.so: + +oa_input.so: + +#Object Files +Events/Event.o: Events/Event.cpp Events/Event.h Object.h + $(CPP) -c $(INCLUDE_DIRS) -o Events/Event.o Events/Event.cpp + +Object.o: Object.cpp Object.h + $(CPP) -c $(INCLUDE_DIRS) -o Object.o Object.cpp + +Events/KeyPressEvent.o: Events/KeyPressEvent.cpp Events/KeyPressEvent.h Events/Event.h + $(CPP) -c $(INCLUDE_DIRS) -o Events/KeyPressEvent.o Events/KeyPressEvent.cpp + +Events/KeyReleaseEvent.o: Events/KeyReleaseEvent.cpp Events/KeyReleaseEvent.h Events/Event.h + $(CPP) -c $(INCLUDE_DIRS) -o Events/KeyReleaseEvent.o Events/KeyReleaseEvent.cpp + +Events/DrawEvent.o: Events/DrawEvent.cpp Events/DrawEvent.h Events/Event.h + $(CPP) -c $(INCLUDE_DIRS) -o Events/DrawEvent.o Events/DrawEvent.cpp + +screen.o: screen.cpp screen.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o screen.o screen.cpp + +bmp.o: bmp.cpp bmp.h mygl.h datatypes.h texture.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o bmp.o bmp.cpp + +camera.o: camera.cpp camera.h vector.h mygl.h screen.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o camera.o camera.cpp + +ctrls.o: ctrls.cpp ctrls.h keys.h datatypes.h list.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o ctrls.o ctrls.cpp + +level.o: level.cpp level.h version.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o level.o level.cpp + +mygl.o: mygl.cpp mygl.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o mygl.o mygl.cpp + +myglFont.o: myglFont.cpp myglFont.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o myglFont.o myglFont.cpp + +myglTexture.o: myglTexture.cpp myglTexture.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o myglTexture.o myglTexture.cpp + +player.o: player.cpp player.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o player.o player.cpp + +strmanip.o: strmanip.cpp strmanip.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o strmanip.o strmanip.cpp + +tga.o: tga.cpp tga.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o tga.o tga.cpp + +vector.o: vector.cpp vector.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o vector.o vector.cpp + +window.o: window.cpp window.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o window.o window.cpp + +keys.o: keys.cpp keys.h config.h + $(CPP) -c $(INCLUDE_DIRS) -o keys.o keys.cpp + +main.o: macosx.cpp main.h config.h Events/Event.h Events/DrawEvent.h EventManager.h + $(CPP) -c $(INCLUDE_DIRS) -o main.o macosx.cpp + +x11.o: x11.cpp x11.h EventManager.h main.h mygl.h + $(CPP) -c $(INCLUDE_DIRS) -o x11.o x11.cpp + +EventManager.o: EventManager.cpp EventManager.h Events/Event.h + $(CPP) -c $(INCLUDE_DIRS) -o EventManager.o EventManager.cpp diff --git a/macosx/src/Object.cpp b/macosx/src/Object.cpp new file mode 100644 index 0000000..9a06666 --- /dev/null +++ b/macosx/src/Object.cpp @@ -0,0 +1,17 @@ +#include "Object.h" + +namespace OpenArena +{ + Object::Object() + { + } + + Object::~Object() + { + } + + const char * Object::GetClassName() + { + return 0x0; + } +}; \ No newline at end of file diff --git a/macosx/src/Object.h b/macosx/src/Object.h new file mode 100644 index 0000000..1daa293 --- /dev/null +++ b/macosx/src/Object.h @@ -0,0 +1,15 @@ +#ifndef __OpenArena_Object_h__ +#define __OpenArena_Object_h__ + +namespace OpenArena +{ + class Object + { + public: + Object(); + virtual ~Object(); + virtual const char* GetClassName(); + }; +}; + +#endif //__OpenArena_Object_h__ diff --git a/macosx/src/ctrls.cpp b/macosx/src/ctrls.cpp new file mode 100644 index 0000000..ba0ee9f --- /dev/null +++ b/macosx/src/ctrls.cpp @@ -0,0 +1,224 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: ctrls.cpp +// Author: Tom Hicks +// Creation: 09-01-2003 +// LastEdit: 06-19-2005 +// Editors: Tom Hicks +// +// Purpose: +// To implement a system for managing a bindable control scheme. +// +// Summary of Methods: +// ControlScheme +// void LoadDefaultControlScheme(); +// -Loads the default control scheme +// void ClearControlScheme(); +// -Clears the control scheme +// void Unbind(uint8 key); +// -Removes key from all control lists. +// +// Summary of Properties: +// ControlScheme +// +//////////////////////////////////////////////////////////////////////////////// + +#include "ctrls.h" +#include "strmanip.h" +using std::string; +using std::ostream; +using std::endl; + +namespace OpenArena{ + void ControlScheme::LoadDefaultControlScheme() + { + Bind(OpenArena::KEY_LBUTTON, ACTION_FORWARD); + Bind(OpenArena::KEY_RBUTTON, ACTION_BACKWARD); + Bind(OpenArena::KEY_LEFT, ACTION_LOOKLEFT); + Bind(OpenArena::KEY_RIGHT, ACTION_LOOKRIGHT); + Bind(OpenArena::KEY_UP, ACTION_LOOKUP); + Bind(OpenArena::KEY_DOWN, ACTION_LOOKDOWN); + Bind(OpenArena::KEY_S, ACTION_MOVELEFT); + Bind(OpenArena::KEY_D, ACTION_MOVERIGHT); + Bind(OpenArena::KEY_SPACE, ACTION_MOVEUP); + Bind(OpenArena::KEY_A, ACTION_MOVEDOWN); + Bind(OpenArena::KEY_F, ACTION_FIREPRIMARY); + Bind(OpenArena::KEY_G, ACTION_FIRESECONDARY); + Bind(OpenArena::KEY_T, ACTION_WEAPONNEXT); + Bind(OpenArena::KEY_R, ACTION_WEAPONPREV); + Bind(OpenArena::KEY_L, ACTION_TOGGLE_LIGHTS); + Bind(OpenArena::KEY_P, ACTION_TOGGLE_FPS); + Bind(OpenArena::KEY_OEM_3, ACTION_TOGGLE_CONSOLE); + Bind(OpenArena::KEY_M, ACTION_TOGGLE_MOUSELOOK); + Bind(OpenArena::KEY_Q, ACTION_QUICKMOUSELOOK); + Bind(OpenArena::KEY_W, ACTION_ROLLLEFT); + Bind(OpenArena::KEY_E, ACTION_ROLLRIGHT); + } + void ControlScheme::UnBindAll() + { + OpenArena::Keys key; + for(key=(OpenArena::Keys)0; key<(OpenArena::Keys)256; key = (OpenArena::Keys)(key+1)) + { + UnBind(key); + } + } + + void ControlScheme::UnBind(OpenArena::Keys key) + { + keyActions[key] = ACTION_NONE; + } + + void ControlScheme::Bind(OpenArena::Keys key, Action action) + { + keyActions[key] = action; + } + + void ControlScheme::WriteToStream(std::ostream& output) + { + //output << " bind " << action << keyname << endl; + OpenArena::Keys key; + for(key=(OpenArena::Keys)0; key<(OpenArena::Keys)256; key = (OpenArena::Keys)(key+1)) + { + if(keyActions[key] != ACTION_NONE) + { + output << " bind " << ActionName(keyActions[key]) << GetKeyName(key) << endl; + } + } + } + + ControlScheme::Action ControlScheme::GetAction(const char* actionName) + { + string str = actionName; + str = tolower(str); + if(str == "none"){ + return ACTION_NONE; + }else if(str == "forward"){ + return ACTION_FORWARD; + }else if(str == "backward"){ + return ACTION_BACKWARD; + }else if(str == "lookleft"){ + return ACTION_LOOKLEFT; + }else if(str == "lookright"){ + return ACTION_LOOKRIGHT; + }else if(str == "lookup"){ + return ACTION_LOOKUP; + }else if(str == "lookdown"){ + return ACTION_LOOKDOWN; + }else if(str == "moveleft"){ + return ACTION_MOVELEFT; + }else if(str == "moveright"){ + return ACTION_MOVERIGHT; + }else if(str == "moveup"){ + return ACTION_MOVEUP; + }else if(str == "movedown"){ + return ACTION_MOVEDOWN; + }else if(str == "rollleft"){ + return ACTION_ROLLLEFT; + }else if(str == "rollright"){ + return ACTION_ROLLRIGHT; + }else if(str == "fireprimary"){ + return ACTION_FIREPRIMARY; + }else if(str == "firesecondary"){ + return ACTION_FIRESECONDARY; + }else if(str == "weaponnext"){ + return ACTION_WEAPONNEXT; + }else if(str == "weaponprev"){ + return ACTION_WEAPONPREV; + }else if(str == "togglelights"){ + return ACTION_TOGGLE_LIGHTS; + }else if(str == "togglefps"){ + return ACTION_TOGGLE_FPS; + }else if(str == "toggleconsole"){ + return ACTION_TOGGLE_CONSOLE; + }else if(str == "togglemouselook"){ + return ACTION_TOGGLE_MOUSELOOK; + }else if(str == "quickmouselook"){ + return ACTION_QUICKMOUSELOOK; + }else{ + return ACTION_NONE; + } + } + + string ControlScheme::ActionName(Action action) + { + switch(action) + { + case ACTION_NONE: + return "none"; + case ACTION_FORWARD: + return "forward"; + case ACTION_BACKWARD: + return "backward"; + case ACTION_LOOKLEFT: + return "lookleft"; + case ACTION_LOOKRIGHT: + return "lookright"; + case ACTION_LOOKUP: + return "lookup"; + case ACTION_LOOKDOWN: + return "lookdown"; + case ACTION_MOVELEFT: + return "moveleft"; + case ACTION_MOVERIGHT: + return "moveright"; + case ACTION_MOVEUP: + return "moveup"; + case ACTION_MOVEDOWN: + return "movedown"; + case ACTION_ROLLLEFT: + return "rollleft"; + case ACTION_ROLLRIGHT: + return "rollright"; + case ACTION_FIREPRIMARY: + return "fireprimary"; + case ACTION_FIRESECONDARY: + return "firesecondary"; + case ACTION_WEAPONNEXT: + return "weaponnext"; + case ACTION_WEAPONPREV: + return "weaponprev"; + case ACTION_TOGGLE_LIGHTS: + return "togglelights"; + case ACTION_TOGGLE_FPS: + return "togglefps"; + case ACTION_TOGGLE_CONSOLE: + return "toggleconsole"; + case ACTION_TOGGLE_MOUSELOOK: + return "togglemouselook"; + case ACTION_QUICKMOUSELOOK: + return "quickmouselook"; + default: + return "unknown"; + }; + } + + bool ControlScheme::IsBound(OpenArena::Keys key, Action action) + { + if(keyActions[key] == action) + { + return true; + } + + return false; + } +}; + diff --git a/macosx/src/ctrls.h b/macosx/src/ctrls.h new file mode 100644 index 0000000..f333d3f --- /dev/null +++ b/macosx/src/ctrls.h @@ -0,0 +1,76 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __ctrls_h__ +#define __ctrls_h__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif +#include +#include +#include "keys.h" +#include "datatypes.h" + +namespace OpenArena{ + class ControlScheme + { + public: + enum Action + { + ACTION_NONE = 0, + ACTION_FORWARD, + ACTION_BACKWARD, + ACTION_LOOKLEFT, + ACTION_LOOKRIGHT, + ACTION_LOOKUP, + ACTION_LOOKDOWN, + ACTION_MOVELEFT, + ACTION_MOVERIGHT, + ACTION_MOVEUP, + ACTION_MOVEDOWN, + ACTION_ROLLLEFT, + ACTION_ROLLRIGHT, + ACTION_FIREPRIMARY, + ACTION_FIRESECONDARY, + ACTION_WEAPONNEXT, + ACTION_WEAPONPREV, + ACTION_TOGGLE_LIGHTS, + ACTION_TOGGLE_FPS, + ACTION_TOGGLE_CONSOLE, + ACTION_TOGGLE_MOUSELOOK, + ACTION_QUICKMOUSELOOK, + NUM_ACTIONS + }; + + void LoadDefaultControlScheme(); + void UnBindAll(); + void UnBind(OpenArena::Keys key); + void Bind(OpenArena::Keys key, Action action); + void WriteToStream(std::ostream& output); + static Action GetAction(const char* actionName); + static const char* GetActionName(Action action); + bool IsBound(OpenArena::Keys key, Action action); + private: + std::string ActionName(Action action); + Action keyActions[256]; + }; +}; + +#endif diff --git a/macosx/src/keys.cpp b/macosx/src/keys.cpp new file mode 100644 index 0000000..b30dc66 --- /dev/null +++ b/macosx/src/keys.cpp @@ -0,0 +1,572 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "keys.h" + +#include + +using std::string; + +char OpenArena::KeyToASCII(Keys key, bool shift) +{ + if(key == KEY_UNKNOWN) + { + return '\0'; + } + else + { + switch(key) + { + case KEY_OEM_1: + if(shift) + { + return ':'; + } + else + { + return ';'; + } + case KEY_OEM_2: + if(shift) + { + return '?'; + } + else + { + return '/'; + } + case KEY_OEM_3: + if(shift) + { + return '~'; + } + else + { + return '`'; + } + case KEY_OEM_4: + if(shift) + { + return '{'; + } + else + { + return '['; + } + case KEY_OEM_5: + if(shift) + { + return '|'; + } + else + { + return '\\'; + } + case KEY_OEM_6: + if(shift) + { + return '}'; + } + else + { + return ']'; + } + case KEY_OEM_7: + if(shift) + { + return '\''; + } + else + { + return '"'; + } + case KEY_OEM_PERIOD: + if(shift) + { + return '>'; + } + else + { + return '.'; + } + case KEY_OEM_PLUS: + if(shift) + { + return '+'; + } + else + { + return '='; + } + case KEY_OEM_COMMA: + if(shift) + { + return '<'; + } + else + { + return ','; + } + case KEY_OEM_MINUS: + if(shift) + { + return '_'; + } + else + { + return '-'; + } + default: + if(key >= KEY_A && key <= KEY_Z) + { + if(shift) + { + return key - KEY_A + 'A'; + } + else + { + return key - KEY_A + 'a'; + } + } + else if(key >= KEY_0 && key <= KEY_9) + { + if(shift) + { + switch(key - KEY_0) + { + case 0: + return ')'; + case 1: + return '!'; + case 2: + return '@'; + case 3: + return '#'; + case 4: + return '$'; + case 5: + return '%'; + case 6: + return '^'; + case 7: + return '&'; + case 8: + return '*'; + case 9: + return '('; + } + } + else + { + return key - KEY_0 + '0'; + } + } + else + { + return '\0'; + } + } + } + return '\0'; +} + +const char* OpenArena::GetKeyName(Keys key) +{ + switch(key) + { + case KEY_UNKNOWN: + return "unknown"; + case KEY_BUTTON0: + return "button0"; + case KEY_BUTTON1: + return "button1"; + case KEY_BUTTON2: + return "button2"; + case KEY_BUTTON3: + return "button3"; + case KEY_BUTTON4: + return "button4"; + case KEY_LEFT: + return "left"; + case KEY_RIGHT: + return "right"; + case KEY_UP: + return "up"; + case KEY_DOWN: + return "down"; + case KEY_SPACE: + return "space"; + case KEY_RETURN: + return "return"; + case KEY_SHIFT: + return "shift"; + case KEY_PAUSE: + return "pause"; + case KEY_CONTROL: + return "ctrl"; + case KEY_CAPITAL: + return "caps"; + case KEY_ESCAPE: + return "esc"; + case KEY_PRIOR: + return "pgup"; + case KEY_NEXT: + return "pgdn"; + case KEY_END: + return "end"; + case KEY_HOME: + return "home"; + case KEY_INSERT: + return "insert"; + case KEY_DELETE: + return "del"; + case KEY_LWIN: + return "leftwin"; + case KEY_RWIN: + return "rightwin"; + case KEY_APPS: + return "apps"; + case KEY_NUMPAD0: + return "kp0"; + case KEY_NUMPAD1: + return "kp1"; + case KEY_NUMPAD2: + return "kp2"; + case KEY_NUMPAD3: + return "kp3"; + case KEY_NUMPAD4: + return "kp4"; + case KEY_NUMPAD5: + return "kp5"; + case KEY_NUMPAD6: + return "kp6"; + case KEY_NUMPAD7: + return "kp7"; + case KEY_NUMPAD8: + return "kp8"; + case KEY_NUMPAD9: + return "kp9"; + case KEY_MULTIPLY: + return "multiply"; + case KEY_ADD: + return "plus"; + case KEY_SUBTRACT: + return "minus"; + case KEY_DIVIDE: + return "divide"; + case KEY_F1: + return "f1"; + case KEY_F2: + return "f2"; + case KEY_F3: + return "f3"; + case KEY_F4: + return "f4"; + case KEY_F5: + return "f5"; + case KEY_F6: + return "f6"; + case KEY_F7: + return "f7"; + case KEY_F8: + return "f8"; + case KEY_F9: + return "f9"; + case KEY_F10: + return "f10"; + case KEY_F11: + return "f11"; + case KEY_F12: + return "f12"; + case KEY_NUMLOCK: + return "numlock"; + case KEY_SCROLL: + return "scrolllock"; + case KEY_SEPARATOR: + return "_separator"; + case KEY_OEM_1: + return "semicolon"; + case KEY_OEM_2: + return "slash"; + case KEY_OEM_3: + return "tilde"; + case KEY_OEM_4: + return "leftbracket"; + case KEY_OEM_5: + return "backslash"; + case KEY_OEM_6: + return "rightbracket"; + case KEY_OEM_7: + return "quote"; + case KEY_OEM_PERIOD: + return "period"; + case KEY_OEM_PLUS: + return "equals"; + case KEY_OEM_MINUS: + return "minus"; + case KEY_OEM_COMMA: + return "comma"; + case KEY_BACK: + return "backspace"; + case KEY_TAB: + return "tab"; + case KEY_0: + return "0"; + case KEY_1: + return "1"; + case KEY_2: + return "2"; + case KEY_3: + return "3"; + case KEY_4: + return "4"; + case KEY_5: + return "5"; + case KEY_6: + return "6"; + case KEY_7: + return "7"; + case KEY_8: + return "8"; + case KEY_9: + return "9"; + case KEY_A: + return "a"; + case KEY_B: + return "b"; + case KEY_C: + return "c"; + case KEY_D: + return "d"; + case KEY_E: + return "e"; + case KEY_F: + return "f"; + case KEY_G: + return "g"; + case KEY_H: + return "h"; + case KEY_I: + return "i"; + case KEY_J: + return "j"; + case KEY_K: + return "k"; + case KEY_L: + return "l"; + case KEY_M: + return "m"; + case KEY_N: + return "n"; + case KEY_O: + return "o"; + case KEY_P: + return "p"; + case KEY_Q: + return "q"; + case KEY_R: + return "r"; + case KEY_S: + return "s"; + case KEY_T: + return "t"; + case KEY_U: + return "u"; + case KEY_V: + return "v"; + case KEY_W: + return "w"; + case KEY_X: + return "x"; + case KEY_Y: + return "y"; + case KEY_Z: + return "z"; + case KEY_ALT_L: + return "leftalt"; + case KEY_ALT_R: + return "rightalt"; + case KEY_COMMAND: + return "command"; + case KEY_ENTER: + return "enter"; + case KEY_OPTION: + return "option"; + } + + return "invalid"; +} + +OpenArena::Keys OpenArena::GetKey(const char* keyName) +{ + string str = keyName; + if (str.length() > 1) + { + if (str.substr(0,2) == "up") + return OpenArena::KEY_UP; + else if (str.substr(0,4) == "down") + return OpenArena::KEY_DOWN; + else if (str.substr(0,3) == "esc") + return OpenArena::KEY_ESCAPE; + else if (str.substr(0,6) == "pageup") + return OpenArena::KEY_PRIOR; + else if (str.substr(0,8) == "pagedown") + return OpenArena::KEY_NEXT; + else if (str.substr(0,5) == "right") + return OpenArena::KEY_RIGHT; + else if (str.substr(0,4) == "left") + return OpenArena::KEY_LEFT; + else if (str.substr(0,5) == "space") + return OpenArena::KEY_SPACE; + else if (str.substr(0,6) == "mouse1") + return OpenArena::KEY_LBUTTON; + else if (str.substr(0,6) == "mouse2") + return OpenArena::KEY_RBUTTON; + else if (str.substr(0,6) == "mouse3") + return OpenArena::KEY_MBUTTON; + else if (str.substr(0,4) == "home") + return OpenArena::KEY_HOME; + else if (str.substr(0,3) == "end") + return OpenArena::KEY_END; + else if (str.substr(0,3) == "tab") + return OpenArena::KEY_TAB; + else if (str.substr(0,5) == "enter") + return OpenArena::KEY_RETURN; + else if (str.substr(0,6) == "insert") + return OpenArena::KEY_INSERT; + else if (str.substr(0,6) == "delete") + return OpenArena::KEY_DELETE; + else if (str.substr(0,7) == "control") + return OpenArena::KEY_CONTROL; + else if (str.substr(0,5) == "shift") + return OpenArena::KEY_SHIFT; + else if (str.substr(0,7) == "numpad0") + return OpenArena::KEY_NUMPAD0; + else if (str.substr(0,7) == "numpad1") + return OpenArena::KEY_NUMPAD1; + else if (str.substr(0,7) == "numpad2") + return OpenArena::KEY_NUMPAD2; + else if (str.substr(0,7) == "numpad3") + return OpenArena::KEY_NUMPAD3; + else if (str.substr(0,7) == "numpad4") + return OpenArena::KEY_NUMPAD4; + else if (str.substr(0,7) == "numpad5") + return OpenArena::KEY_NUMPAD5; + else if (str.substr(0,7) == "numpad6") + return OpenArena::KEY_NUMPAD6; + else if (str.substr(0,7) == "numpad7") + return OpenArena::KEY_NUMPAD7; + else if (str.substr(0,7) == "numpad8") + return OpenArena::KEY_NUMPAD8; + else if (str.substr(0,7) == "numpad9") + return OpenArena::KEY_NUMPAD9; + else if (str.substr(0,9) == "separator") + return OpenArena::KEY_SEPARATOR; + else if (str.substr(0,4) == "lwin") + return OpenArena::KEY_LWIN; + else if (str.substr(0,4) == "rwin") + return OpenArena::KEY_RWIN; + else if (str.substr(0,4) == "apps") + return OpenArena::KEY_APPS; + else if (str.substr(0,7) == "numpad*") + return OpenArena::KEY_MULTIPLY; + else if (str.substr(0,7) == "numpad+") + return OpenArena::KEY_ADD; + else if (str.substr(0,7) == "numpad/") + return OpenArena::KEY_DIVIDE; + else if (str.substr(0,7) == "numpad-") + return OpenArena::KEY_SUBTRACT; + else if (str.substr(0,6) == "scroll") + return OpenArena::KEY_SCROLL; + else if (str.substr(0,7) == "numlock") + return OpenArena::KEY_NUMLOCK; + else if (str.substr(0,5) == "pause") + return OpenArena::KEY_PAUSE; + else if (str.substr(0,8) == "capslock") + return OpenArena::KEY_CAPITAL; + + + + /*uncomment this to enable f1 as a mappable key + else if(str.substr(0,2) == "f1") + return OpenArena::KEY_F1; + */ + + else if (str.substr(0,2) == "f2") + return OpenArena::KEY_F2; + else if (str.substr(0,2) == "f3") + return OpenArena::KEY_F3; + else if (str.substr(0,2) == "f4") + return OpenArena::KEY_F4; + else if (str.substr(0,2) == "f5") + return OpenArena::KEY_F5; + else if (str.substr(0,2) == "f6") + return OpenArena::KEY_F6; + else if (str.substr(0,2) == "f7") + return OpenArena::KEY_F7; + else if (str.substr(0,2) == "f8") + return OpenArena::KEY_F8; + else if (str.substr(0,2) == "f9") + return OpenArena::KEY_F9; + else if (str.substr(0,2) == "f10") + return OpenArena::KEY_F10; + else if (str.substr(0,2) == "f11") + return OpenArena::KEY_F11; + else if (str.substr(0,2) == "f12") + return OpenArena::KEY_F12; + //Add Game specific keys here and e-mail headhunter45@hotmail.com subject OpenArena keys so I can add them please + else if (str.substr(0,4) == "null") + return OpenArena::KEY_UNKNOWN; + else + return OpenArena::KEY_UNKNOWN; + } + else + { + if(str[0] == '~' || str[0] == '`') + return OpenArena::KEY_OEM_3; + else if (str[0] == '?' || str[0] == '/') + return OpenArena::KEY_OEM_2; + else if (str[0] == '.' || str[0] == '>') + return OpenArena::KEY_OEM_PERIOD; + else if (str[0] == '+' || str[0] == '=') + return OpenArena::KEY_OEM_PLUS; + else if (str[0] == ';' || str[0] == ':') + return OpenArena::KEY_OEM_1; + else if (str[0] == ',' || str[0] == '<') + return OpenArena::KEY_OEM_COMMA; + else if (str[0] == '-' || str[0] == '_') + return OpenArena::KEY_OEM_MINUS; + else if (str[0] == '[' || str[0] == '{') + return OpenArena::KEY_OEM_4; + else if (str[0] == ']' || str[0] == '}') + return OpenArena::KEY_OEM_6; + else if (str[0] == '\\' || str[0] == '|') + return OpenArena::KEY_OEM_5; + else if (str[0] == '\'' || str[0] == '"') + return OpenArena::KEY_OEM_7; + else if (isalpha(str[0])) + return (OpenArena::Keys)(toupper(str[0]) - 'A' + OpenArena::KEY_A); + else if(isdigit(str[0])) + return (OpenArena::Keys)(str[0] - '0' + OpenArena::KEY_0); + else + return OpenArena::KEY_UNKNOWN; + } +} + + diff --git a/macosx/src/keys.h b/macosx/src/keys.h new file mode 100644 index 0000000..c66eaad --- /dev/null +++ b/macosx/src/keys.h @@ -0,0 +1,220 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __keys_h__ +#define __keys_h__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +namespace OpenArena +{ + /*! + * \brief + * Write brief comment for Keys here. + * + * Write detailed description for Keys here. + * + * \remarks + * Write remarks for Keys here. + * + * \see + * Separate items with the '|' character. + */ + enum Keys{ + KEY_UNKNOWN = 0, + KEY_BUTTON0, + KEY_BUTTON1, + KEY_BUTTON2, + KEY_BUTTON3, + KEY_BUTTON4, + KEY_LEFT, + KEY_RIGHT, + KEY_UP, + KEY_DOWN, + KEY_SPACE, + KEY_RETURN, + KEY_SHIFT, + KEY_PAUSE, + KEY_CONTROL, + KEY_CAPITAL, + KEY_ESCAPE, + KEY_PRIOR, + KEY_NEXT, + KEY_END, + KEY_HOME, + KEY_INSERT, + KEY_DELETE, + KEY_LWIN, + KEY_RWIN, + KEY_APPS, + KEY_NUMPAD0, + KEY_NUMPAD1, + KEY_NUMPAD2, + KEY_NUMPAD3, + KEY_NUMPAD4, + KEY_NUMPAD5, + KEY_NUMPAD6, + KEY_NUMPAD7, + KEY_NUMPAD8, + KEY_NUMPAD9, + KEY_MULTIPLY, + KEY_ADD, + KEY_SUBTRACT, + KEY_DIVIDE, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_NUMLOCK, + KEY_SCROLL, + KEY_SEPARATOR, + KEY_OEM_1, + KEY_OEM_2, + KEY_OEM_3, + KEY_OEM_4, + KEY_OEM_5, + KEY_OEM_6, + KEY_OEM_7, + KEY_OEM_PERIOD, + KEY_OEM_PLUS, + KEY_OEM_MINUS, + KEY_OEM_COMMA, + KEY_BACK, + KEY_TAB, + KEY_0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_ALT_L, + KEY_ALT_R, + KEY_ENTER, + KEY_COMMAND, + KEY_OPTION + }; + /*! + * \brief + * Write brief comment for KEY_LBUTTON here. + * + * Write detailed description for KEY_LBUTTON here. + * + * \remarks + * Write remarks for KEY_LBUTTON here. + * + * \see + * Separate items with the '|' character. + */ + const Keys KEY_LBUTTON = KEY_BUTTON0; + /*! + * \brief + * Write brief comment for KEY_RBUTTON here. + * + * Write detailed description for KEY_RBUTTON here. + * + * \remarks + * Write remarks for KEY_RBUTTON here. + * + * \see + * Separate items with the '|' character. + */ + const Keys KEY_RBUTTON = KEY_BUTTON1; + /*! + * \brief + * Write brief comment for KEY_MBUTTON here. + * + * Write detailed description for KEY_MBUTTON here. + * + * \remarks + * Write remarks for KEY_MBUTTON here. + * + * \see + * Separate items with the '|' character. + */ + const Keys KEY_MBUTTON = KEY_BUTTON2; + /*! + * \brief + * Write brief comment for KeyToASCII here. + * + * \param key + * Description of parameter key. + * + * \param shift + * Description of parameter shift. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for KeyToASCII here. + * + * \remarks + * Write remarks for KeyToASCII here. + * + * \see + * Separate items with the '|' character. + */ + char KeyToASCII(Keys key, bool shift); + const char* GetKeyName(Keys key); + OpenArena::Keys GetKey(const char* keyName); + +}; +#endif diff --git a/macosx/src/level.cpp b/macosx/src/level.cpp new file mode 100644 index 0000000..b4679d6 --- /dev/null +++ b/macosx/src/level.cpp @@ -0,0 +1,956 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: level.cpp +// Author: Tom Hicks +// Creation: 09-01-2003 +// LastEdit: 06-20-2005 +// Editors: Tom Hicks +// +// Purpose: +// To implement the world or at least a reasonable copy. +// +// Summary of Methods: +// Global +// -function name +// description +// blahClass +// -function name +// description +// +// Summary of Properties: +// blahClass +// -property name +// description +// +//////////////////////////////////////////////////////////////////////////////// + +#include "level.h" +#include "version.h" + +#pragma comment(lib, "bass.lib") +#ifdef WIN32 +#pragma warning(disable:4996) +#endif +using namespace std; + +namespace OpenArena +{ + Level::Level(EventManager* eventManager) + { + _eventManager = eventManager; + _window = NULL; + textureNames = NULL; + numTextures = 0; + + screen.SetName(OPENARENA_VERSION); + + showFPS = false; + showConsole = false; + + nextLevel = "intro.map"; + gamedir = "oa/"; + sound = true; + + defaultPlayer = new Player; + + numTriangles = 0; + triangles = NULL; + /* + for(int x=0; x<4; x++) + LightAmbient[x] = 5; + */ + //Player Stuff + mouseSpeed = 5; + turnSpeed = 1.0f; + moveSpeed = 0.2f; + mlook = true; + } + + Level::~Level() + { + if(defaultPlayer) + { + delete defaultPlayer; + defaultPlayer = NULL; + } + } + + bool Level::LoadMap(string mapname) + { + ifstream input; + string readBuffer; + + //players.Insert(*defaultPlayer); + + mapname = gamedir + "maps/" + mapname; + + if(tolower(Right(mapname, 4)) != ".map") + mapname = mapname + ".map"; + + input.open(mapname.c_str()); + + if(!input) + { + char* tmpChar = new char[mapname.length() + 41]; + strcpy(tmpChar, "Unable to load level file "); + strcat(tmpChar, mapname.c_str()); + strcat(tmpChar, " doesn't exist."); + + //This needs to be abstracted somehow + #ifdef WIN32 + MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); + #endif + delete [] tmpChar; + return false; + } + else + { + ConsolePrint("map file \"" + mapname + "\" opened successfully"); + } + + //Gravity + input >> readBuffer; + gravity = (float)atof(readBuffer.c_str()); + + //Number of triangles + input >> readBuffer; + numTriangles = Integer(readBuffer); + + //Triangle Data + triangles = new Triangle[numTriangles]; + for(unsigned int i=0; i> readBuffer; + triangles[i].texID = Integer(readBuffer); + + for(unsigned int i2=0; i2<3; i2++) + { + //Vertex Data + input >> readBuffer; + triangles[i].vertecies[i2].coordinates.x = atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].vertecies[i2].coordinates.y = atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].vertecies[i2].coordinates.z = atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].vertecies[i2].textureCoordinates.x = (float)atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].vertecies[i2].textureCoordinates.y = (float)atof(readBuffer.c_str()); + } + + //Normal + input >> readBuffer; + + triangles[i].normal.x = atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].normal.y = atof(readBuffer.c_str()); + input >> readBuffer; + triangles[i].normal.z = atof(readBuffer.c_str()); + } + char lpszNumTriangles[6]; + sprintf(lpszNumTriangles, "%d", numTriangles); + ConsolePrint(lpszNumTriangles + string(" triangles successfully read")); + + //Number of textures; + input >> readBuffer; + numTextures = Integer(readBuffer); + + //Texture data + textureNames = new string[numTextures]; + for(unsigned int i=0; i> textureNames[i]; + } + LoadGLTextures(); + char lpszNumTextures[6]; + sprintf(lpszNumTextures, "%d", numTextures); + ConsolePrint(lpszNumTextures + string(" textures successfully read")); + + //BGM + input >> bgm; + + //Build display list + + //Sound + if (sound) + { + ConsolePrint("Starting sound"); + + //This needs to be abstracted somehow + #ifdef WIN32 + BASS_Init(-1, 44100, BASS_DEVICE_LEAVEVOL, g_hWnd); + BASS_Start(); + BASS_CDInit(NULL, BASS_DEVICE_LEAVEVOL); + #endif + + if(bgm.length()>=4) + { + if( toupper(bgm[0]) == 'C' && + toupper(bgm[1]) == 'D' && + toupper(bgm[2]) == 'A') + { + bgmCDA = Integer(bgm.substr(3,bgm.length())); + //This needs to be abstracted somehow + #ifdef WIN32 + BASS_CDPlay(bgmCDA, 1, 0); + #endif + } + else + { + bgmCDA=0; + string tmpstr = gamedir + "music/bgm/" + bgm; + //This needs to be abstracted somehow + #ifdef WIN32 + bgmStream = BASS_StreamCreateFile(0, (void*)tmpstr.c_str(), 0, 0, BASS_STREAM_AUTOFREE); + BASS_StreamPlay(bgmStream, 1, BASS_SAMPLE_LOOP); + #endif + } + } + + ConsolePrint("Sound init complete"); + } + else + { + ConsolePrint("Sound disabled"); + } + + return true; + } + bool Level::LoadMap() + { + return LoadMap(nextLevel); + } + + void Level::SaveMap(string mapname) + { + ofstream output; + + mapname = gamedir + "maps/" + mapname; + + if(tolower(Right(mapname, 4)) != ".map") + mapname = mapname + ".map"; + + output.open(mapname.c_str()); + + if(!output) + { + char* tmpChar = new char[mapname.length() + 42]; + strcpy(tmpChar, "Unable to save level file "); + strcat(tmpChar, mapname.c_str()); + strcat(tmpChar, " already exists."); + + //This needs to be abstracted somehow + #ifdef WIN32 + MessageBox(NULL,tmpChar,"ERROR",MB_OK|MB_ICONEXCLAMATION); + #endif + delete [] tmpChar; + return; + } + + //Gravity + output << gravity << endl; + + //Number of triangles + output << numTriangles << endl; + + //Triangle Data + for(unsigned int i=0; icamera.Look(); + + for (uint32 i=0; iID());//Bind this triangle's texture + glBegin(GL_TRIANGLES); + // glNormal3f((GLfloat)triangles[i].normal.x, (GLfloat)triangles[i].normal.y, (GLfloat)triangles[i].normal.z); + for (uint32 i2=0; i2<3; i2++) + { + glTexCoord2f(triangles[i].vertecies[i2].textureCoordinates.x, + triangles[i].vertecies[i2].textureCoordinates.y); + glVertex3f((GLfloat)triangles[i].vertecies[i2].coordinates.x, + (GLfloat)triangles[i].vertecies[i2].coordinates.y, + (GLfloat)triangles[i].vertecies[i2].coordinates.z); + } + glEnd(); + } + glPopMatrix(); + + //Draw HUD + //ummm nothing here yet + + + + //Draw FPS + //This may not work yet + if (showFPS) + { + char fps[20]; + sprintf(fps, "fps %d", FPS()); + glPushMatrix(); + glLoadIdentity(); + glColor3f(1,1,1); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glFont.Print(glFont.ScreenWidth() - 120, glFont.ScreenHeight() - 30, fps, 0); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glPopMatrix(); + } + + if(showConsole) + { + glPushMatrix(); + glLoadIdentity(); + glColor3f(1,1,1); + + //disable lighting and depth testing + glDisable(GL_DEPTH_TEST); + + glBindTexture(GL_TEXTURE_2D, menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].ID()); + //glBindTexture(GL_TEXTURE_2D, 4); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, screen.GetWidth(), 0, screen.GetHeight(), -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + + glBegin(GL_QUADS); + glTexCoord2f(0,0); + glVertex2i(0,screen.GetHeight()/2); + glTexCoord2f(0,1); + glVertex2i(0,screen.GetHeight()); + glTexCoord2f(1,1); + glVertex2i(screen.GetWidth(),screen.GetHeight()); + glTexCoord2f(1,0); + glVertex2i(screen.GetWidth(),screen.GetHeight()/2); + glEnd(); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + glDisable(GL_LIGHTING); + + //enable blending + glEnable(GL_BLEND); + + //render the console background + //render the console output text + unsigned int i; + for(i=0; iLoad(gamedir + "textures/" + textureNames[i])) + texture->Load(DEFAULT_TEXTURE_NAME); + textures[i] = texture; + } + + if(!glFont.BuildFont((gamedir + "textures/menu/font.bmp").c_str())) + glFont.BuildFont("oa/textures/menu/font.bmp"); + + //Load the console background image + if(!menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load(gamedir + "textures/menu/con_back.tga")) + { + menuTextures[GL_MY_TEXTURE_CONSOLEBACKGROUND].Load("oa/textures/menu/con_back.bmp"); + } + } + } + + uint32 Level::FPS() + { + static uint32 fps=0; + static uint32 fps2=0; + static float last=0.0f; // might need to change to double + + //hmmm what the hell is this called in linux I should possibly abstract this + #ifdef WIN32 + float time=GetTickCount()*.001f; + #else + float time = 0; + #endif + + ++fps; + + if(time>last+1) + { + last=time; + fps2 = fps; + fps=0; + } + return fps2; + } + + void Level::Execute(string cmd) + { + string command; + + uint32 i=0xFFFFFFFF; + while(word(cmd, ++i) != "") + { + command = tolower(word(cmd, i)); + + if(command == "set") + { + command = tolower(word(cmd, ++i)); + + if(command == "turnspeed") + { + turnSpeed = (float)atof(word(cmd, ++i).c_str());//Floating(word(cmd, ++i)); + } + else if(command == "movespeed") + { + moveSpeed = (float)atof(word(cmd, ++i).c_str());//FLoating(word(cmd, ++i)); + } + else if(command == "mousespeed") + { + mouseSpeed = (float)atof(word(cmd, ++i).c_str()); + } + else if(command == "mouselook") + { + mlook = Truth(word(cmd, ++i)); + } + else if(command == "maxfps") + { + maxFPS = Integer(word(cmd, ++i)); + } + else if(command == "sound") + { + sound = Truth(word(cmd, ++i)); + } + else if(command == "game") + { + gamedir= word(cmd, ++i); + } + else if(command == "screenwidth") + { + screen.SetWidth(Integer(word(cmd, ++i))); + } + else if(command == "screenheight") + { + screen.SetHeight(Integer(word(cmd, ++i))); + } + else if(command == "fullscreen") + { + screen.SetFullscreen(Truth(word(cmd, ++i))); + } + else if(command == "colordepth") + { + screen.SetColorDepth(Integer(word(cmd, ++i))); + } + else + { + ConsolePrint("Variable " + command + " doesn't exist"); + } + } + else if(command == "bind") + { + command = tolower(word(cmd, ++i)); + string key = tolower(word(cmd, ++i)); + if(ControlScheme::GetAction(command.c_str())==OpenArena::ControlScheme::ACTION_NONE) + { + ConsolePrint("No action identified by " + command); + } + else if (GetKey(key.c_str()) == OpenArena::KEY_UNKNOWN) + { + ConsolePrint("No key identified by " + key); + } + else + { + defaultPlayer[0].controls.Bind(GetKey(key.c_str()), ControlScheme::GetAction(command.c_str())); + } + } + else if(command == "map" || command == "map_load") + { + nextLevel = word(cmd, ++i); + UnloadMap(); + if(!LoadMap()) + { + ConsolePrint("Unable to load level " + command); + nextLevel = "intro.map"; + LoadMap(); + } + } + else if(command == "unbind") + { + command = tolower(word(cmd, ++i)); + + if(command == "all") + { + defaultPlayer[0].controls.UnBindAll(); + } + else + { + defaultPlayer[0].controls.UnBind(GetKey(command.c_str())); + } + } + else if(command == "exec" || command == "config_load") + { + command = tolower(word(cmd, ++i)); + if(!LoadConfig(command)) + { + ConsolePrint("Unable to load config file " + word(cmd, i)); + } + } + else if(command == "map_save") + { + command = tolower(word(cmd, ++i)); + SaveMap(command); + } + else if(command == "config_save") + { + command = tolower(word(cmd, ++i)); + SaveConfig(command); + } + /* + else if(command == "map_add_triangle") + { + if(triangles != NULL) + { + TRIANGLE* temp = triangles; + triangles = new TRIANGLE[numTriangles + 1]; + for(int i=0; icontrols.WriteToStream(output); + } + + void Level::Print(int x, int y, const char* str, unsigned int set) + { + glFont.Print(x,y,str, set); + } + + void Level::UpdateConsole(char newChar) + { + if(newChar == '\n') + { + for (int i=MAX_CONSOLE_HISTORY_LINES - 1; i>0; i--) + { + consoleHistory[i] = consoleHistory[i-1]; + } + consoleHistory[0] = ""; + ConsolePrint(consoleHistory[1]); + Execute(tolower(consoleHistory[1])); + + } + else if(newChar == OpenArena::KEY_BACK) + { + consoleHistory[0] = Left(consoleHistory[0], consoleHistory[0].length()-1); + } + else if(!(defaultPlayer->controls.IsBound(GetKey(&newChar), ControlScheme::ACTION_TOGGLE_CONSOLE))) + { + consoleHistory[0] = consoleHistory[0] + newChar; + /* + char errmsg[256]; + sprintf(errmsg, "Unhangled keypress: %d", newChar); + MessageBox(NULL, errmsg, "Balls", MB_OK); + */ + } + } + + void Level::ConsolePrint(string line) + { + for (int i=MAX_CONSOLE_OUTPUT_LINES - 1; i>0; i--) + { + consoleOutput[i] = consoleOutput[i-1]; + } + consoleOutput[0] = line; + } + + void Level::SetWindow(Window* window) + { + _window = window; + } + + Window* Level::GetWindow() + { + return _window; + } +}; diff --git a/macosx/src/level.h b/macosx/src/level.h new file mode 100644 index 0000000..b2ba69e --- /dev/null +++ b/macosx/src/level.h @@ -0,0 +1,143 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __LEVEL_H__ +#define __LEVEL_H__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#if defined USE_GLX +#include +#elif defined USE_AGL +#include +#elif defined USE_CGL +#include +#elif defined USE_WGL +#include +#include +#endif + +#include //for file I/O + +#include "mydefs.h" +#include "bmp.h" +#include "tga.h" +#include "list.h" +#ifdef WIN32 +#include "../lib/bass.h" //for audio in windows only this should be replaced by oa_audio +#endif +#include "vector.h" +#include "camera.h" +#include "geometry.h" +#include "myglFont.h" +#include "myglTexture.h" +#include "player.h" +#include "strmanip.h" +#include "keys.h" +#include "EventManager.h" + +using namespace std; +using OpenArena::Triangle; + +namespace OpenArena +{ + const float piover180 = 0.0174532925f; + const string DEFAULT_TEXTURE_NAME = "oa/textures/default.bmp"; + const unsigned int MAX_CONSOLE_LINES = 30; //The max number of lines to be displayed in the console + const unsigned int MAX_CONSOLE_HISTORY_LINES = MAX_CONSOLE_LINES + 20; //The max number of console lines to store in the history + const unsigned int MAX_CONSOLE_OUTPUT_LINES = MAX_CONSOLE_LINES; + const unsigned int MAX_OUTPUT_TEXT_LINES = 4; //The max number of output lines to be displayed on the screen + + enum {GL_MY_TEXTURE_CONSOLEBACKGROUND=0, NUM_MENU_TEXTURES}; + + class Level + { + public: + Level(EventManager* eventManager); + ~Level(); + bool LoadMap(string mapname); + bool LoadMap(); + void SaveMap(string mapname); + bool LoadConfig(string cfgname); + void LoadConfig(); + void SaveConfig(string cfgname); + void Execute(string cmd); + void LoadGLTextures(); + void Render(); + void UnloadMap(); + void UpdateConsole(char); + uint32 FPS(); + void ParseCmds(const char*); + void Print(int x, int y, const char* string, unsigned int set); + void SetWindow(Window*); + Window* GetWindow(); + + /*Not Yet Implemented + void PlayerConnect(); // implement later + void PlayerDisconnect(); // implement later + */ + Screen screen; + Font glFont; + string nextLevel; + Player* defaultPlayer; + uint32 numTextures; + string* textureNames; + + string bgm; + #ifdef WIN32 + HSTREAM bgmStream; + #endif + unsigned char bgmCDA; + string gamedir; + float gravity; + bool mlook; + bool showFPS; + bool showConsole; + bool sound; + float turnSpeed; + float moveSpeed; + float mouseSpeed; + unsigned char maxFPS; + //Map + Triangle* triangles; + uint32 numTriangles; + list players; +// list ents; + list textures; + Texture menuTextures[NUM_MENU_TEXTURES]; + Window* _window; + +// private: + void ConsolePrint(string); + private: + EventManager* _eventManager; + string consoleHistory[MAX_CONSOLE_HISTORY_LINES]; + string consoleOutput[MAX_CONSOLE_OUTPUT_LINES]; + string outputText[MAX_OUTPUT_TEXT_LINES]; + }; +}; +#endif diff --git a/macosx/src/linux.cpp b/macosx/src/linux.cpp new file mode 100644 index 0000000..d8f1240 --- /dev/null +++ b/macosx/src/linux.cpp @@ -0,0 +1,254 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: linux.cpp +// Author: Tom Hicks +// Creation: 09-01-2003 +// LastEdit: 06-19-2005 +// Editors: Tom Hicks +// +// Purpose: +// To implement the OpenArena SDK. +// +// Summary of Methods: +// Global +// -InitControls() +// Loads the defaultPlayer's configuration. +// -InitGL() +// Initializes OpenGL and is responsible for loading textures. +// -ResizeGLScene(GLsizei width, GLsizei height) +// Resizes the viewport to the current size of the visible area of the window specified by width and height. +// -KillGLWindow() +// Closes the window. +// -CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) +// Creates the window with the specified parameters. +// -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +// Main procedure. +// -WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +// Window Procedure for the OpenGL window. +// +//////////////////////////////////////////////////////////////////////////////// +#ifdef __linux + +//include necessary header files +#include "main.h" +#include "version.h" +#include "x11.h" +using namespace std; + +void InitControls(); + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Function Definitions + +int DrawGLScene(OpenArena::Level* level) +{ + level->Render(); + + g_Screen->SwapBuffers(); + + return true; +} + +// +//void InitControls() +// Purpose: +// Initializes controls by loading the default control config file "my.cfg". +void InitControls(OpenArena::Level* level) +{ + if (!level->LoadConfig("my.cfg")) + level->LoadConfig(); +} + +int main(int argc, char** argv) +{ + OpenArena::EventManager* em = new OpenArena::EventManager(); + OpenArena::Level* level = new OpenArena::Level(em); + XEvent event; + bool done = false; + + string commandLine = ""; + int i; + for(i=1; iParseCmds(commandLine.c_str()); + + InitControls(level); + + level->glFont.SetScreenDimensions(level->screen.GetWidth()*2, level->screen.GetHeight()*2); + + //Hack for now + if(level->screen.GetColorDepth() == 32) + { + level->screen.SetColorDepth(24); + } + +// g_Screen.SetOnInit(InitGL); +// g_Screen.SetOnResize(ResizeGLScene); + + if(!g_Screen->Open(OPENARENA_VERSION, level->screen.GetWidth(), level->screen.GetHeight(), level->screen.GetColorDepth(), level->screen.GetFullscreen())) + { + return 1; + } + + level->SetWindow(g_Screen); + + if(level->nextLevel == "") + { + level->LoadMap("intro.map"); + } + else + { + level->LoadMap(); + } + + while(!done) + { + while(XPending(g_Screen->GetDisplay()) > 0) + { + //Equivalent of WNDPROC + XNextEvent(g_Screen->GetDisplay(), &event); + switch(event.type) + { + case Expose: + if(event.xexpose.count != 0) + { + break; + } + DrawGLScene(level); + break; + case ConfigureNotify: + if((event.xconfigure.width != g_Screen->GetWidth()) || (event.xconfigure.height != g_Screen->GetHeight())) + { + g_Screen->SetWidth(event.xconfigure.width); + g_Screen->SetHeight(event.xconfigure.height); + ResizeGLScene(event.xconfigure.width, event.xconfigure.height); + } + break; + case ButtonPress: + keys[TranslateButton(event.xbutton.button)] = true; + break; + case ButtonRelease: + keys[TranslateButton(event.xbutton.button)] = false; + keys2[TranslateButton(event.xbutton.button)] = false; + break; + case KeyPress: + if(level->showConsole) + { + HandleConsoleKeyPress((OpenArena::Keys)TranslateKey(XLookupKeysym(&event.xkey, 0)), level); + } + else + { + keys[TranslateKey(XLookupKeysym(&event.xkey, 0))] = true; + } + break; + case KeyRelease: + keys[TranslateKey(XLookupKeysym(&event.xkey, 0))] = false; + keys2[TranslateKey(XLookupKeysym(&event.xkey, 0))] = false; + break; + case ClientMessage: + if(*XGetAtomName(g_Screen->GetDisplay(), event.xclient.message_type) == *"WM_PROTOCOLS") + { + printf("Exiting sanely...\n"); + done = true; + } + break; + default: + break; + } + } //End Equivalent of WNDPROC + + if(active) + { + if(keys[OpenArena::KEY_ESCAPE]) + { + done = true; + } + else if(keys[OpenArena::KEY_F1]) + { + g_Screen->Close(); + g_Screen->ToggleFullscreen(); + g_Screen->Open(); + } + else + { + level->defaultPlayer[0].camera.Update(); + if(!level->showConsole) + { + if(level->mlook) + { + using OpenArena::Vec2i; + Vec2i middleOfScreen = Vec2i(g_Screen->GetWidth()/2, g_Screen->GetHeight()/2); + Vec2i mousePosition = g_Screen->GetMousePosition(); + if(mousePosition != middleOfScreen) + { + //Vec2i mouseDelta = mousePosition - middleOfScreen; + Vec2i mouseDelta = middleOfScreen - mousePosition; + g_Screen->SetMousePosition(middleOfScreen); + const float MOUSE_SENSITIVITY_HORIZONTAL = 0.005; + const float MOUSE_SENSITIVITY_VERTICAL = 0.005; + float horizontalAngle = mouseDelta.x * MOUSE_SENSITIVITY_HORIZONTAL; + float verticalAngle = mouseDelta.y * MOUSE_SENSITIVITY_VERTICAL; + level->defaultPlayer[0].camera.RotateHorizontal(horizontalAngle); + level->defaultPlayer[0].camera.RotateVertical(verticalAngle); + } + } + else + { +#ifdef WIN32 + SetCursorPos(g_Screen->width/2, g_Screen->height/2);//Shit this may be windows specific +#endif + } + } + } + } + + DrawGLScene(level); + + if(keys[OpenArena::KEY_F1]) + { + keys[OpenArena::KEY_F1] = false; + g_Screen->Close(); + g_Screen->ToggleFullscreen(); + if(!g_Screen->Open(OPENARENA_VERSION, level->screen.GetWidth(), level->screen.GetHeight(), level->screen.GetColorDepth(), level->screen.GetFullscreen())) + { + return 1; + } + } + + } + level->UnloadMap(); + g_Screen->Close(); + exit(0); +} + +bool keys[256]; +bool keys2[256]; +bool active; +bool fullscreen; +//bool showConsole = false; +OpenArena::Vec2i g_mousePosition; +float lastTime; +float currentTime; + +#endif diff --git a/macosx/src/macosx.cpp b/macosx/src/macosx.cpp new file mode 100644 index 0000000..5a895a8 --- /dev/null +++ b/macosx/src/macosx.cpp @@ -0,0 +1,318 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: macosx.cpp +// Author: Tom Hicks +// Creation: 03-11-2006 +// LastEdit: 03-11-2006 +// Editors: Tom Hicks +// +// Purpose: +// To implement the OpenArena SDK. +// +// Summary of Methods: +// Global +// -InitControls() +// Loads the defaultPlayer's configuration. +// -InitGL() +// Initializes OpenGL and is responsible for loading textures. +// -ResizeGLScene(GLsizei width, GLsizei height) +// Resizes the viewport to the current size of the visible area of the window specified by width and height. +// -KillGLWindow() +// Closes the window. +// -CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) +// Creates the window with the specified parameters. +// -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +// Main procedure. +// -WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +// Window Procedure for the OpenGL window. +// +//////////////////////////////////////////////////////////////////////////////// +#ifdef __APPLE__ +#include "main.h" +#include "version.h" +#include "EventManager.h" +#include "Events/DrawEvent.h" +#include "Events/KeyPressEvent.h" +#include "Events/KeyReleaseEvent.h" +#include "x11.h" +//include necessary header files +using namespace std; + +bool g_done = false; +class KeyPressEventHandler: public OpenArena::Events::KeyPressEvent::KeyPressEventHandler +{ +private: +public: + KeyPressEventHandler() + { + } + + virtual void HandleEvent(OpenArena::Events::Event* event) + { + OpenArena::Events::KeyPressEvent* ev = (OpenArena::Events::KeyPressEvent*) event; + switch (ev->GetKey()) + { + case OpenArena::KEY_ESCAPE: + g_done = true; + break; + + default: + break; + }; + } +}; + +int DrawGLScene(OpenArena::Level* level) +{ + //The context is somehow different if this call is inside the RT function + level->Render(); + + g_Screen->SwapBuffers(); + + return true; +} + +#if defined USE_GLX +//void InitControls(); +void HandleConsoleKeyPress(OpenArena::Keys key); + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Function Definitions + +void ProcessCommandLineArgs(int argc, char** argv, OpenArena::Level* level) +{ + string commandLine = ""; + int i; + for(i=1; iParseCmds(commandLine.c_str()); +} + +int main(int argc, char** argv) +{ + g_Screen = new OpenArena::Window(); + OpenArena::EventManager* em = new OpenArena::EventManager(); + OpenArena::Level* level = new OpenArena::Level(em); + OpenArena::Events::DrawEvent::DrawEventHandler* _drawEventHandler = new OpenArena::Events::DrawEvent::DrawEventHandler(level); + KeyPressEventHandler* _keyPressEventHandler = new KeyPressEventHandler(); + OpenArena::Events::KeyReleaseEvent::KeyReleaseEventHandler* _keyReleaseEventHandler = new OpenArena::Events::KeyReleaseEvent::KeyReleaseEventHandler(); + em->RegisterEventHandler(_drawEventHandler); + em->RegisterEventHandler(_keyPressEventHandler); + em->RegisterEventHandler(_keyReleaseEventHandler); + + XEvent event; + OpenArena::Events::Event* ev; + + ProcessCommandLineArgs(argc, argv, level); + + if (!level->LoadConfig("my.cfg")) + level->LoadConfig(); + + level->glFont.SetScreenDimensions(level->screen.GetWidth()*2, level->screen.GetHeight()*2); + + if(level->nextLevel == "") + { + level->LoadMap("intro.map"); + } + else + { + level->LoadMap(); + } + + //Hack for now X11 no like 32 bit depth + if(level->screen.GetColorDepth() == 32) + { + level->screen.SetColorDepth(24); + } + + if(!g_Screen->Open(OPENARENA_VERSION, level->screen.GetWidth(), level->screen.GetHeight(), level->screen.GetColorDepth(), level->screen.GetFullscreen())) + { + return 1; + } + + level->SetWindow(g_Screen); + + level->LoadGLTextures(); + + while(!g_done) + { + while(XPending(g_Screen->GetDisplay()) > 0) + { + OpenArena::Events::Event* ev = 0x0; + //Equivalent of WNDPROC + XNextEvent(g_Screen->GetDisplay(), &event); + switch(event.type) + { + case Expose: + if(event.xexpose.count != 0) + { + break; + } + + em->SendEvent(new OpenArena::Events::DrawEvent()); + break; + case ConfigureNotify: + if((event.xconfigure.width != g_Screen->GetWidth()) || (event.xconfigure.height != g_Screen->GetHeight())) + { + g_Screen->SetWidth(event.xconfigure.width); + g_Screen->SetHeight(event.xconfigure.height); + ResizeGLScene(event.xconfigure.width, event.xconfigure.height); + + //em->SendEvent(new ResizeWindowEvent(event.xconfigure.width, event.xconfigure.width); + } + break; + case ButtonPress: + em->SendEvent(new OpenArena::Events::KeyPressEvent(TranslateButton(event.xbutton.button))); + break; + case ButtonRelease: + em->SendEvent(new OpenArena::Events::KeyReleaseEvent(TranslateButton(event.xbutton.button))); + break; + case KeyPress: + em->SendEvent(new OpenArena::Events::KeyPressEvent((OpenArena::Keys)TranslateKey(XLookupKeysym(&event.xkey, 0)))); + /* + if(level->showConsole) + { + HandleConsoleKeyPress((OpenArena::Keys)TranslateKey(XLookupKeysym(&event.xkey, 0))); + } + else + { + keys[TranslateKey(XLookupKeysym(&event.xkey, 0))] = true; + } + */ + break; + case KeyRelease: + em->SendEvent(new OpenArena::Events::KeyReleaseEvent((OpenArena::Keys)TranslateKey(XLookupKeysym(&event.xkey, 0)))); +// keys[TranslateKey(XLookupKeysym(&event.xkey, 0))] = false; +// keys2[TranslateKey(XLookupKeysym(&event.xkey, 0))] = false; + break; + case ClientMessage: + if(*XGetAtomName(g_Screen->GetDisplay(), event.xclient.message_type) == *"WM_PROTOCOLS") + { + printf("Exiting sanely...\n"); + g_done = true; + } + break; + default: + break; + } + } //End Equivalent of WNDPROC + + /* + if(active) + { + if(keys[OpenArena::KEY_ESCAPE]) + { + g_done = true; + } + else if(keys[OpenArena::KEY_F1]) + { + g_Screen->Close(); + g_Screen->ToggleFullscreen(); + g_Screen->Open(); + } + else + { + level->defaultPlayer[0].camera.Update(); + } + } + */ + + em->SendEvent(new OpenArena::Events::DrawEvent()); + + if(keys[OpenArena::KEY_F1]) + { + keys[OpenArena::KEY_F1] = false; + g_Screen->Close(); + g_Screen->ToggleFullscreen(); + if(!g_Screen->Open(OPENARENA_VERSION, level->screen.GetWidth(), level->screen.GetHeight(), level->screen.GetColorDepth(), level->screen.GetFullscreen())) + { + return 1; + } + } + } + level->UnloadMap(); + g_Screen->Close(); + exit(0); +} + +#elif defined USE_AGL +int main(int argc, char** argv) +{ + g_Screen = new OpenArena::Window(); + OpenArena::Events::DrawEvent::DrawEventHandler* _drawEventHandler = new OpenArena::Events::DrawEvent::DrawEventHandler(); + OpenArena::Events::KeyPressEvent::KeyPressEventHandler* _keyPressEventHandler = new OpenArena::Events::KeyPressEvent::KeyPressEventHandler(); + OpenArena::Events::KeyReleaseEvent::KeyReleaseEventHandler* _keyReleaseEventHandler = new OpenArena::Events::KeyReleaseEvent::KeyReleaseEventHandler(); + OpenArena::EventManager* em = new OpenArena::EventManager(); + em->RegisterEventHandler(_drawEventHandler); + em->RegisterEventHandler(_keyPressEventHandler); + em->RegisterEventHandler(_keyReleaseEventHandler); + +// ProcessCommandLineArgs(argc, argv); + +// InitControls(); + + level->glFont.SetScreenDimensions(level->screen.GetWidth()*2, level->screen.GetHeight()*2); + + if(level->nextLevel == "") + { + level->LoadMap("intro.map"); + } + else + { + level->LoadMap(); + } + + //Hack for now X11 no like 32 bit depth + if(level->screen.GetColorDepth() == 32) + { + level->screen.SetColorDepth(24); + } + + if(!g_Screen->Open(OPENARENA_VERSION, level->screen.GetWidth(), level->screen.GetHeight(), level->screen.GetColorDepth(), level->screen.GetFullscreen())) + { + return 1; + } + + level->SetWindow(g_Screen); + + level->LoadGLTextures(); + + RunApplicationEventLoop(); + +} +#elif defined USE_CGL +#error +#endif + +bool keys[256] = {0}; // Array for which keys are down now +bool keys2[256] = {0}; // Array for which keys are were down already +bool active = true; // Is window active flag +bool fullscreen = false; // Is window fullscreen flag +//bool showConsole = false;// Do we need to draw the console +OpenArena::Vec2i g_mousePosition; +float lastTime = 0.0f; // This will hold the time from the last frame +float currentTime; + +#endif + diff --git a/macosx/src/main.h b/macosx/src/main.h new file mode 100644 index 0000000..49b529a --- /dev/null +++ b/macosx/src/main.h @@ -0,0 +1,135 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __main_h__ +#define __main_h__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined USE_GLX +#include // Header file for OpenGL32 library +#include // Header file for Glu32 library +#elif defined USE_AGL +#include "mygl.h" +#elif defined USE_CGL +#error unimplemented method +#elif defined USE_WGL +#include +#include // Header file for OpenGL32 library +#include // Header file for Glu32 library +#endif + +#include // Header file for standard input/output +#include + +#include "camera.h" +#include "level.h" +#include "mygl.h" +#include "worlddefs.h" +#include "mydefs.h" +#include "screen.h" +#include "window.h" +#include "vector.h" +#pragma warning(disable: 4786) + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Variables + +extern bool keys[256]; // Array for which keys are down now +extern bool keys2[256]; // Array for which keys are were down already +extern bool active; // Is window active flag +extern bool fullscreen; // Is window fullscreen flag +//extern bool showConsole = false;// Do we need to draw the console +extern OpenArena::Vec2i g_mousePosition; + + +#ifdef WIN32 +extern POINT mpos; +#endif +extern float lastTime; // This will hold the time from the last frame +extern float currentTime; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Function Declarations + +//This shouldn't need to be here +//LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc + +/*! + * \brief + * Write brief comment for InitControls here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for InitControls here. + * + * \remarks + * Write remarks for InitControls here. + * + * \see + * Separate items with the '|' character. + */ +void InitControls(); // Sets up player controls +/*! + * \brief + * Write brief comment for InitGL here. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for InitGL here. + * + * \remarks + * Write remarks for InitGL here. + * + * \see + * Separate items with the '|' character. + */ +int InitGL(); // All setup for OpenGL goes here +/*! + * \brief + * Write brief comment for ReSizeGLScene here. + * + * \param width + * Description of parameter width. + * + * \param height + * Description of parameter height. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for ReSizeGLScene here. + * + * \remarks + * Write remarks for ReSizeGLScene here. + * + * \see + * Separate items with the '|' character. + */ +void ReSizeGLScene(GLsizei width, GLsizei height); // Resize and initialize the GL window +int DrawGLScene(OpenArena::Level* level); + +#endif diff --git a/macosx/src/mygl.cpp b/macosx/src/mygl.cpp new file mode 100644 index 0000000..33327e9 --- /dev/null +++ b/macosx/src/mygl.cpp @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mygl.h" +namespace OpenArena +{ + void FreeGLTexture(GLuint& texture) + { + glDeleteTextures(1, &texture); + } + + bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min) + { + if(Right(tolower(fn), 4) == ".bmp") + { + TextureImage* texImage = NULL; + if(texImage = LoadBMP(fn.c_str())) + { + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data); + + if(texImage) //Just in case somehow the file was empty or unloadable + { + if(texImage->data) + free(texImage->data); + free(texImage); + } + return true; + } + else + { + return false; + } + } + else if(Right(tolower(fn), 4) == ".tga") + { + TextureImage* texImage = NULL; + if(texImage = LoadTGA(fn.c_str())) + { + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + if(texImage) //Just in case somehow the file was empty or unloadable + { + if(texImage->data) + free(texImage->data); + free(texImage); + } + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } +}; + +OpenArena::Window* g_Screen = new OpenArena::Window(); diff --git a/macosx/src/mygl.h b/macosx/src/mygl.h new file mode 100644 index 0000000..a99bd2c --- /dev/null +++ b/macosx/src/mygl.h @@ -0,0 +1,113 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __MYGL_H__ +#define __MYGL_H__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined USE_GLX +#include +#include +#elif defined USE_AGL +#include +#include +#include +//#error unimplemented method +#elif defined USE_CGL +#error unimplemented method +#elif defined USE_WGL +#include +#include +#include +#endif + +#include +#include "datatypes.h" +#include "screen.h" +#include "tga.h" +#include "bmp.h" +#include "strmanip.h" +#include "window.h" + +using namespace std; + +#ifdef WIN32 +//These this is windows specific +static HINSTANCE hInstance; // Application instance +#endif +extern OpenArena::Window* g_Screen; +//This doesn't need to be here I think +//int InitGL(GLvoid); +namespace OpenArena +{ + /*! + * \brief + * Write brief comment for LoadGLTexture here. + * + * \param + * Description of parameter . + * + * \param + * Description of parameter . + * + * \param + * Description of parameter . + * + * \param + * Description of parameter . + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for LoadGLTexture here. + * + * \remarks + * Write remarks for LoadGLTexture here. + * + * \see + * Separate items with the '|' character. + */ + bool LoadGLTexture(string , GLuint&, GLuint = GL_LINEAR, GLuint = GL_LINEAR); + /*! + * \brief + * Write brief comment for FreeGLTexture here. + * + * \param + * Description of parameter . + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for FreeGLTexture here. + * + * \remarks + * Write remarks for FreeGLTexture here. + * + * \see + * Separate items with the '|' character. + */ + void FreeGLTexture(GLuint&); +}; +#endif diff --git a/macosx/src/player.h b/macosx/src/player.h new file mode 100644 index 0000000..bf81130 --- /dev/null +++ b/macosx/src/player.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __PLAYER_H__ +#define __PLAYER_H__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#include "EventManager.h" +#include "camera.h" +#include "ctrls.h" + +namespace OpenArena +{ + class Player + { + public: + void Load(); + void Save(); + void CreateCharacter(); + void AddItem(unsigned int item); + void RemoveItem(unsigned int item); + + ControlScheme controls; + Camera camera; + EventManager* eventManager; + + class EventHandler + { + public: + + private: + + }; + + private: + }; +}; +#endif diff --git a/macosx/src/strmanip.cpp b/macosx/src/strmanip.cpp new file mode 100644 index 0000000..11ab731 --- /dev/null +++ b/macosx/src/strmanip.cpp @@ -0,0 +1,320 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "strmanip.h" + +bool Truth(std::string str) +{ + if (toupper(str[0]) == 'T' || str[0] == '1') + return true; + else + return false; +} + +int Integer(std::string str) +{ + int last = str.length() - 1; + int number = 0; + + for (int x = last; x>=0; x--) + { + switch(str[x]) + { + case '1': + number += (int)pow(10.0, last-x); + break; + case '2': + number += 2 * (int)pow(10.0, last-x); + break; + case '3': + number += 3 * (int)pow(10.0, last-x); + break; + case '4': + number += 4 * (int)pow(10.0, last-x); + break; + case '5': + number += 5 * (int)pow(10.0, last-x); + break; + case '6': + number += 6 * (int)pow(10.0, last-x); + break; + case '7': + number += 7 * (int)pow(10.0, last-x); + break; + case '8': + number += 8 * (int)pow(10.0, last-x); + break; + case '9': + number += 9 * (int)pow(10.0, last-x); + } + } + return number; +} + +float Floating(std::string str) +{ + //this doesn't work right yet so use atof for now + + int last = str.length() - 1; + float number = 0.0f; + bool period = false; + + for (int x = last; x>=0; x--) + { + switch(str[x]) + { + case '1': + number += (float)pow(10.0, last-x); + break; + case '2': + number += 2 * (float)pow(10.0, last-x); + break; + case '3': + number += 3 * (float)pow(10.0, last-x); + break; + case '4': + number += 4 * (float)pow(10.0, last-x); + break; + case '5': + number += 5 * (float)pow(10.0, last-x); + break; + case '6': + number += 6 * (float)pow(10.0, last-x); + break; + case '7': + number += 7 * (float)pow(10.0, last-x); + break; + case '8': + number += 8 * (float)pow(10.0, last-x); + break; + case '9': + number += 9 * (float)pow(10.0, last-x); + break; + case '.': + if (!period) + { + number *= (float)pow(10.0, -(last-x)); + last -= (x+1); + period = true; + } + else + return number; + + } + } + + if(str[0] =='-') + return -number; + else + return number; +} + +string KeyString(uint8 key) +{ + switch (key) + { + case OpenArena::KEY_LBUTTON: + return "mouse1"; + case OpenArena::KEY_RBUTTON: + return "mouse2"; + case OpenArena::KEY_MBUTTON: + return "mouse3"; + case OpenArena::KEY_TAB: + return "tab"; + case OpenArena::KEY_RETURN: + return "enter"; + case OpenArena::KEY_SHIFT: + return "shift"; + case OpenArena::KEY_CONTROL: + return "control"; + case OpenArena::KEY_PAUSE: + return "pause"; + case OpenArena::KEY_CAPITAL: + return "capslock"; + case OpenArena::KEY_ESCAPE: + return "esc"; + case OpenArena::KEY_SPACE: + return "space"; + case OpenArena::KEY_PRIOR: + return "pageup"; + case OpenArena::KEY_NEXT: + return "pagedown"; + case OpenArena::KEY_END: + return "end"; + case OpenArena::KEY_HOME: + return "home"; + case OpenArena::KEY_LEFT: + return "left"; + case OpenArena::KEY_UP: + return "up"; + case OpenArena::KEY_RIGHT: + return "right"; + case OpenArena::KEY_DOWN: + return "down"; + case OpenArena::KEY_INSERT: + return "insert"; + case OpenArena::KEY_DELETE: + return "delete"; + case OpenArena::KEY_LWIN: + return "lwin"; + case OpenArena::KEY_RWIN: + return "rwin"; + case OpenArena::KEY_APPS: + return "apps"; + case OpenArena::KEY_NUMPAD0: + return "numpad0"; + case OpenArena::KEY_NUMPAD1: + return "numpad1"; + case OpenArena::KEY_NUMPAD2: + return "numpad2"; + case OpenArena::KEY_NUMPAD3: + return "numpad3"; + case OpenArena::KEY_NUMPAD4: + return "numpad4"; + case OpenArena::KEY_NUMPAD5: + return "numpad5"; + case OpenArena::KEY_NUMPAD6: + return "numpad6"; + case OpenArena::KEY_NUMPAD7: + return "numpad7"; + case OpenArena::KEY_NUMPAD8: + return "numpad8"; + case OpenArena::KEY_NUMPAD9: + return "numpad9"; + case OpenArena::KEY_MULTIPLY: + return "numpad*"; + case OpenArena::KEY_ADD: + return "numpad+"; + case OpenArena::KEY_SUBTRACT: + return "numpad-"; + case OpenArena::KEY_DIVIDE: + return "numpad/"; + case OpenArena::KEY_F1: + return "f1"; + case OpenArena::KEY_F2: + return "f2"; + case OpenArena::KEY_F3: + return "f3"; + case OpenArena::KEY_F4: + return "f4"; + case OpenArena::KEY_F5: + return "f5"; + case OpenArena::KEY_F6: + return "f6"; + case OpenArena::KEY_F7: + return "f7"; + case OpenArena::KEY_F8: + return "f8"; + case OpenArena::KEY_F9: + return "f9"; + case OpenArena::KEY_F10: + return "f10"; + case OpenArena::KEY_F11: + return "f11"; + case OpenArena::KEY_F12: + return "f2"; + case OpenArena::KEY_NUMLOCK: + return "numlock"; + case OpenArena::KEY_SCROLL: + return "scroll"; + case OpenArena::KEY_SEPARATOR: + return "separator"; + default: + return "null"; + }; +} + +string Right(string str, uint32 len) +{ + return str.substr(str.length()-len, len); +} + +string Left(string str, uint32 len) +{ + return str.substr(0, len); +} + +string tolower(string str) +{ + for(uint32 i=0; i 0) + { + if(wordNum < 1) + { + while(isspace(str[start])) + ++start; + + while (!isspace(str[++length]) && length < maxLength); + + if(length < maxLength || isspace(str[length])){ + if(length >0) + { + length--; + } + } + return str.substr(start, length); + } + else + { + while(isspace(str[start])) + ++start; + + for(uint32 i=0; i +#include +#include "keys.h" +#include "datatypes.h" + +using namespace std; + +/*! + * \brief + * Write brief comment for Truth here. + * + * \param str + * Description of parameter str. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for Truth here. + * + * \remarks + * Write remarks for Truth here. + * + * \see + * Separate items with the '|' character. + */ +bool Truth(string str); +/*! + * \brief + * Write brief comment for Integer here. + * + * \param str + * Description of parameter str. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for Integer here. + * + * \remarks + * Write remarks for Integer here. + * + * \see + * Separate items with the '|' character. + */ +int Integer(string str); +/*! + * \brief + * Write brief comment for Floating here. + * + * \param str + * Description of parameter str. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for Floating here. + * + * \remarks + * Write remarks for Floating here. + * + * \see + * Separate items with the '|' character. + */ +float Floating(string str); + +/** + * @brief + * Write brief comment for KeyString here. + * + * @param keyCode - Description of parameter . + * + * @returns + * Write description of return value here. + * + * Write detailed description for KeyString here. + * + * @remarks + * Write remarks for KeyString here. + * + * @see + * Separate items with the '|' character. + */ +string KeyString(uint8 keyCode); +/*! + * @brief + * Write brief comment for Right here. + * + * @param + * Description of parameter . + * + * @param + * Description of parameter . + * + * @returns + * Write description of return value here. + * + * @throws + * Description of criteria for throwing this exception. + * + * Write detailed description for Right here. + * + * @remarks + * Write remarks for Right here. + * + * @see + * Separate items with the '|' character. + */ +string Right(string, uint32); +/*! + * @brief + * Write brief comment for Left here. + * + * @param + * Description of parameter . + * + * @param + * Description of parameter . + * + * @returns + * Write description of return value here. + * + * @throws + * Description of criteria for throwing this exception. + * + * Write detailed description for Left here. + * + * @remarks + * Write remarks for Left here. + * + * @see + * Separate items with the '|' character. + */ +string Left(string, uint32); +/*! + * \brief + * Write brief comment for tolower here. + * + * \param + * Description of parameter . + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for tolower here. + * + * \remarks + * Write remarks for tolower here. + * + * \see + * Separate items with the '|' character. + */ +string tolower(string); +/*! + * \brief + * Write brief comment for toupper here. + * + * \param + * Description of parameter . + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for toupper here. + * + * \remarks + * Write remarks for toupper here. + * + * \see + * Separate items with the '|' character. + */ +string toupper(string); +/*! + * \brief + * Write brief comment for word here. + * + * \param + * Description of parameter . + * + * \param + * Description of parameter . + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for word here. + * + * \remarks + * Write remarks for word here. + * + * \see + * Separate items with the '|' character. + */ +string word(string, uint32); + +#endif diff --git a/macosx/src/tga.h b/macosx/src/tga.h new file mode 100644 index 0000000..66ebba0 --- /dev/null +++ b/macosx/src/tga.h @@ -0,0 +1,101 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __TGA_H__ +#define __TGA_H__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#include "mygl.h" +#include +#include +#include "texture.h" + +namespace OpenArena{ + /*! + * \brief + * Write brief comment for TGAHeader here. + * + * Write detailed description for TGAHeader here. + * + * \remarks + * Write remarks for TGAHeader here. + * + * \see + * Separate items with the '|' character. + */ + struct TGAHeader + { + GLubyte Header[12]; // File Header To Determine File Type + }; + + /*! + * \brief + * Write brief comment for TGA here. + * + * Write detailed description for TGA here. + * + * \remarks + * Write remarks for TGA here. + * + * \see + * Separate items with the '|' character. + */ + struct TGA + { + GLubyte header[6]; // Holds The First 6 Useful Bytes Of The File + GLuint bytesPerPixel; // Number Of BYTES Per Pixel (3 Or 4) + GLuint imageSize; // Amount Of Memory Needed To Hold The Image + GLuint type; // The Type Of Image, GL_RGB Or GL_RGBA + GLuint Height; // Height Of Image + GLuint Width; // Width Of Image + GLuint Bpp; // Number Of BITS Per Pixel (24 Or 32) + }; + + /*! + * \brief + * Write brief comment for LoadTGA here. + * + * \param filename + * Description of parameter filename. + * + * \returns + * Write description of return value here. + * + * \throws + * Description of criteria for throwing this exception. + * + * Write detailed description for LoadTGA here. + * + * \remarks + * Write remarks for LoadTGA here. + * + * \see + * Separate items with the '|' character. + */ + TextureImage* LoadTGA(const char *filename); + + const GLubyte uTGAcompare[12] = {0,0,2, 0,0,0,0,0,0,0,0,0}; // Uncompressed TGA Header + const GLubyte cTGAcompare[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; // Compressed TGA Header + TextureImage* LoadUncompressedTGA(FILE *); // Load an Uncompressed file + TextureImage* LoadCompressedTGA(FILE *); // Load a Compressed file +}; +#endif diff --git a/macosx/src/window.cpp b/macosx/src/window.cpp new file mode 100644 index 0000000..9d2c4cb --- /dev/null +++ b/macosx/src/window.cpp @@ -0,0 +1,515 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "window.h" + +void OpenArena::Window::SwapBuffers() +{ + #if defined USE_GLX + if(doubleBuffered) + { + glXSwapBuffers(display, window); + } + #elif defined USE_AGL + aglSwapBuffers(_aglContext); + #elif defined USE_CGL + CGLFlushDrawable(cglContext); + #elif defined USE_WGL + ::SwapBuffers(deviceContext); + #endif +} + +bool OpenArena::Window::Open() +{ + #if defined USE_GLX + XVisualInfo* vi; + Colormap cmap; + int bestMode = 0; + int vidModeMajorVersion; + int vidModeMinorVersion; + int glxMajorVersion; + int glxMinorVersion; + int modeNum; + #if defined HAVE_XF86VIDMODE + XF86VidModeModeInfo** modes; + #endif + Atom wmDelete; + ::Window winDummy; + unsigned int borderDummy; + + display = XOpenDisplay(0); + screen = DefaultScreen(display); + + #if defined HAVE_XF86VIDMODE + XF86VidModeQueryVersion(display, &vidModeMajorVersion, &vidModeMinorVersion); + printf("XF86VidModeExtension-Version %d.%d\n", vidModeMajorVersion, vidModeMinorVersion); + + XF86VidModeGetAllModeLines(display, screen, &modeNum, &modes); + vidMode = *modes[0]; + + int i; + for(i=0; ihdisplay == _width) && (modes[i]->vdisplay == _height)) + { + bestMode = i; + } + } + #endif + + vi = glXChooseVisual(display, screen, attrListDbl); + if(vi == NULL){ + vi = glXChooseVisual(display, screen, attrListSgl); + doubleBuffered = false; + printf("Only Singlebuffered Visual!\n"); + } + else + { + doubleBuffered = true; + printf("Got Doublebuffered Visual!\n"); + } + + glXQueryVersion(display, &glxMajorVersion, & glxMinorVersion); + printf("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion); + + hRC = glXCreateContext(display, vi, 0, GL_TRUE); + cmap = XCreateColormap(display, RootWindow(display, vi->screen), vi->visual, AllocNone); + attributes.colormap = cmap; + attributes.border_pixel = 0; + + attributes.event_mask = ExposureMask | + KeyPressMask | KeyReleaseMask | + ButtonPressMask | ButtonReleaseMask | +// PointerMotionMask | ButtonMotionMask | + StructureNotifyMask; + + if(_fullscreen) + { + #if defined HAVE_XF86VIDMODE + XF86VidModeSwitchToMode(display, screen, modes[bestMode]); + XF86VidModeSetViewPort(display, screen, 0, 0); + XFree(modes); + #endif + + attributes.override_redirect = true; + window = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &attributes); + XWarpPointer(display, None, window, 0, 0, 0, 0, 0, 0); + XMapRaised(display, window); + XGrabKeyboard(display, window, true, GrabModeAsync, GrabModeAsync, CurrentTime); + XGrabPointer(display, window, true, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); + XDefineCursor(display, window, CreateFullscreenCursor()); + } + else + { + window = XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, _width, _height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &attributes); + wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", true); + XSetWMProtocols(display, window, &wmDelete, 1); + XSetStandardProperties(display, window, GetName(), GetName(), None, NULL, 0, NULL); + XMapRaised(display, window); + XDefineCursor(display, window, CreateWindowedCursor()); + } + + glXMakeCurrent(display, window, hRC); + unsigned int twidth, theight, depth; + XGetGeometry(display, window, &winDummy, &x, &y, &twidth, &theight, &borderDummy, &depth); + _colorDepth = (char)depth; + _height = (short)twidth; + _width = (short)theight; + printf("Resolution %dx%d\n", twidth, theight); + printf("Depth %d\n", depth); + if(glXIsDirect(display, hRC)) + { + printf("Congrats, you have Direct Rendering!\n"); + } + else + { + printf("Sorry, no Direct Rendering possible!\n"); + } + _initializer->Initialize(); + return true; + #elif defined USE_AGL + OSStatus err = noErr; + SetRect(&_bounds, 0, 0, 640, 480); + err = CreateNewWindow(kDocumentWindowClass, kWindowStandardHandlerAttribute | kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute, &_bounds, &_window); + if(err != noErr) + { + return false; + } + + RepositionWindow(_window, NULL, kWindowCascadeOnMainScreen); + + AGLDevice* devices = NULL; + GLint deviceCount = 0; + GLint attributes[] = {AGL_ACCELERATED, AGL_NO_RECOVERY, AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE}; + AGLPixelFormat pixelFormat; + + pixelFormat = aglChoosePixelFormat(devices,deviceCount,attributes); + _aglContext = aglCreateContext(pixelFormat, NULL); + if(!_aglContext) + { + exit (5); + } + + aglDestroyPixelFormat(pixelFormat); + + if(!aglSetCurrentContext(_aglContext)) + { + exit(6); + } + + if(!aglSetDrawable(_aglContext, GetWindowPort(_window))) + { + exit(7); + } + + glClearColor(0.0f,0.0f,0.0f,0.0f); + glClear(GL_COLOR_BUFFER_BIT); + aglSwapBuffers(_aglContext); + ShowWindow(_window); + #elif defined USE_CGL + #error undefined method + #elif defined USE_WGL + unsigned int PixelFormat; + WNDCLASS wc; + DWORD dwExStyle; + DWORD dwStyle; + RECT WindowRect; + WindowRect.left=(long)0; + WindowRect.right=(long)_width; + WindowRect.top=(long)0; + WindowRect.bottom=(long)_height; + + instance = GetModuleHandle(NULL); + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC)WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = instance; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "OpenArena v0.1.0"; + + if (!RegisterClass(&wc)) + { + MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + if (_fullscreen) + { + DEVMODE dmScreenSettings; + memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); + dmScreenSettings.dmSize = sizeof(dmScreenSettings); + dmScreenSettings.dmPelsWidth = _width; + dmScreenSettings.dmPelsHeight = _height; + dmScreenSettings.dmBitsPerPel = _colorDepth; + dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; + + + if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) + { + if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","OpenArena",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) + _fullscreen = false; + else + { + + MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); + return false; + } + } + } + + if (_fullscreen) + { + dwExStyle = WS_EX_APPWINDOW; + dwStyle = WS_POPUP; + ShowCursor(/*true*/false); + } + else + { + ShowCursor(false); + dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + dwStyle = WS_OVERLAPPEDWINDOW; + } + + AdjustWindowRectEx(&WindowRect, dwStyle, false, dwExStyle); + + if (!(window = CreateWindowEx(dwExStyle, "OpenArena v0.1.0", GetName(), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dwStyle, 0, 0, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, instance, NULL))) + { + Close(); + MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + static PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, _colorDepth, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; + + if (!(deviceContext=GetDC(window))) + { + Close(); + MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + if (!(PixelFormat=ChoosePixelFormat(deviceContext,&pfd))) + { + Close(); + MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + if(!SetPixelFormat(deviceContext,PixelFormat,&pfd)) + { + Close(); + MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + if (!(glContext=wglCreateContext(deviceContext))) + { + Close(); + MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + if(!wglMakeCurrent(deviceContext,glContext)) + { + Close(); + MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + ShowWindow(window,SW_SHOW); + SetForegroundWindow(window); + SetFocus(window); + _resizer->Resize(_width, _height); + + if (!_initializer->Initialize()) + { + Close(); + MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); + return false; + } + + return true; + #endif +} + +void OpenArena::Window::Close() +{ + #if defined USE_GLX + if(_fullscreen) + { + #if defined HAVE_XF86VIDMODE + XF86VidModeSwitchToMode(display, screen, &vidMode); + XF86VidModeSetViewPort(display, screen, 0, 0); + #endif + } + + if(hRC) + { + if(!glXMakeCurrent(display, None, NULL)) + { + printf("Could not release drawing context.\n"); + } + glXDestroyContext(display, hRC); + hRC = NULL; + } + + XCloseDisplay(display); + #elif defined USE_AGL + if(!_fullscreen) + { + aglSetCurrentContext(NULL); + aglDestroyContext(_aglContext); + _aglContext = NULL; + } + #elif defined USE_CGL + #error unimplemented method + #elif defined USE_WGL + if(_fullscreen) + { + ChangeDisplaySettings(NULL, 0); + ShowCursor(true); + } + + if(glContext) + { + if(!wglMakeCurrent(NULL, NULL)) + MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + + if (!wglDeleteContext(glContext)) + MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + + glContext=NULL; + } + + if (deviceContext && !ReleaseDC(window, deviceContext)) + { + MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + deviceContext=NULL; + } + + if (window && !DestroyWindow(window)) + { + MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + window=NULL; + } + + if (!UnregisterClass("OpenArena v0.1.0", instance)) + { + MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + instance=NULL; + } + #endif +} + +bool OpenArena::Window::Open(string title, int width, int height, int bits, bool fullscreenflag) +{ + _fullscreen = fullscreenflag; + _width = width; + _height = height; + _colorDepth = bits; + _name = title; + + return Open(); +} + +OpenArena::Window::Window() +{ + _initializer = new Initializer(); + _resizer = new Resizer(); +} + +OpenArena::Window::~Window() +{ +} + +void OpenArena::Window::SetInitializer(OpenArena::Window::Initializer* initializer) +{ + _initializer = initializer; +} + +void OpenArena::Window::SetResizer(OpenArena::Window::Resizer* resizer) +{ + _resizer = resizer; +} + +void OpenArena::Window::Resizer::Resize(GLsizei width, GLsizei height) +{ + if (height==0) + height=1; + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + +} + +int OpenArena::Window::Initializer::Initialize() +{ + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0f); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + return true; +} + +void OpenArena::Window::Resize(GLsizei width, GLsizei height) +{ + _resizer->Resize(width, height); +} + +OpenArena::Vec2i OpenArena::Window::GetMousePosition() +{ + #ifdef USE_GLX + ::Window rootWindow; + ::Window childWindow; + int rootX; + int rootY; + int mouseX; + int mouseY; + unsigned int mask; + if(!XQueryPointer(display, window, &rootWindow, &childWindow, &rootX, &rootY, &mouseX, &mouseY, &mask)) + { + return Vec2i(-1,-1); + } + else + { + return Vec2i(mouseX, mouseY); + } + #elif defined USE_AGL + #warning unimplemented method + #elif defined USE_CGL + #error unimplemented method + #elif defined USE_WGL + POINT pos; + GetCursorPos(&pos); + return Vec2i(pos.x, pos.y); + #endif +} + +void OpenArena::Window::SetMousePosition(Vec2i pos) +{ + #if defined USE_GLX + XWarpPointer(display, None, window, 0, 0, 0, 0, pos.x, pos.y); + #elif defined USE_AGL + #warning unimplemented method + #elif defined USE_CGL + #error unimplemented method + #elif defined USE_WGL + SetCursorPos(pos.x, pos.y); + #endif +} + +#ifdef USE_GLX +Display* OpenArena::Window::GetDisplay() +{ + return display; +} + +Cursor OpenArena::Window::CreateWindowedCursor() +{ + return CreateFullscreenCursor(); +} + +Cursor OpenArena::Window::CreateFullscreenCursor() +{ + Pixmap pixmap = XCreatePixmap(display, window, 1, 1, 1); + XColor color; + color.pixel = 0; + color.red = 0; + color.flags = DoRed; + Cursor cur = XCreatePixmapCursor(display, pixmap, pixmap, &color, &color, 0, 0); + XFreePixmap(display, pixmap); + return cur; +} +#endif diff --git a/macosx/src/window.h b/macosx/src/window.h new file mode 100644 index 0000000..5ba83be --- /dev/null +++ b/macosx/src/window.h @@ -0,0 +1,125 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __window_h__ +#define __window_h__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#include "screen.h" + +#if defined USE_GLX + #include + #include //maybe not necessary + #include + #include + #include + #include + #if defined HAVE_XF86VIDMODE + #include + #endif +#elif defined USE_AGL + #include + #include + #include +#elif defined USE_CGL + #include + #include +#elif defined USE_WGL + #include + #include + #include +#endif + +#ifdef WIN32 +#endif +#include "vector.h" + +namespace OpenArena +{ + class Window: public Screen + { + public: + class Resizer + { + public: + void Resize(GLsizei width, GLsizei height); + }; + + class Initializer + { + public: + int Initialize(); + }; + + public: + Window(); + ~Window(); + void Close(); + bool Open(); + bool Open(string title, int width, int height, int bits, bool fullscreenflag); //make that string a const char* after this works + void SetInitializer(Initializer* initializer); + void SetResizer(Resizer* resizer); + void SwapBuffers(); + void Resize(GLsizei width, GLsizei height); + Vec2i GetMousePosition(); + void SetMousePosition(Vec2i pos); + + #ifdef USE_GLX + Display* GetDisplay(); + #endif + private: + #ifdef USE_GLX + Cursor CreateWindowedCursor(); + Cursor CreateFullscreenCursor(); + int screen; + ::Window window; + GLXContext hRC; + XSetWindowAttributes attributes; + bool doubleBuffered; + #if defined HAVE_XF86VIDMODE + XF86VidModeModeInfo vidMode; + #endif + int x, y; + Display* display; + #elif defined USE_AGL + AGLContext _aglContext; + WindowRef _window; + Rect _bounds; + #elif defined USE_WGL + HGLRC glContext; + HWND window; + HDC deviceContext; + HINSTANCE instance; + #endif + Resizer* _resizer; + Initializer* _initializer; + }; +}; + +#if defined USE_GLX +static int attrListSgl[] = {GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None}; +static int attrListDbl[] = {GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, None}; +#elif defined USE_WGL +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +#endif + +#endif diff --git a/macosx/src/worlddefs.h b/macosx/src/worlddefs.h new file mode 100644 index 0000000..2e95ed1 --- /dev/null +++ b/macosx/src/worlddefs.h @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __WorldDefs_h__ +#define __WorldDefs_h__ + +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#include "level.h" + +//static OpenArena::Level level; + +#endif diff --git a/macosx/src/x11.cpp b/macosx/src/x11.cpp new file mode 100644 index 0000000..ab6ca60 --- /dev/null +++ b/macosx/src/x11.cpp @@ -0,0 +1,408 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//////////////////////////////////////////////////////////////////////////////// +// +// Module: x11.cpp +// Author: Tom Hicks +// Creation: 10-08-2006 +// LastEdit: 10-08-2006 +// Editors: Tom Hicks +// +// Purpose: +// To implement the OpenArena SDK. +// +// Summary of Methods: +// Global +// -InitControls() +// Loads the defaultPlayer's configuration. +// -InitGL() +// Initializes OpenGL and is responsible for loading textures. +// -ResizeGLScene(GLsizei width, GLsizei height) +// Resizes the viewport to the current size of the visible area of the window specified by width and height. +// -KillGLWindow() +// Closes the window. +// -CreateGLWindow(string title, int width, int height, int bits, bool fullscreenflag) +// Creates the window with the specified parameters. +// -WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +// Main procedure. +// -WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +// Window Procedure for the OpenGL window. +// +//////////////////////////////////////////////////////////////////////////////// +#include "x11.h" +#if defined USE_GLX +#include "main.h" +#include "version.h" + +int InitGL(OpenArena::Level* level) +{ + level->LoadGLTextures(); + + glEnable(GL_TEXTURE_2D); + glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0f); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + + /*lighting disabled temporarily + glLightfv(GL_LIGHT1, GL_AMBIENT, level->LightAmbient); + for(index=0; indexnumLights; index++) + { + glLightfv(GL_LIGHT1, GL_DIFFUSE, level->light[index].color); + glLightfv(GL_LIGHT1, GL_POSITION, level->light[index].coords); + } + + glEnable(GL_LIGHT1); + glEnable(GL_LIGHTING); + */ + //BuildFont(); + return true; +} + +//This should probably be moved into oa_input +OpenArena::Keys TranslateKey(int keyCode) +{ + switch (keyCode) + { + case XK_BackSpace: + return OpenArena::KEY_BACK; + case XK_Tab: + return OpenArena::KEY_TAB; + case XK_Return: + return OpenArena::KEY_RETURN; + case XK_Escape: + return OpenArena::KEY_ESCAPE; + case XK_Left: + return OpenArena::KEY_LEFT; + case XK_Right: + return OpenArena::KEY_RIGHT; + case XK_Up: + return OpenArena::KEY_UP; + case XK_Down: + return OpenArena::KEY_DOWN; + case XK_Home: + return OpenArena::KEY_HOME; + case XK_End: + return OpenArena::KEY_END; + case XK_Prior: + return OpenArena::KEY_PRIOR; + case XK_Next: + return OpenArena::KEY_NEXT; + case XK_Num_Lock: + return OpenArena::KEY_NUMLOCK; + case XK_KP_Enter: + return OpenArena::KEY_RETURN; + case XK_KP_Home: + return OpenArena::KEY_HOME; + case XK_KP_End: + return OpenArena::KEY_END; + case XK_KP_Prior: + return OpenArena::KEY_PRIOR; + case XK_KP_Next: + return OpenArena::KEY_NEXT; + case XK_KP_0: + return OpenArena::KEY_NUMPAD0; + case XK_KP_1: + return OpenArena::KEY_NUMPAD1; + case XK_KP_2: + return OpenArena::KEY_NUMPAD2; + case XK_KP_3: + return OpenArena::KEY_NUMPAD3; + case XK_KP_4: + return OpenArena::KEY_NUMPAD4; + case XK_KP_5: + return OpenArena::KEY_NUMPAD5; + case XK_KP_6: + return OpenArena::KEY_NUMPAD6; + case XK_KP_7: + return OpenArena::KEY_NUMPAD7; + case XK_KP_8: + return OpenArena::KEY_NUMPAD8; + case XK_KP_9: + return OpenArena::KEY_NUMPAD9; + case XK_KP_Multiply: + return OpenArena::KEY_MULTIPLY; + case XK_KP_Add: + return OpenArena::KEY_ADD; + case XK_KP_Subtract: + return OpenArena::KEY_SUBTRACT; + case XK_KP_Divide: + return OpenArena::KEY_DIVIDE; + case XK_F1: + return OpenArena::KEY_F1; + case XK_F2: + return OpenArena::KEY_F2; + case XK_F3: + return OpenArena::KEY_F3; + case XK_F4: + return OpenArena::KEY_F4; + case XK_F5: + return OpenArena::KEY_F5; + case XK_F6: + return OpenArena::KEY_F6; + case XK_F7: + return OpenArena::KEY_F7; + case XK_F8: + return OpenArena::KEY_F8; + case XK_F9: + return OpenArena::KEY_F9; + case XK_F10: + return OpenArena::KEY_F10; + case XK_F11: + return OpenArena::KEY_F11; + case XK_F12: + return OpenArena::KEY_F12; + case XK_Shift_L: + return OpenArena::KEY_SHIFT; + case XK_Shift_R: + return OpenArena::KEY_SHIFT; + case XK_Control_L: + return OpenArena::KEY_CONTROL; + case XK_Control_R: + return OpenArena::KEY_CONTROL; + case XK_Caps_Lock: + return OpenArena::KEY_CAPITAL; + case XK_Pause: + return OpenArena::KEY_PAUSE; + case XK_KP_Space: + case XK_space: + return OpenArena::KEY_SPACE; + case XK_Insert: + return OpenArena::KEY_INSERT; + case XK_Delete: + return OpenArena::KEY_DELETE; + case XK_KP_Separator: + return OpenArena::KEY_SEPARATOR; + case XK_Scroll_Lock: + return OpenArena::KEY_SCROLL; + case XK_period: + return OpenArena::KEY_OEM_PERIOD; + case XK_plus: + return OpenArena::KEY_OEM_PLUS; + case XK_minus: + return OpenArena::KEY_OEM_MINUS; + case XK_comma: + return OpenArena::KEY_OEM_COMMA; + case XK_0: + return OpenArena::KEY_0; + case XK_1: + return OpenArena::KEY_1; + case XK_2: + return OpenArena::KEY_2; + case XK_3: + return OpenArena::KEY_3; + case XK_4: + return OpenArena::KEY_4; + case XK_5: + return OpenArena::KEY_5; + case XK_6: + return OpenArena::KEY_6; + case XK_7: + return OpenArena::KEY_7; + case XK_8: + return OpenArena::KEY_8; + case XK_9: + return OpenArena::KEY_9; + case XK_a: + case XK_A: + return OpenArena::KEY_A; + case XK_b: + case XK_B: + return OpenArena::KEY_B; + case XK_c: + case XK_C: + return OpenArena::KEY_C; + case XK_d: + case XK_D: + return OpenArena::KEY_D; + case XK_e: + case XK_E: + return OpenArena::KEY_E; + case XK_f: + case XK_F: + return OpenArena::KEY_F; + case XK_g: + case XK_G: + return OpenArena::KEY_G; + case XK_h: + case XK_H: + return OpenArena::KEY_H; + case XK_i: + case XK_I: + return OpenArena::KEY_I; + case XK_j: + case XK_J: + return OpenArena::KEY_J; + case XK_k: + case XK_K: + return OpenArena::KEY_K; + case XK_l: + case XK_L: + return OpenArena::KEY_L; + case XK_m: + case XK_M: + return OpenArena::KEY_M; + case XK_n: + case XK_N: + return OpenArena::KEY_N; + case XK_o: + case XK_O: + return OpenArena::KEY_O; + case XK_p: + case XK_P: + return OpenArena::KEY_P; + case XK_q: + case XK_Q: + return OpenArena::KEY_Q; + case XK_r: + case XK_R: + return OpenArena::KEY_R; + case XK_s: + case XK_S: + return OpenArena::KEY_S; + case XK_t: + case XK_T: + return OpenArena::KEY_T; + case XK_u: + case XK_U: + return OpenArena::KEY_U; + case XK_v: + case XK_V: + return OpenArena::KEY_V; + case XK_w: + case XK_W: + return OpenArena::KEY_W; + case XK_x: + case XK_X: + return OpenArena::KEY_X; + case XK_y: + case XK_Y: + return OpenArena::KEY_Y; + case XK_z: + case XK_Z: + return OpenArena::KEY_Z; + case XK_grave: + return OpenArena::KEY_OEM_3; + case XK_Super_L: + return OpenArena::KEY_LWIN; + case XK_Super_R: + return OpenArena::KEY_RWIN; + case XK_Menu: + return OpenArena::KEY_APPS; + case XK_bracketleft: + return OpenArena::KEY_OEM_4; + case XK_bracketright: + return OpenArena::KEY_OEM_6; + case XK_backslash: + return OpenArena::KEY_OEM_5; + case XK_semicolon: + return OpenArena::KEY_OEM_1; + case XK_apostrophe: + return OpenArena::KEY_OEM_7; + case XK_slash: + return OpenArena::KEY_OEM_2; + case XK_Alt_L: + return OpenArena::KEY_ALT_L; + case XK_Alt_R: + return OpenArena::KEY_ALT_L; + case XK_equal: + return OpenArena::KEY_OEM_PLUS; + case XK_Mode_switch: + return OpenArena::KEY_OPTION; + case XK_Meta_L: + return OpenArena::KEY_COMMAND; + case 16777219: + return OpenArena::KEY_ENTER; + default: + return OpenArena::KEY_UNKNOWN; + } +} + +OpenArena::Keys TranslateButton(int keyCode) +{ + switch(keyCode) + { + case Button1: + return OpenArena::KEY_BUTTON0; + case Button2: + return OpenArena::KEY_BUTTON2; + case Button3: + return OpenArena::KEY_BUTTON1; + case Button4: + return OpenArena::KEY_BUTTON3; + case Button5: + return OpenArena::KEY_BUTTON4; + } +} + +void HandleConsoleKeyPress(OpenArena::Keys key, OpenArena::Level* level) +{ + if(level->defaultPlayer[0].controls.IsBound(key, OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE)) + { + level->showConsole = false; + } + + switch (key) + { + case OpenArena::KEY_SHIFT: + keys[OpenArena::KEY_SHIFT] = true; + break; + case OpenArena::KEY_RETURN: + level->UpdateConsole('\n'); + break; + case OpenArena::KEY_SPACE: + printf("hello"); + level->UpdateConsole(' '); + break; + case OpenArena::KEY_BACK: + level->UpdateConsole(OpenArena::KEY_BACK); + break; + case OpenArena::KEY_ESCAPE: + level->showConsole = false; + break; + default: + char ascii = OpenArena::KeyToASCII(key, keys[OpenArena::KEY_SHIFT]); + if(ascii != '\0') + { + level->UpdateConsole(ascii); + } + } +} + +void ResizeGLScene(GLsizei width, GLsizei height) +{ + if(height == 0) + height = 1; + + glViewport(0,0,width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat)width/height, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); +} + +void RT() +{ +} + +#endif /* USE_GLX */ diff --git a/macosx/src/x11.h b/macosx/src/x11.h new file mode 100644 index 0000000..3f3324d --- /dev/null +++ b/macosx/src/x11.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2006 by Tom Hicks * + * tomhicks@cse.buffalo.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef __x11_h__ +#define __x11_h__ +#if defined HAVE_CONFIG_H +#include "config.h" +#endif + +#if defined USE_GLX +#include "mygl.h" +#include "EventManager.h" +#include "level.h" + +int DrawGLScene(); +OpenArena::Keys TranslateButton(int keyCode); +OpenArena::Keys TranslateKey(int keyCode); +void ResizeGLScene(GLsizei width, GLsizei height); +void HandleConsoleKeyPress(OpenArena::Keys key); +int DrawGLScene(OpenArena::Level* level); +int InitGL(OpenArena::Level* level); +void HandleConsoleKeyPress(OpenArena::Keys key, OpenArena::Level* level); +#endif /* USE_GLX */ +#endif /* __x11_h__ */