*** empty log message ***
@@ -1,26 +0,0 @@
|
||||
EXECUTABLES = OpenArena/OA
|
||||
LIBRARIES =
|
||||
BUILDROOT = /usr/local
|
||||
PREFIX =
|
||||
|
||||
.Phony: all clean install distclean
|
||||
|
||||
all:
|
||||
$(MAKE) -C src all
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
|
||||
install:
|
||||
|
||||
install-devel:
|
||||
|
||||
install-doc:
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
rm -f src/Makefile
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
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:
|
||||
|
||||
|
||||
|
||||
|
||||
54
configure
vendored
@@ -1,54 +0,0 @@
|
||||
#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
|
||||
28
heading.txt
@@ -1,28 +0,0 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1 +0,0 @@
|
||||
This program can be distributed under either the GPL or the QTPL. Copies of which will soon be added to this distribution.
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>OpenArena</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>net.olympusonline.OpenArena</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>OpenArena</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1 +0,0 @@
|
||||
APPL????
|
||||
205
oa.nsi
@@ -1,205 +0,0 @@
|
||||
; 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
|
||||
41
oa.sln
@@ -1,41 +0,0 @@
|
||||
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
|
||||
520
oa.vcproj
@@ -1,520 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="oa"
|
||||
ProjectGUID="{6F5D0FF6-A032-4356-932E-865B601E0DD4}"
|
||||
RootNamespace="oa"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\OpenArena"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/oa.tlb"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\include"
|
||||
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Release/oa.pch"
|
||||
AssemblerListingLocation=".\"
|
||||
ObjectFile=".\"
|
||||
ProgramDataBaseFileName=".\"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\OpenArena\oa.exe"
|
||||
Version="0.1.0-alpha"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories=".\lib"
|
||||
ProgramDatabaseFile=".\Release/oa.pdb"
|
||||
SubSystem="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/oa.tlb"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,USE_WGL"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\Debug/oa.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/MACHINE:I386"
|
||||
OutputFile=".\Debug\oa.exe"
|
||||
LinkIncremental="2"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories=".\lib"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\Debug/oa.pdb"
|
||||
SubSystem="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\bmp.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\camera.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ctrls.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\keys.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\level.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\linux.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\macosx.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\main.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mygl.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\myglFont.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\myglTexture.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NullVideoPlugin.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\player.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\PluginManager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\screen.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\strmanip.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tga.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\vector.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\window.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\windows.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\WindowsLogger.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\bmp.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\camera.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\ctrls.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\datatypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\geometry.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\image.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\keys.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\level.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\list.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Logger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\main.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Model.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mydefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mygl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\myglFont.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\myglTexture.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\NullVideoPlugin.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\player.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Plugin.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\PluginManager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\screen.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\strmanip.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\texture.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\tga.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\vector.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\version.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\VideoPlugin.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\window.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\WindowsLogger.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\worlddefs.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="oa"
|
||||
>
|
||||
<Filter
|
||||
Name="maps"
|
||||
Filter=".map, .lit"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OpenArena\oa\maps\intro.map"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OpenArena\oa\maps\oamap1.map"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="textures"
|
||||
Filter=".bmp, .jpg, .tga, .png"
|
||||
>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\textures\groundc.tga"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\textures\moonc.tga"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\textures\nightSkyc.tga"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="menu"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\OpenArena\oa\textures\menu\con_back.bmp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OpenArena\oa\textures\menu\con_back.tga"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\textures\menu\font.bmp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="config"
|
||||
Filter=".cfg"
|
||||
>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\config\G2k.cfg"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\config\My.cfg"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="music"
|
||||
>
|
||||
<Filter
|
||||
Name="bgm"
|
||||
>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\music\bgm\bgm1.mp3"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="OpenArena\oa\music\bgm\bgm2.mp3"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Doxyfile.doxygen"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\heading.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,30 +0,0 @@
|
||||
bind forward up
|
||||
bind backward down
|
||||
bind forward mouse1
|
||||
bind backward mouse2
|
||||
bind lookleft left
|
||||
bind lookright right
|
||||
bind lookup pageup
|
||||
bind lookdown pagedown
|
||||
bind moveleft s
|
||||
bind moveright d
|
||||
bind moveup space
|
||||
bind movedown a
|
||||
bind fireprimary f
|
||||
bind firesecondary g
|
||||
bind weapnext t
|
||||
bind weapprev r
|
||||
bind togglelights l
|
||||
bind togglefps p
|
||||
bind toggleconsole `
|
||||
bind togglemouselook null
|
||||
bind quickmouselook null
|
||||
set turnspeed 1.0
|
||||
//set movespeed 0.2
|
||||
set fullscreen 0
|
||||
set mousespeed 5
|
||||
set mouselook 1
|
||||
set screenwidth 1024
|
||||
set screenheight 768
|
||||
set colordepth 32
|
||||
set maxfps 500
|
||||
@@ -1,34 +0,0 @@
|
||||
bind forward up
|
||||
bind backward down
|
||||
bind forward mouse1
|
||||
bind backward mouse2
|
||||
bind lookleft left
|
||||
bind lookright right
|
||||
bind lookup pageup
|
||||
bind lookdown pagedown
|
||||
bind moveleft s
|
||||
bind moveright d
|
||||
bind moveup space
|
||||
bind movedown a
|
||||
bind fireprimary f
|
||||
bind firesecondary g
|
||||
bind weapnext t
|
||||
bind weapprev r
|
||||
bind togglelights l
|
||||
bind togglefps p
|
||||
bind toggleconsole ~
|
||||
bind togglemouselook m
|
||||
bind quickmouselook y
|
||||
set turnspeed 0.02
|
||||
set movespeed 0.2
|
||||
set mousespeed 5
|
||||
set mouselook 1
|
||||
set screenwidth 800
|
||||
set screenheight 600
|
||||
set colordepth 16
|
||||
set fullscreen 0
|
||||
map intro.map
|
||||
set maxfps 60
|
||||
bind rollleft w
|
||||
bind rollright e
|
||||
set sound false
|
||||
@@ -1,16 +0,0 @@
|
||||
1
|
||||
1
|
||||
|
||||
|
||||
0
|
||||
-10 -10 -5 0 0
|
||||
-10 10 -5 0 1
|
||||
10 -10 -5 1 0
|
||||
0 0 1
|
||||
|
||||
3
|
||||
default.bmp
|
||||
moonc.tga
|
||||
nightSkyc.tga
|
||||
|
||||
bgm1.mp3
|
||||
@@ -1,225 +0,0 @@
|
||||
1
|
||||
36
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
1
|
||||
-10.0 -1.0 -10.0 0.0 0.0
|
||||
-10.0 10.0 -10.0 0.0 1.1
|
||||
-5.0 10.0 -10.0 .5 1.1
|
||||
0.0 0.0 1.0
|
||||
|
||||
1
|
||||
-10.0 -1.0 -10.0 0.0 0.0
|
||||
-5.0 -1.0 -10.0 .5 0.0
|
||||
-5.0 10.0 -10.0 .5 1.1
|
||||
0.0 0.0 1.0
|
||||
|
||||
1
|
||||
5.0 -1.0 -10.0 1.5 0.0
|
||||
5.0 10.0 -10.0 1.5 1.1
|
||||
10.0 10.0 -10.0 2 1.1
|
||||
0.0 0.0 1.0
|
||||
|
||||
1
|
||||
5.0 -1.0 -10.0 1.5 0.0
|
||||
10.0 -1.0 -10.0 2 0.0
|
||||
10.0 10.0 -10.0 2 1.1
|
||||
0.0 0.0 1.0
|
||||
|
||||
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
|
||||
0.0 0.0 -1.0
|
||||
|
||||
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
|
||||
0.0 0.0 -1.0
|
||||
|
||||
2
|
||||
-10.0 10.0 -10.0 0.0 32.0
|
||||
10.0 10.0 -10.0 32.0 32.0
|
||||
-10.0 10.0 10.0 0.0 0.0
|
||||
0.0 -1.0 0.0
|
||||
|
||||
2
|
||||
-10.0 10.0 10.0 0.0 0.0
|
||||
10.0 10.0 10.0 32.0 0.0
|
||||
10.0 10.0 -10.0 32.0 32.0
|
||||
0.0 -1.0 0.0
|
||||
|
||||
0
|
||||
-10.0 -1.0 -10.0 0.0 4.0
|
||||
10.0 -1.0 -10.0 4.0 4.0
|
||||
-10.0 -1.0 10.0 0.0 0.0
|
||||
0.0 1.0 0.0
|
||||
|
||||
0
|
||||
-10.0 -1.0 10.0 0.0 0.0
|
||||
10.0 -1.0 10.0 4.0 0.0
|
||||
10.0 -1.0 -10.0 4.0 4.0
|
||||
0.0 1.0 0.0
|
||||
|
||||
0
|
||||
-5 -1 -10 1 0
|
||||
-5 -1 -20 1 2
|
||||
5 -1 -10 3 0
|
||||
0 1 0
|
||||
|
||||
0
|
||||
5 -1 -10 3 0
|
||||
-5 -1 -20 1 2
|
||||
5 -1 -20 3 2
|
||||
0 1 0
|
||||
|
||||
1
|
||||
-5 -1 -10 0 0
|
||||
-5 10 -10 0 1.1
|
||||
-5 -1 -20 1 0
|
||||
1 0 0
|
||||
|
||||
1
|
||||
-5 10 -10 0 1.1
|
||||
-5 10 -20 1 1.1
|
||||
-5 -1 -20 1 0
|
||||
1 0 0
|
||||
|
||||
1
|
||||
5 -1 -10 0 0
|
||||
5 10 -10 0 1.1
|
||||
5 -1 -20 1 0
|
||||
-1 0 0
|
||||
|
||||
1
|
||||
5 10 -10 0 1.1
|
||||
5 10 -20 1 1.1
|
||||
5 -1 -20 1 0
|
||||
-1 0 0
|
||||
|
||||
2
|
||||
-5 10 -10 8 0
|
||||
-5 10 -20 8 16
|
||||
5 10 -10 24 0
|
||||
0 -1 0
|
||||
|
||||
2
|
||||
5 10 -10 24 0
|
||||
-5 10 -20 8 16
|
||||
5 10 -20 24 16
|
||||
0 -1 0
|
||||
|
||||
0
|
||||
-10 -1 -20 0 2
|
||||
10 -1 -20 4 2
|
||||
-10 -1 -40 0 6
|
||||
0 1 0
|
||||
|
||||
0
|
||||
-10 -1 -40 0 6
|
||||
10 -1 -40 4 6
|
||||
10 -1 -20 4 2
|
||||
0 1 0
|
||||
|
||||
1
|
||||
-10 -1 -20 0 0
|
||||
-10 -1 -40 2 0
|
||||
-10 10 -20 0 1.1
|
||||
1 0 0
|
||||
|
||||
1
|
||||
-10 10 -20 0 1.1
|
||||
-10 10 -40 2 1.1
|
||||
-10 -1 -40 2 0
|
||||
1 0 0
|
||||
|
||||
1
|
||||
10 -1 -20 0 0
|
||||
10 -1 -40 2 0
|
||||
10 10 -20 0 1.1
|
||||
-1 0 0
|
||||
|
||||
1
|
||||
10 10 -20 0 1.1
|
||||
10 10 -40 2 1.1
|
||||
10 -1 -40 2 0
|
||||
-1 0 0
|
||||
|
||||
1
|
||||
-10 -1 -40 0 0
|
||||
-10 10 -40 0 1.1
|
||||
10 -1 -40 2 0
|
||||
0 0 1
|
||||
|
||||
1
|
||||
-10 10 -40 0 1.1
|
||||
10 10 -40 2 1.1
|
||||
10 -1 -40 2 0
|
||||
0 0 1
|
||||
|
||||
2
|
||||
-10 10 -20 0 0
|
||||
10 10 -20 32 0
|
||||
-10 10 -40 0 32
|
||||
0 -1 0
|
||||
|
||||
2
|
||||
-10 10 -40 0 32
|
||||
10 10 -40 32 32
|
||||
10 10 -20 32 0
|
||||
0 -1 0
|
||||
|
||||
1
|
||||
-10 -1 -20 0 0
|
||||
-5 -1 -20 .5 0
|
||||
-10 10 -20 0 1.1
|
||||
0 0 -1
|
||||
|
||||
1
|
||||
-10 10 -20 0 1.1
|
||||
-5 -1 -20 .5 0
|
||||
-5 10 -20 .5 1.1
|
||||
0 0 -1
|
||||
|
||||
1
|
||||
5 -1 -20 1.5 0
|
||||
10 -1 -20 2 0
|
||||
5 10 -20 1.5 1.1
|
||||
0 0 -1
|
||||
|
||||
1
|
||||
5 10 -20 1.5 1.1
|
||||
10 -1 -20 2 0
|
||||
10 10 -20 2 1.1
|
||||
0 0 -1
|
||||
|
||||
|
||||
3
|
||||
groundc.tga
|
||||
moonc.tga
|
||||
nightSkyc.tga
|
||||
bgm1.mp3
|
||||
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 450 KiB |
|
Before Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB |
3
src/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
*.o
|
||||
Makefile
|
||||
config.h
|
||||
@@ -1,76 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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<Events::Event::EventHandler*> eventHandlers;
|
||||
};
|
||||
}
|
||||
#endif /*__OpenArena_EventMangaer_h__*/
|
||||
@@ -1 +0,0 @@
|
||||
#include "Point.h"
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef __OpenArena_Geometry2D_Point_h__
|
||||
#define __OpenArena_Geometry2D_Point_h__
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
namespace Geometry2D
|
||||
{
|
||||
class Point
|
||||
{
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif // __OpenArena_Geometry2D_Point_h__
|
||||
@@ -1 +0,0 @@
|
||||
#include "Rectangle.h"
|
||||
115
src/Logger.h
@@ -1,115 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __Logger_h__
|
||||
#define __Logger_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Logger here.
|
||||
*
|
||||
* Write detailed description for Logger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Logger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for MESSAGETYPE_DEBUG here.
|
||||
*/
|
||||
enum MessageType{MESSAGETYPE_ALL, MESSAGETYPE_NONE, MESSAGETYPE_INFORMATION, MESSAGETYPE_ERROR, MESSAGETYPE_DEBUG};
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~Logger here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~Logger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~Logger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~Logger(void){}
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Log here.
|
||||
*
|
||||
* \param message
|
||||
* Description of parameter message.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Log here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Log here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual void Log(const char* message, MessageType type=MESSAGETYPE_INFORMATION) = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Log here.
|
||||
*
|
||||
* \param message
|
||||
* Description of parameter message.
|
||||
*
|
||||
* \param classification
|
||||
* Description of parameter classification.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Log here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Log here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual void Log(const char* message, const char* classification, MessageType type=MESSAGETYPE_INFORMATION) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,99 +0,0 @@
|
||||
#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
|
||||
@@ -1,109 +0,0 @@
|
||||
#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
|
||||
@@ -1,33 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "Model.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
|
||||
Model::Model()
|
||||
{
|
||||
}
|
||||
|
||||
Model::~Model()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
39
src/Model.h
@@ -1,39 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 MODEL_H_
|
||||
#define MODEL_H_
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
|
||||
class Model
|
||||
{
|
||||
public:
|
||||
Model();
|
||||
virtual ~Model();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /*MODEL_H_*/
|
||||
@@ -1,37 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "NullVideoPlugin.h"
|
||||
namespace OpenArena
|
||||
{
|
||||
|
||||
NullVideoPlugin::NullVideoPlugin(void)
|
||||
{
|
||||
}
|
||||
|
||||
NullVideoPlugin::~NullVideoPlugin(void)
|
||||
{
|
||||
}
|
||||
|
||||
OpenArena::Window* NullVideoPlugin::CreateNewWindow(uint32 width, uint32 height, uint32 bpp, bool fullscreen, const char* title)
|
||||
{
|
||||
return new OpenArena::Window();
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,119 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __NullVideoPlugin_h__
|
||||
#define __NullVideoPlugin_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "VideoPlugin.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for NullVideoPlugin here.
|
||||
*
|
||||
* Write detailed description for NullVideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for NullVideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class NullVideoPlugin :
|
||||
public OpenArena::VideoPlugin
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for NullVideoPlugin here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for NullVideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for NullVideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
NullVideoPlugin(void);
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~NullVideoPlugin here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~NullVideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~NullVideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~NullVideoPlugin(void);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for CreateNewWindow here.
|
||||
*
|
||||
* \param width
|
||||
* Description of parameter width.
|
||||
*
|
||||
* \param height
|
||||
* Description of parameter height.
|
||||
*
|
||||
* \param bpp
|
||||
* Description of parameter bpp.
|
||||
*
|
||||
* \param fullscreen
|
||||
* Description of parameter fullscreen.
|
||||
*
|
||||
* \param title
|
||||
* Description of parameter title.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for CreateNewWindow here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for CreateNewWindow here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual Window* CreateNewWindow(uint32 width, uint32 height, uint32 bpp = 32, bool fullscreen = false, const char* title = NULL);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
70
src/Plugin.h
@@ -1,70 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __Plugin_h__
|
||||
#define __Plugin_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Plugin here.
|
||||
*
|
||||
* Write detailed description for Plugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Plugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Plugin
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~Plugin here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~Plugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~Plugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~Plugin(void){}
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for InputPlugin here.
|
||||
*/
|
||||
enum Type {VideoPlugin, AudioPlugin, InputPlugin};
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "PluginManager.h"
|
||||
#include "NullVideoPlugin.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
PluginManager::PluginManager(void)
|
||||
{
|
||||
}
|
||||
|
||||
PluginManager::~PluginManager(void)
|
||||
{
|
||||
}
|
||||
|
||||
list<Plugin*> PluginManager::GetPluginsOfType(Plugin::Type type)
|
||||
{
|
||||
return list<Plugin*>();
|
||||
}
|
||||
VideoPlugin* PluginManager::GetDefaultVideoPlugin(void)
|
||||
{
|
||||
return new NullVideoPlugin();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __PluginManager_h__
|
||||
#define __PluginManager_h___
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "list.h"
|
||||
#include "Plugin.h"
|
||||
#include "VideoPlugin.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/**
|
||||
* Perhaps this class should be a singleton.
|
||||
*/
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for PluginManager here.
|
||||
*
|
||||
* Write detailed description for PluginManager here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for PluginManager here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class PluginManager
|
||||
{
|
||||
private:
|
||||
list<Plugin*> _plugins;
|
||||
public:
|
||||
/**
|
||||
* Creates a new PluginManager object
|
||||
*/
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for PluginManager here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for PluginManager here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for PluginManager here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
PluginManager(void);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~PluginManager here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~PluginManager here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~PluginManager here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
~PluginManager(void);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetPluginsOfType here.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetPluginsOfType here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetPluginsOfType here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
list<Plugin*> GetPluginsOfType(Plugin::Type type);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetDefaultVideoPlugin here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetDefaultVideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetDefaultVideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
VideoPlugin* GetDefaultVideoPlugin(void);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,106 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __VideoPlugin_h__
|
||||
#define __VideoPlugin_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "Plugin.h"
|
||||
#include "window.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for VideoPlugin here.
|
||||
*
|
||||
* Write detailed description for VideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for VideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class VideoPlugin :public Plugin
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~VideoPlugin here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~VideoPlugin here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~VideoPlugin here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~VideoPlugin(){}
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for CreateNewWindow here.
|
||||
*
|
||||
* \param width
|
||||
* Description of parameter width.
|
||||
*
|
||||
* \param height
|
||||
* Description of parameter height.
|
||||
*
|
||||
* \param bpp
|
||||
* Description of parameter bpp.
|
||||
*
|
||||
* \param fullscreen
|
||||
* Description of parameter fullscreen.
|
||||
*
|
||||
* \param title
|
||||
* Description of parameter title.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for CreateNewWindow here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for CreateNewWindow here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual Window* CreateNewWindow(uint32 width,
|
||||
uint32 height,
|
||||
uint32 bpp = 32,
|
||||
bool fullscreen = false,
|
||||
const char* title = NULL) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,68 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#ifdef WIN32
|
||||
#include <cstdlib>
|
||||
#include "WindowsLogger.h"
|
||||
#include <windows.h>
|
||||
namespace OpenArena
|
||||
{
|
||||
WindowsLogger::WindowsLogger()
|
||||
{
|
||||
_type = MESSAGETYPE_ALL;
|
||||
}
|
||||
|
||||
WindowsLogger::~WindowsLogger(void)
|
||||
{
|
||||
}
|
||||
|
||||
WindowsLogger::WindowsLogger(Logger::MessageType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
void WindowsLogger::Log(const char* message, MessageType type)
|
||||
{
|
||||
Log(message, "unspecified", type);
|
||||
}
|
||||
|
||||
void WindowsLogger::Log(const char* message, const char* classification, MessageType type)
|
||||
{
|
||||
if(_type != MESSAGETYPE_NONE || _type == type || _type == MESSAGETYPE_ALL)
|
||||
{
|
||||
MessageBox(NULL, message, classification, MB_OK | GetIconFromMessageType(type));
|
||||
}
|
||||
}
|
||||
|
||||
uint32 WindowsLogger::GetIconFromMessageType(MessageType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MESSAGETYPE_ERROR:
|
||||
return MB_ICONERROR;
|
||||
case MESSAGETYPE_INFORMATION:
|
||||
return MB_ICONINFORMATION;
|
||||
case MESSAGETYPE_DEBUG:
|
||||
return MB_ICONWARNING;
|
||||
default:
|
||||
return MB_ICONASTERISK;
|
||||
};
|
||||
}
|
||||
};
|
||||
#endif
|
||||
@@ -1,173 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __WindowsLogger_h__
|
||||
#define __WindowsLogger_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "logger.h"
|
||||
#include "datatypes.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for WindowsLogger here.
|
||||
*
|
||||
* Write detailed description for WindowsLogger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for WindowsLogger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class WindowsLogger :
|
||||
public OpenArena::Logger
|
||||
{
|
||||
private:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetIconFromMessageType here.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetIconFromMessageType here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetIconFromMessageType here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
uint32 GetIconFromMessageType(MessageType type);
|
||||
MessageType _type;
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for WindowsLogger here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for WindowsLogger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for WindowsLogger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
WindowsLogger();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for WindowsLogger here.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for WindowsLogger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for WindowsLogger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
WindowsLogger(Logger::MessageType type);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Log here.
|
||||
*
|
||||
* \param message
|
||||
* Description of parameter message.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Log here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Log here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual void Log(const char* message, MessageType type=MESSAGETYPE_INFORMATION);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Log here.
|
||||
*
|
||||
* \param message
|
||||
* Description of parameter message.
|
||||
*
|
||||
* \param classification
|
||||
* Description of parameter classification.
|
||||
*
|
||||
* \param type
|
||||
* Description of parameter type.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Log here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Log here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual void Log(const char* message, const char* classification, MessageType type=MESSAGETYPE_INFORMATION);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~WindowsLogger here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~WindowsLogger here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~WindowsLogger here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~WindowsLogger();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
305
src/bmp.cpp
@@ -1,305 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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: bmp.cpp
|
||||
// Author: Tom Hicks
|
||||
// Creation: 09-01-2003
|
||||
// LastEdit: 06-20-2005
|
||||
// Editors: Tom Hicks
|
||||
//
|
||||
// Purpose:
|
||||
// To implement a wrapper function that will load a 24bit windows bitmap
|
||||
// file and return a pointer to a TextureImage object containing the image.
|
||||
//
|
||||
// Summary of Methods:
|
||||
// Global
|
||||
// -LoadBMP
|
||||
// Loads a 24 bit windows bitmap file specified by fn and returns a
|
||||
// pointer to a TextureImage object containing the bitmap image.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstdio>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <GL/gl.h>
|
||||
#include "bmp.h"
|
||||
#include "datatypes.h"
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
namespace OpenArena{
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct BITMAP_HEADER
|
||||
{
|
||||
uint16 type;
|
||||
uint32 size;
|
||||
uint16 reserved1;
|
||||
uint16 reserved2;
|
||||
uint32 offset;
|
||||
};
|
||||
|
||||
struct BITMAP_INFO
|
||||
{
|
||||
uint32 size;
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
uint16 planes;
|
||||
uint16 bitCount;
|
||||
uint32 compression;
|
||||
uint32 sizeImage;
|
||||
uint32 xPelsPerMeter;
|
||||
uint32 yPelsPerMeter;
|
||||
uint32 clrUsed;
|
||||
uint32 clrImportant;
|
||||
};
|
||||
|
||||
struct BITMAP_QUAD
|
||||
{
|
||||
uint8 blue;
|
||||
uint8 green;
|
||||
uint8 red;
|
||||
uint8 reserved;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#define BITMAP_MAGIC 19778
|
||||
|
||||
void PrintBMPHeader(BITMAP_HEADER header)
|
||||
{
|
||||
printf("Header\n");
|
||||
printf("Type: %X\nSize: %X\nReserved1: %X\nReserved2: %X\nOffset:%X\n", header.type, header.size, header.reserved1, header.reserved2, header.offset);
|
||||
}
|
||||
|
||||
void PrintBMPInfo(BITMAP_INFO info)
|
||||
{
|
||||
printf("Info\n");
|
||||
printf("Size: %X\nWidth: %X\nHeight:%X\n", info.size, info.width, info.height);
|
||||
printf("Planes: %X\nBitCount: %X\nCompression: %X\n", info.planes, info.bitCount, info.compression);
|
||||
printf("SizeImage: %X\nXPelsPerMeter: %X\nYPelsPerMeter: %X\n", info.sizeImage, info.xPelsPerMeter, info.yPelsPerMeter);
|
||||
printf("ClrUsed: %X\nClrImportant: %X\n", info.clrUsed, info.clrImportant);
|
||||
}
|
||||
|
||||
TextureImage* LoadBMP(const char* fn)
|
||||
{
|
||||
//If anything is not perfect return NULL after cleaning up our mess
|
||||
|
||||
FILE* f=NULL; //A pointer to our file structure
|
||||
|
||||
//If our filename is null
|
||||
if(!fn)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Try to open our file and if successfull...
|
||||
|
||||
f=fopen(fn, "rb");
|
||||
if(f)
|
||||
{
|
||||
BITMAP_HEADER bmpHeader;
|
||||
BITMAP_INFO bmpInfo;
|
||||
BITMAP_QUAD* bmpPallette = NULL;
|
||||
uint32 palletteEntries = 0;
|
||||
|
||||
fread(&bmpHeader, sizeof(bmpHeader), 1, f);
|
||||
uint8 t[2] = {1,0};
|
||||
if( *((short*)t) !=1)
|
||||
{
|
||||
//If big endian reorder bytes
|
||||
bmpHeader.type = ((bmpHeader.type & 0xff00) >> 8) |
|
||||
((bmpHeader.type & 0x00ff) << 8);
|
||||
bmpHeader.size = (bmpHeader.size & 0xff000000) >> 24 |
|
||||
(bmpHeader.size & 0x00ff0000) >> 8 |
|
||||
(bmpHeader.size & 0x0000ff00) << 8 |
|
||||
(bmpHeader.size & 0x000000ff) << 24;
|
||||
bmpHeader.reserved1 = ((bmpHeader.reserved1 & 0xff00) >> 8) |
|
||||
((bmpHeader.reserved1 & 0x00ff) << 8);
|
||||
bmpHeader.reserved2 = ((bmpHeader.reserved2 & 0xff00) >> 8) |
|
||||
((bmpHeader.reserved2 & 0x00ff) << 8);
|
||||
bmpHeader.offset = (bmpHeader.offset & 0xff000000) >> 24 |
|
||||
(bmpHeader.offset & 0x00ff0000) >> 8 |
|
||||
(bmpHeader.offset & 0x0000ff00) << 8 |
|
||||
(bmpHeader.offset & 0x000000ff) << 24;
|
||||
}
|
||||
|
||||
fread(&bmpInfo, sizeof(bmpInfo), 1, f);
|
||||
if( *((short*)t) !=1)
|
||||
{
|
||||
//If big endian reorder bytes
|
||||
bmpInfo.size = (bmpInfo.size & 0xff000000) >> 24 |
|
||||
(bmpInfo.size & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.size & 0x0000ff00) << 8 |
|
||||
(bmpInfo.size & 0x000000ff) << 24;
|
||||
bmpInfo.width = (bmpInfo.width & 0xff000000) >> 24 |
|
||||
(bmpInfo.width & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.width & 0x0000ff00) << 8 |
|
||||
(bmpInfo.width & 0x000000ff) << 24;
|
||||
bmpInfo.height = (bmpInfo.height & 0xff000000) >> 24 |
|
||||
(bmpInfo.height & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.height & 0x0000ff00) << 8 |
|
||||
(bmpInfo.height & 0x000000ff) << 24;
|
||||
bmpInfo.planes = ((bmpInfo.planes & 0xff00) >> 8) |
|
||||
((bmpInfo.planes & 0x00ff) << 8);
|
||||
bmpInfo.bitCount = ((bmpInfo.bitCount & 0xff00) >> 8) |
|
||||
((bmpInfo.bitCount & 0x00ff) << 8);
|
||||
bmpInfo.compression = (bmpInfo.compression & 0xff000000) >> 24 |
|
||||
(bmpInfo.compression & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.compression & 0x0000ff00) << 8 |
|
||||
(bmpInfo.compression & 0x000000ff) << 24;
|
||||
bmpInfo.sizeImage = (bmpInfo.sizeImage & 0xff000000) >> 24 |
|
||||
(bmpInfo.sizeImage & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.sizeImage & 0x0000ff00) << 8 |
|
||||
(bmpInfo.sizeImage & 0x000000ff) << 24;
|
||||
bmpInfo.xPelsPerMeter = (bmpInfo.xPelsPerMeter & 0xff000000) >> 24 |
|
||||
(bmpInfo.xPelsPerMeter & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.xPelsPerMeter & 0x0000ff00) << 8 |
|
||||
(bmpInfo.xPelsPerMeter & 0x000000ff) << 24;
|
||||
bmpInfo.yPelsPerMeter = (bmpInfo.yPelsPerMeter & 0xff000000) >> 24 |
|
||||
(bmpInfo.yPelsPerMeter & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.yPelsPerMeter & 0x0000ff00) << 8 |
|
||||
(bmpInfo.yPelsPerMeter & 0x000000ff) << 24;
|
||||
bmpInfo.clrUsed = (bmpInfo.clrUsed & 0xff000000) >> 24 |
|
||||
(bmpInfo.clrUsed & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.clrUsed & 0x0000ff00) << 8 |
|
||||
(bmpInfo.clrUsed & 0x000000ff) << 24;
|
||||
bmpInfo.clrImportant = (bmpInfo.clrImportant & 0xff000000) >> 24 |
|
||||
(bmpInfo.clrImportant & 0x00ff0000) >> 8 |
|
||||
(bmpInfo.clrImportant & 0x0000ff00) << 8 |
|
||||
(bmpInfo.clrImportant & 0x000000ff) << 24;
|
||||
}
|
||||
|
||||
if(bmpInfo.width < 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Image width is negative", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(bmpInfo.width % 4 != 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Image width must be a multiple of 8", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(bmpInfo.height < 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Image height is negative", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(bmpInfo.height % 4 != 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Image height must be a multiple of 8", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if((bmpInfo.bitCount != 8 && bmpInfo.bitCount != 24) || bmpInfo.compression != 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Only 8 and 24 bit uncompressed windows bmp files are currently supported", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Allocate memory for a TextureImage structure
|
||||
TextureImage* tex = new TextureImage;
|
||||
tex->sizeX = bmpInfo.width;
|
||||
tex->sizeY = bmpInfo.height;
|
||||
if(bmpInfo.bitCount >= 8)
|
||||
{
|
||||
tex->bpp = bmpInfo.bitCount >> 3;
|
||||
}
|
||||
tex->type = GL_RGB;
|
||||
uint32 pixels = tex->sizeX * tex->sizeY;
|
||||
uint32 bytes = pixels * tex->bpp;
|
||||
tex->data = new uint8[bytes];
|
||||
|
||||
if(bmpInfo.bitCount == 8)
|
||||
{
|
||||
//Load the pallette
|
||||
palletteEntries = bmpInfo.bitCount << 8;
|
||||
bmpPallette = new BITMAP_QUAD[palletteEntries];
|
||||
fread(bmpPallette, sizeof(BITMAP_QUAD), palletteEntries, f);
|
||||
}
|
||||
|
||||
fseek(f, bmpHeader.offset, SEEK_SET);
|
||||
fread(tex->data, bytes, 1, f);
|
||||
|
||||
if(bmpInfo.bitCount == 8)
|
||||
{
|
||||
//Apply the pallette
|
||||
uint8* image = tex->data;
|
||||
tex->bpp = 24;
|
||||
bytes = pixels * tex->bpp;
|
||||
tex->data = new uint8[bytes];
|
||||
|
||||
uint32 i;
|
||||
uint32 i2;
|
||||
for(i=0; i<pixels; i++)
|
||||
{
|
||||
i2 = (i << 1) + 1;
|
||||
//Should make sure image[i] < palletteEntries
|
||||
tex->data[i2] = bmpPallette[image[i]].red;
|
||||
tex->data[i2 + 1] = bmpPallette[image[i]].blue;
|
||||
tex->data[i2 + 2] = bmpPallette[image[i]].green;
|
||||
}
|
||||
|
||||
delete [] image;
|
||||
image = NULL;
|
||||
}
|
||||
else if(bmpInfo.bitCount == 24)
|
||||
{
|
||||
uint32 i;
|
||||
uint8 t;
|
||||
|
||||
for(i=0; i<bytes; i+=3)
|
||||
{
|
||||
t = tex->data[i];
|
||||
tex->data[i] = tex->data[i+2];
|
||||
tex->data[i+2] = t;
|
||||
}
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
48
src/bmp.h
@@ -1,48 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __bmp_h__
|
||||
#define __bmp_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "texture.h"
|
||||
|
||||
namespace OpenArena{
|
||||
/**
|
||||
* \brief
|
||||
* Loads a bitmap (*.bmp) file and returns a pointer to a TextureImage object.
|
||||
*
|
||||
* \param filename
|
||||
* The path to the file to open.
|
||||
*
|
||||
* \returns
|
||||
* A pointer to the created TextureImage object.
|
||||
*
|
||||
* \remarks
|
||||
* Will be replaced with an actual class soon
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
TextureImage* LoadBMP(const char* Filename);
|
||||
};
|
||||
|
||||
#endif
|
||||
232
src/camera.cpp
@@ -1,232 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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: camera.cpp
|
||||
// Author: Tom Hicks
|
||||
// Creation: 09-01-2003
|
||||
// LastEdit: 10-09-2003
|
||||
// Editors: Tom Hicks
|
||||
//
|
||||
// Purpose:
|
||||
// To implement an OpenGL Camera
|
||||
//
|
||||
// Summary of Methods:
|
||||
// Camera
|
||||
// -Camera();
|
||||
// Initalize PDM's. Sets position to 0,0,0 up to 0,1,0 and view to 0,0,-1
|
||||
// -Vec3f Position();
|
||||
// Returns a copy of the position vector.
|
||||
// -Vec3f View();
|
||||
// Returns a copy of the view vector.
|
||||
// -Vec3f UpVector();
|
||||
// Returns a copy of the up vector.
|
||||
// -Vec3f Strafe();
|
||||
// Returns a copy of the strafe vector.
|
||||
// -void PositionCamera(double xpos, double ypos, double zpos,
|
||||
// double xview, double yview, double zview,
|
||||
// double xup, double yup, double zup);
|
||||
// Sets the position, up, and view vectors to those created from the respective input values.
|
||||
// -void PositionCamera(Vec3f pos, Vec3f view, Vec3f up);
|
||||
// Sets the position, up, and view vectors to those passed in.
|
||||
// -void RotateView(double angle, double X, double Y, double Z);
|
||||
// Rotates the view angle degrees on the axis specified by X, Y, and Z.
|
||||
// -void SetViewByMouse(Screen g_Screen);
|
||||
// Rotates the pitch and yaw of the view based on the mouse.
|
||||
// -void RotateAroundPoint(double angle, double X, double Y, double Z, Vec3f vCenter);
|
||||
// Rotates the view angle degrees around a point vCenter on the axis specified by X, Y, Z.
|
||||
// -void StrafeCamera(double speed);
|
||||
// Moves the camera along an axis perpendicular to the plane specified by the up and view vectors a distance specified by speed.
|
||||
// -void MoveCamera(double speed);
|
||||
// Moves the camera along the axis specified by it's view vector a distance equal to speed.
|
||||
// -void Update();
|
||||
// Update the internal strafe vector.
|
||||
// -void Look();
|
||||
// Positions the current viewport at point of the camera and facing the same direction.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
Camera::Camera()
|
||||
{
|
||||
_position = Vec3f(0,0,0);
|
||||
_heading = Vec3f(0,0,-1);
|
||||
_up = Vec3f(0,1,0);
|
||||
}
|
||||
|
||||
void Camera::PositionCamera(double xpos, double ypos, double zpos,
|
||||
double xview, double yview, double zview,
|
||||
double xup, double yup, double zup)
|
||||
{
|
||||
_position = Vec3f(xpos, ypos, zpos);
|
||||
_heading = Vec3f(xview-xpos, yview-ypos, zview-zpos);
|
||||
_up = Vec3f(xup, yup, zup).normalized();
|
||||
UpdateVectors();
|
||||
}
|
||||
|
||||
void Camera::PositionCamera(Vec3f pos, Vec3f view, Vec3f up)
|
||||
{
|
||||
_position = pos;
|
||||
_heading = view-pos;
|
||||
_up = up;
|
||||
UpdateVectors();
|
||||
}
|
||||
|
||||
void Camera::SetViewByMouse(Window window)
|
||||
{
|
||||
static double currentRotX = 0.0f;
|
||||
Vec2i pos;
|
||||
Vec2i middle;
|
||||
double angleZ;
|
||||
|
||||
middle.x = window.GetWidth()/2;
|
||||
middle.y = window.GetHeight()/2;
|
||||
pos = window.GetMousePosition();
|
||||
if(pos != middle)
|
||||
{
|
||||
window.SetMousePosition(middle);
|
||||
angleZ = (middle.y - pos.y)/1000.0;
|
||||
currentRotX-=angleZ;
|
||||
if(currentRotX >1.0)
|
||||
{
|
||||
currentRotX = 1.0;
|
||||
}
|
||||
else if(currentRotX < -1.0)
|
||||
{
|
||||
currentRotX = -1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3d axis = (_heading).cross(_up);
|
||||
axis.normalize();
|
||||
RotateView(angleZ, axis.x, axis.y, axis.z);
|
||||
RotateView((middle.x-pos.x)/1000.0, 0, 1, 0);
|
||||
//RotateView((middle.x-pos.x)/1000.0, m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::MoveCamera(double speed)
|
||||
{
|
||||
_position = _position + _heading * speed;
|
||||
UpdateVectors();
|
||||
}
|
||||
|
||||
void Camera::RotateView(double angle, Vec3d axis)
|
||||
{
|
||||
//Maybe make this not call the other RotateView later
|
||||
axis.normalize();
|
||||
RotateView(angle, axis.x, axis.y, axis.z);
|
||||
}
|
||||
|
||||
void Camera::RotateView(double angle, double x, double y, double z)
|
||||
{
|
||||
double cosTheta = cos(angle);
|
||||
double sinTheta = sin(angle);
|
||||
|
||||
double newX = (cosTheta + (1 - cosTheta) * x * x) * _heading.x +
|
||||
((1 - cosTheta) * x * y - z * sinTheta) * _heading.y +
|
||||
((1 - cosTheta) * x * z + y * sinTheta) * _heading.z;
|
||||
|
||||
double newY = (cosTheta + (1 - cosTheta) * y * y) * _heading.y +
|
||||
((1 - cosTheta) * x * y + z * sinTheta) * _heading.x +
|
||||
((1 - cosTheta) * y * z - x * sinTheta) * _heading.z;
|
||||
|
||||
double newZ = (cosTheta + (1 - cosTheta) * z * z) * _heading.z +
|
||||
((1 - cosTheta) * x * z - y * sinTheta) * _heading.x +
|
||||
((1 - cosTheta) * y * z + x * sinTheta) * _heading.y;
|
||||
|
||||
_heading.x = newX;
|
||||
_heading.y = newY;
|
||||
_heading.z = newZ;
|
||||
}
|
||||
|
||||
void Camera::StrafeCamera(double speed)
|
||||
{
|
||||
_position = _position + _strafe * speed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Camera::Update()
|
||||
{
|
||||
_strafe = ((_heading).cross(_up)).normalized();
|
||||
}
|
||||
|
||||
void Camera::Look()
|
||||
{
|
||||
Vec3f view = _position + _heading;
|
||||
gluLookAt(_position.x, _position.y, _position.z,
|
||||
view.x, view.y, view.z,
|
||||
_up.x, _up.y, _up.z);
|
||||
}
|
||||
|
||||
Vec3f Camera::Position()
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
|
||||
Vec3f Camera::Strafe()
|
||||
{
|
||||
return _strafe;
|
||||
}
|
||||
|
||||
Vec3f Camera::UpVector()
|
||||
{
|
||||
return _up;
|
||||
}
|
||||
|
||||
Vec3f Camera::View()
|
||||
{
|
||||
return _heading + _position;
|
||||
}
|
||||
|
||||
void Camera::RotateHorizontal(float angle)
|
||||
{
|
||||
RotateView(angle, GetUpVector());
|
||||
}
|
||||
|
||||
void Camera::RotateVertical(float angle)
|
||||
{
|
||||
RotateView(angle, GetRightVector());
|
||||
}
|
||||
|
||||
Vec3f Camera::GetUpVector()
|
||||
{
|
||||
return _up;
|
||||
}
|
||||
|
||||
Vec3f Camera::GetRightVector()
|
||||
{
|
||||
return _strafe;
|
||||
}
|
||||
|
||||
Vec3f Camera::GetForwardVector()
|
||||
{
|
||||
return _heading;
|
||||
}
|
||||
|
||||
void Camera::UpdateVectors()
|
||||
{
|
||||
}
|
||||
};
|
||||
384
src/camera.h
@@ -1,384 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 comment goes here!!>
|
||||
*
|
||||
* Copyright (c) 2005 by Tom Hicks tomhicks@olympusonline.net
|
||||
*/
|
||||
#ifndef __camera_h__
|
||||
#define __camera_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#ifdef WIN32
|
||||
#include <windows.h> //Currently used for mouse stuff this should be replaced by oa_input
|
||||
#endif
|
||||
#include "vector.h"
|
||||
#include "mygl.h"
|
||||
#include "screen.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* The Camera class represents a camera or view in 3-dimensional space.
|
||||
*
|
||||
* The Camera class maintains location, view, and orientation (up view) vectors. The Camera can be moved and rotated in any direction. It includes a wrapper, Look(), for gluLookAt.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Creates a new Camera object.
|
||||
*
|
||||
* Creates a new Camera object located at the origin, pointing at the negative z-axis with up being the positive y-axis.
|
||||
*
|
||||
*/
|
||||
Camera(); //Default Constructor
|
||||
|
||||
//Camera(const Camera&); //Copy Constructor
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns this Camera's position.
|
||||
*
|
||||
* \returns
|
||||
* This Camera's position as a Vec3d vector.
|
||||
*
|
||||
* Returns this Camera's position.
|
||||
*
|
||||
*/
|
||||
Vec3f Position();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns the view vector of this camera.
|
||||
*
|
||||
* \returns
|
||||
* The view vector of this camera.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
Vec3d View();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns a vector pointing up with respect to the view.
|
||||
*
|
||||
* \returns
|
||||
* A vector pointing up with respect to the view.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
Vec3d UpVector();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns this Camera's strafe vector.
|
||||
*
|
||||
* The strafe axis is an axis perpendicular to both the up vector and the view vector.
|
||||
*
|
||||
* \returns
|
||||
* This Camera's strafe vector.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
Vec3d Strafe();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Relocates and reorients this Camera.
|
||||
*
|
||||
* \param xpos
|
||||
* The x-coordinate of the new position vector.
|
||||
*
|
||||
* \param ypos
|
||||
* The y-coordinate of the new position vector.
|
||||
*
|
||||
* \param zpos
|
||||
* The z-coordinate of the new position vector.
|
||||
*
|
||||
* \param xview
|
||||
* The x-coordinate of the new view vector.
|
||||
*
|
||||
* \param yview
|
||||
* The y-coordinate of the new view vector.
|
||||
*
|
||||
* \param zview
|
||||
* The z-coordinate of the new view vector.
|
||||
*
|
||||
* \param xup
|
||||
* The x-coordinate of the new up vector.
|
||||
*
|
||||
* \param yup
|
||||
* The y-coordinate of the new up vector.
|
||||
*
|
||||
* \param zup
|
||||
* The z-coordinate of the new up vector.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void PositionCamera(double xpos, double ypos, double zpos,
|
||||
double xview, double yview, double zview,
|
||||
double xup, double yup, double zup);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Relocates and reorients this Camera.
|
||||
*
|
||||
* \param pos
|
||||
* The new position vector.
|
||||
*
|
||||
* \param view
|
||||
* The new view vector.
|
||||
*
|
||||
* \param up
|
||||
* The new up vector.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void PositionCamera(Vec3d pos, Vec3d view, Vec3d up);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Rotates the camera a given ammount around a given axis.
|
||||
*
|
||||
* \param angle
|
||||
* The number of degrees to rotate.
|
||||
*
|
||||
* \param axis
|
||||
* A vector representing the axis to rotate around.
|
||||
*
|
||||
* This method passes the arguments to glRotatef()
|
||||
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void RotateView(double angle, Vec3d axis);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Rotates the camera a given ammount around a given axis.
|
||||
*
|
||||
* \param angle
|
||||
* The number of degrees to rotate.
|
||||
*
|
||||
* \param X
|
||||
* The x component of the vector representing the axis to rotate around
|
||||
*
|
||||
* \param Y
|
||||
* The y component of the vector representing the axis to rotate around
|
||||
*
|
||||
* \param Z
|
||||
* The z component of the vector representing the axis to rotate around
|
||||
*
|
||||
* \remarks
|
||||
* The vector should be normalized as the values get passed directly to glRotatef().
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void RotateView(double angle, double X, double Y, double Z);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Updates the view and up vectors based on mouse movement.
|
||||
*
|
||||
* \param window
|
||||
* The Window used to get the mouse coordinates.
|
||||
*
|
||||
* \remarks
|
||||
* This will be removed in favor of some sort of event trigger.
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void SetViewByMouse(Window window);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Moves the camera along its strafe axis a given distance.
|
||||
*
|
||||
* \param speed
|
||||
* The distance to move.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void StrafeCamera(double speed);
|
||||
//Purpose:
|
||||
// Moves the camera along it's strafe vector speed units.
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Moves the camera along its view vector a given number of units.
|
||||
*
|
||||
* \param speed
|
||||
* The distance to move the camera.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void MoveCamera(double speed);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Recalculates the strafe vector.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void Update();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Calls gluLookAt to tell OpenGL where to render from.
|
||||
*
|
||||
* \remarks
|
||||
* Uses the position, view, and up vectors.
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
void Look();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for RotateHorizontal here.
|
||||
*
|
||||
* \param angle
|
||||
* Description of parameter angle.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for RotateHorizontal here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for RotateHorizontal here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void RotateHorizontal(float angle);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for RotateVertical here.
|
||||
*
|
||||
* \param angle
|
||||
* Description of parameter angle.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for RotateVertical here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for RotateVertical here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void RotateVertical(float angle);
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetUpVector here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetUpVector here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetUpVector here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
Vec3f GetUpVector();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns a unit vector pointing to the immediate right of the current view.
|
||||
*
|
||||
*
|
||||
* \returns
|
||||
* A unit vector pointing to the immediate right of the current view.
|
||||
*
|
||||
* Returns a unit vector pointing to the immediate right of the current view.
|
||||
* This is the direction of a positive strafe movement.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
Vec3f GetRightVector();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Returns a unit vector pointing directly into the current view.
|
||||
*
|
||||
* \returns
|
||||
* A unit vector pointing directly into the current view.
|
||||
*
|
||||
* Returns a unit vector pointing directly into the current view. This is the direction of positive movement.
|
||||
*
|
||||
* \remarks
|
||||
*
|
||||
* \see
|
||||
*/
|
||||
Vec3f GetForwardVector();
|
||||
|
||||
void UpdateVectors();
|
||||
|
||||
private:
|
||||
Vec3f _heading;
|
||||
Vec3f _position;
|
||||
Vec3f _up;
|
||||
Vec3f _strafe;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifndef __carbon_h__
|
||||
#define __carbon_h__
|
||||
|
||||
#endif /*__carbon_h__*/
|
||||
224
src/ctrls.cpp
@@ -1,224 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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;
|
||||
}
|
||||
};
|
||||
|
||||
76
src/ctrls.h
@@ -1,76 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <iostream>
|
||||
#include <string>
|
||||
#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
|
||||
@@ -1,81 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __datatypes_h__
|
||||
#define __datatypes_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32 //Make this MSVC something
|
||||
typedef unsigned __int8 uint8;
|
||||
typedef unsigned __int16 uint16;
|
||||
typedef unsigned __int32 uint32;
|
||||
typedef unsigned __int64 uint64;
|
||||
typedef __int8 int8;
|
||||
typedef __int16 int16;
|
||||
typedef __int32 int32;
|
||||
typedef __int64 int64;
|
||||
typedef signed __int8 sint8;
|
||||
typedef signed __int16 sint16;
|
||||
typedef signed __int32 sint32;
|
||||
typedef signed __int64 sint64;
|
||||
|
||||
/*
|
||||
typedef unsigned __int8 byte;
|
||||
typedef unsigned __int16 word;
|
||||
typedef unsigned __int32 dword;
|
||||
typedef unsigned __int64 qword;
|
||||
|
||||
typedef byte db;
|
||||
typedef word dw;
|
||||
typedef dword dd;
|
||||
typedef qword dq;
|
||||
*/
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__ //ie if we are using GCC //used to be __linux
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned long uint32;
|
||||
typedef unsigned long long uint64;
|
||||
typedef char int8;
|
||||
typedef short int16;
|
||||
typedef long int32;
|
||||
typedef long long int64;
|
||||
typedef signed char sint8;
|
||||
typedef signed short sint16;
|
||||
typedef signed long sint32;
|
||||
typedef signed long long sint64;
|
||||
|
||||
/*
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned long dword;
|
||||
typedef unsigned long long qword;
|
||||
|
||||
typedef byte db;
|
||||
typedef word dw;
|
||||
typedef dword dd;
|
||||
typedef qword dq;
|
||||
*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __geometry_h__
|
||||
#define __geometry_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "vector.h"
|
||||
#include "myglTexture.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
class Vertex
|
||||
{
|
||||
public:
|
||||
Vec3f coordinates;
|
||||
Vec2f textureCoordinates;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Triangle here.
|
||||
*
|
||||
* Write detailed description for Triangle here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Triangle here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Triangle
|
||||
{
|
||||
public:
|
||||
Texture texture;
|
||||
uint32 texID;
|
||||
Vertex vertecies[3];
|
||||
// Vec3f vertecies[3];
|
||||
// Vec2f texCoords[3];
|
||||
Vec3f normal;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
181
src/image.h
@@ -1,181 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __image_h__
|
||||
#define __image_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "datatypes.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Image here.
|
||||
*
|
||||
* Write detailed description for Image here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Image here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
//RGB should equal GL_RGB;
|
||||
enum Type{Type_RGB};
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetImageData here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetImageData here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetImageData here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual uint8 * GetImageData() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetBitsPerPixel here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetBitsPerPixel here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetBitsPerPixel here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual uint32 GetBitsPerPixel() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetBytesPerPixel here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetBytesPerPixel here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetBytesPerPixel here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual uint32 GetBytesPerPixel() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetWidth here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetWidth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetWidth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual uint32 GetWidth() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetHeight here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetHeight here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetHeight here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual uint32 GetHeight() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetType here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetType here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetType here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual Image::Type GetType() const = 0;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~Image here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~Image here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~Image here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
virtual ~Image(void){}
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
572
src/keys.cpp
@@ -1,572 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <string>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
220
src/keys.h
@@ -1,220 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <exception class>
|
||||
* 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
|
||||
956
src/level.cpp
@@ -1,956 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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<numTriangles; i++)
|
||||
{
|
||||
//TextureID
|
||||
input >> 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<numTextures; i++)
|
||||
{
|
||||
input >> 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; i<numTriangles; i++)
|
||||
{
|
||||
output << triangles[i].texID << endl;
|
||||
|
||||
for(unsigned int i2=0; i2<3; i2++)
|
||||
{
|
||||
output << triangles[i].vertecies[i2].coordinates.x << " "
|
||||
<< triangles[i].vertecies[i2].coordinates.y << " "
|
||||
<< triangles[i].vertecies[i2].coordinates.z << " "
|
||||
<< triangles[i].vertecies[i2].textureCoordinates.x << " "
|
||||
<< triangles[i].vertecies[i2].textureCoordinates.y << endl;
|
||||
}
|
||||
|
||||
output << triangles[i].normal.x << " "
|
||||
<< triangles[i].normal.y << " "
|
||||
<< triangles[i].normal.z << endl;
|
||||
}
|
||||
|
||||
//Number of textures;
|
||||
output << numTextures;
|
||||
|
||||
//Texture data
|
||||
for(unsigned int i=0; i<numTextures; i++)
|
||||
{
|
||||
output << textureNames[i];
|
||||
}
|
||||
|
||||
//BGM
|
||||
output << bgm;
|
||||
|
||||
}
|
||||
|
||||
void Level::Render()
|
||||
{
|
||||
glPushMatrix();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
|
||||
// Move the camera to where the player is
|
||||
defaultPlayer->camera.Look();
|
||||
|
||||
for (uint32 i=0; i<numTriangles; i++)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textures[triangles[i].texID]->ID());//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; i<MAX_CONSOLE_LINES-1; i++)
|
||||
{
|
||||
Print(30, glFont.ScreenHeight() - i*20, consoleOutput[MAX_CONSOLE_LINES-i-2].c_str(), 0);
|
||||
}
|
||||
|
||||
//Render the currently typed command
|
||||
Print(30,glFont.ScreenHeight() - i*20, consoleHistory[0].c_str(),0);
|
||||
|
||||
//disable blending
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
//re-enable lighting and depth testing
|
||||
//glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
void Level::UnloadMap()
|
||||
{
|
||||
//Stop audio
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
BASS_StreamFree(bgmStream);
|
||||
BASS_Stop();
|
||||
BASS_CDFree();
|
||||
BASS_Free();
|
||||
#endif
|
||||
|
||||
//Delete display list
|
||||
|
||||
//Free all polygon data
|
||||
if(triangles)
|
||||
{
|
||||
delete [] triangles;
|
||||
triangles = NULL;
|
||||
}
|
||||
|
||||
//Free all map textures
|
||||
if(!textures.IsEmpty())
|
||||
{
|
||||
//TODOiterate over list and delete all entries
|
||||
}
|
||||
textures.Clear();
|
||||
|
||||
//Free the array of texture names
|
||||
if (textureNames)
|
||||
{
|
||||
delete [] textureNames;
|
||||
textureNames = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Level::LoadGLTextures()
|
||||
{
|
||||
if(_window != NULL)
|
||||
{
|
||||
/*
|
||||
GLfloat light[4] = {1.0f,1.0f,1.0f,0.5f};
|
||||
glLightfv(GL_LIGHT1, GL_AMBIENT, light);
|
||||
glEnable(GL_LIGHT1);
|
||||
glEnable(GL_LIGHTING);
|
||||
*/
|
||||
|
||||
textures.Clear();
|
||||
|
||||
for(uint32 i=0; i<numTextures; i++)
|
||||
{
|
||||
Texture* texture = new Texture();
|
||||
if(!texture->Load(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; i<numTriangles; i++)
|
||||
{
|
||||
triangles[i] = temp[i];
|
||||
}
|
||||
|
||||
triangles[numTriangles].texID = 0;
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
triangles[numTriangles].vertecies[i].x = 0;
|
||||
triangles[numTriangles].vertecies[i].y = 0;
|
||||
triangles[numTriangles].vertecies[i].z = 0;
|
||||
triangles[numTriangles].texCoords[i].x = 0;
|
||||
triangles[numTriangles].texCoords[i].y = 0;
|
||||
}
|
||||
numTriangles++;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
*/
|
||||
else if(command == "quit")
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
PostQuitMessage(0);
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ConsolePrint("Unknown command " + command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level::ParseCmds(const char* lpCmdLine)
|
||||
{
|
||||
string cmd = lpCmdLine;
|
||||
string command;
|
||||
|
||||
uint32 i=0;
|
||||
command = word(cmd, i);
|
||||
while(command != "")
|
||||
{
|
||||
if(command == "+set")
|
||||
{
|
||||
command = tolower(word(cmd, ++i));
|
||||
|
||||
if(command == "turnspeed")
|
||||
{
|
||||
turnSpeed = (float)atof(word(cmd, ++i).c_str());
|
||||
}
|
||||
else if(command == "mousespeed")
|
||||
{
|
||||
mouseSpeed = (float)atof(word(cmd, ++i).c_str());
|
||||
}
|
||||
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);
|
||||
if(gamedir[gamedir.length()-1] != '/'){
|
||||
gamedir = gamedir + '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(command == "+bind")
|
||||
{
|
||||
command = tolower(word(cmd, ++i));
|
||||
|
||||
if(command == "forward")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FORWARD);
|
||||
}
|
||||
else if(command == "backward")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_BACKWARD);
|
||||
}
|
||||
else if(command == "lookleft")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKLEFT);
|
||||
}
|
||||
else if(command == "lookright")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKRIGHT);
|
||||
}
|
||||
else if(command == "lookup")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKUP);
|
||||
}
|
||||
else if(command == "lookdown")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_LOOKDOWN);
|
||||
}
|
||||
else if(command == "moveup")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVEUP);
|
||||
}
|
||||
else if(command == "movedown")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVEDOWN);
|
||||
}
|
||||
else if(command == "moveleft")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVELEFT);
|
||||
}
|
||||
else if(command == "moveright")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_MOVERIGHT);
|
||||
}
|
||||
else if(command == "fireprimary")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FIREPRIMARY);
|
||||
}
|
||||
else if(command == "firesecondary")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_FIRESECONDARY);
|
||||
}
|
||||
else if(command == "weapnext")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_WEAPONNEXT);
|
||||
}
|
||||
else if(command == "weapprev")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_WEAPONPREV);
|
||||
}
|
||||
else if(command == "togglelights" || command == "togglelighting")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_LIGHTS);
|
||||
}
|
||||
else if(command == "togglefps")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_FPS);
|
||||
}
|
||||
else if(command == "toggleconsole")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_CONSOLE);
|
||||
}
|
||||
else if(command == "togglemouselook")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_TOGGLE_MOUSELOOK);
|
||||
}
|
||||
else if(command == "quickmouselook")
|
||||
{
|
||||
defaultPlayer[0].controls.Bind(GetKey(word(cmd, ++i).c_str()), OpenArena::ControlScheme::ACTION_QUICKMOUSELOOK);
|
||||
}
|
||||
}
|
||||
else if(command == "+map" || command == "+map_load")
|
||||
{
|
||||
nextLevel = word(cmd, ++i);
|
||||
UnloadMap();
|
||||
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));
|
||||
LoadConfig(command);
|
||||
}
|
||||
else if(command == "+map_save")
|
||||
{
|
||||
command = tolower(word(cmd, ++i));
|
||||
SaveMap(command);
|
||||
}
|
||||
else if(command == "+config_save")
|
||||
{
|
||||
command = tolower(word(cmd, ++i));
|
||||
SaveConfig(command);
|
||||
}
|
||||
|
||||
command = word(cmd, ++i);
|
||||
}
|
||||
}
|
||||
|
||||
void Level::LoadConfig()
|
||||
{
|
||||
showFPS = false;
|
||||
nextLevel = "intro.map";
|
||||
gamedir = "oa/";
|
||||
sound = true;
|
||||
|
||||
mouseSpeed = 5;
|
||||
turnSpeed = 1.0f;
|
||||
moveSpeed = .2f;
|
||||
mlook = true;
|
||||
}
|
||||
bool Level::LoadConfig(string cfgname)
|
||||
{
|
||||
ifstream input;
|
||||
string readBuffer;
|
||||
|
||||
cfgname = gamedir + "config/" + cfgname;
|
||||
|
||||
if(tolower(Right(cfgname, 4)) !=".cfg")
|
||||
cfgname = cfgname + ".cfg";
|
||||
|
||||
input.open(cfgname.c_str());
|
||||
|
||||
if(!input)
|
||||
return false;
|
||||
|
||||
getline(input, readBuffer);
|
||||
|
||||
while(input)
|
||||
{
|
||||
uint32 i=0xFFFFFFFF;
|
||||
|
||||
if(readBuffer[0] == '/' && readBuffer[1] == '/')
|
||||
{
|
||||
getline(input, readBuffer);
|
||||
}
|
||||
|
||||
Execute(readBuffer);
|
||||
|
||||
getline(input, readBuffer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Level::SaveConfig(string cfgname)
|
||||
{
|
||||
ofstream output;
|
||||
|
||||
cfgname = gamedir + "config/" + cfgname;
|
||||
|
||||
if(tolower(Right(cfgname, 4)) !=".cfg")
|
||||
cfgname = cfgname + ".cfg";
|
||||
|
||||
output.open(cfgname.c_str());
|
||||
|
||||
if(!output)
|
||||
return;
|
||||
|
||||
//Client Config
|
||||
output << "set turnspeed " << turnSpeed << endl;
|
||||
output << "set mousespeed " << mouseSpeed << endl;
|
||||
output << "set mouselook " << mlook << endl;
|
||||
output << "set screenwidth " << screen.GetWidth() << endl;
|
||||
output << "set screenheight " << screen.GetHeight() << endl;
|
||||
output << "set colordepth " << screen.GetColorDepth() << endl;
|
||||
output << "set fullscreen " << screen.GetFullscreen() << endl;
|
||||
output << "set maxfps " << maxFPS << endl;
|
||||
|
||||
//Control Scheme
|
||||
defaultPlayer->controls.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;
|
||||
}
|
||||
};
|
||||
143
src/level.h
@@ -1,143 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <string>
|
||||
#include <fstream>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#if defined USE_GLX
|
||||
#include <GL/gl.h>
|
||||
#elif defined USE_AGL
|
||||
#include <OpenGL/gl.h>
|
||||
#elif defined USE_CGL
|
||||
#include <OpenGL/gl.h>
|
||||
#elif defined USE_WGL
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio> //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<Player> players;
|
||||
// list<ENTITY> ents;
|
||||
list<Texture*> 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
|
||||
254
src/linux.cpp
@@ -1,254 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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; i<argc; i++)
|
||||
{
|
||||
commandLine = commandLine + " " + argv[i];
|
||||
}
|
||||
level->ParseCmds(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
|
||||
817
src/list.h
@@ -1,817 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __list_h__
|
||||
#define __list_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#pragma warning(disable:4715)
|
||||
|
||||
namespace OpenArena{
|
||||
typedef unsigned int LIST_ARRAY_INDEX_TYPE;
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for listNode here.
|
||||
*
|
||||
* \param ItemType
|
||||
* Description of parameter ItemType.
|
||||
*
|
||||
* Write detailed description for listNode here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for listNode here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
template <class ItemType>
|
||||
class listNode
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for listNode here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for listNode here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for listNode here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
listNode();
|
||||
ItemType data;
|
||||
listNode<ItemType>* next;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for list here.
|
||||
*
|
||||
* \param ItemType
|
||||
* Description of parameter ItemType.
|
||||
*
|
||||
* Write detailed description for list here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for list here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
template <class ItemType>
|
||||
class list
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for list here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for list here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for list here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
list();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~list here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~list here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~list here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
~list();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for list here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for list here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for list here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
list(const list&);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for IsEmpty here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for IsEmpty here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for IsEmpty here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool IsEmpty() const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for IsFull here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for IsFull here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for IsFull here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool IsFull() const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Insert here.
|
||||
*
|
||||
* \param newItem
|
||||
* Description of parameter newItem.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Insert here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Insert here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Insert(ItemType newItem);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Remove here.
|
||||
*
|
||||
* \param target
|
||||
* Description of parameter target.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Remove here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Remove here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Remove(ItemType target);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Remove here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Remove here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Remove here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Remove();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Retrieve here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Retrieve here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Retrieve here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
ItemType Retrieve() const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for PrevPosition here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for PrevPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for PrevPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool PrevPosition();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for NextPosition here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for NextPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for NextPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool NextPosition();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for IsFirstPosition here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for IsFirstPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for IsFirstPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool IsFirstPosition() const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for IsLastPosition here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for IsLastPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for IsLastPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool IsLastPosition() const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for FirstPosition here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for FirstPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for FirstPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void FirstPosition();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for LastPosition here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for LastPosition here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for LastPosition here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void LastPosition();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Clear here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Clear here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Clear here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Clear();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Contains here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Contains here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Contains here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool Contains(ItemType) const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Length here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Length here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Length here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
unsigned int Length();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator = here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator = here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator = here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void operator=(const list<ItemType>&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator [] here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator [] here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator [] here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
ItemType operator[](LIST_ARRAY_INDEX_TYPE) const;
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator [] here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator [] here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator [] here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
ItemType& operator[](LIST_ARRAY_INDEX_TYPE);
|
||||
|
||||
private:
|
||||
listNode<ItemType>* head;
|
||||
listNode<ItemType>* tail;
|
||||
listNode<ItemType>* currPos;
|
||||
};
|
||||
|
||||
template <class ItemType>
|
||||
listNode<ItemType>::listNode()
|
||||
{
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
list<ItemType>::list()
|
||||
{
|
||||
head = NULL;
|
||||
tail = NULL;
|
||||
currPos = NULL;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
list<ItemType>::~list()
|
||||
{
|
||||
currPos = NULL;
|
||||
while(head != NULL)
|
||||
{
|
||||
tail = head;
|
||||
head = head->next;
|
||||
delete tail;
|
||||
tail = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
list<ItemType>::list(const list<ItemType>& rtOp)
|
||||
{
|
||||
head = NULL;
|
||||
tail = NULL;
|
||||
currPos = NULL;
|
||||
|
||||
operator=(rtOp);
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::Clear()
|
||||
{
|
||||
while(head)
|
||||
Remove(head->data);
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::operator=(const list<ItemType>& rtOp)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if(!rtOp.IsEmpty())
|
||||
{
|
||||
listNode<ItemType>* temp = rtOp.head->next;
|
||||
listNode<ItemType>* temp2 = NULL;
|
||||
|
||||
if(temp != NULL)
|
||||
{
|
||||
head = new listNode<ItemType>;
|
||||
head->data = rtOp.head->data;
|
||||
tail = head;
|
||||
temp2 = head;
|
||||
}
|
||||
|
||||
while (temp != NULL)
|
||||
{
|
||||
temp2->next = new listNode<ItemType>;
|
||||
temp2 = temp2->next;
|
||||
temp2->data = temp->data;
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
tail = temp2;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::IsEmpty() const
|
||||
{
|
||||
return head == NULL;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::IsFull() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::Insert(ItemType newItem)
|
||||
{
|
||||
listNode<ItemType>* temp = head;
|
||||
listNode<ItemType>* temp2 = NULL;
|
||||
|
||||
if(head == NULL)
|
||||
{
|
||||
temp = tail = head = new listNode<ItemType>;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(newItem < head->data)
|
||||
{
|
||||
temp2 = head;
|
||||
temp = head = new listNode<ItemType>;
|
||||
head->next = temp2;
|
||||
temp2 = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//temp = head;
|
||||
while(temp->next != NULL && newItem > temp->next->data)
|
||||
{
|
||||
temp = temp->next;
|
||||
}
|
||||
temp2 = temp->next;
|
||||
temp = temp->next = new listNode<ItemType>;
|
||||
temp->next = temp2;
|
||||
temp2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
temp->data = newItem;
|
||||
|
||||
if(temp->next == NULL)
|
||||
{
|
||||
tail = temp;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::Remove(ItemType target)
|
||||
{
|
||||
if(head != NULL)
|
||||
{
|
||||
listNode<ItemType>* temp = head;
|
||||
listNode<ItemType>* temp2 = head;
|
||||
|
||||
while(temp->next != NULL && temp->data != target)
|
||||
{
|
||||
temp2 = temp;
|
||||
temp = temp->next;
|
||||
}
|
||||
|
||||
if(temp->data == target)
|
||||
{
|
||||
if(temp != head)
|
||||
{
|
||||
temp2->next = temp->next;
|
||||
delete temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(tail == head)
|
||||
tail = NULL;
|
||||
head = head->next;
|
||||
delete temp2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::PrevPosition()
|
||||
{
|
||||
if(currPos != head)
|
||||
{
|
||||
tail->next = currPos;
|
||||
currPos = head;
|
||||
|
||||
if(currPos != tail->next)
|
||||
{
|
||||
while(currPos->next != tail->next)
|
||||
{
|
||||
currPos = currPos->next;
|
||||
}
|
||||
}
|
||||
|
||||
tail->next = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::NextPosition()
|
||||
{
|
||||
if(currPos != tail)
|
||||
{
|
||||
currPos = currPos->next;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::Remove()
|
||||
{
|
||||
if(currPos != NULL)
|
||||
{
|
||||
tail->next = currPos;
|
||||
currPos = currPos->next;
|
||||
delete tail->next;
|
||||
tail->next = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
ItemType list<ItemType>::Retrieve() const
|
||||
{
|
||||
if(currPos != NULL)
|
||||
return currPos->data;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::IsFirstPosition() const
|
||||
{
|
||||
return currPos == head;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
bool list<ItemType>::IsLastPosition() const
|
||||
{
|
||||
return currPos == tail;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::FirstPosition()
|
||||
{
|
||||
currPos = head;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
void list<ItemType>::LastPosition()
|
||||
{
|
||||
currPos = tail;
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
ItemType list<ItemType>::operator[](LIST_ARRAY_INDEX_TYPE index) const
|
||||
{
|
||||
if(head == NULL)
|
||||
{
|
||||
//We should throw an exception here but instead I'll just return shit guess for now if somebody does this they're just fucked.
|
||||
}
|
||||
else
|
||||
{
|
||||
listNode<ItemType>* temp = head;
|
||||
LIST_ARRAY_INDEX_TYPE current;
|
||||
|
||||
for(current=0;current <index; current++)
|
||||
{
|
||||
if(temp->next == NULL)
|
||||
{
|
||||
temp->next = new listNode<ItemType>;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
return temp->data;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
ItemType& list<ItemType>::operator[](LIST_ARRAY_INDEX_TYPE index)
|
||||
{
|
||||
if(head == NULL)
|
||||
{
|
||||
tail = currPos = head = new listNode<ItemType>;
|
||||
return (ItemType&)(head->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
listNode<ItemType>* temp = head;
|
||||
LIST_ARRAY_INDEX_TYPE current;
|
||||
|
||||
for(current=0;current <index; current++)
|
||||
{
|
||||
if(temp->next == NULL)
|
||||
{
|
||||
temp->next = new listNode<ItemType>;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
return (ItemType&)(temp->data);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ItemType>
|
||||
unsigned int list<ItemType>::Length()
|
||||
{
|
||||
if (head == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len = 1;
|
||||
listNode<ItemType>* temp = head->next;
|
||||
while (temp != NULL)
|
||||
{
|
||||
temp = temp->next;
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
template<class ItemType>
|
||||
bool list<ItemType>::Contains(ItemType value) const
|
||||
{
|
||||
listNode<ItemType>* temp = head;
|
||||
while(temp != NULL)
|
||||
{
|
||||
if(temp->data == value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
318
src/macosx.cpp
@@ -1,318 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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; i<argc; i++)
|
||||
{
|
||||
commandLine = commandLine + " " + argv[i];
|
||||
}
|
||||
level->ParseCmds(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
|
||||
|
||||
32
src/main.cpp
@@ -1,32 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
#if defined __APPLE__
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <AGL/agl.h>
|
||||
#include <OpenGL/gl.h>
|
||||
|
||||
/*
|
||||
OSStatus main(int argc, char** argv)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
135
src/main.h
@@ -1,135 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <GL/gl.h> // Header file for OpenGL32 library
|
||||
#include <GL/glu.h> // Header file for Glu32 library
|
||||
#elif defined USE_AGL
|
||||
#include "mygl.h"
|
||||
#elif defined USE_CGL
|
||||
#error unimplemented method
|
||||
#elif defined USE_WGL
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h> // Header file for OpenGL32 library
|
||||
#include <GL/glu.h> // Header file for Glu32 library
|
||||
#endif
|
||||
|
||||
#include <cstdio> // Header file for standard input/output
|
||||
#include <math.h>
|
||||
|
||||
#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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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
|
||||
32
src/mydefs.h
@@ -1,32 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __mydefs_h__
|
||||
#define __mydefs_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32 //This whole file is windows specific right now
|
||||
#include <windows.h>
|
||||
static HWND g_hWnd = NULL;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
85
src/mygl.cpp
@@ -1,85 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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();
|
||||
113
src/mygl.h
@@ -1,113 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#elif defined USE_AGL
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#include <OpenGL/OpenGL.h>
|
||||
//#error unimplemented method
|
||||
#elif defined USE_CGL
|
||||
#error unimplemented method
|
||||
#elif defined USE_WGL
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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
|
||||
164
src/myglFont.cpp
@@ -1,164 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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: myglFont.cpp
|
||||
// Author: Tom Hicks
|
||||
// Creation: 09-01-2003
|
||||
// LastEdit: 06-19-2005
|
||||
// Editors: None
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// Summary of Methods:
|
||||
// Global
|
||||
// -function name
|
||||
// description
|
||||
// blahClass
|
||||
// -function name
|
||||
// description
|
||||
//
|
||||
// Summary of Properties:
|
||||
// blahClass
|
||||
// -property name
|
||||
// description
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "myglFont.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
Font::Font()
|
||||
{
|
||||
status = 0;
|
||||
base = 0;
|
||||
texture = 0;
|
||||
screenWidth = 1;
|
||||
screenHeight = 1;
|
||||
}
|
||||
|
||||
Font::~Font()
|
||||
{
|
||||
FreeFont();
|
||||
}
|
||||
|
||||
bool Font::BuildFont(const char* texName)
|
||||
{
|
||||
FreeFont();
|
||||
|
||||
if(LoadGLTexture(texName, texture, GL_NEAREST, GL_NEAREST))
|
||||
{
|
||||
float x, y;
|
||||
base = glGenLists(256);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
for(short i = 0; i<256; i++)
|
||||
{
|
||||
x = i%16/16.0f;
|
||||
y = i/16/16.0f;
|
||||
glNewList(base+i, GL_COMPILE);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(x, 1-y-0.0625f);
|
||||
glVertex2i(0,0);
|
||||
glTexCoord2f(x+0.0625f, 1-y-0.0625f);
|
||||
glVertex2i(16,0);
|
||||
glTexCoord2f(x+0.0625f, 1-y);
|
||||
glVertex2i(16,16);
|
||||
glTexCoord2f(x, 1-y);
|
||||
glVertex2i(0,16);
|
||||
glEnd();
|
||||
glTranslated(16,0,0);
|
||||
glEndList();
|
||||
}
|
||||
status = true;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Font::FreeFont()
|
||||
{
|
||||
if(status)
|
||||
{
|
||||
glDeleteLists(base, 256);
|
||||
status = false;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void Font::Print(int x, int y, const char* str, unsigned int set)
|
||||
{
|
||||
if(status)
|
||||
{
|
||||
if(set>1)
|
||||
set = 1;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
//glEnable(GL_BLEND);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0,screenWidth,0,screenHeight,-1,1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslated(x, y, 0);
|
||||
glListBase(base-32+(128*set));
|
||||
glCallLists(strlen(str), GL_BYTE, str);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
//glDisable(GL_BLEND);
|
||||
//glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
bool Font::Loaded()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
void Font::SetScreenDimensions(short x, short y)
|
||||
{
|
||||
screenWidth = x;
|
||||
screenHeight = y;
|
||||
}
|
||||
|
||||
void Font::SetScreenWidth(short x)
|
||||
{
|
||||
screenWidth = x;
|
||||
}
|
||||
|
||||
void Font::SetScreenHeight(short y)
|
||||
{
|
||||
screenHeight = y;
|
||||
}
|
||||
|
||||
short Font::ScreenWidth()
|
||||
{
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
short Font::ScreenHeight()
|
||||
{
|
||||
return screenHeight;
|
||||
}
|
||||
};
|
||||
273
src/myglFont.h
@@ -1,273 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __glPrint_h__
|
||||
#define __glPrint_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "mygl.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Font here.
|
||||
*
|
||||
* Write detailed description for Font here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Font here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Font
|
||||
{
|
||||
private:
|
||||
short screenWidth;
|
||||
short screenHeight;
|
||||
unsigned int base;
|
||||
GLuint texture;
|
||||
bool status;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Font here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Font here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Font here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
Font();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~Font here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~Font here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~Font here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
~Font();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for BuildFont here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for BuildFont here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for BuildFont here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool BuildFont(const char*);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for FreeFont here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for FreeFont here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for FreeFont here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool FreeFont();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Print here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Print here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Print here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Print(int, int, const char*, unsigned int = 0);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Loaded here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Loaded here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Loaded here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool Loaded();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetScreenDimensions here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetScreenDimensions here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetScreenDimensions here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetScreenDimensions(short, short);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetScreenWidth here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetScreenWidth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetScreenWidth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetScreenWidth(short);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetScreenHeight here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetScreenHeight here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetScreenHeight here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetScreenHeight(short);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ScreenWidth here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ScreenWidth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ScreenWidth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
short ScreenWidth();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ScreenHeight here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ScreenHeight here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ScreenHeight here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
short ScreenHeight();
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -1,132 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "myglTexture.h"
|
||||
using namespace OpenArena;
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
Texture::Texture()
|
||||
{
|
||||
id=0xFFFFFFFF;
|
||||
filename = "";
|
||||
minFilter = GL_LINEAR;
|
||||
magFilter = GL_LINEAR;
|
||||
}
|
||||
|
||||
Texture::~Texture()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
string Texture::Filename()
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
||||
GLuint Texture::ID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
bool Texture::Loaded()
|
||||
{
|
||||
return filename != "";
|
||||
}
|
||||
|
||||
bool Texture::Load(string fn)
|
||||
{
|
||||
if(Loaded())
|
||||
Free();
|
||||
|
||||
if(LoadGLTexture(fn.c_str(), id, minFilter, magFilter))
|
||||
{
|
||||
filename = fn;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = 0xFFFFFFFF;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::Load(string fn, GLuint min, GLuint mag)
|
||||
{
|
||||
if(Loaded())
|
||||
Free();
|
||||
|
||||
if(LoadGLTexture(fn.c_str(), id, min, mag))
|
||||
{
|
||||
filename = fn;
|
||||
minFilter = min;
|
||||
magFilter = mag;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
id=0xFFFFFFFF;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::Free()
|
||||
{
|
||||
if(Loaded())
|
||||
{
|
||||
//This is only temporarily removed for mac os x
|
||||
//TODO make this work on all operating systems
|
||||
//FreeGLTexture(id);
|
||||
minFilter = GL_LINEAR;
|
||||
magFilter = GL_LINEAR;
|
||||
filename = "";
|
||||
id = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::operator<(const Texture& rtOp)
|
||||
{
|
||||
return id < rtOp.id;
|
||||
}
|
||||
|
||||
bool Texture::operator<=(const Texture& rtOp)
|
||||
{
|
||||
return id<= rtOp.id;
|
||||
}
|
||||
|
||||
bool Texture::operator==(const Texture& rtOp)
|
||||
{
|
||||
return id== rtOp.id;
|
||||
}
|
||||
|
||||
bool Texture::operator!=(const Texture& rtOp)
|
||||
{
|
||||
return id!= rtOp.id;
|
||||
}
|
||||
|
||||
bool Texture::operator>=(const Texture& rtOp)
|
||||
{
|
||||
return id>= rtOp.id;
|
||||
}
|
||||
|
||||
bool Texture::operator>(const Texture& rtOp)
|
||||
{
|
||||
return id> rtOp.id;
|
||||
}
|
||||
};
|
||||
@@ -1,345 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __myglTexture_h__
|
||||
#define __myglTexture_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include "datatypes.h"
|
||||
#include "mygl.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Texture here.
|
||||
*
|
||||
* Write detailed description for Texture here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Texture here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Texture here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Texture here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Texture here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
Texture();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ~Texture here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ~Texture here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ~Texture here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
~Texture();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Filename here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Filename here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Filename here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
string Filename();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ID here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ID here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ID here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
GLuint ID();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Load here.
|
||||
*
|
||||
* \param filename
|
||||
* Description of parameter filename.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Load here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Load here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool Load(string filename);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Load here.
|
||||
*
|
||||
* \param filename
|
||||
* Description of parameter filename.
|
||||
*
|
||||
* \param min
|
||||
* Description of parameter min.
|
||||
*
|
||||
* \param mag
|
||||
* Description of parameter mag.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Load here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Load here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool Load(string filename, GLuint min, GLuint mag);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Free here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Free here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Free here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Free();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Loaded here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Loaded here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Loaded here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool Loaded();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator < here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator < here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator < here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator<(const Texture&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator <= here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator <= here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator <= here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator<=(const Texture&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator == here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator == here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator == here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator==(const Texture&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator != here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator != here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator != here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator!=(const Texture&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator >= here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator >= here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator >= here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator>=(const Texture&);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for operator > here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for operator > here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for operator > here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool operator>(const Texture&);
|
||||
|
||||
private:
|
||||
GLuint minFilter;
|
||||
GLuint magFilter;
|
||||
string filename;
|
||||
GLuint id;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@@ -1,45 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "player.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
void Player::Load()
|
||||
{
|
||||
}
|
||||
|
||||
void Player::Save()
|
||||
{
|
||||
}
|
||||
|
||||
void Player::AddItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory | item;
|
||||
}
|
||||
|
||||
void Player::RemoveItem(unsigned int item)
|
||||
{
|
||||
// inventory = inventory & ~item;
|
||||
}
|
||||
|
||||
void Player::CreateCharacter()
|
||||
{
|
||||
}
|
||||
};
|
||||
57
src/player.h
@@ -1,57 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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
|
||||
@@ -1,98 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "screen.h"
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
Screen::Screen()
|
||||
{
|
||||
_width=640;
|
||||
_height=480;
|
||||
_colorDepth=16;
|
||||
_fullscreen=false;
|
||||
_name = "";
|
||||
}
|
||||
|
||||
int Screen::GetWidth()
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
int Screen::GetHeight()
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
int Screen::GetColorDepth()
|
||||
{
|
||||
return _colorDepth;
|
||||
}
|
||||
|
||||
bool Screen::GetFullscreen()
|
||||
{
|
||||
return _fullscreen;
|
||||
}
|
||||
|
||||
const char* Screen::GetName()
|
||||
{
|
||||
return _name.c_str();
|
||||
}
|
||||
|
||||
void Screen::SetWidth(int width)
|
||||
{
|
||||
_width = width;
|
||||
}
|
||||
|
||||
void Screen::SetHeight(int height)
|
||||
{
|
||||
_height = height;
|
||||
}
|
||||
|
||||
void Screen::Resize(int width, int height)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
|
||||
void Screen::SetColorDepth(int colorDepth)
|
||||
{
|
||||
_colorDepth = colorDepth;
|
||||
}
|
||||
|
||||
void Screen::SetFullscreen(bool status)
|
||||
{
|
||||
_fullscreen = status;
|
||||
}
|
||||
|
||||
void Screen::ToggleFullscreen()
|
||||
{
|
||||
_fullscreen = !_fullscreen;
|
||||
}
|
||||
|
||||
void Screen::SetName(const char* name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
void Screen::SetName(string name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
};
|
||||
318
src/screen.h
@@ -1,318 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __screen_h__
|
||||
#define __screen_h__
|
||||
#include <string>
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Screen here.
|
||||
*
|
||||
* Write detailed description for Screen here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Screen here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class Screen
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Screen here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Screen here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Screen here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
Screen();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetWidth here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetWidth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetWidth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
int GetWidth();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetHeight here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetHeight here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetHeight here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
int GetHeight();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetColorDepth here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetColorDepth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetColorDepth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
int GetColorDepth();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetFullscreen here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetFullscreen here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetFullscreen here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
bool GetFullscreen();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for GetName here.
|
||||
*
|
||||
* \returns
|
||||
* Write description of return value here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for GetName here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for GetName here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
const char* GetName();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetWidth here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetWidth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetWidth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetWidth(int);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetHeight here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetHeight here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetHeight here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetHeight(int);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for Resize here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for Resize here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for Resize here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void Resize(int, int);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetColorDepth here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetColorDepth here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetColorDepth here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetColorDepth(int);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetFullscreen here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetFullscreen here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetFullscreen here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetFullscreen(bool);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for ToggleFullscreen here.
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for ToggleFullscreen here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for ToggleFullscreen here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void ToggleFullscreen();
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetName here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetName here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetName here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetName(const char*);
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for SetName here.
|
||||
*
|
||||
* \param
|
||||
* Description of parameter .
|
||||
*
|
||||
* \throws <exception class>
|
||||
* Description of criteria for throwing this exception.
|
||||
*
|
||||
* Write detailed description for SetName here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for SetName here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
void SetName(string);
|
||||
protected:
|
||||
short _width;
|
||||
short _height;
|
||||
char _colorDepth;
|
||||
bool _fullscreen;
|
||||
// public:
|
||||
string _name;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
320
src/strmanip.cpp
@@ -1,320 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <cctype>
|
||||
#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<str.length(); i++)
|
||||
str[i] = tolower(str[i]);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
string toupper(string str)
|
||||
{
|
||||
for(uint32 i=0; i<str.length(); i++)
|
||||
str[i] = toupper(str[i]);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
string word(string str, uint32 wordNum)
|
||||
{
|
||||
///////////////
|
||||
//stopped here
|
||||
///////////////
|
||||
uint32 start = 0;
|
||||
uint32 length = 0;
|
||||
uint32 maxLength = str.length();
|
||||
if(str.length() > 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<wordNum; i++)
|
||||
{
|
||||
while(start <maxLength && !isspace(str[start]))// && start <= maxLength)
|
||||
++start;
|
||||
while(start < maxLength && isspace(str[start]))
|
||||
++start;
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
while((start+length) < maxLength && !isspace(str[start+length]))
|
||||
++length;
|
||||
|
||||
return str.substr(start, length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
239
src/strmanip.h
@@ -1,239 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __strmanip_h__
|
||||
#define __strmanip_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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 <exception class>
|
||||
* 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
|
||||
@@ -1,51 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 __texture_h__
|
||||
#define __texture_h__
|
||||
|
||||
#if defined HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
namespace OpenArena
|
||||
{
|
||||
/*!
|
||||
* \brief
|
||||
* Write brief comment for TextureImage here.
|
||||
*
|
||||
* Write detailed description for TextureImage here.
|
||||
*
|
||||
* \remarks
|
||||
* Write remarks for TextureImage here.
|
||||
*
|
||||
* \see
|
||||
* Separate items with the '|' character.
|
||||
*/
|
||||
class TextureImage
|
||||
{
|
||||
public:
|
||||
unsigned char* data;
|
||||
unsigned int bpp;
|
||||
unsigned int sizeX;
|
||||
unsigned int sizeY;
|
||||
unsigned int type;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
688
src/tga.cpp
@@ -1,688 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "tga.h"
|
||||
#include "datatypes.h"
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
namespace OpenArena{
|
||||
TextureImage* LoadTGA(const char * filename)
|
||||
{
|
||||
TGAHeader tgaheader;
|
||||
TextureImage* image;
|
||||
std::string errmsg;
|
||||
FILE* file = fopen(filename, "rb");
|
||||
|
||||
if(file == NULL)
|
||||
{
|
||||
errmsg = "Could not open texture file ";
|
||||
errmsg = errmsg + filename;
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, errmsg.c_str(), "ERROR", MB_OK);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(&tgaheader, sizeof(TGAHeader), 1, file) == 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read file header", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(file != NULL)
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(memcmp(uTGAcompare, &tgaheader, sizeof(tgaheader)) == 0)
|
||||
image = LoadUncompressedTGA(file);
|
||||
else if(memcmp(cTGAcompare, &tgaheader, sizeof(tgaheader)) == 0)
|
||||
image = LoadCompressedTGA(file);
|
||||
else
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "TGA file must be type 2 or type 10 ", "Invalid Image", MB_OK);
|
||||
#endif
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
TextureImage* LoadUncompressedTGA(FILE * fTGA)
|
||||
{
|
||||
TGA tga;
|
||||
TextureImage* image = new TextureImage;
|
||||
|
||||
if(fread(tga.header, sizeof(tga.header), 1, fTGA) == 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read info header", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->sizeY = tga.header[1] * 256 + tga.header[0];
|
||||
image->sizeX = tga.header[3] * 256 + tga.header[2];
|
||||
image->bpp = tga.header[4];
|
||||
tga.Width = image->sizeX;
|
||||
tga.Height = image->sizeY;
|
||||
tga.Bpp = image->bpp;
|
||||
|
||||
if((image->sizeX <= 0) || (image->sizeY <= 0) || ((image->bpp != 24) && (image->bpp !=32)))
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Invalid texture information", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(image->bpp == 24)
|
||||
{
|
||||
image->type = GL_RGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
image->type = GL_RGBA;
|
||||
}
|
||||
|
||||
tga.bytesPerPixel = (tga.Bpp / 8);
|
||||
tga.imageSize = (tga.bytesPerPixel * tga.Width * tga.Height);
|
||||
image->data = (GLubyte *)malloc(tga.imageSize);
|
||||
|
||||
if(image->data == NULL)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not allocate memory for image", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(image->data, 1, tga.imageSize, fTGA) != tga.imageSize)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read image data", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for(GLuint cswap = 0; cswap < (int)tga.imageSize; cswap += tga.bytesPerPixel)
|
||||
{
|
||||
image->data[cswap] ^= image->data[cswap+2] ^=
|
||||
image->data[cswap] ^= image->data[cswap+2];
|
||||
}
|
||||
|
||||
fclose(fTGA);
|
||||
return image;
|
||||
}
|
||||
|
||||
TextureImage* LoadCompressedTGA(FILE * fTGA)
|
||||
{
|
||||
TextureImage* image = new TextureImage;
|
||||
TGA tga;
|
||||
|
||||
if(fread(tga.header, sizeof(tga.header), 1, fTGA) == 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read info header", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->sizeX = tga.header[1] * 256 + tga.header[0];
|
||||
image->sizeY = tga.header[3] * 256 + tga.header[2];
|
||||
image->bpp = tga.header[4];
|
||||
tga.Width = image->sizeX;
|
||||
tga.Height = image->sizeY;
|
||||
tga.Bpp = image->bpp;
|
||||
|
||||
if((image->sizeX <= 0) || (image->sizeY <= 0) || ((image->bpp != 24) && (image->bpp !=32)))
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Invalid texture information", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tga.bytesPerPixel = (tga.Bpp / 8);
|
||||
tga.imageSize = (tga.bytesPerPixel * tga.Width * tga.Height);
|
||||
image->data = (GLubyte *)malloc(tga.imageSize);
|
||||
|
||||
if(image->data == NULL)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not allocate memory for image", "ERROR", MB_OK);
|
||||
#endif
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLuint pixelcount = tga.Height * tga.Width;
|
||||
GLuint currentpixel = 0;
|
||||
GLuint currentbyte = 0;
|
||||
GLubyte * colorbuffer = (GLubyte *)malloc(tga.bytesPerPixel);
|
||||
|
||||
do
|
||||
{
|
||||
GLubyte chunkheader = 0;
|
||||
|
||||
if(fread(&chunkheader, sizeof(GLubyte), 1, fTGA) == 0)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read RLE header", "ERROR", MB_OK);
|
||||
#endif
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(chunkheader < 128)
|
||||
{
|
||||
chunkheader++;
|
||||
for(short counter = 0; counter < chunkheader; counter++)
|
||||
{
|
||||
if(fread(colorbuffer, 1, tga.bytesPerPixel, fTGA) != tga.bytesPerPixel)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read image data", "ERROR", MB_OK);
|
||||
#endif
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->data[currentbyte ] = colorbuffer[2];
|
||||
image->data[currentbyte + 1 ] = colorbuffer[1];
|
||||
image->data[currentbyte + 2 ] = colorbuffer[0];
|
||||
|
||||
if(tga.bytesPerPixel == 4)
|
||||
{
|
||||
image->data[currentbyte + 3] = colorbuffer[3];
|
||||
}
|
||||
|
||||
currentbyte += tga.bytesPerPixel;
|
||||
currentpixel++;
|
||||
|
||||
if(currentpixel > pixelcount)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Too many pixels read", "ERROR", NULL);
|
||||
#endif
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chunkheader -= 127;
|
||||
if(fread(colorbuffer, 1, tga.bytesPerPixel, fTGA) != tga.bytesPerPixel)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Could not read from file", "ERROR", MB_OK);
|
||||
#endif
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(short counter = 0; counter < chunkheader; counter++)
|
||||
{
|
||||
image->data[currentbyte ] = colorbuffer[2];
|
||||
image->data[currentbyte + 1 ] = colorbuffer[1];
|
||||
image->data[currentbyte + 2 ] = colorbuffer[0];
|
||||
|
||||
if(tga.bytesPerPixel == 4)
|
||||
{
|
||||
image->data[currentbyte + 3] = colorbuffer[3];
|
||||
}
|
||||
|
||||
currentbyte += tga.bytesPerPixel;
|
||||
currentpixel++;
|
||||
|
||||
if(currentpixel > pixelcount)
|
||||
{
|
||||
//This needs to be abstracted somehow
|
||||
#ifdef WIN32
|
||||
MessageBox(NULL, "Too many pixels read", "ERROR", NULL);
|
||||
#endif
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(currentpixel < pixelcount);
|
||||
fclose(fTGA);
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TextureImage* LoadTGA(const char * filename)
|
||||
{
|
||||
TGAHeader tgaheader;
|
||||
TextureImage* image;
|
||||
std::string errmsg;
|
||||
FILE* file = fopen(filename, "rb");
|
||||
|
||||
if(file == NULL)
|
||||
{
|
||||
errmsg = "Could not open texture file ";
|
||||
errmsg = errmsg + filename;
|
||||
MessageBox(NULL, errmsg.c_str(), "ERROR", MB_OK);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(&tgaheader, sizeof(TGAHeader), 1, file) == 0)
|
||||
{
|
||||
MessageBox(NULL, "Could not read file header", "ERROR", MB_OK);
|
||||
if(file != NULL)
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(memcmp(uTGAcompare, &tgaheader, sizeof(tgaheader)) == 0)
|
||||
image = LoadUncompressedTGA(file);
|
||||
else if(memcmp(cTGAcompare, &tgaheader, sizeof(tgaheader)) == 0)
|
||||
image = LoadCompressedTGA(file);
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, "TGA file must be type 2 or type 10 ", "Invalid Image", MB_OK);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
TextureImage* LoadUncompressedTGA(FILE * fTGA)
|
||||
{
|
||||
TGA tga;
|
||||
TextureImage* image = new TextureImage;
|
||||
|
||||
if(fread(tga.header, sizeof(tga.header), 1, fTGA) == 0)
|
||||
{
|
||||
MessageBox(NULL, "Could not read info header", "ERROR", MB_OK);
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->sizeY = tga.header[1] * 256 + tga.header[0];
|
||||
image->sizeX = tga.header[3] * 256 + tga.header[2];
|
||||
image->bpp = tga.header[4];
|
||||
tga.Width = image->sizeX;
|
||||
tga.Height = image->sizeY;
|
||||
tga.Bpp = image->bpp;
|
||||
|
||||
if((image->sizeX <= 0) || (image->sizeY <= 0) || ((image->bpp != 24) && (image->bpp !=32)))
|
||||
{
|
||||
MessageBox(NULL, "Invalid texture information", "ERROR", MB_OK);
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(image->bpp == 24)
|
||||
{
|
||||
image->type = GL_RGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
image->type = GL_RGBA;
|
||||
}
|
||||
|
||||
tga.bytesPerPixel = (tga.Bpp / 8);
|
||||
tga.imageSize = (tga.bytesPerPixel * tga.Width * tga.Height);
|
||||
image->data = (GLubyte *)malloc(tga.imageSize);
|
||||
|
||||
if(image->data == NULL)
|
||||
{
|
||||
MessageBox(NULL, "Could not allocate memory for image", "ERROR", MB_OK);
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(fread(image->data, 1, tga.imageSize, fTGA) != tga.imageSize)
|
||||
{
|
||||
MessageBox(NULL, "Could not read image data", "ERROR", MB_OK);
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for(GLuint cswap = 0; cswap < (int)tga.imageSize; cswap += tga.bytesPerPixel)
|
||||
{
|
||||
image->data[cswap] ^= image->data[cswap+2] ^=
|
||||
image->data[cswap] ^= image->data[cswap+2];
|
||||
}
|
||||
|
||||
fclose(fTGA);
|
||||
return image;
|
||||
}
|
||||
|
||||
TextureImage* LoadCompressedTGA(FILE * fTGA)
|
||||
{
|
||||
TextureImage* image = new TextureImage;
|
||||
TGA tga;
|
||||
|
||||
if(fread(tga.header, sizeof(tga.header), 1, fTGA) == 0)
|
||||
{
|
||||
MessageBox(NULL, "Could not read info header", "ERROR", MB_OK);
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->sizeX = tga.header[1] * 256 + tga.header[0];
|
||||
image->sizeY = tga.header[3] * 256 + tga.header[2];
|
||||
image->bpp = tga.header[4];
|
||||
tga.Width = image->sizeX;
|
||||
tga.Height = image->sizeY;
|
||||
tga.Bpp = image->bpp;
|
||||
|
||||
if((image->sizeX <= 0) || (image->sizeY <= 0) || ((image->bpp != 24) && (image->bpp !=32)))
|
||||
{
|
||||
MessageBox(NULL, "Invalid texture information", "ERROR", MB_OK);
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tga.bytesPerPixel = (tga.Bpp / 8);
|
||||
tga.imageSize = (tga.bytesPerPixel * tga.Width * tga.Height);
|
||||
image->data = (GLubyte *)malloc(tga.imageSize);
|
||||
|
||||
if(image->data == NULL)
|
||||
{
|
||||
MessageBox(NULL, "Could not allocate memory for image", "ERROR", MB_OK);
|
||||
fclose(fTGA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GLuint pixelcount = tga.Height * tga.Width;
|
||||
GLuint currentpixel = 0;
|
||||
GLuint currentbyte = 0;
|
||||
GLubyte * colorbuffer = (GLubyte *)malloc(tga.bytesPerPixel);
|
||||
|
||||
do
|
||||
{
|
||||
GLubyte chunkheader = 0;
|
||||
|
||||
if(fread(&chunkheader, sizeof(GLubyte), 1, fTGA) == 0)
|
||||
{
|
||||
MessageBox(NULL, "Could not read RLE header", "ERROR", MB_OK);
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(chunkheader < 128)
|
||||
{
|
||||
chunkheader++;
|
||||
for(short counter = 0; counter < chunkheader; counter++)
|
||||
{
|
||||
if(fread(colorbuffer, 1, tga.bytesPerPixel, fTGA) != tga.bytesPerPixel)
|
||||
{
|
||||
MessageBox(NULL, "Could not read image data", "ERROR", MB_OK);
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image->data[currentbyte ] = colorbuffer[2];
|
||||
image->data[currentbyte + 1 ] = colorbuffer[1];
|
||||
image->data[currentbyte + 2 ] = colorbuffer[0];
|
||||
|
||||
if(tga.bytesPerPixel == 4)
|
||||
{
|
||||
image->data[currentbyte + 3] = colorbuffer[3];
|
||||
}
|
||||
|
||||
currentbyte += tga.bytesPerPixel;
|
||||
currentpixel++;
|
||||
|
||||
if(currentpixel > pixelcount)
|
||||
{
|
||||
MessageBox(NULL, "Too many pixels read", "ERROR", NULL);
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
chunkheader -= 127;
|
||||
if(fread(colorbuffer, 1, tga.bytesPerPixel, fTGA) != tga.bytesPerPixel)
|
||||
{
|
||||
MessageBox(NULL, "Could not read from file", "ERROR", MB_OK);
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(short counter = 0; counter < chunkheader; counter++)
|
||||
{
|
||||
image->data[currentbyte ] = colorbuffer[2];
|
||||
image->data[currentbyte + 1 ] = colorbuffer[1];
|
||||
image->data[currentbyte + 2 ] = colorbuffer[0];
|
||||
|
||||
if(tga.bytesPerPixel == 4)
|
||||
{
|
||||
image->data[currentbyte + 3] = colorbuffer[3];
|
||||
}
|
||||
|
||||
currentbyte += tga.bytesPerPixel;
|
||||
currentpixel++;
|
||||
|
||||
if(currentpixel > pixelcount)
|
||||
{
|
||||
MessageBox(NULL, "Too many pixels read", "ERROR", NULL);
|
||||
|
||||
if(fTGA != NULL)
|
||||
{
|
||||
fclose(fTGA);
|
||||
}
|
||||
|
||||
if(colorbuffer != NULL)
|
||||
{
|
||||
free(colorbuffer);
|
||||
}
|
||||
|
||||
if(image->data != NULL)
|
||||
{
|
||||
free(image->data);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(currentpixel < pixelcount);
|
||||
fclose(fTGA);
|
||||
return image;
|
||||
}
|
||||
*/
|
||||
};
|
||||
101
src/tga.h
@@ -1,101 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <cstdio>
|
||||
#include <string>
|
||||
#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 <exception class>
|
||||
* 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
|
||||
270
src/vector.cpp
@@ -1,270 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "vector.h"
|
||||
|
||||
namespace OpenArena{
|
||||
Vec3d::Vec3d()
|
||||
{
|
||||
x=0.0f;
|
||||
y=0.0f;
|
||||
z=0.0f;
|
||||
}
|
||||
|
||||
Vec3d::Vec3d(const Vec3d& orig)
|
||||
{
|
||||
operator=(orig);
|
||||
}
|
||||
|
||||
Vec3d::Vec3d(double xr=0, double zr=0)
|
||||
{
|
||||
x=(double)sin(90-xr);
|
||||
y=(double)sin(xr);
|
||||
z=(double)(y*tan(zr));
|
||||
}
|
||||
|
||||
Vec3d::Vec3d(double X, double Y, double Z)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
z = Z;
|
||||
}
|
||||
|
||||
double Vec3d::lengthsquared()const
|
||||
{
|
||||
return (x*x+y*y+z*z);
|
||||
}
|
||||
|
||||
double Vec3d::length() const
|
||||
{
|
||||
return (double)sqrt(lengthsquared());
|
||||
}
|
||||
|
||||
void Vec3d::normalize()
|
||||
{
|
||||
x/=length();
|
||||
y/=length();
|
||||
z/=length();
|
||||
}
|
||||
|
||||
void Vec3d::operator=(const Vec3d& v)
|
||||
{
|
||||
x = v.x;
|
||||
y = v.y;
|
||||
z = v.z;
|
||||
}
|
||||
|
||||
Vec3d Vec3d::cross(const Vec3d& v) const
|
||||
{
|
||||
return Vec3d(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::operator*(const Vec3d& v) const
|
||||
{
|
||||
return Vec3d(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::operator+(const Vec3d& v)const
|
||||
{
|
||||
return Vec3d(x+v.x, y+v.y, z+v.z);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::operator*(double f) const
|
||||
{
|
||||
return Vec3d(x*f, y*f, z*f);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::operator-(const Vec3d& v)const
|
||||
{
|
||||
return Vec3d(x-v.x, y-v.y, z-v.z);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::operator/(double k) const
|
||||
{
|
||||
return Vec3d(x/k, y/k, z/k);
|
||||
}
|
||||
|
||||
Vec3d Vec3d::normalized() const
|
||||
{
|
||||
return Vec3d(x/length(), y/length(), z/length());
|
||||
}
|
||||
|
||||
|
||||
Vec2f::Vec2f()
|
||||
{
|
||||
x=0;
|
||||
y=0;
|
||||
}
|
||||
|
||||
Vec2f::Vec2f(const Vec2f& rtOp)
|
||||
{
|
||||
x=rtOp.x;
|
||||
y=rtOp.y;
|
||||
}
|
||||
|
||||
Vec2f Vec2f::cross(const Vec2f& rtOp) const
|
||||
{
|
||||
return Vec2f(y-rtOp.y, rtOp.x-x);
|
||||
}
|
||||
|
||||
double Vec2f::length()const
|
||||
{
|
||||
return sqrt(x*x+y*y);
|
||||
}
|
||||
|
||||
double Vec2f::lengthsquared()const
|
||||
{
|
||||
return (x*x+y*y);
|
||||
}
|
||||
|
||||
void Vec2f::normalize()
|
||||
{
|
||||
x/=(float)length();
|
||||
y/=(float)length();
|
||||
}
|
||||
|
||||
Vec2f Vec2f::normalized() const
|
||||
{
|
||||
return Vec2f(x/length(), y/length());
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator*(double rtOp) const
|
||||
{
|
||||
return Vec2f(x*rtOp, y*rtOp);
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator+(const Vec2f& rtOp) const
|
||||
{
|
||||
return Vec2f(x+rtOp.x, y+rtOp.y);
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator*(const Vec2f& rtOp) const
|
||||
{
|
||||
return Vec2f(x*rtOp.x, y*rtOp.y);
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator-(const Vec2f& rtOp) const
|
||||
{
|
||||
return Vec2f(x-rtOp.x, y-rtOp.y);
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator/(double rtOp) const
|
||||
{
|
||||
return Vec2f(x/rtOp, y/rtOp);
|
||||
}
|
||||
|
||||
Vec2f Vec2f::operator=(const Vec2f& rtOp)
|
||||
{
|
||||
x=rtOp.x;
|
||||
y=rtOp.y;
|
||||
return Vec2f(x,y);
|
||||
}
|
||||
|
||||
Vec2f::Vec2f(double X, double Y)
|
||||
{
|
||||
x=(float)X;
|
||||
y=(float)Y;
|
||||
}
|
||||
////////////
|
||||
Vec2i::Vec2i()
|
||||
{
|
||||
x=0;
|
||||
y=0;
|
||||
}
|
||||
|
||||
Vec2i::Vec2i(const Vec2i& rtOp)
|
||||
{
|
||||
x=rtOp.x;
|
||||
y=rtOp.y;
|
||||
}
|
||||
|
||||
Vec2i Vec2i::cross(const Vec2i& rtOp) const
|
||||
{
|
||||
return Vec2i(y-rtOp.y, rtOp.x-x);
|
||||
}
|
||||
|
||||
int Vec2i::length()const
|
||||
{
|
||||
return (int)sqrt((float)(x*x+y*y));
|
||||
}
|
||||
|
||||
int Vec2i::lengthsquared()const
|
||||
{
|
||||
return (x*x+y*y);
|
||||
}
|
||||
|
||||
void Vec2i::normalize()
|
||||
{
|
||||
x/=length();
|
||||
y/=length();
|
||||
}
|
||||
|
||||
Vec2i Vec2i::normalized() const
|
||||
{
|
||||
return Vec2i(x/length(), y/length());
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator*(int rtOp) const
|
||||
{
|
||||
return Vec2i(x*rtOp, y*rtOp);
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator+(const Vec2i& rtOp) const
|
||||
{
|
||||
return Vec2i(x+rtOp.x, y+rtOp.y);
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator*(const Vec2i& rtOp) const
|
||||
{
|
||||
return Vec2i(x*rtOp.x, y*rtOp.y);
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator-(const Vec2i& rtOp) const
|
||||
{
|
||||
return Vec2i(x-rtOp.x, y-rtOp.y);
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator/(int rtOp) const
|
||||
{
|
||||
return Vec2i(x/rtOp, y/rtOp);
|
||||
}
|
||||
|
||||
Vec2i Vec2i::operator=(const Vec2i& rtOp)
|
||||
{
|
||||
x=rtOp.x;
|
||||
y=rtOp.y;
|
||||
return Vec2i(x,y);
|
||||
}
|
||||
|
||||
Vec2i::Vec2i(int X, int Y)
|
||||
{
|
||||
x=X;
|
||||
y=Y;
|
||||
}
|
||||
|
||||
bool Vec2i::operator==(const Vec2i& rtOp) const
|
||||
{
|
||||
return x == rtOp.x && y == rtOp.y;
|
||||
}
|
||||
|
||||
bool Vec2i::operator!=(const Vec2i& rtOp) const
|
||||
{
|
||||
return !(x == rtOp.x && y == rtOp.y);
|
||||
}
|
||||
};
|
||||
1060
src/vector.h
@@ -1,21 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
//#define OPENARENA_VERSION "OpenArena: v0.1.2"
|
||||
#define OPENARENA_VERSION "OpenArena: CVS"
|
||||
515
src/window.cpp
@@ -1,515 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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; i<modeNum; i++)
|
||||
{
|
||||
//Add a check for colordepth here
|
||||
if((modes[i]->hdisplay == _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
|
||||
125
src/window.h
@@ -1,125 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 <GL/gl.h>
|
||||
#include <GL/glu.h> //maybe not necessary
|
||||
#include <GL/glx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#if defined HAVE_XF86VIDMODE
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
#endif
|
||||
#elif defined USE_AGL
|
||||
#include <AGL/agl.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#elif defined USE_CGL
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#elif defined USE_WGL
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#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
|
||||
891
src/windows.cpp
@@ -1,891 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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: windows.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 WIN32
|
||||
//include necessary header files
|
||||
#include "main.h"
|
||||
#include <GL/glu.h>
|
||||
#include "version.h"
|
||||
#include "vector.h"
|
||||
using OpenArena::Vec2i;
|
||||
|
||||
//link necessary libraries
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
#pragma comment(lib, "glu32.lib")
|
||||
#pragma comment(lib, "glaux.lib")
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
//Ensure CDS_FULLSCREEN is defined
|
||||
#ifndef CDS_FULLSCREEN
|
||||
#define CDS_FULLSCREEN 4
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
void InitControls();
|
||||
int InitGL(GLvoid);
|
||||
void ReSizeGLScene(GLsizei width, GLsizei height);
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
OpenArena::Keys TranslateKey(int keyCode);
|
||||
void HandleConsoleKeyPress(OpenArena::Keys key);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function Definitions
|
||||
|
||||
//
|
||||
//void InitControls()
|
||||
// Purpose:
|
||||
// Initializes controls by loading the default control config file "my.cfg".
|
||||
|
||||
void InitControls()
|
||||
{
|
||||
if (!level.LoadConfig("my.cfg"))
|
||||
level.LoadConfig();
|
||||
}
|
||||
|
||||
//
|
||||
// int InitGL(GLvoid)
|
||||
// Purpose:
|
||||
// To do all required setup before creating an OpenGL window
|
||||
// Pre:
|
||||
//
|
||||
// Post:
|
||||
//
|
||||
|
||||
int InitGL(GLvoid)
|
||||
{
|
||||
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; index<level.numLights; 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;
|
||||
}
|
||||
|
||||
//
|
||||
// GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
|
||||
// Purpose:
|
||||
// To resize the OpenGL window also called on creation
|
||||
// Pre:
|
||||
//
|
||||
// Post:
|
||||
//
|
||||
|
||||
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/(GLfloat)height, 0.1f, 100.0f);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
if (!HIWORD(wParam))
|
||||
{
|
||||
active=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
active=false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_SYSCOMMAND:
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case SC_SCREENSAVE:
|
||||
case SC_MONITORPOWER:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
if(level.showConsole)
|
||||
{
|
||||
HandleConsoleKeyPress((OpenArena::Keys)TranslateKey(wParam));
|
||||
}
|
||||
else
|
||||
{
|
||||
keys[TranslateKey(wParam)] = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case WM_KEYUP:
|
||||
{
|
||||
keys[TranslateKey(wParam)] = false;
|
||||
keys2[TranslateKey(wParam)] = false;
|
||||
return 0;
|
||||
}
|
||||
case WM_SYSKEYDOWN:
|
||||
break;
|
||||
case WM_SIZE:
|
||||
{
|
||||
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
keys[OpenArena::KEY_LBUTTON] = true;
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONUP:
|
||||
{
|
||||
keys[OpenArena::KEY_LBUTTON] = false;
|
||||
keys[OpenArena::KEY_LBUTTON] = false;
|
||||
return 0;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
keys[OpenArena::KEY_RBUTTON] = true;
|
||||
return 0;
|
||||
}
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
keys[OpenArena::KEY_RBUTTON] = false;
|
||||
keys[OpenArena::KEY_RBUTTON] = false;
|
||||
return 0;
|
||||
}
|
||||
case WM_MBUTTONDOWN:
|
||||
{
|
||||
keys[OpenArena::KEY_MBUTTON] = true;
|
||||
return 0;
|
||||
}
|
||||
case WM_MBUTTONUP:
|
||||
{
|
||||
keys[OpenArena::KEY_MBUTTON] = false;
|
||||
keys[OpenArena::KEY_MBUTTON] = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd,uMsg,wParam,lParam);
|
||||
}
|
||||
|
||||
int WINAPI WinMain( HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
bool done=false;
|
||||
|
||||
|
||||
if (strlen(lpCmdLine))
|
||||
level.ParseCmds(lpCmdLine);
|
||||
|
||||
InitControls();
|
||||
|
||||
g_Screen.SetInitializer(new OpenArena::Window::Initializer());
|
||||
g_Screen.SetResizer(new OpenArena::Window::Resizer());
|
||||
if (!g_Screen.Open(string(OPENARENA_VERSION), level.screen.GetWidth(), level.screen.GetHeight(), level.screen.GetColorDepth(), level.screen.GetFullscreen()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
level.SetWindow(&g_Screen);
|
||||
level.glFont.SetScreenDimensions(level.screen.GetWidth()*2, level.screen.GetHeight()*2);
|
||||
//level.glFont.BuildFont("oa\\textures\\menu\\font.bmp");//(level.gamedir + "\\textures\\menu\\font.bmp").c_str());
|
||||
if (level.nextLevel == "")
|
||||
{
|
||||
level.LoadMap("intro.map");
|
||||
}
|
||||
else
|
||||
{
|
||||
level.LoadMap();
|
||||
}
|
||||
|
||||
while(!done)
|
||||
{
|
||||
while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
|
||||
{
|
||||
if (msg.message==WM_QUIT)
|
||||
{
|
||||
done=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (active)
|
||||
{
|
||||
if (keys[OpenArena::KEY_ESCAPE])
|
||||
{
|
||||
done=true;
|
||||
}
|
||||
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.005f;
|
||||
const float MOUSE_SENSITIVITY_VERTICAL = 0.005f;
|
||||
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
|
||||
{
|
||||
g_Screen.SetMousePosition(Vec2i(g_Screen.GetWidth()/2, g_Screen.GetHeight()/2));
|
||||
//SetCursorPos(g_Screen.GetWidth()/2, g_Screen.GetHeight()/2);
|
||||
}
|
||||
|
||||
//////////
|
||||
//Move Backward
|
||||
if(!level.defaultPlayer->controls.backward.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.backward.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.backward.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.MoveCamera(-level.moveSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.backward.NextPosition() && (keys[level.defaultPlayer->controls.backward.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.backward.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.MoveCamera(-level.moveSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Move forward
|
||||
if(!level.defaultPlayer->controls.forward.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.forward.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.forward.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.MoveCamera(level.moveSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.forward.NextPosition() && (keys[level.defaultPlayer->controls.forward.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.forward.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.MoveCamera(level.moveSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Strafe Left
|
||||
if(!level.defaultPlayer->controls.moveLeft.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.moveLeft.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.moveLeft.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.StrafeCamera(-level.moveSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.moveLeft.NextPosition() && (keys[level.defaultPlayer->controls.moveLeft.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.moveLeft.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.StrafeCamera(-level.moveSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Strafe Right
|
||||
if(!level.defaultPlayer->controls.moveRight.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.moveRight.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.moveRight.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer[0].camera.StrafeCamera(level.moveSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.moveRight.NextPosition() && (keys[level.defaultPlayer->controls.moveRight.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.moveRight.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.StrafeCamera(level.moveSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Keyboard Look Left
|
||||
if(!level.defaultPlayer->controls.lookLeft.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.lookLeft.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.lookLeft.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer[0].camera.RotateView(level.turnSpeed, 0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.lookLeft.NextPosition() && (keys[level.defaultPlayer->controls.lookLeft.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.lookLeft.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer[0].camera.RotateView(level.turnSpeed, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Keyboard Look Right
|
||||
if(!level.defaultPlayer->controls.lookRight.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.lookRight.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.lookRight.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(-level.turnSpeed, 0, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.lookRight.NextPosition() && (keys[level.defaultPlayer->controls.lookRight.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.lookRight.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(-level.turnSpeed, 0, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Keyboard Look Up
|
||||
if(!level.defaultPlayer->controls.lookUp.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.lookUp.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.lookUp.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(level.turnSpeed, 1, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.lookUp.NextPosition() && (keys[level.defaultPlayer->controls.lookUp.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.lookUp.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(level.turnSpeed, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Keyboard Look Down
|
||||
if(!level.defaultPlayer->controls.lookDown.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.lookDown.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.lookDown.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(-level.turnSpeed, 1, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.lookDown.NextPosition() && (keys[level.defaultPlayer->controls.lookDown.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.lookDown.Retrieve()])
|
||||
{
|
||||
level.defaultPlayer->camera.RotateView(-level.turnSpeed, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Toggle Show FPS
|
||||
if(!level.defaultPlayer->controls.toggleFPS.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.toggleFPS.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.toggleFPS.Retrieve()])
|
||||
{
|
||||
if(!keys2[level.defaultPlayer->controls.toggleFPS.Retrieve()])
|
||||
{
|
||||
level.showFPS = !level.showFPS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.toggleFPS.NextPosition() && (keys[level.defaultPlayer->controls.toggleFPS.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.toggleFPS.Retrieve()])
|
||||
{
|
||||
if(!keys2[level.defaultPlayer->controls.toggleFPS.Retrieve()])
|
||||
{
|
||||
level.showFPS = !level.showFPS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Toggle MouseLook
|
||||
if(!level.defaultPlayer->controls.toggleMouseLook.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.toggleMouseLook.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.toggleMouseLook.Retrieve()])
|
||||
{
|
||||
if(keys2[level.defaultPlayer->controls.toggleMouseLook.Retrieve()])
|
||||
{
|
||||
level.mlook = ! level.mlook;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.toggleMouseLook.NextPosition() && (keys[level.defaultPlayer->controls.toggleMouseLook.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.toggleMouseLook.Retrieve()])
|
||||
{
|
||||
if(keys2[level.defaultPlayer->controls.toggleMouseLook.Retrieve()])
|
||||
{
|
||||
level.mlook = ! level.mlook;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Toggle Console
|
||||
if(!level.defaultPlayer[0].controls.toggleConsole.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer[0].controls.toggleConsole.FirstPosition();
|
||||
if(keys[level.defaultPlayer[0].controls.toggleConsole.Retrieve()])
|
||||
{
|
||||
if(!keys2[level.defaultPlayer[0].controls.toggleConsole.Retrieve()])
|
||||
{
|
||||
level.showConsole = !level.showConsole;
|
||||
keys2[level.defaultPlayer[0].controls.toggleConsole.Retrieve()] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer[0].controls.toggleConsole.NextPosition() && (keys[level.defaultPlayer[0].controls.toggleConsole.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer[0].controls.toggleConsole.Retrieve()])
|
||||
{
|
||||
if(!keys2[level.defaultPlayer[0].controls.toggleConsole.Retrieve()])
|
||||
{
|
||||
level.showConsole = !level.showConsole;
|
||||
keys2[level.defaultPlayer[0].controls.toggleConsole.Retrieve()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////
|
||||
//Quick MouseLook
|
||||
if(!level.defaultPlayer->controls.quickMouseLook.IsEmpty())
|
||||
{
|
||||
level.defaultPlayer->controls.quickMouseLook.FirstPosition();
|
||||
if(keys[level.defaultPlayer->controls.quickMouseLook.Retrieve()])
|
||||
{
|
||||
if(keys2[level.defaultPlayer->controls.quickMouseLook.Retrieve()])
|
||||
{
|
||||
level.mlook = ! level.mlook;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer->controls.quickMouseLook.NextPosition() && (keys[level.defaultPlayer->controls.quickMouseLook.Retrieve()] != true));
|
||||
{
|
||||
if(keys[level.defaultPlayer->controls.quickMouseLook.Retrieve()])
|
||||
{
|
||||
if(keys2[level.defaultPlayer->controls.quickMouseLook.Retrieve()])
|
||||
{
|
||||
level.mlook = ! level.mlook;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//level.Render();
|
||||
}
|
||||
level.Render();
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
g_Screen.SwapBuffers();
|
||||
|
||||
if (keys[OpenArena::KEY_F1])
|
||||
{
|
||||
keys[OpenArena::KEY_F1]=false;
|
||||
g_Screen.Close();
|
||||
g_Screen.ToggleFullscreen();
|
||||
if (!g_Screen.Open("OpenArena",g_Screen.GetWidth(),g_Screen.GetHeight(),g_Screen.GetColorDepth(),g_Screen.GetFullscreen()))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
level.UnloadMap();
|
||||
g_Screen.Close();
|
||||
return (msg.wParam);
|
||||
}
|
||||
|
||||
OpenArena::Keys TranslateKey(int keyCode)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
case VK_LEFT:
|
||||
return OpenArena::KEY_LEFT;
|
||||
case VK_RIGHT:
|
||||
return OpenArena::KEY_RIGHT;
|
||||
case VK_UP:
|
||||
return OpenArena::KEY_UP;
|
||||
case VK_DOWN:
|
||||
return OpenArena::KEY_DOWN;
|
||||
case VK_SPACE:
|
||||
return OpenArena::KEY_SPACE;
|
||||
case VK_RETURN:
|
||||
return OpenArena::KEY_RETURN;
|
||||
case VK_SHIFT:
|
||||
return OpenArena::KEY_SHIFT;
|
||||
case VK_PAUSE:
|
||||
return OpenArena::KEY_PAUSE;
|
||||
case VK_CONTROL:
|
||||
return OpenArena::KEY_CONTROL;
|
||||
case VK_CAPITAL:
|
||||
return OpenArena::KEY_CAPITAL;
|
||||
case VK_ESCAPE:
|
||||
return OpenArena::KEY_ESCAPE;
|
||||
case VK_PRIOR:
|
||||
return OpenArena::KEY_PRIOR;
|
||||
case VK_NEXT:
|
||||
return OpenArena::KEY_NEXT;
|
||||
case VK_END:
|
||||
return OpenArena::KEY_END;
|
||||
case VK_HOME:
|
||||
return OpenArena::KEY_HOME;
|
||||
case VK_INSERT:
|
||||
return OpenArena::KEY_INSERT;
|
||||
case VK_DELETE:
|
||||
return OpenArena::KEY_DELETE;
|
||||
case VK_LWIN:
|
||||
return OpenArena::KEY_LWIN;
|
||||
case VK_RWIN:
|
||||
return OpenArena::KEY_RWIN;
|
||||
case VK_APPS:
|
||||
return OpenArena::KEY_APPS;
|
||||
case VK_NUMPAD0:
|
||||
return OpenArena::KEY_NUMPAD0;
|
||||
case VK_NUMPAD1:
|
||||
return OpenArena::KEY_NUMPAD1;
|
||||
case VK_NUMPAD2:
|
||||
return OpenArena::KEY_NUMPAD2;
|
||||
case VK_NUMPAD3:
|
||||
return OpenArena::KEY_NUMPAD3;
|
||||
case VK_NUMPAD4:
|
||||
return OpenArena::KEY_NUMPAD4;
|
||||
case VK_NUMPAD5:
|
||||
return OpenArena::KEY_NUMPAD5;
|
||||
case VK_NUMPAD6:
|
||||
return OpenArena::KEY_NUMPAD6;
|
||||
case VK_NUMPAD7:
|
||||
return OpenArena::KEY_NUMPAD7;
|
||||
case VK_NUMPAD8:
|
||||
return OpenArena::KEY_NUMPAD8;
|
||||
case VK_NUMPAD9:
|
||||
return OpenArena::KEY_NUMPAD9;
|
||||
case VK_MULTIPLY:
|
||||
return OpenArena::KEY_MULTIPLY;
|
||||
case VK_ADD:
|
||||
return OpenArena::KEY_ADD;
|
||||
case VK_SUBTRACT:
|
||||
return OpenArena::KEY_SUBTRACT;
|
||||
case VK_DIVIDE:
|
||||
return OpenArena::KEY_DIVIDE;
|
||||
case VK_F1:
|
||||
return OpenArena::KEY_F1;
|
||||
case VK_F2:
|
||||
return OpenArena::KEY_F2;
|
||||
case VK_F3:
|
||||
return OpenArena::KEY_F3;
|
||||
case VK_F4:
|
||||
return OpenArena::KEY_F4;
|
||||
case VK_F5:
|
||||
return OpenArena::KEY_F5;
|
||||
case VK_F6:
|
||||
return OpenArena::KEY_F6;
|
||||
case VK_F7:
|
||||
return OpenArena::KEY_F7;
|
||||
case VK_F8:
|
||||
return OpenArena::KEY_F8;
|
||||
case VK_F9:
|
||||
return OpenArena::KEY_F9;
|
||||
case VK_F10:
|
||||
return OpenArena::KEY_F10;
|
||||
case VK_F11:
|
||||
return OpenArena::KEY_F11;
|
||||
case VK_F12:
|
||||
return OpenArena::KEY_F12;
|
||||
case VK_NUMLOCK:
|
||||
return OpenArena::KEY_NUMLOCK;
|
||||
case VK_SCROLL:
|
||||
return OpenArena::KEY_SCROLL;
|
||||
case VK_SEPARATOR:
|
||||
return OpenArena::KEY_SEPARATOR;
|
||||
case VK_OEM_1:
|
||||
return OpenArena::KEY_OEM_1;
|
||||
case VK_OEM_2:
|
||||
return OpenArena::KEY_OEM_2;
|
||||
case VK_OEM_3:
|
||||
return OpenArena::KEY_OEM_3;
|
||||
case VK_OEM_4:
|
||||
return OpenArena::KEY_OEM_4;
|
||||
case VK_OEM_5:
|
||||
return OpenArena::KEY_OEM_5;
|
||||
case VK_OEM_6:
|
||||
return OpenArena::KEY_OEM_6;
|
||||
case VK_OEM_7:
|
||||
return OpenArena::KEY_OEM_7;
|
||||
case VK_OEM_PERIOD:
|
||||
return OpenArena::KEY_OEM_PERIOD;
|
||||
case VK_OEM_PLUS:
|
||||
return OpenArena::KEY_OEM_PLUS;
|
||||
case VK_OEM_MINUS:
|
||||
return OpenArena::KEY_OEM_MINUS;
|
||||
case VK_OEM_COMMA:
|
||||
return OpenArena::KEY_OEM_COMMA;
|
||||
case VK_BACK:
|
||||
return OpenArena::KEY_BACK;
|
||||
case VK_TAB:
|
||||
return OpenArena::KEY_TAB;
|
||||
case '0':
|
||||
return OpenArena::KEY_0;
|
||||
case '1':
|
||||
return OpenArena::KEY_1;
|
||||
case '2':
|
||||
return OpenArena::KEY_2;
|
||||
case '3':
|
||||
return OpenArena::KEY_3;
|
||||
case '4':
|
||||
return OpenArena::KEY_4;
|
||||
case '5':
|
||||
return OpenArena::KEY_5;
|
||||
case '6':
|
||||
return OpenArena::KEY_6;
|
||||
case '7':
|
||||
return OpenArena::KEY_7;
|
||||
case '8':
|
||||
return OpenArena::KEY_8;
|
||||
case '9':
|
||||
return OpenArena::KEY_9;
|
||||
case 'A':
|
||||
return OpenArena::KEY_A;
|
||||
case 'B':
|
||||
return OpenArena::KEY_B;
|
||||
case 'C':
|
||||
return OpenArena::KEY_C;
|
||||
case 'D':
|
||||
return OpenArena::KEY_D;
|
||||
case 'E':
|
||||
return OpenArena::KEY_E;
|
||||
case 'F':
|
||||
return OpenArena::KEY_F;
|
||||
case 'G':
|
||||
return OpenArena::KEY_G;
|
||||
case 'H':
|
||||
return OpenArena::KEY_H;
|
||||
case 'I':
|
||||
return OpenArena::KEY_I;
|
||||
case 'J':
|
||||
return OpenArena::KEY_J;
|
||||
case 'K':
|
||||
return OpenArena::KEY_K;
|
||||
case 'L':
|
||||
return OpenArena::KEY_L;
|
||||
case 'M':
|
||||
return OpenArena::KEY_M;
|
||||
case 'N':
|
||||
return OpenArena::KEY_N;
|
||||
case 'O':
|
||||
return OpenArena::KEY_O;
|
||||
case 'P':
|
||||
return OpenArena::KEY_P;
|
||||
case 'Q':
|
||||
return OpenArena::KEY_Q;
|
||||
case 'R':
|
||||
return OpenArena::KEY_R;
|
||||
case 'S':
|
||||
return OpenArena::KEY_S;
|
||||
case 'T':
|
||||
return OpenArena::KEY_T;
|
||||
case 'U':
|
||||
return OpenArena::KEY_U;
|
||||
case 'V':
|
||||
return OpenArena::KEY_V;
|
||||
case 'W':
|
||||
return OpenArena::KEY_W;
|
||||
case 'X':
|
||||
return OpenArena::KEY_X;
|
||||
case 'Y':
|
||||
return OpenArena::KEY_Y;
|
||||
case 'Z':
|
||||
return OpenArena::KEY_Z;
|
||||
case VK_LBUTTON:
|
||||
return OpenArena::KEY_LBUTTON;
|
||||
case VK_RBUTTON:
|
||||
return OpenArena::KEY_RBUTTON;
|
||||
case VK_MBUTTON:
|
||||
return OpenArena::KEY_MBUTTON;
|
||||
default:
|
||||
return OpenArena::KEY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleConsoleKeyPress(OpenArena::Keys key)
|
||||
{
|
||||
//See if we need to hide the console
|
||||
level.defaultPlayer[0].controls.toggleConsole.FirstPosition();
|
||||
if(key == level.defaultPlayer[0].controls.toggleConsole.Retrieve())
|
||||
{
|
||||
level.showConsole = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(level.defaultPlayer[0].controls.toggleConsole.NextPosition() && level.showConsole)
|
||||
{
|
||||
if(level.defaultPlayer[0].controls.toggleConsole.Retrieve() == key)
|
||||
{
|
||||
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;
|
||||
default:
|
||||
char ascii = OpenArena::KeyToASCII(key, keys[OpenArena::KEY_SHIFT]);
|
||||
if(ascii != '\0')
|
||||
{
|
||||
level.UpdateConsole(ascii);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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
|
||||
408
src/x11.cpp
@@ -1,408 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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; index<level->numLights; 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 */
|
||||
40
src/x11.h
@@ -1,40 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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__ */
|
||||