--- a/.hgignore Mon Jun 27 13:39:46 2011 -0400
+++ b/.hgignore Tue Jun 28 17:57:54 2011 +0200
@@ -36,3 +36,16 @@
glob:*.orig
glob:*.bak
glob:*.rej
+glob:project_files/Android-build/SDL-android-project/jni/SDL*
+glob:project_files/Android-build/SDL-android-project/jni/freetype
+glob:project_files/Android-build/SDL-android-project/jni/tremor
+glob:project_files/Android-build/SDL-android-project/jni/mikmod
+glob:project_files/Android-build/SDL-android-project/jni/jpeg
+glob:project_files/Android-build/SDL-android-project/jni/png
+glob:project_files/Android-build/SDL-android-project/jni/Android.mk
+glob:project_files/Android-build/SDL-android-project/obj
+glob:project_files/Android-build/SDL-android-project/libs
+glob:project_files/Android-build/SDL-android-project/bin
+glob:project_files/Android-build/SDL-android-project/gen
+glob:project_files/Android-build/out
+glob:project_files/Android-build/DataPackage
--- a/hedgewars/SDLh.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/SDLh.pas Tue Jun 28 17:57:54 2011 +0200
@@ -35,13 +35,15 @@
{$ENDIF}
{$IFDEF UNIX}
- {$IFNDEF DARWIN}
+ {$IFNDEF DARWIN}
{$linklib c}
{$ENDIF}
{$IFDEF HAIKU}
{$linklib root}
{$ELSE}
- {$linklib pthread}
+ {$IFNDEF ANDROID}
+ {$linklib pthread}
+ {$ENDIF}
{$ENDIF}
{$ENDIF}
@@ -81,11 +83,19 @@
SDL_ImageLibName = 'SDL_image';
SDL_NetLibName = 'SDL_net';
{$ELSE}
- SDLLibName = 'libSDL.so';
- SDL_TTFLibName = 'libSDL_ttf.so';
- SDL_MixerLibName = 'libSDL_mixer.so';
- SDL_ImageLibName = 'libSDL_image.so';
- SDL_NetLibName = 'libSDL_net.so';
+ {$IFDEF ANDROID}
+ SDLLibName = 'SDL';
+ SDL_TTFLibName = 'libSDL_ttf.so';
+ SDL_MixerLibName = 'libSDL_mixer.so';
+ SDL_ImageLibName = 'libSDL_image.so';
+ SDL_NetLibName = 'libSDL_net.so';
+ {$ELSE}
+ SDLLibName = 'SDL';
+ SDL_TTFLibName = 'libSDL_ttf.so';
+ SDL_MixerLibName = 'libSDL_mixer.so';
+ SDL_ImageLibName = 'libSDL_image.so';
+ SDL_NetLibName = 'libSDL_net.so';
+ {$ENDIF}
{$ENDIF}
{$ENDIF}
@@ -345,7 +355,8 @@
alpha: Byte;
{$ENDIF}
end;
-
+
+ SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT);
PSDL_Surface = ^TSDL_Surface;
TSDL_Surface = record
@@ -473,7 +484,7 @@
type_: LongInt;
windowID: LongInt;
padding1, padding2: byte;
- x, y, z, xrel, yrel : LongInt;
+ x, y, z,xrel, yrel : LongInt;
pressure, pressure_max, pressure_min,
rotation, tilt, cursor: LongInt;
{$ELSE}
@@ -784,8 +795,13 @@
function SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
function SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
-procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
-function SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
+
+procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName ;
+
+function SDL_SetHint(name, value: PChar): boolean; cdecl; external SDLLibName;
+
+function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongInt): LongInt; cdecl; external SDLLibName;
+
{$ENDIF}
function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
@@ -850,7 +866,6 @@
function TTF_RenderUTF8_Solid(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
-
function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
@@ -981,6 +996,4 @@
(PByteArray(buf)^[1] shl 16) or
(PByteArray(buf)^[0] shl 24)
end;
-
end.
-
--- a/hedgewars/hwengine.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/hwengine.pas Tue Jun 28 17:57:54 2011 +0200
@@ -31,7 +31,7 @@
uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions,
- sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted;
+ sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted {$IFDEF ANDROID}, GLUnit {$ENDIF};
{$IFDEF HWLIBRARY}
procedure initEverything(complete:boolean);
@@ -150,8 +150,12 @@
PrevTime:= SDL_GetTicks;
while isTerminated = false do
begin
-
- while SDL_PollEvent(@event) <> 0 do
+{$IFDEF ANDROID}
+ SDL_PumpEvents();
+ while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0 do
+{$ELSE}
+ while SDL_PollEvent(@event) <> 0 do
+{$ENDIF}
begin
case event.type_ of
SDL_KEYDOWN: if GameState = gsChat then
@@ -211,9 +215,14 @@
begin
{$IFDEF HWLIBRARY}
cBits:= 32;
+ cTimerInterval:= 8;
+{$IFDEF ANDROID}
+ PathPrefix:= gameArgs[11];
+ cFullScreen:= true;
+{$ELSE}
+ PathPrefix:= 'Data';
cFullScreen:= false;
- cTimerInterval:= 8;
- PathPrefix:= 'Data';
+{$ENDIF}
UserPathPrefix:= '.';
cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
val(gameArgs[0], ipcPort);
@@ -341,7 +350,10 @@
if complete then
begin
- uAI.initModule;
+{$IFDEF ANDROID}
+ GLUnit.init;
+{$ENDIF}
+ uAI.initModule;
//uAIActions does not need initialization
//uAIAmmoTests does not need initialization
uAIMisc.initModule;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/log.pas Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,28 @@
+unit log;
+{$ifdef fpc}
+ {$mode delphi}
+{$endif}
+
+interface
+
+const libname='liblog.so';
+
+ ANDROID_LOG_UNKNOWN=0;
+ ANDROID_LOG_DEFAULT=1;
+ ANDROID_LOG_VERBOSE=2;
+ ANDROID_LOG_DEBUG=3;
+ ANDROID_LOG_INFO=4;
+ ANDROID_LOG_WARN=5;
+ ANDROID_LOG_ERROR=6;
+ ANDROID_LOG_FATAL=7;
+ ANDROID_LOG_SILENT=8;
+
+type android_LogPriority=integer;
+
+function __android_log_write(prio:longint;tag,text:pchar):longint; cdecl; external libname name '__android_log_write';
+
+//function __android_log_print(prio:longint;tag,print:pchar;params:array of pchar):longint; cdecl; external libname name '__android_log_print';
+
+implementation
+
+end.
--- a/hedgewars/options.inc Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/options.inc Tue Jun 28 17:57:54 2011 +0200
@@ -27,11 +27,22 @@
{$DEFINE GLunit:=GL}
+{$IFDEF ANDROID}
+ {$DEFINE SDL13}
+ {$DEFINE HWLIBRARY}
+ {$DEFINE S3D_DISABLED}
+ {$DEFINE LUA_DISABLED}
+ {$DEFINE GLunit:=gles11}
+ {$DEFINE DEBUGFILE}
+ {$DEFINE MOBILE}
+{$ENDIF}
+
{$IFDEF IPHONEOS}
{$DEFINE SDL13}
{$DEFINE HWLIBRARY}
{$DEFINE S3D_DISABLED}
{$DEFINE GLunit:=gles11}
+ {$DEFINE MOBILE}
{$ENDIF}
{$DEFINE DEBUGFILE}
--- a/hedgewars/uAI.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uAI.pas Tue Jun 28 17:57:54 2011 +0200
@@ -30,7 +30,7 @@
implementation
uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions,
- uAmmos, SysUtils{$IFDEF UNIX}, cthreads{$ENDIF}, uTypes,
+ uAmmos, SysUtils{$IFDEF UNIX}{$IFNDEF ANDROID}, cthreads{$ENDIF}{$ENDIF}, uTypes,
uVariables, uCommands, uUtils, uDebug;
var BestActions: TActions;
--- a/hedgewars/uCommandHandlers.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uCommandHandlers.pas Tue Jun 28 17:57:54 2011 +0200
@@ -84,8 +84,8 @@
begin
val(s, i, c);
if (c <> 0) or (i = 0) then exit;
-TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true);
-TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true)
+//TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old', true);
+//TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new', true)
end
end;
--- a/hedgewars/uConsole.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uConsole.pas Tue Jun 28 17:57:54 2011 +0200
@@ -26,9 +26,10 @@
procedure WriteToConsole(s: shortstring);
procedure WriteLnToConsole(s: shortstring);
function GetLastConsoleLine: shortstring;
+function ShortStringAsPChar(var s: shortstring): PChar;
implementation
-uses Types, uVariables, uUtils;
+uses Types, uVariables, uUtils {$IFDEF ANDROID}, log in 'log.pas'{$ENDIF};
const cLineWidth: LongInt = 0;
cLinesCount = 8;
@@ -52,6 +53,9 @@
done: boolean;
begin
{$IFNDEF NOCONSOLE}
+ {$IFDEF ANDROID}
+ Log.__android_log_write(Log.Android_LOG_DEBUG, 'HW_Engine', ShortStringAsPChar(s));
+{$ELSE}
AddFileLog('[Con] ' + s);
Write(stderr, s);
done:= false;
@@ -70,18 +74,21 @@
done:= (Length(s) = 0);
end;
{$ENDIF}
+{$ENDIF}
end;
procedure WriteLnToConsole(s: shortstring);
begin
{$IFNDEF NOCONSOLE}
WriteToConsole(s);
+{$IFNDEF ANDROID}
WriteLn(stderr);
inc(CurrLine);
if CurrLine = cLinesCount then
CurrLine:= 0;
PByte(@ConsoleLines[CurrLine].s)^:= 0
{$ENDIF}
+{$ENDIF}
end;
@@ -118,4 +125,12 @@
end;
+Function ShortStringAsPChar(var S: ShortString) : PChar;
+Var NewString : String;
+Begin
+if Length(S) = High(S) then Dec(S[0]);
+s[Ord(Length(s))+1] := #0;
+Result := @S[1];
+End;
+
end.
--- a/hedgewars/uLand.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uLand.pas Tue Jun 28 17:57:54 2011 +0200
@@ -1358,7 +1358,7 @@
if digest = '' then
digest:= s
else
- TryDo(s = digest, 'Different maps generated, sorry', true);
+// TryDo(s = digest, 'Different maps generated, sorry', true);
end;
procedure chSendLandDigest(var s: shortstring);
--- a/hedgewars/uStore.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uStore.pas Tue Jun 28 17:57:54 2011 +0200
@@ -533,7 +533,7 @@
{$ENDIF}
begin
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
{$ELSE}
@@ -952,7 +952,7 @@
y:= SDL_WINDOWPOS_CENTERED_MASK;
flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN;
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
// make the sdl window appear on the second monitor when present
x:= x or (SDL_GetNumVideoDisplays() - 1);
y:= y or (SDL_GetNumVideoDisplays() - 1);
--- a/hedgewars/uUtils.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uUtils.pas Tue Jun 28 17:57:54 2011 +0200
@@ -21,7 +21,7 @@
unit uUtils;
interface
-uses uTypes, uFloat, GLunit;
+uses uTypes, uFloat, GLunit, uConsole;
procedure SplitBySpace(var a, b: shortstring);
procedure SplitByChar(var a, b: ansistring; c: char);
@@ -262,9 +262,13 @@
begin
s:= s;
{$IFDEF DEBUGFILE}
+{$IFDEF ANDROID}
+ WriteToConsole(s);
+{$ELSE}
writeln(f, GameTicks: 6, ': ', s);
flush(f)
{$ENDIF}
+{$ENDIF}
end;
--- a/hedgewars/uWorld.pas Mon Jun 27 13:39:46 2011 -0400
+++ b/hedgewars/uWorld.pas Tue Jun 28 17:57:54 2011 +0200
@@ -180,7 +180,7 @@
WorldDx:= - (LAND_WIDTH div 2) + cScreenWidth div 2;
WorldDy:= - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
AMSlotSize:= 33;
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
AMxOffset:= 10;
AMyOffset:= 10 + 123; // moved downwards
AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset;
@@ -245,7 +245,7 @@
SlotsNum:= 0;
x:= (cScreenWidth shr 1) - AMWidth + AMxShift;
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
Slot:= cMaxSlotIndex;
x:= x - cOffsetY;
y:= AMyOffset;
@@ -369,7 +369,7 @@
RenderWeaponTooltip(amSel)
end;
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
@@ -393,7 +393,7 @@
else
FreeWeaponTooltip;
if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, AMyOffset - 1);
{$ELSE}
ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40));
@@ -877,7 +877,7 @@
SetScale(cDefaultZoomLevel);
// Turn time
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
offsetX:= cScreenHeight - 13;
{$ELSE}
offsetX:= 48;
@@ -966,7 +966,7 @@
if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
// Wind bar
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
offsetX:= cScreenHeight - 13;
offsetY:= (cScreenWidth shr 1) + 74;
{$ELSE}
@@ -1018,7 +1018,7 @@
end;
// fps
-{$IFDEF IPHONEOS}
+{$IFDEF MOBILE}
offsetX:= 8;
{$ELSE}
offsetX:= 10;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/Makefile.android Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,27 @@
+#USER DEFINED
+FPC_DIR=/home/richard/SoftDev/fpc-2.4.4
+ANDROID_NDK=/home/richard/SoftDev/android/android-ndk-r5b
+ANDROID_SDK=/home/richard/SoftDev/android/android-sdk-linux_86
+#END USER DEFINED
+
+SDL_ANDROID_DIR=./SDL-android-project
+ANDROID_API_LVL=5
+
+PPCROSSARM=$(FPC_DIR)/compiler/ppcrossarm
+PPCROSSARM_FLAGS= -Xd -O- -Tlinux -XParm-linux-androideabi- -vwnh -XS -a-
+PPCROSSARM_INCLUDES= \
+ -FD$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin \
+ -Fu$(FPC_DIR)/rtl/units/arm-linux \
+ -Fl$(ANDROID_NDK)/platforms/android-$(ANDROID_API_LVL)/arch-arm/usr/lib \
+ -Fl$(SDL_ANDROID_DIR)/libs/armeabi \
+ -Fl$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux/arm-linux-androideabi/4.4.3/ \
+#LINKERFLAGS= -k"--static"
+FPC_DEFINES=-dandroid -darm
+
+
+all:
+ -mkdir out
+ $(PPCROSSARM) $(LINKERFLAGS) $(PPCROSSARM_FLAGS) $(PPCROSSARM_INCLUDES) $(FPC_DEFINES) -oout/libhwengine.so ../../hedgewars/hwLibrary.pas
+ cp out/libhwengine.so SDL-android-project/libs/armeabi
+clean:
+ rm out/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.hedgewars"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:label="@string/app_name" android:icon="@drawable/icon">
+ <activity android:name="SDLActivity"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+ android:screenOrientation='landscape'>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/build.properties Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/build.xml Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="SDLApp" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked in in Version
+ Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the default property values
+ used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ application.package
+ the name of your application package as defined in the manifest. Used by the
+ 'uninstall' rule.
+ source.dir
+ the name of the source directory. Default is 'src'.
+ out.dir
+ the name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should be updated
+ using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android' tool, as well
+ as ADT.
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+ <!-- Execute the Android Setup task that will setup some properties specific to the target,
+ and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/templates/android_rules.xml
+
+ To customize some build steps for your project:
+ - copy the content of the main node <project> from android_rules.xml
+ - paste it in this build.xml below the <setup /> task.
+ - disable the import by changing the setup task below to <setup import="false" />
+
+ This will ensure that the properties are setup correctly but that your customized
+ build steps are used.
+ -->
+ <setup />
+
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/default.properties Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/Android.mk Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,2 @@
+include $(call all-subdir-makefiles)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,263 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2011 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+#include "SDL_stdinc.h"
+
+#include "SDL_android.h"
+
+extern "C" {
+#include "../../events/SDL_events_c.h"
+#include "../../video/android/SDL_androidkeyboard.h"
+#include "../../video/android/SDL_androidtouch.h"
+#include "../../video/android/SDL_androidvideo.h"
+
+/* Impelemented in audio/android/SDL_androidaudio.c */
+extern void Android_RunAudioThread();
+} // C
+
+/*******************************************************************************
+ This file links the Java side of Android with libsdl
+*******************************************************************************/
+#include <jni.h>
+#include <android/log.h>
+
+
+/*******************************************************************************
+ Globals
+*******************************************************************************/
+static JNIEnv* mEnv = NULL;
+static JNIEnv* mAudioEnv = NULL;
+
+// Main activity
+static jclass mActivityClass;
+
+// method signatures
+static jmethodID midCreateGLContext;
+static jmethodID midFlipBuffers;
+static jmethodID midAudioInit;
+static jmethodID midAudioWriteShortBuffer;
+static jmethodID midAudioWriteByteBuffer;
+static jmethodID midAudioQuit;
+
+// Accelerometer data storage
+static float fLastAccelerometer[3];
+
+
+/*******************************************************************************
+ Functions called by JNI
+*******************************************************************************/
+
+// Library init
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+ return JNI_VERSION_1_4;
+}
+
+// Called before SDL_main() to initialize JNI bindings
+extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls)
+{
+ __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
+
+ mEnv = env;
+ mActivityClass = cls;
+
+ midCreateGLContext = mEnv->GetStaticMethodID(mActivityClass,
+ "createGLContext","(II)Z");
+ midFlipBuffers = mEnv->GetStaticMethodID(mActivityClass,
+ "flipBuffers","()V");
+ midAudioInit = mEnv->GetStaticMethodID(mActivityClass,
+ "audioInit", "(IZZI)Ljava/lang/Object;");
+ midAudioWriteShortBuffer = mEnv->GetStaticMethodID(mActivityClass,
+ "audioWriteShortBuffer", "([S)V");
+ midAudioWriteByteBuffer = mEnv->GetStaticMethodID(mActivityClass,
+ "audioWriteByteBuffer", "([B)V");
+ midAudioQuit = mEnv->GetStaticMethodID(mActivityClass,
+ "audioQuit", "()V");
+
+ if(!midCreateGLContext || !midFlipBuffers || !midAudioInit ||
+ !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) {
+ __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
+ }
+}
+
+// Resize
+extern "C" void Java_org_hedgewars_SDLActivity_onNativeResize(
+ JNIEnv* env, jclass jcls,
+ jint width, jint height, jint format)
+{
+ Android_SetScreenResolution(width, height, format);
+}
+
+// Keydown
+extern "C" void Java_org_hedgewars_SDLActivity_onNativeKeyDown(
+ JNIEnv* env, jclass jcls, jint keycode)
+{
+ Android_OnKeyDown(keycode);
+}
+
+// Keyup
+extern "C" void Java_org_hedgewars_SDLActivity_onNativeKeyUp(
+ JNIEnv* env, jclass jcls, jint keycode)
+{
+ Android_OnKeyUp(keycode);
+}
+
+// Touch
+extern "C" void Java_org_hedgewars_SDLActivity_onNativeTouch(
+ JNIEnv* env, jclass jcls,
+ jint action, jfloat x, jfloat y, jfloat p)
+{
+ Android_OnTouch(action, x, y, p);
+}
+
+// Accelerometer
+extern "C" void Java_org_hedgewars_SDLActivity_onNativeAccel(
+ JNIEnv* env, jclass jcls,
+ jfloat x, jfloat y, jfloat z)
+{
+ fLastAccelerometer[0] = x;
+ fLastAccelerometer[1] = y;
+ fLastAccelerometer[2] = z;
+}
+
+// Quit
+extern "C" void Java_org_hedgewars_SDLActivity_nativeQuit(
+ JNIEnv* env, jclass cls)
+{
+ // Inject a SDL_QUIT event
+ SDL_SendQuit();
+}
+
+extern "C" void Java_org_hedgewars_SDLActivity_nativeRunAudioThread(
+ JNIEnv* env, jclass cls)
+{
+ /* This is the audio thread, with a different environment */
+ mAudioEnv = env;
+
+ Android_RunAudioThread();
+}
+
+
+/*******************************************************************************
+ Functions called by SDL into Java
+*******************************************************************************/
+extern "C" SDL_bool Android_JNI_CreateContext(int majorVersion, int minorVersion)
+{
+ if (mEnv->CallStaticBooleanMethod(mActivityClass, midCreateGLContext, majorVersion, minorVersion)) {
+ return SDL_TRUE;
+ } else {
+ return SDL_FALSE;
+ }
+}
+
+extern "C" void Android_JNI_SwapWindow()
+{
+ mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers);
+}
+
+extern "C" void Android_JNI_SetActivityTitle(const char *title)
+{
+ jmethodID mid;
+
+ mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
+ if (mid) {
+ mEnv->CallStaticVoidMethod(mActivityClass, mid, mEnv->NewStringUTF(title));
+ }
+}
+
+extern "C" void Android_JNI_GetAccelerometerValues(float values[3])
+{
+ int i;
+ for (i = 0; i < 3; ++i) {
+ values[i] = fLastAccelerometer[i];
+ }
+}
+
+//
+// Audio support
+//
+static jboolean audioBuffer16Bit = JNI_FALSE;
+static jboolean audioBufferStereo = JNI_FALSE;
+static jobject audioBuffer = NULL;
+static void* audioBufferPinned = NULL;
+
+extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
+{
+ int audioBufferFrames;
+
+ __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
+ audioBuffer16Bit = is16Bit;
+ audioBufferStereo = channelCount > 1;
+
+ audioBuffer = mEnv->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
+
+ if (audioBuffer == NULL) {
+ __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
+ return 0;
+ }
+ audioBuffer = mEnv->NewGlobalRef(audioBuffer);
+
+ jboolean isCopy = JNI_FALSE;
+ if (audioBuffer16Bit) {
+ audioBufferPinned = mEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
+ audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer);
+ } else {
+ audioBufferPinned = mEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
+ audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer);
+ }
+ if (audioBufferStereo) {
+ audioBufferFrames /= 2;
+ }
+
+ return audioBufferFrames;
+}
+
+extern "C" void * Android_JNI_GetAudioBuffer()
+{
+ return audioBufferPinned;
+}
+
+extern "C" void Android_JNI_WriteAudioBuffer()
+{
+ if (audioBuffer16Bit) {
+ mAudioEnv->ReleaseShortArrayElements((jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
+ mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
+ } else {
+ mAudioEnv->ReleaseByteArrayElements((jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
+ mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
+ }
+
+ /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */
+}
+
+extern "C" void Android_JNI_CloseAudioDevice()
+{
+ mEnv->CallStaticVoidMethod(mActivityClass, midAudioQuit);
+
+ if (audioBuffer) {
+ mEnv->DeleteGlobalRef(audioBuffer);
+ audioBuffer = NULL;
+ audioBufferPinned = NULL;
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,49 @@
+
+/* Include the SDL main definition header */
+#include "SDL_main.h"
+
+/*******************************************************************************
+ Functions called by JNI
+*******************************************************************************/
+#include <jni.h>
+
+// Called before SDL_main() to initialize JNI bindings in SDL library
+extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls);
+
+// Library init
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+ return JNI_VERSION_1_4;
+}
+
+// Start up the SDL app
+extern "C" void Java_org_hedgewars_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobjectArray strArray)
+{
+ /* This interface could expand with ABI negotiation, calbacks, etc. */
+ SDL_Android_Init(env, cls);
+
+ //Get the String array from java
+ int argc = env->GetArrayLength(strArray);
+ char *argv[argc];
+ jstring jstringArgv[argc];
+ for(int i = 0; i < argc; i++){
+ jstringArgv[i] = (jstring)env->GetObjectArrayElement(strArray, i); //get the element
+ argv[i] = (char*)malloc(sizeof(char) * env->GetStringLength(jstringArgv[i]));
+ strcpy(argv[i], env->GetStringUTFChars(jstringArgv[i], JNI_FALSE)); //copy it to a mutable location
+ //Don't release memory the JAVA GC will take care of it
+ //env->ReleaseStringChars(jstringArgv[i], (jchar*)argv[i]);
+ }
+
+ /* Run the application code! */
+ int status;
+ status = SDL_main(argc, argv);
+
+ //Clean up argv
+ for(int i = 0; i < argc; i++){
+ }
+
+ /* We exit here for consistency with other platforms. */
+ exit(status);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/Android.mk Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := SDL_net
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../SDL/include $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -O3
+
+LOCAL_CPP_EXTENSION := .cpp
+
+LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.c))
+
+LOCAL_SHARED_LIBRARIES := SDL
+LOCAL_STATIC_LIBRARIES :=
+LOCAL_LDLIBS :=
+
+include $(BUILD_SHARED_LIBRARY)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/CHANGES Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,83 @@
+1.2.7:
+Joakim L. Gilje - Sat Jul 14 22:54:37 PDT 2007
+ * Set server TCP sockets to blocking mode on Mac OS X, Solaris, etc.
+
+1.2.6:
+Sam Lantinga - Sun Apr 30 01:48:40 PDT 2006
+ * Added gcc-fat.sh for generating Universal binaries on Mac OS X
+ * Updated libtool support to version 1.5.22
+Sam Lantinga - Wed Nov 19 00:23:44 PST 2003
+ * Updated libtool support for new mingw32 DLL build process
+Shard - Thu, 05 Jun 2003 09:30:20 -0500
+ * Fixed compiling on BeOS, which may not have SO_BROADCAST
+Kyle Davenport - Sat, 19 Apr 2003 17:13:31 -0500
+ * Added .la files to the development RPM, fixing RPM build on RedHat 8
+
+1.2.5:
+Luc-Olivier de Charrière - Sun, 05 Jan 2003 22:04:29 +0100
+ * Added support for sending UDP broadcast packets
+Sam Lantinga - Sun Oct 20 20:54:41 PDT 2002
+ * Added shared library support for MacOS X
+Sam Lantinga - Sat Aug 24 18:16:08 PDT 2002
+ * It is now safe to nest calls to SDLNet_Init() / SDLNet_Quit()
+Gaëtan de Menten - Sat Aug 24 18:08:39 PDT 2002
+ * Fixed UDP virtual address bind bug
+
+1.2.4:
+Sam Lantinga - Sat Apr 13 07:49:47 PDT 2002
+ * Updated autogen.sh for new versions of automake
+ * Specify the SDL API calling convention (C by default)
+Stephane Magnenat - Wed Feb 13 15:28:04 PST 2002
+ * Sockets are created with the SO_REUSEADDR flag by default
+Juergen Wind - Wed Feb 13 09:21:55 PST 2002
+ * Fixed data alignment problems on IRIX
+
+1.2.3:
+Sam Lantinga - Fri Oct 26 07:15:28 PDT 2001
+ * Fixed byte order read/write macros on sparc
+Jonathan Atkins - Sun Sep 23 10:44:27 PDT 2001
+ * Fixed non-blocking socket flags on Windows
+
+1.2.2:
+Sam Lantinga - Sun Jul 22 16:41:44 PDT 2001
+ * Added Project Builder projects for building MacOS X framework
+Masahiro Minami - Sun, 27 May 2001 02:10:35 +0900
+ * Added working MacOS Open Transport support
+
+1.2.1:
+Sam Lantinga - Tue Apr 17 11:42:13 PDT 2001
+ * Cleaned up swap function definitions in SDL_net.h
+ * Added the swap functions back in for binary compatibility
+Paul Jenner - Sat, 14 Apr 2001 09:20:38 -0700 (PDT)
+ * Added support for building RPM directly from tar archive
+
+1.2.0:
+Sam Lantinga - Wed Apr 4 12:42:20 PDT 2001
+ * Synchronized release version with SDL 1.2.0
+
+1.1.2:
+Sam Lantinga - Sat Feb 10 16:33:59 PST 2001
+ * SDL_net works with the sockets API out of the box on MacOS X.
+Paul S Jenner - Sun, 4 Feb 2001 03:58:44 -0800 (PST)
+ * Added an RPM spec file
+Patrick Levin - Mon, 8 Jan 2001 23:20:11 +0100
+ * Fixed non-blocking socket modes on Win32
+John Lawrence - Mon, 13 Nov 2000 10:39:48 -0800
+ * Fixed compile problem with MSVC++ (type casting)
+
+1.1.1:
+Sam Lantinga - Sat Jul 1 15:20:51 PDT 2000
+ * Modified chat example to work with GUIlib 1.1.0
+Roy Wood - Fri Jun 30 10:41:05 PDT 2000
+ * A few MacOS fixes (not yet complete)
+
+1.1.0:
+Andreas Umbach - Sat May 27 14:44:06 PDT 2000
+ * Suggested non-blocking server sockets
+ * Suggested setting TCP_NODELAY by default
+Roy Wood - Sat May 27 14:41:42 PDT 2000
+ * Ported to MacOS (not yet complete)
+
+1.0.2:
+Miguel Angel Blanch - Sat, 22 Apr 2000 23:06:05
+ * Implemented SDLNet_ResolveIP()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/COPYING Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,458 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/README Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,27 @@
+
+SDL_net 1.2
+
+The latest version of this library is available from:
+http://www.libsdl.org/projects/SDL_net/
+
+This is an example portable network library for use with SDL.
+It is available under the GNU Library General Public License.
+The API can be found in the file SDL_net.h
+This library supports UNIX, Windows, MacOS Classic, MacOS X,
+BeOS and QNX.
+
+The demo program is a chat client and server.
+The chat client requires the sample GUI library available at:
+http://www.libsdl.org/projects/GUIlib/
+The chat client connects to the server via TCP, registering itself.
+The server sends back a list of connected clients, and keeps the
+client updated with the status of other clients.
+Every line of text from a client is sent via UDP to every other client.
+
+Note that this isn't necessarily how you would want to write a chat
+program, but it demonstrates how to use the basic features of the
+network library.
+
+Enjoy!
+ -Sam Lantinga and Roy Wood
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnet.c Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,430 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDLnet.c 2207 2006-04-20 16:48:25Z slouken $ */
+
+#include <string.h>
+
+#include "SDL_endian.h"
+
+#include "SDLnetsys.h"
+#include "SDL_net.h"
+
+
+const SDL_version *SDLNet_Linked_Version(void)
+{
+ static SDL_version linked_version;
+ SDL_NET_VERSION(&linked_version);
+ return(&linked_version);
+}
+
+/* Since the UNIX/Win32/BeOS code is so different from MacOS,
+ we'll just have two completely different sections here.
+*/
+static int SDLNet_started = 0;
+
+#ifdef MACOS_OPENTRANSPORT
+
+#include <Events.h>
+
+typedef struct
+{
+ Uint8 stat;
+ InetSvcRef dns;
+}DNSStatus, *DNSStatusRef;
+
+enum
+{
+ dnsNotReady = 0,
+ dnsReady = 1,
+ dnsResolved = 2,
+ dnsError = 255
+};
+
+//static InetSvcRef dns = 0;
+static DNSStatus dnsStatus;
+Uint32 OTlocalhost = 0;
+
+/* We need a notifier for opening DNS.*/
+/* ( 010311 masahiro minami<elsur@aaa.letter.co.jp>) */
+static pascal void OpenDNSNotifier(
+ void* context, OTEventCode code, OTResult result, void* cookie )
+{
+ switch( code )
+ {
+ case T_OPENCOMPLETE:
+ // DNS is ready now.
+ if( result == kOTNoError )
+ {
+ dnsStatus.dns = (InetSvcRef)cookie;
+ dnsStatus.stat = dnsReady;
+ }
+ else
+ {
+ SDLNet_SetError("T_DNRSTRINGTOADDRCOMPLETE event returned an error");
+ dnsStatus.dns = NULL;
+ dnsStatus.stat = dnsError;
+ }
+ break;
+ case T_DNRSTRINGTOADDRCOMPLETE:
+ // DNR resolved the name to address
+ // WORK IN PROGRESS (TODO )
+ dnsStatus.stat = dnsResolved;
+ break;
+ default:
+ if( result != kOTNoError )
+ dnsStatus.stat = dnsError;
+ }
+ // Is there anything else to be done here ???
+ // ( 010311 masahiro minami<elsur@aaa.letter.co.jp> )
+ // (TODO)
+}
+
+/* Local functions for initializing and cleaning up the DNS resolver */
+static int OpenDNS(void)
+{
+ int retval;
+ OSStatus status;
+
+ retval = 0;
+ status = OTAsyncOpenInternetServices(
+ kDefaultInternetServicesPath, 0, OpenDNSNotifier, NULL);
+ if ( status == noErr ) {
+ InetInterfaceInfo info;
+
+ dnsStatus.stat = dnsNotReady;
+
+ while( dnsStatus.stat != dnsError && dnsStatus.dns == NULL)
+ {
+ // what's to be done ? Yield ? WaitNextEvent ? or what ?
+ // ( 010311 masahiro minami<elsur@aaa.letter.co.jp> )
+ //YieldToAnyThread();
+ }
+ /* Get the address of the local system -
+ What should it be if ethernet is off?
+ */
+ OTInetGetInterfaceInfo(&info, kDefaultInetInterface);
+ OTlocalhost = info.fAddress;
+ } else {
+ SDLNet_SetError("Unable to open DNS handle");
+ retval = status;
+ }
+
+ return(retval);
+}
+
+static void CloseDNS(void)
+{
+ if ( dnsStatus.dns ) {
+ OTCloseProvider(dnsStatus.dns);
+ dnsStatus.dns = 0;
+ dnsStatus.stat = dnsNotReady;
+ }
+
+ OTlocalhost = 0;
+}
+
+/* Initialize/Cleanup the network API */
+int SDLNet_Init(void)
+{
+ OSStatus status;
+ int retval;
+
+ dnsStatus.stat = dnsNotReady;
+ dnsStatus.dns = 0;
+
+
+ retval = 0;
+ if ( ! SDLNet_started ) {
+ status = InitOpenTransport();
+ if ( status == noErr ) {
+ retval = OpenDNS();
+ if ( retval < 0 ) {
+ SDLNet_Quit();
+ }
+ } else {
+ SDLNet_SetError("Unable to initialize Open Transport");
+ retval = status;
+ }
+ }
+ if ( retval == 0 ) {
+ ++SDLNet_started;
+ }
+ return(retval);
+}
+
+void SDLNet_Quit(void)
+{
+ if ( SDLNet_started == 0 ) {
+ return;
+ }
+ if ( --SDLNet_started == 0 ) {
+ CloseDNS();
+ CloseOpenTransport();
+ }
+}
+
+/* Resolve a host name and port to an IP address in network form */
+int SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port)
+{
+ int retval = 0;
+
+ /* Perform the actual host resolution */
+ if ( host == NULL ) {
+ address->host = INADDR_ANY;
+ } else {
+/* int a[4];
+
+ address->host = INADDR_NONE;
+
+ if ( sscanf(host, "%d.%d.%d.%d", a, a+1, a+2, a+3) == 4 ) {
+ if ( !(a[0] & 0xFFFFFF00) && !(a[1] & 0xFFFFFF00) &&
+ !(a[2] & 0xFFFFFF00) && !(a[3] & 0xFFFFFF00) ) {
+ address->host = ((a[0] << 24) |
+ (a[1] << 16) |
+ (a[2] << 8) | a[3]);
+ if ( address->host == 0x7F000001 ) {
+ address->host = OTlocalhost;
+ }
+ }
+ }
+
+ if ( address->host == INADDR_NONE ) {*/
+ InetHostInfo hinfo;
+
+ /* Check for special case - localhost */
+ if ( strcmp(host, "localhost") == 0 )
+ return(SDLNet_ResolveHost(address, "127.0.0.1", port));
+
+ /* Have OpenTransport resolve the hostname for us */
+ retval = OTInetStringToAddress(dnsStatus.dns, (char *)host, &hinfo);
+ if (retval == noErr) {
+ while( dnsStatus.stat != dnsResolved )
+ {WaitNextEvent(everyEvent, 0, 1, NULL );}
+ address->host = hinfo.addrs[0];
+ }
+ //}
+ }
+
+ address->port = SDL_SwapBE16(port);
+
+ /* Return the status */
+ return(retval);
+}
+
+/* Resolve an ip address to a host name in canonical form.
+ If the ip couldn't be resolved, this function returns NULL,
+ otherwise a pointer to a static buffer containing the hostname
+ is returned. Note that this function is not thread-safe.
+*/
+/* MacOS implementation by Roy Wood
+ */
+const char *SDLNet_ResolveIP(IPaddress *ip)
+{
+ if (ip != nil)
+ {
+ InetHost theIP;
+ static InetDomainName theInetDomainName;
+ OSStatus theOSStatus;
+
+
+ /* Default result will be null string */
+
+ theInetDomainName[0] = '\0';
+
+
+ /* Do a reverse DNS lookup */
+
+ theIP = ip->host;
+
+ theOSStatus = OTInetAddressToName(dnsStatus.dns,theIP,theInetDomainName);
+
+ /* If successful, return the result */
+
+ if (theOSStatus == kOTNoError)
+ {
+ while( dnsStatus.stat != dnsResolved )
+ { /*should we yield or what ? */ }
+ return(theInetDomainName);
+ }
+ }
+
+ SDLNet_SetError("Can't perform reverse DNS lookup");
+
+ return(NULL);
+}
+
+#else /* !MACOS_OPENTRANSPORT */
+
+#ifndef __USE_W32_SOCKETS
+#include <signal.h>
+#endif
+
+/* Initialize/Cleanup the network API */
+int SDLNet_Init(void)
+{
+ if ( !SDLNet_started ) {
+#ifdef __USE_W32_SOCKETS
+ /* Start up the windows networking */
+ WORD version_wanted = MAKEWORD(1,1);
+ WSADATA wsaData;
+
+ if ( WSAStartup(version_wanted, &wsaData) != 0 ) {
+ SDLNet_SetError("Couldn't initialize Winsock 1.1\n");
+ return(-1);
+ }
+#else
+ /* SIGPIPE is generated when a remote socket is closed */
+ void (*handler)(int);
+ handler = signal(SIGPIPE, SIG_IGN);
+ if ( handler != SIG_DFL ) {
+ signal(SIGPIPE, handler);
+ }
+#endif
+ }
+ ++SDLNet_started;
+ return(0);
+}
+void SDLNet_Quit(void)
+{
+ if ( SDLNet_started == 0 ) {
+ return;
+ }
+ if ( --SDLNet_started == 0 ) {
+#ifdef __USE_W32_SOCKETS
+ /* Clean up windows networking */
+ if ( WSACleanup() == SOCKET_ERROR ) {
+ if ( WSAGetLastError() == WSAEINPROGRESS ) {
+ WSACancelBlockingCall();
+ WSACleanup();
+ }
+ }
+#else
+ /* Restore the SIGPIPE handler */
+ void (*handler)(int);
+ handler = signal(SIGPIPE, SIG_DFL);
+ if ( handler != SIG_IGN ) {
+ signal(SIGPIPE, handler);
+ }
+#endif
+ }
+}
+
+/* Resolve a host name and port to an IP address in network form */
+int SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port)
+{
+ int retval = 0;
+
+ /* Perform the actual host resolution */
+ if ( host == NULL ) {
+ address->host = INADDR_ANY;
+ } else {
+ address->host = inet_addr(host);
+ if ( address->host == INADDR_NONE ) {
+ struct hostent *hp;
+
+ hp = gethostbyname(host);
+ if ( hp ) {
+ memcpy(&address->host,hp->h_addr,hp->h_length);
+ } else {
+ retval = -1;
+ }
+ }
+ }
+ address->port = SDL_SwapBE16(port);
+
+ /* Return the status */
+ return(retval);
+}
+
+/* Resolve an ip address to a host name in canonical form.
+ If the ip couldn't be resolved, this function returns NULL,
+ otherwise a pointer to a static buffer containing the hostname
+ is returned. Note that this function is not thread-safe.
+*/
+/* Written by Miguel Angel Blanch.
+ * Main Programmer of Arianne RPG.
+ * http://come.to/arianne_rpg
+ */
+const char *SDLNet_ResolveIP(IPaddress *ip)
+{
+ struct hostent *hp;
+
+ hp = gethostbyaddr((char *)&ip->host, 4, AF_INET);
+ if ( hp != NULL ) {
+ return hp->h_name;
+ }
+ return NULL;
+}
+
+#endif /* MACOS_OPENTRANSPORT */
+
+#if !SDL_DATA_ALIGNED /* function versions for binary compatibility */
+
+/* Write a 16 bit value to network packet buffer */
+#undef SDLNet_Write16
+void SDLNet_Write16(Uint16 value, void *areap)
+{
+ (*(Uint16 *)(areap) = SDL_SwapBE16(value));
+}
+
+/* Write a 32 bit value to network packet buffer */
+#undef SDLNet_Write32
+void SDLNet_Write32(Uint32 value, void *areap)
+{
+ *(Uint32 *)(areap) = SDL_SwapBE32(value);
+}
+
+/* Read a 16 bit value from network packet buffer */
+#undef SDLNet_Read16
+Uint16 SDLNet_Read16(void *areap)
+{
+ return (SDL_SwapBE16(*(Uint16 *)(areap)));
+}
+
+/* Read a 32 bit value from network packet buffer */
+#undef SDLNet_Read32
+Uint32 SDLNet_Read32(void *areap)
+{
+ return (SDL_SwapBE32(*(Uint32 *)(areap)));
+}
+
+#endif /* !SDL_DATA_ALIGNED */
+
+
+#ifdef USE_GUSI_SOCKETS
+
+/* Configure Socket Factories */
+
+void GUSISetupFactories()
+{
+ GUSIwithInetSockets();
+}
+
+/* Configure File Devices */
+
+void GUSISetupDevices()
+{
+ return;
+}
+
+#endif /* USE_GUSI_SOCKETS */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnetTCP.c Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,953 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDLnetTCP.c 3280 2007-07-15 05:55:42Z slouken $ */
+
+#include "SDLnetsys.h"
+#include "SDL_net.h"
+
+/* The network API for TCP sockets */
+
+/* Since the UNIX/Win32/BeOS code is so different from MacOS,
+ we'll just have two completely different sections here.
+*/
+
+#ifdef MACOS_OPENTRANSPORT
+
+#include <Events.h>
+#include <Threads.h>
+#include <OpenTransport.h>
+#include <OpenTptInternet.h>
+#include <OTDebug.h>
+
+struct _TCPsocket {
+ int ready;
+ SOCKET channel;
+
+ // These are taken from GUSI interface.
+ // I'm not sure if it's really necessary here yet
+ // ( masahiro minami<elsur@aaa.letter.co.jp> )
+ // ( 01/02/19 )
+ OTEventCode curEvent;
+ OTEventCode newEvent;
+ OTEventCode event;
+ OTEventCode curCompletion;
+ OTEventCode newCompletion;
+ OTEventCode completion;
+ OSStatus error;
+ TEndpointInfo info;
+ Boolean readShutdown;
+ Boolean writeShutdown;
+ Boolean connected;
+ OTConfigurationRef config; // Master configuration. you can clone this.
+ TCPsocket nextListener;
+ // ( end of new members --- masahiro minami<elsur@aaa.letter.co.jp>
+
+ IPaddress remoteAddress;
+ IPaddress localAddress;
+ int sflag;
+
+ // Maybe we don't need this---- it's from original SDL_net
+ // (masahiro minami<elsur@aaa.letter.co.jp>)
+ // ( 01/02/20 )
+ int rcvdPassConn;
+};
+
+// To be used in WaitNextEvent() here and there....
+// (010311 masahiro minami<elsur@aaa.letter.co.jp>)
+EventRecord macEvent;
+
+#if TARGET_API_MAC_CARBON
+/* for Carbon */
+OTNotifyUPP notifier;
+#endif
+
+/* Input: ep - endpointref on which to negotiate the option
+ enableReuseIPMode - desired option setting - true/false
+ Return: kOTNoError indicates that the option was successfully negotiated
+ OSStatus is an error if < 0, otherwise, the status field is
+ returned and is > 0.
+
+ IMPORTANT NOTE: The endpoint is assumed to be in synchronous more, otherwise
+ this code will not function as desired
+*/
+
+/*
+NOTE: As this version is written async way, we don't use this function...
+(010526) masahiro minami<elsur@aaa.letter.co.jp>
+*/
+/*
+OSStatus DoNegotiateIPReuseAddrOption(EndpointRef ep, Boolean enableReuseIPMode)
+
+{
+ UInt8 buf[kOTFourByteOptionSize]; // define buffer for fourByte Option size
+ TOption* opt; // option ptr to make items easier to access
+ TOptMgmt req;
+ TOptMgmt ret;
+ OSStatus err;
+
+ if (!OTIsSynchronous(ep))
+ {
+ return (-1);
+ }
+ opt = (TOption*)buf; // set option ptr to buffer
+ req.opt.buf = buf;
+ req.opt.len = sizeof(buf);
+ req.flags = T_NEGOTIATE; // negotiate for option
+
+ ret.opt.buf = buf;
+ ret.opt.maxlen = kOTFourByteOptionSize;
+
+ opt->level = INET_IP; // dealing with an IP Level function
+ opt->name = IP_REUSEADDR;
+ opt->len = kOTFourByteOptionSize;
+ opt->status = 0;
+ *(UInt32*)opt->value = enableReuseIPMode; // set the desired option level, true or false
+
+ err = OTOptionManagement(ep, &req, &ret);
+
+ // if no error then return the option status value
+ if (err == kOTNoError)
+ {
+ if (opt->status != T_SUCCESS)
+ err = opt->status;
+ else
+ err = kOTNoError;
+ }
+
+ return err;
+}
+*/
+
+/* A helper function for Mac OpenTransport support*/
+// This function is a complete copy from GUSI
+// ( masahiro minami<elsur@aaa.letter.co.jp> )
+// ( 01/02/19 )
+static __inline__ Uint32 CompleteMask(OTEventCode code)
+{
+ return 1 << (code & 0x1F);
+}
+
+/* Notifier for async OT calls */
+static pascal void AsyncTCPNotifier( TCPsocket sock, OTEventCode code,
+ OTResult result, void* cookie )
+{
+
+#ifdef DEBUG_NET
+ printf("AsyncTCPNotifier got an event : 0x%8.8x\n", code );
+#endif
+
+ switch( code & 0x7f000000L)
+ {
+ case 0:
+ sock->newEvent |= code;
+ result = 0;
+ break;
+ case kCOMPLETEEVENT:
+ if(!(code & 0x00FFFFE0 ))
+ sock->newCompletion |= CompleteMask( code );
+ if( code == T_OPENCOMPLETE )
+ sock->channel = (SOCKET)(cookie);
+ break;
+ default:
+ if( code != kOTProviderWillClose )
+ result = 0;
+ }
+ // Do we need these ???? TODO
+ // sock->SetAsyncMacError( result );
+ // sock->Wakeup();
+}
+
+/* Retrieve OT event */
+// This function is taken from GUSI interface.
+// ( 01/02/19 masahiro minami<elsur@aaa.letter.co.jp> )
+static void AsyncTCPPopEvent( TCPsocket sock )
+{
+ // Make sure OT calls are not interrupted
+ // Not sure if we really need this.
+ OTEnterNotifier( sock->channel );
+
+ sock->event |= (sock->curEvent = sock->newEvent );
+ sock->completion |= ( sock->curCompletion = sock->newCompletion );
+ sock->newEvent = sock->newCompletion = 0;
+
+ OTLeaveNotifier( sock->channel );
+
+ if( sock->curEvent & T_UDERR)
+ {
+ // We just clear the error.
+ // Should we feed this back to users ?
+ // (TODO )
+ OTRcvUDErr( sock->channel, NULL );
+
+#ifdef DEBUG_NET
+ printf("AsyncTCPPopEvent T_UDERR recognized");
+#endif
+ }
+
+ // Remote is disconnecting...
+ if( sock->curEvent & ( T_DISCONNECT | T_ORDREL ))
+ {
+ sock->readShutdown = true;
+ }
+
+ if( sock->curEvent &T_CONNECT )
+ {
+ // Ignore the info of remote (second parameter).
+ // Shoule we care ?
+ // (TODO)
+ OTRcvConnect( sock->channel, NULL );
+ sock->connected = 1;
+ }
+
+ if( sock->curEvent & T_ORDREL )
+ {
+ OTRcvOrderlyDisconnect( sock->channel );
+ }
+
+ if( sock->curEvent & T_DISCONNECT )
+ {
+ OTRcvDisconnect( sock->channel, NULL );
+ }
+
+ // Do we need to ?
+ // (masahiro minami<elsur@aaa.letter.co.jp>)
+ //YieldToAnyThread();
+}
+
+/* Create a new TCPsocket */
+// Because TCPsocket structure gets bigger and bigger,
+// I think we'd better have a constructor function and delete function.
+// ( 01/02/25 masahiro minami<elsur@aaa.letter.co.jp> )
+static TCPsocket AsyncTCPNewSocket()
+{
+ TCPsocket sock;
+
+ sock = (TCPsocket)malloc(sizeof(*sock));
+ if ( sock == NULL ) {
+ SDLNet_SetError("Out of memory");
+ return NULL;
+ }
+
+ sock->newEvent = 0;
+ sock->event = 0;
+ sock->curEvent = 0;
+ sock->newCompletion = 0;
+ sock->completion = 0;
+ sock->curCompletion = 0;
+ //sock->info = NULL;
+ sock->readShutdown = sock->writeShutdown = sock->connected = false;
+ sock->error = 0;
+ sock->config = NULL;
+ sock->nextListener = NULL;
+ sock->sflag = 0;
+ return sock;
+}
+
+// hmmm.... do we need this ???
+// ( 01/02/25 masahiro minami<elsur@aaa.letter.co.jp>)
+static void AsycnTCPDeleteSocket( TCPsocket sock )
+{
+ SDLNet_TCP_Close( sock );
+}
+/* Open a TCP network socket
+ If 'remote' is NULL, this creates a local server socket on the given port,
+ otherwise a TCP connection to the remote host and port is attempted.
+ The newly created socket is returned, or NULL if there was an error.
+
+ ( re-written by masahiro minami<elsur@aaa.letter.co.jp>
+ Now endpoint is created in Async mode.
+ 01/02/20 )
+*/
+TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+{
+ EndpointRef dummy = NULL;
+
+ TCPsocket sock = AsyncTCPNewSocket();
+ if( ! sock)
+ return NULL;
+
+ // Determin whether bind locally, or connect to remote
+ if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) )
+ {
+ // ######## Connect to remote
+ OTResult stat;
+ InetAddress inAddr;
+ TBind bindReq;
+
+ // Open endpoint
+ sock->error = OTAsyncOpenEndpoint(
+ OTCreateConfiguration(kTCPName), NULL, &(sock->info),
+ (OTNotifyProcPtr)(AsyncTCPNotifier),
+ sock );
+
+ AsyncTCPPopEvent( sock );
+ while( !sock->error && !( sock->completion & CompleteMask(T_OPENCOMPLETE)))
+ {
+ //SetThreadState( kCurrentThreadID, kReadyThreadState, kNoThreadID );
+ //YieldToAnyThread();
+ //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+ AsyncTCPPopEvent( sock );
+ }
+
+ if( !sock->channel )
+ {
+ SDLNet_SetError("OTAsyncOpenEndpoint failed --- client socket could not be opened");
+ goto error_return;
+ }
+
+ // Set blocking mode
+ // I'm not sure if this is a good solution....
+ // Check out Apple's sample code, OT Virtual Server
+ // ( 010314 masahiro minami<elsur@aaa.letter.co.jp>)
+
+ sock->error = OTSetBlocking( sock->channel );
+ if( sock->error != kOTNoError )
+ {
+ SDLNet_SetError("OTSetBlocking() returned an error");
+ goto error_return;
+ }
+
+ // Bind the socket
+ OTInitInetAddress(&inAddr, 0, 0 );
+ bindReq.addr.len = sizeof( InetAddress );
+ bindReq.addr.buf = (unsigned char*)&inAddr;
+ bindReq.qlen = 0;
+
+ sock->error = OTBind( sock->channel, &bindReq, NULL );
+ AsyncTCPPopEvent(sock);
+ while( !sock->error && !( sock->completion & CompleteMask(T_BINDCOMPLETE)))
+ {
+ //YieldToAnyThread();
+ //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+ AsyncTCPPopEvent(sock);
+ }
+
+
+ switch( stat = OTGetEndpointState( sock->channel ))
+ {
+ InetAddress inAddr;
+ TCall sndCall;
+ OTResult res;
+
+ case T_OUTCON:
+ SDLNet_SetError("SDLNet_Open() failed -- T_OUTCON");
+ goto error_return;
+ break;
+ case T_IDLE:
+ sock->readShutdown = false;
+ sock->writeShutdown = false;
+ sock->event &=~T_CONNECT;
+
+ OTMemzero(&sndCall, sizeof(TCall));
+ OTInitInetAddress(&inAddr, ip->port, ip->host );
+ sndCall.addr.len = sizeof(InetAddress);
+ sndCall.addr.buf = (unsigned char*)&inAddr;
+ sock->connected = 0;
+ res = OTConnect( sock->channel, &sndCall, NULL );
+ AsyncTCPPopEvent(sock);
+ while( sock->error == kOTNoDataErr || !sock->connected )
+ AsyncTCPPopEvent(sock);
+ break;
+ default:
+ // What's to be done ? (TODO)
+ SDLNet_SetError("SDLNet_TCP_Open() failed -- EndpointState not good");
+ goto error_return;
+
+ }
+ if( !(sock->event & (T_CONNECT|T_DISCONNECT)))
+ goto error_return;
+
+ AsyncTCPPopEvent( sock );
+ while( !(sock->event & (T_CONNECT|T_DISCONNECT)))
+ {
+ AsyncTCPPopEvent( sock );
+ }
+ // OTConnect successfull
+ if( sock->event & T_CONNECT)
+ {
+ sock->remoteAddress.host = inAddr.fHost;
+ sock->remoteAddress.port = inAddr.fPort;
+ sock->sflag = false;
+ }
+ else
+ {
+ // OTConnect failed
+ sock->event &= ~T_DISCONNECT;
+ goto error_return;
+ }
+ }
+ else
+ {
+ // ######## Bind locally
+ TBind bindReq;
+ InetAddress inAddr;
+
+ // First, get InetInterfaceInfo.
+ // I don't search for all of them.
+ // Does that matter ?
+
+ sock->error = OTAsyncOpenEndpoint(
+ OTCreateConfiguration("tilisten, tcp"), NULL, &(sock->info),
+ (OTNotifyProcPtr)(AsyncTCPNotifier),
+ sock);
+ AsyncTCPPopEvent( sock );
+ while( !sock->error && !( sock->completion & CompleteMask( T_OPENCOMPLETE)))
+ {
+ AsyncTCPPopEvent( sock );
+ }
+
+ if( ! sock->channel )
+ {
+ SDLNet_SetError("OTAsyncOpenEndpoint failed --- server socket could not be opened");
+ goto error_return;
+ }
+
+ // Create a master OTConfiguration
+ sock->config = OTCreateConfiguration(kTCPName);
+ if( ! sock->config )
+ {
+ SDLNet_SetError("Could not create master OTConfiguration");
+ goto error_return;
+ }
+
+ // Bind the socket
+ OTInitInetAddress(&inAddr, ip->port, 0 );
+ inAddr.fAddressType = AF_INET;
+ bindReq.addr.len = sizeof( InetAddress );
+ bindReq.addr.buf = (unsigned char*)&inAddr;
+ bindReq.qlen = 35; // This number is NOT well considered. (TODO)
+ sock->localAddress.host = inAddr.fHost;
+ sock->localAddress.port = inAddr.fPort;
+ sock->sflag = true;
+
+ sock->error = OTBind( sock->channel, &bindReq, NULL );
+ AsyncTCPPopEvent(sock);
+ while( !sock->error && !( sock->completion & CompleteMask(T_BINDCOMPLETE)))
+ {
+ AsyncTCPPopEvent(sock);
+ }
+ if( sock->error != kOTNoError )
+ {
+ SDLNet_SetError("Could not bind server socket");
+ goto error_return;
+ }
+
+ if( dummy )
+ OTCloseProvider( dummy );
+
+ }
+
+ sock->ready = 0;
+ return sock;
+
+ error_return:
+ if( dummy )
+ OTCloseProvider( dummy );
+ SDLNet_TCP_Close( sock );
+ return NULL;
+}
+
+/* Accept an incoming connection on the given server socket.
+ The newly created socket is returned, or NULL if there was an error.
+*/
+TCPsocket SDLNet_TCP_Accept(TCPsocket server)
+{
+
+ /* Only server sockets can accept */
+ if ( ! server->sflag ) {
+ SDLNet_SetError("Only server sockets can accept()");
+ return(NULL);
+ }
+ server->ready = 0;
+
+ /* Accept a new TCP connection on a server socket */
+ {
+ InetAddress peer;
+ TCall peerinfo;
+ TCPsocket sock = NULL;
+ Boolean mustListen = false;
+ OTResult err;
+
+ memset(&peerinfo, 0, (sizeof peerinfo ));
+ peerinfo.addr.buf = (Uint8 *) &peer;
+ peerinfo.addr.maxlen = sizeof(peer);
+
+ while( mustListen || !sock )
+ {
+ // OTListen
+ // We do NOT block ---- right thing ? (TODO)
+ err = OTListen( server->channel, &peerinfo );
+
+ if( err )
+ goto error_return;
+ else
+ {
+ mustListen = false;
+ sock = AsyncTCPNewSocket();
+ if( ! sock )
+ goto error_return;
+ }
+ }
+ if( sock )
+ {
+ // OTAsyncOpenEndpoint
+ server->error = OTAsyncOpenEndpoint( OTCloneConfiguration( server->config ),
+ NULL, &(sock->info), (OTNotifyProcPtr)AsyncTCPNotifier, sock );
+ AsyncTCPPopEvent( sock );
+ while( !sock->error && !( sock->completion & CompleteMask( T_OPENCOMPLETE)))
+ {
+ AsyncTCPPopEvent( sock );
+ }
+ if( ! sock->channel )
+ {
+ mustListen = false;
+ goto error_return;
+ }
+
+ // OTAccept
+ server->completion &= ~(CompleteMask(T_ACCEPTCOMPLETE));
+ server->error = OTAccept( server->channel, sock->channel, &peerinfo );
+ AsyncTCPPopEvent( server );
+ while( !(server->completion & CompleteMask(T_ACCEPTCOMPLETE)))
+ {
+ AsyncTCPPopEvent( server );
+ }
+
+ switch( server->error )
+ {
+ case kOTLookErr:
+ switch( OTLook(server->channel ))
+ {
+ case T_LISTEN:
+ mustListen = true;
+ break;
+ case T_DISCONNECT:
+ goto error_return;
+ }
+ break;
+ case 0:
+ sock->nextListener = server->nextListener;
+ server->nextListener = sock;
+ sock->remoteAddress.host = peer.fHost;
+ sock->remoteAddress.port = peer.fPort;
+ return sock;
+ // accept successful
+ break;
+ default:
+ free( sock );
+ }
+ }
+ sock->remoteAddress.host = peer.fHost;
+ sock->remoteAddress.port = peer.fPort;
+ sock->sflag = 0;
+ sock->ready = 0;
+
+ /* The socket is ready */
+ return(sock);
+
+ // Error; close the socket and return
+ error_return:
+ SDLNet_TCP_Close(sock);
+ return(NULL);
+ }
+}
+
+/* Get the IP address of the remote system associated with the socket.
+ If the socket is a server socket, this function returns NULL.
+*/
+IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)
+{
+ if ( sock->sflag ) {
+ return(NULL);
+ }
+ return(&sock->remoteAddress);
+}
+
+/* Send 'len' bytes of 'data' over the non-server socket 'sock'
+ This function returns the actual amount of data sent. If the return value
+ is less than the amount of data sent, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
+{
+ const Uint8 *data = (const Uint8 *)datap; /* For pointer arithmetic */
+ int sent, left;
+
+ /* Server sockets are for accepting connections only */
+ if ( sock->sflag ) {
+ SDLNet_SetError("Server sockets cannot send");
+ return(-1);
+ }
+
+ /* Keep sending data until it's sent or an error occurs */
+ left = len;
+ sent = 0;
+ errno = 0;
+ do {
+ len = OTSnd(sock->channel, (void *)data, left, 0);
+ if (len == kOTFlowErr)
+ len = 0;
+ if ( len > 0 ) {
+ sent += len;
+ left -= len;
+ data += len;
+ }
+ // Do we need to ?
+ // ( masahiro minami<elsur@aaa.letter.co.jp> )
+ // (TODO)
+ //WaitNextEvent(everyEvent, &macEvent, 1, NULL);
+ //AsyncTCPPopEvent(sock);
+ } while ( (left > 0) && (len > 0) );
+
+ return(sent);
+}
+
+/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
+ and store them in the buffer pointed to by 'data'.
+ This function returns the actual amount of data received. If the return
+ value is less than or equal to zero, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
+{
+ int len = 0;
+ OSStatus res;
+ /* Server sockets are for accepting connections only */
+ if ( sock->sflag ) {
+ SDLNet_SetError("Server sockets cannot receive");
+ return(-1);
+ }
+
+ do
+ {
+ res = OTRcv(sock->channel, data, maxlen-len, 0);
+ if (res > 0) {
+ len = res;
+ }
+
+#ifdef DEBUG_NET
+ if ( res != kOTNoDataErr )
+ printf("SDLNet_TCP_Recv received ; %d\n", res );
+#endif
+
+ AsyncTCPPopEvent(sock);
+ if( res == kOTLookErr )
+ {
+ res = OTLook(sock->channel );
+ continue;
+ }
+ } while ( (len == 0) && (res == kOTNoDataErr) );
+
+ sock->ready = 0;
+ if ( len == 0 ) { /* Open Transport error */
+#ifdef DEBUG_NET
+ printf("Open Transport error: %d\n", res);
+#endif
+ return(-1);
+ }
+ return(len);
+}
+
+/* Close a TCP network socket */
+void SDLNet_TCP_Close(TCPsocket sock)
+{
+ if ( sock != NULL ) {
+ if ( sock->channel != INVALID_SOCKET ) {
+ //closesocket(sock->channel);
+ OTSndOrderlyDisconnect( sock->channel );
+ }
+ free(sock);
+ }
+}
+
+#else /* !MACOS_OPENTRANSPORT */
+
+struct _TCPsocket {
+ int ready;
+ SOCKET channel;
+ IPaddress remoteAddress;
+ IPaddress localAddress;
+ int sflag;
+};
+
+/* Open a TCP network socket
+ If 'remote' is NULL, this creates a local server socket on the given port,
+ otherwise a TCP connection to the remote host and port is attempted.
+ The newly created socket is returned, or NULL if there was an error.
+*/
+TCPsocket SDLNet_TCP_Open(IPaddress *ip)
+{
+ TCPsocket sock;
+ struct sockaddr_in sock_addr;
+
+ /* Allocate a TCP socket structure */
+ sock = (TCPsocket)malloc(sizeof(*sock));
+ if ( sock == NULL ) {
+ SDLNet_SetError("Out of memory");
+ goto error_return;
+ }
+
+ /* Open the socket */
+ sock->channel = socket(AF_INET, SOCK_STREAM, 0);
+ if ( sock->channel == INVALID_SOCKET ) {
+ SDLNet_SetError("Couldn't create socket");
+ goto error_return;
+ }
+
+ /* Connect to remote, or bind locally, as appropriate */
+ if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) {
+
+ // ######### Connecting to remote
+
+ memset(&sock_addr, 0, sizeof(sock_addr));
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = ip->host;
+ sock_addr.sin_port = ip->port;
+
+ /* Connect to the remote host */
+ if ( connect(sock->channel, (struct sockaddr *)&sock_addr,
+ sizeof(sock_addr)) == SOCKET_ERROR ) {
+ SDLNet_SetError("Couldn't connect to remote host");
+ goto error_return;
+ }
+ sock->sflag = 0;
+ } else {
+
+ // ########## Binding locally
+
+ memset(&sock_addr, 0, sizeof(sock_addr));
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = INADDR_ANY;
+ sock_addr.sin_port = ip->port;
+
+/*
+ * Windows gets bad mojo with SO_REUSEADDR:
+ * http://www.devolution.com/pipermail/sdl/2005-September/070491.html
+ * --ryan.
+ */
+#ifndef WIN32
+ /* allow local address reuse */
+ { int yes = 1;
+ setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes));
+ }
+#endif
+
+ /* Bind the socket for listening */
+ if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
+ sizeof(sock_addr)) == SOCKET_ERROR ) {
+ SDLNet_SetError("Couldn't bind to local port");
+ goto error_return;
+ }
+ if ( listen(sock->channel, 5) == SOCKET_ERROR ) {
+ SDLNet_SetError("Couldn't listen to local port");
+ goto error_return;
+ }
+
+ /* Set the socket to non-blocking mode for accept() */
+#if defined(__BEOS__) && defined(SO_NONBLOCK)
+ /* On BeOS r5 there is O_NONBLOCK but it's for files only */
+ {
+ long b = 1;
+ setsockopt(sock->channel, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
+ }
+#elif defined(O_NONBLOCK)
+ {
+ fcntl(sock->channel, F_SETFL, O_NONBLOCK);
+ }
+#elif defined(WIN32)
+ {
+ unsigned long mode = 1;
+ ioctlsocket (sock->channel, FIONBIO, &mode);
+ }
+#elif defined(__OS2__)
+ {
+ int dontblock = 1;
+ ioctl(sock->channel, FIONBIO, &dontblock);
+ }
+#else
+#warning How do we set non-blocking mode on other operating systems?
+#endif
+ sock->sflag = 1;
+ }
+ sock->ready = 0;
+
+#ifdef TCP_NODELAY
+ /* Set the nodelay TCP option for real-time games */
+ { int yes = 1;
+ setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes));
+ }
+#endif /* TCP_NODELAY */
+
+ /* Fill in the channel host address */
+ sock->remoteAddress.host = sock_addr.sin_addr.s_addr;
+ sock->remoteAddress.port = sock_addr.sin_port;
+
+ /* The socket is ready */
+ return(sock);
+
+error_return:
+ SDLNet_TCP_Close(sock);
+ return(NULL);
+}
+
+/* Accept an incoming connection on the given server socket.
+ The newly created socket is returned, or NULL if there was an error.
+*/
+TCPsocket SDLNet_TCP_Accept(TCPsocket server)
+{
+ TCPsocket sock;
+ struct sockaddr_in sock_addr;
+ int sock_alen;
+
+ /* Only server sockets can accept */
+ if ( ! server->sflag ) {
+ SDLNet_SetError("Only server sockets can accept()");
+ return(NULL);
+ }
+ server->ready = 0;
+
+ /* Allocate a TCP socket structure */
+ sock = (TCPsocket)malloc(sizeof(*sock));
+ if ( sock == NULL ) {
+ SDLNet_SetError("Out of memory");
+ goto error_return;
+ }
+
+ /* Accept a new TCP connection on a server socket */
+ sock_alen = sizeof(sock_addr);
+ sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr,
+#ifdef USE_GUSI_SOCKETS
+ (unsigned int *)&sock_alen);
+#else
+ &sock_alen);
+#endif
+ if ( sock->channel == SOCKET_ERROR ) {
+ SDLNet_SetError("accept() failed");
+ goto error_return;
+ }
+#ifdef WIN32
+ {
+ /* passing a zero value, socket mode set to block on */
+ unsigned long mode = 0;
+ ioctlsocket (sock->channel, FIONBIO, &mode);
+ }
+#elif defined(O_NONBLOCK)
+ {
+ int flags = fcntl(sock->channel, F_GETFL, 0);
+ fcntl(sock->channel, F_SETFL, flags & ~O_NONBLOCK);
+ }
+#endif /* WIN32 */
+ sock->remoteAddress.host = sock_addr.sin_addr.s_addr;
+ sock->remoteAddress.port = sock_addr.sin_port;
+
+ sock->sflag = 0;
+ sock->ready = 0;
+
+ /* The socket is ready */
+ return(sock);
+
+error_return:
+ SDLNet_TCP_Close(sock);
+ return(NULL);
+}
+
+/* Get the IP address of the remote system associated with the socket.
+ If the socket is a server socket, this function returns NULL.
+*/
+IPaddress *SDLNet_TCP_GetPeerAddress(TCPsocket sock)
+{
+ if ( sock->sflag ) {
+ return(NULL);
+ }
+ return(&sock->remoteAddress);
+}
+
+/* Send 'len' bytes of 'data' over the non-server socket 'sock'
+ This function returns the actual amount of data sent. If the return value
+ is less than the amount of data sent, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+int SDLNet_TCP_Send(TCPsocket sock, const void *datap, int len)
+{
+ const Uint8 *data = (const Uint8 *)datap; /* For pointer arithmetic */
+ int sent, left;
+
+ /* Server sockets are for accepting connections only */
+ if ( sock->sflag ) {
+ SDLNet_SetError("Server sockets cannot send");
+ return(-1);
+ }
+
+ /* Keep sending data until it's sent or an error occurs */
+ left = len;
+ sent = 0;
+ errno = 0;
+ do {
+ len = send(sock->channel, (const char *) data, left, 0);
+ if ( len > 0 ) {
+ sent += len;
+ left -= len;
+ data += len;
+ }
+ } while ( (left > 0) && ((len > 0) || (errno == EINTR)) );
+
+ return(sent);
+}
+
+/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
+ and store them in the buffer pointed to by 'data'.
+ This function returns the actual amount of data received. If the return
+ value is less than or equal to zero, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+int SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen)
+{
+ int len;
+
+ /* Server sockets are for accepting connections only */
+ if ( sock->sflag ) {
+ SDLNet_SetError("Server sockets cannot receive");
+ return(-1);
+ }
+
+ errno = 0;
+ do {
+ len = recv(sock->channel, (char *) data, maxlen, 0);
+ } while ( errno == EINTR );
+
+ sock->ready = 0;
+ return(len);
+}
+
+/* Close a TCP network socket */
+void SDLNet_TCP_Close(TCPsocket sock)
+{
+ if ( sock != NULL ) {
+ if ( sock->channel != INVALID_SOCKET ) {
+ closesocket(sock->channel);
+ }
+ free(sock);
+ }
+}
+
+#endif /* MACOS_OPENTRANSPORT */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnetUDP.c Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,797 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDLnetUDP.c 1192 2004-01-04 17:41:55Z slouken $ */
+
+#include "SDLnetsys.h"
+#include "SDL_net.h"
+#ifdef MACOS_OPENTRANSPORT
+#include <Events.h>
+#endif
+
+struct _UDPsocket {
+ int ready;
+ SOCKET channel;
+ IPaddress address;
+
+#ifdef MACOS_OPENTRANSPORT
+ OTEventCode newEvent;
+ OTEventCode event;
+ OTEventCode curEvent;
+ OTEventCode newCompletion;
+ OTEventCode completion;
+ OTEventCode curCompletion;
+ TEndpointInfo info;
+ Boolean readShutdown;
+ Boolean writeShutdown;
+ OSStatus error;
+ OTConfigurationRef config; // Master configuration. you can clone this.
+#endif /* MACOS_OPENTRANSPORT */
+
+ struct UDP_channel {
+ int numbound;
+ IPaddress address[SDLNET_MAX_UDPADDRESSES];
+ } binding[SDLNET_MAX_UDPCHANNELS];
+};
+
+#ifdef MACOS_OPENTRANSPORT
+
+/* A helper function for Mac OpenTransport support*/
+// This function is a complete copy from GUSI
+// ( masahiro minami<elsur@aaa.letter.co.jp> )
+// ( 01/02/19 )
+//
+// I guess this function should be put in SDLnet.c
+// ( 010315 masahiro minami<elsur@aaa.letter.co.jp>)
+// (TODO)
+static __inline__ Uint32 CompleteMask(OTEventCode code)
+{
+ return 1 << (code & 0x1F);
+}
+
+/* Notifier for async OT calls */
+// This function is completely same as AsyncTCPNotifier,
+// except for the argument, UDPsocket / TCPsocket
+// ( 010315 masahiro minami<elsur@aaa.letter.co.jp>)
+static pascal void AsyncUDPNotifier( UDPsocket sock, OTEventCode code,
+ OTResult result, void* cookie )
+{
+ switch( code & 0x7f000000L)
+ {
+ case 0:
+ sock->newEvent |= code;
+ result = 0;
+ break;
+ case kCOMPLETEEVENT:
+ if(!(code & 0x00FFFFE0 ))
+ sock->newCompletion |= CompleteMask( code );
+ if( code == T_OPENCOMPLETE )
+ sock->channel = (SOCKET)(cookie);
+ break;
+ default:
+ if( code != kOTProviderWillClose )
+ result = 0;
+ }
+ // Do we need these ???? TODO
+ // sock->SetAsyncMacError( result );
+ // sock->Wakeup();
+
+ // Do we need to ?
+ //YieldToAnyThread();
+}
+
+/* Retrieve OT event */
+// This function is completely same as AsyncTCPPopEvent,
+// except for the argument, UDPsocket / TCPsocket
+// ( 010315 masahiro minami<elsur@aaa.letter.co.jp>)
+static void AsyncUDPPopEvent( UDPsocket sock )
+{
+ // Make sure OT calls are not interrupted
+ // Not sure if we really need this.
+ OTEnterNotifier( sock->channel );
+
+ sock->event |= (sock->curEvent = sock->newEvent );
+ sock->completion |= ( sock->curCompletion = sock->newCompletion );
+ sock->newEvent = sock->newCompletion = 0;
+
+ OTLeaveNotifier( sock->channel );
+
+ if( sock->curEvent & T_UDERR)
+ {
+ // We just clear the error.
+ // Should we feed this back to users ?
+ // (TODO )
+ OTRcvUDErr( sock->channel, NULL );
+ }
+
+ // Remote is disconnecting...
+ if( sock->curEvent & ( T_DISCONNECT | T_ORDREL ))
+ {
+ sock->readShutdown = true;
+ }
+
+ if( sock->curEvent &T_CONNECT)
+ {
+ // Ignore the info of remote (second parameter).
+ // Shoule we care ?
+ // (TODO)
+ OTRcvConnect( sock->channel, NULL );
+ }
+
+ if( sock->curEvent & T_ORDREL )
+ {
+ OTRcvOrderlyDisconnect( sock->channel );
+ }
+
+ if( sock->curEvent & T_DISCONNECT )
+ {
+ OTRcvDisconnect( sock->channel, NULL );
+ }
+
+ // Should we ??
+ // (010318 masahiro minami<elsur@aaa.letter.co.jp>
+ //YieldToAnyThread();
+}
+
+/* Create a new UDPsocket */
+// Because TCPsocket structure gets bigger and bigger,
+// I think we'd better have a constructor function and delete function.
+// ( 01/02/25 masahiro minami<elsur@aaa.letter.co.jp> )
+/*static*/ UDPsocket AsyncUDPNewSocket()
+{
+ UDPsocket sock;
+
+ sock = (UDPsocket)malloc(sizeof(*sock));
+ if ( sock == NULL ) {
+ SDLNet_SetError("Out of memory");
+ return NULL;
+ }
+
+ sock->newEvent = 0;
+ sock->event = 0;
+ sock->curEvent = 0;
+ sock->newCompletion = 0;
+ sock->completion = 0;
+ sock->curCompletion = 0;
+ //sock->info = NULL;
+ sock->readShutdown = sock->writeShutdown = false;
+ sock->error = 0;
+ sock->config = NULL;
+
+ return sock;
+}
+
+#endif /* MACOS_OPENTRANSPORT */
+
+/* Allocate/free a single UDP packet 'size' bytes long.
+ The new packet is returned, or NULL if the function ran out of memory.
+ */
+extern UDPpacket *SDLNet_AllocPacket(int size)
+{
+ UDPpacket *packet;
+ int error;
+
+
+ error = 1;
+ packet = (UDPpacket *)malloc(sizeof(*packet));
+ if ( packet != NULL ) {
+ packet->maxlen = size;
+ packet->data = (Uint8 *)malloc(size);
+ if ( packet->data != NULL ) {
+ error = 0;
+ }
+ }
+ if ( error ) {
+ SDLNet_FreePacket(packet);
+ packet = NULL;
+ }
+ return(packet);
+}
+int SDLNet_ResizePacket(UDPpacket *packet, int newsize)
+{
+ Uint8 *newdata;
+
+ newdata = (Uint8 *)malloc(newsize);
+ if ( newdata != NULL ) {
+ free(packet->data);
+ packet->data = newdata;
+ packet->maxlen = newsize;
+ }
+ return(packet->maxlen);
+}
+extern void SDLNet_FreePacket(UDPpacket *packet)
+{
+ if ( packet ) {
+ if ( packet->data )
+ free(packet->data);
+ free(packet);
+ }
+}
+
+/* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
+ each 'size' bytes long.
+ A pointer to the packet array is returned, or NULL if the function ran out
+ of memory.
+ */
+UDPpacket **SDLNet_AllocPacketV(int howmany, int size)
+{
+ UDPpacket **packetV;
+
+ packetV = (UDPpacket **)malloc((howmany+1)*sizeof(*packetV));
+ if ( packetV != NULL ) {
+ int i;
+ for ( i=0; i<howmany; ++i ) {
+ packetV[i] = SDLNet_AllocPacket(size);
+ if ( packetV[i] == NULL ) {
+ break;
+ }
+ }
+ packetV[i] = NULL;
+
+ if ( i != howmany ) {
+ SDLNet_FreePacketV(packetV);
+ packetV = NULL;
+ }
+ }
+ return(packetV);
+}
+void SDLNet_FreePacketV(UDPpacket **packetV)
+{
+ if ( packetV ) {
+ int i;
+ for ( i=0; packetV[i]; ++i ) {
+ SDLNet_FreePacket(packetV[i]);
+ }
+ free(packetV);
+ }
+}
+
+/* Since the UNIX/Win32/BeOS code is so different from MacOS,
+ we'll just have two completely different sections here.
+*/
+
+/* Open a UDP network socket
+ If 'port' is non-zero, the UDP socket is bound to a fixed local port.
+*/
+extern UDPsocket SDLNet_UDP_Open(Uint16 port)
+{
+ UDPsocket sock;
+#ifdef MACOS_OPENTRANSPORT
+ EndpointRef dummy = NULL;
+#endif
+
+ /* Allocate a UDP socket structure */
+ sock = (UDPsocket)malloc(sizeof(*sock));
+ if ( sock == NULL ) {
+ SDLNet_SetError("Out of memory");
+ goto error_return;
+ }
+ memset(sock, 0, sizeof(*sock));
+
+ /* Open the socket */
+#ifdef MACOS_OPENTRANSPORT
+ {
+ sock->error = OTAsyncOpenEndpoint(
+ OTCreateConfiguration(kUDPName),0, &(sock->info),
+ (OTNotifyProcPtr)AsyncUDPNotifier, sock );
+ AsyncUDPPopEvent( sock );
+ while( !sock->error && !( sock->completion & CompleteMask(T_OPENCOMPLETE)))
+ {
+ AsyncUDPPopEvent( sock );
+ }
+ if( sock->error )
+ {
+ SDLNet_SetError("Could not open UDP socket");
+ goto error_return;
+ }
+ // Should we ??
+ // (01/05/03 minami<elsur@aaa.letter.co.jp>
+ OTSetBlocking( sock->channel );
+ }
+#else
+ sock->channel = socket(AF_INET, SOCK_DGRAM, 0);
+#endif /* MACOS_OPENTRANSPORT */
+
+ if ( sock->channel == INVALID_SOCKET )
+ {
+ SDLNet_SetError("Couldn't create socket");
+ goto error_return;
+ }
+
+#ifdef MACOS_OPENTRANSPORT
+ {
+ InetAddress required, assigned;
+ TBind req_addr, assigned_addr;
+ OSStatus status;
+ InetInterfaceInfo info;
+
+ memset(&assigned_addr, 0, sizeof(assigned_addr));
+ assigned_addr.addr.maxlen = sizeof(assigned);
+ assigned_addr.addr.len = sizeof(assigned);
+ assigned_addr.addr.buf = (UInt8 *) &assigned;
+
+ if ( port ) {
+ status = OTInetGetInterfaceInfo( &info, kDefaultInetInterface );
+ if( status != kOTNoError )
+ goto error_return;
+ OTInitInetAddress(&required, port, info.fAddress );
+ req_addr.addr.maxlen = sizeof( required );
+ req_addr.addr.len = sizeof( required );
+ req_addr.addr.buf = (UInt8 *) &required;
+
+ sock->error = OTBind(sock->channel, &req_addr, &assigned_addr);
+ } else {
+ sock->error = OTBind(sock->channel, nil, &assigned_addr );
+ }
+ AsyncUDPPopEvent(sock);
+
+ while( !sock->error && !(sock->completion & CompleteMask(T_BINDCOMPLETE)))
+ {
+ AsyncUDPPopEvent(sock);
+ }
+ if (sock->error != noErr)
+ {
+ SDLNet_SetError("Couldn't bind to local port, OTBind() = %d",(int) status);
+ goto error_return;
+ }
+
+ sock->address.host = assigned.fHost;
+ sock->address.port = assigned.fPort;
+
+#ifdef DEBUG_NET
+ printf("UDP open host = %d, port = %d\n", assigned.fHost, assigned.fPort );
+#endif
+ }
+#else
+ /* Bind locally, if appropriate */
+ if ( port )
+ {
+ struct sockaddr_in sock_addr;
+ memset(&sock_addr, 0, sizeof(sock_addr));
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = INADDR_ANY;
+ sock_addr.sin_port = SDL_SwapBE16(port);
+
+ /* Bind the socket for listening */
+ if ( bind(sock->channel, (struct sockaddr *)&sock_addr,
+ sizeof(sock_addr)) == SOCKET_ERROR ) {
+ SDLNet_SetError("Couldn't bind to local port");
+ goto error_return;
+ }
+ /* Fill in the channel host address */
+ sock->address.host = sock_addr.sin_addr.s_addr;
+ sock->address.port = sock_addr.sin_port;
+ }
+
+#ifdef SO_BROADCAST
+ /* Allow LAN broadcasts with the socket */
+ { int yes = 1;
+ setsockopt(sock->channel, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes));
+ }
+#endif
+#endif /* MACOS_OPENTRANSPORT */
+
+ /* The socket is ready */
+
+ return(sock);
+
+error_return:
+#ifdef MACOS_OPENTRANSPORT
+ if( dummy )
+ OTCloseProvider( dummy );
+#endif
+ SDLNet_UDP_Close(sock);
+
+ return(NULL);
+}
+
+/* Verify that the channel is in the valid range */
+static int ValidChannel(int channel)
+{
+ if ( (channel < 0) || (channel >= SDLNET_MAX_UDPCHANNELS) ) {
+ SDLNet_SetError("Invalid channel");
+ return(0);
+ }
+ return(1);
+}
+
+/* Bind the address 'address' to the requested channel on the UDP socket.
+ If the channel is -1, then the first unbound channel will be bound with
+ the given address as it's primary address.
+ If the channel is already bound, this new address will be added to the
+ list of valid source addresses for packets arriving on the channel.
+ If the channel is not already bound, then the address becomes the primary
+ address, to which all outbound packets on the channel are sent.
+ This function returns the channel which was bound, or -1 on error.
+*/
+int SDLNet_UDP_Bind(UDPsocket sock, int channel, IPaddress *address)
+{
+ struct UDP_channel *binding;
+
+ if ( channel == -1 ) {
+ for ( channel=0; channel < SDLNET_MAX_UDPCHANNELS; ++channel ) {
+ binding = &sock->binding[channel];
+ if ( binding->numbound < SDLNET_MAX_UDPADDRESSES ) {
+ break;
+ }
+ }
+ } else {
+ if ( ! ValidChannel(channel) ) {
+ return(-1);
+ }
+ binding = &sock->binding[channel];
+ }
+ if ( binding->numbound == SDLNET_MAX_UDPADDRESSES ) {
+ SDLNet_SetError("No room for new addresses");
+ return(-1);
+ }
+ binding->address[binding->numbound++] = *address;
+ return(channel);
+}
+
+/* Unbind all addresses from the given channel */
+void SDLNet_UDP_Unbind(UDPsocket sock, int channel)
+{
+ if ( (channel >= 0) && (channel < SDLNET_MAX_UDPCHANNELS) ) {
+ sock->binding[channel].numbound = 0;
+ }
+}
+
+/* Get the primary IP address of the remote system associated with the
+ socket and channel.
+ If the channel is not bound, this function returns NULL.
+ */
+IPaddress *SDLNet_UDP_GetPeerAddress(UDPsocket sock, int channel)
+{
+ IPaddress *address;
+
+ address = NULL;
+ switch (channel) {
+ case -1:
+ /* Return the actual address of the socket */
+ address = &sock->address;
+ break;
+ default:
+ /* Return the address of the bound channel */
+ if ( ValidChannel(channel) &&
+ (sock->binding[channel].numbound > 0) ) {
+ address = &sock->binding[channel].address[0];
+ }
+ break;
+ }
+ return(address);
+}
+
+/* Send a vector of packets to the the channels specified within the packet.
+ If the channel specified in the packet is -1, the packet will be sent to
+ the address in the 'src' member of the packet.
+ Each packet will be updated with the status of the packet after it has
+ been sent, -1 if the packet send failed.
+ This function returns the number of packets sent.
+*/
+int SDLNet_UDP_SendV(UDPsocket sock, UDPpacket **packets, int npackets)
+{
+ int numsent, i, j;
+ struct UDP_channel *binding;
+ int status;
+#ifndef MACOS_OPENTRANSPORT
+ int sock_len;
+ struct sockaddr_in sock_addr;
+
+ /* Set up the variables to send packets */
+ sock_len = sizeof(sock_addr);
+#endif
+
+ numsent = 0;
+ for ( i=0; i<npackets; ++i )
+ {
+ /* if channel is < 0, then use channel specified in sock */
+
+ if ( packets[i]->channel < 0 )
+ {
+#ifdef MACOS_OPENTRANSPORT
+ TUnitData OTpacket;
+ InetAddress address;
+
+ memset(&OTpacket, 0, sizeof(OTpacket));
+ OTpacket.addr.buf = (Uint8 *)&address;
+ OTpacket.addr.len = (sizeof address);
+ OTpacket.udata.buf = packets[i]->data;
+ OTpacket.udata.len = packets[i]->len;
+ OTInitInetAddress(&address, packets[i]->address.port, packets[i]->address.host);
+#ifdef DEBUG_NET
+ printf("Packet send address: 0x%8.8x:%d, length = %d\n", packets[i]->address.host, packets[i]->address.port, packets[i]->len);
+#endif
+
+ status = OTSndUData(sock->channel, &OTpacket);
+#ifdef DEBUG_NET
+ printf("SDLNet_UDP_SendV OTSndUData return value is ;%d\n", status );
+#endif
+
+ AsyncUDPPopEvent( sock );
+ packets[i]->status = status;
+
+ if (status == noErr)
+ {
+ ++numsent;
+ }
+#else
+ sock_addr.sin_addr.s_addr = packets[i]->address.host;
+ sock_addr.sin_port = packets[i]->address.port;
+ sock_addr.sin_family = AF_INET;
+ status = sendto(sock->channel,
+ packets[i]->data, packets[i]->len, 0,
+ (struct sockaddr *)&sock_addr,sock_len);
+ if ( status >= 0 )
+ {
+ packets[i]->status = status;
+ ++numsent;
+ }
+#endif /* MACOS_OPENTRANSPORT */
+ }
+ else
+ {
+ /* Send to each of the bound addresses on the channel */
+#ifdef DEBUG_NET
+ printf("SDLNet_UDP_SendV sending packet to channel = %d\n", packets[i]->channel );
+#endif
+
+ binding = &sock->binding[packets[i]->channel];
+
+ for ( j=binding->numbound-1; j>=0; --j )
+ {
+#ifdef MACOS_OPENTRANSPORT
+ TUnitData OTpacket;
+ InetAddress address;
+
+ OTInitInetAddress(&address, binding->address[j].port,binding->address[j].host);
+#ifdef DEBUG_NET
+ printf("Packet send address: 0x%8.8x:%d, length = %d\n", binding->address[j].host, binding->address[j].port, packets[i]->len);
+#endif
+ memset(&OTpacket, 0, sizeof(OTpacket));
+ OTpacket.addr.buf = (Uint8 *)&address;
+ OTpacket.addr.len = (sizeof address);
+ OTpacket.udata.buf = packets[i]->data;
+ OTpacket.udata.len = packets[i]->len;
+
+ status = OTSndUData(sock->channel, &OTpacket);
+#ifdef DEBUG_NET
+ printf("SDLNet_UDP_SendV OTSndUData returne value is;%d\n", status );
+#endif
+ AsyncUDPPopEvent(sock);
+ packets[i]->status = status;
+
+ if (status == noErr)
+ {
+ ++numsent;
+ }
+
+#else
+ sock_addr.sin_addr.s_addr = binding->address[j].host;
+ sock_addr.sin_port = binding->address[j].port;
+ sock_addr.sin_family = AF_INET;
+ status = sendto(sock->channel,
+ packets[i]->data, packets[i]->len, 0,
+ (struct sockaddr *)&sock_addr,sock_len);
+ if ( status >= 0 )
+ {
+ packets[i]->status = status;
+ ++numsent;
+ }
+#endif /* MACOS_OPENTRANSPORT */
+ }
+ }
+ }
+
+ return(numsent);
+}
+
+int SDLNet_UDP_Send(UDPsocket sock, int channel, UDPpacket *packet)
+{
+ /* This is silly, but... */
+ packet->channel = channel;
+ return(SDLNet_UDP_SendV(sock, &packet, 1));
+}
+
+/* Returns true if a socket is has data available for reading right now */
+static int SocketReady(SOCKET sock)
+{
+ int retval = 0;
+#ifdef MACOS_OPENTRANSPORT
+ OTResult status;
+#else
+ struct timeval tv;
+ fd_set mask;
+#endif
+
+#ifdef MACOS_OPENTRANSPORT
+ //status = OTGetEndpointState(sock);
+ status = OTLook(sock);
+ if( status > 0 )
+ retval = 1;
+
+/* switch( status )
+ {
+// case T_IDLE:
+ case T_DATAXFER:
+// case T_INREL:
+ retval = 1;
+ break;
+ default:
+ OTCountDataBytes( sock, &numBytes );
+ if( numBytes )
+ retval = 1;
+ }*/
+#else
+ /* Check the file descriptors for available data */
+ do {
+ errno = 0;
+
+ /* Set up the mask of file descriptors */
+ FD_ZERO(&mask);
+ FD_SET(sock, &mask);
+
+ /* Set up the timeout */
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+
+ /* Look! */
+ retval = select(sock+1, &mask, NULL, NULL, &tv);
+ } while ( errno == EINTR );
+#endif /* MACOS_OPENTRANSPORT */
+
+ return(retval == 1);
+}
+
+/* Receive a vector of pending packets from the UDP socket.
+ The returned packets contain the source address and the channel they arrived
+ on. If they did not arrive on a bound channel, the the channel will be set
+ to -1.
+ This function returns the number of packets read from the network, or -1
+ on error. This function does not block, so can return 0 packets pending.
+*/
+extern int SDLNet_UDP_RecvV(UDPsocket sock, UDPpacket **packets)
+{
+ int numrecv, i, j;
+ struct UDP_channel *binding;
+#ifdef MACOS_OPENTRANSPORT
+ TUnitData OTpacket;
+ OTFlags flags;
+ InetAddress address;
+#else
+ int sock_len;
+ struct sockaddr_in sock_addr;
+#endif
+
+ numrecv = 0;
+ while ( packets[numrecv] && SocketReady(sock->channel) )
+ {
+ UDPpacket *packet;
+
+ packet = packets[numrecv];
+
+#ifdef MACOS_OPENTRANSPORT
+ memset(&OTpacket, 0, sizeof(OTpacket));
+ OTpacket.addr.buf = (Uint8 *)&address;
+ OTpacket.addr.maxlen = (sizeof address);
+ OTpacket.udata.buf = packet->data;
+ OTpacket.udata.maxlen = packet->maxlen;
+
+ packet->status = OTRcvUData(sock->channel, &OTpacket, &flags);
+#ifdef DEBUG_NET
+ printf("Packet status: %d\n", packet->status);
+#endif
+ AsyncUDPPopEvent(sock);
+ if (packet->status == noErr)
+ {
+ packet->len = OTpacket.udata.len;
+ packet->address.host = address.fHost;
+ packet->address.port = address.fPort;
+#ifdef DEBUG_NET
+ printf("Packet address: 0x%8.8x:%d, length = %d\n", packet->address.host, packet->address.port, packet->len);
+#endif
+ }
+#else
+ sock_len = sizeof(sock_addr);
+ packet->status = recvfrom(sock->channel,
+ packet->data, packet->maxlen, 0,
+ (struct sockaddr *)&sock_addr,
+#ifdef USE_GUSI_SOCKETS
+ (unsigned int *)&sock_len);
+#else
+ &sock_len);
+#endif
+ if ( packet->status >= 0 ) {
+ packet->len = packet->status;
+ packet->address.host = sock_addr.sin_addr.s_addr;
+ packet->address.port = sock_addr.sin_port;
+ }
+#endif
+ if (packet->status >= 0)
+ {
+ packet->channel = -1;
+
+ for (i=(SDLNET_MAX_UDPCHANNELS-1); i>=0; --i )
+ {
+ binding = &sock->binding[i];
+
+ for ( j=binding->numbound-1; j>=0; --j )
+ {
+ if ( (packet->address.host == binding->address[j].host) &&
+ (packet->address.port == binding->address[j].port) )
+ {
+ packet->channel = i;
+ goto foundit; /* break twice */
+ }
+ }
+ }
+foundit:
+ ++numrecv;
+ }
+
+ else
+ {
+ packet->len = 0;
+ }
+ }
+
+ sock->ready = 0;
+
+ return(numrecv);
+}
+
+/* Receive a single packet from the UDP socket.
+ The returned packet contains the source address and the channel it arrived
+ on. If it did not arrive on a bound channel, the the channel will be set
+ to -1.
+ This function returns the number of packets read from the network, or -1
+ on error. This function does not block, so can return 0 packets pending.
+*/
+int SDLNet_UDP_Recv(UDPsocket sock, UDPpacket *packet)
+{
+ UDPpacket *packets[2];
+
+ /* Receive a packet array of 1 */
+ packets[0] = packet;
+ packets[1] = NULL;
+ return(SDLNet_UDP_RecvV(sock, packets));
+}
+
+/* Close a UDP network socket */
+extern void SDLNet_UDP_Close(UDPsocket sock)
+{
+ if ( sock != NULL )
+ {
+ if ( sock->channel != INVALID_SOCKET )
+ {
+#ifdef MACOS_OPENTRANSPORT
+ OTUnbind(sock->channel);
+ OTCloseProvider(sock->channel);
+#else
+ closesocket(sock->channel);
+#endif /* MACOS_OPENTRANSPORT */
+ }
+
+ free(sock);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnetselect.c Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,226 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDLnetselect.c 1192 2004-01-04 17:41:55Z slouken $ */
+
+#include "SDLnetsys.h"
+#include "SDL_net.h"
+
+/* The select() API for network sockets */
+
+struct SDLNet_Socket {
+ int ready;
+ SOCKET channel;
+#ifdef MACOS_OPENTRANSPORT
+ OTEventCode curEvent;
+#endif
+};
+
+struct _SDLNet_SocketSet {
+ int numsockets;
+ int maxsockets;
+ struct SDLNet_Socket **sockets;
+};
+
+/* Allocate a socket set for use with SDLNet_CheckSockets()
+ This returns a socket set for up to 'maxsockets' sockets, or NULL if
+ the function ran out of memory.
+ */
+SDLNet_SocketSet SDLNet_AllocSocketSet(int maxsockets)
+{
+ struct _SDLNet_SocketSet *set;
+ int i;
+
+ set = (struct _SDLNet_SocketSet *)malloc(sizeof(*set));
+ if ( set != NULL ) {
+ set->numsockets = 0;
+ set->maxsockets = maxsockets;
+ set->sockets = (struct SDLNet_Socket **)malloc
+ (maxsockets*sizeof(*set->sockets));
+ if ( set->sockets != NULL ) {
+ for ( i=0; i<maxsockets; ++i ) {
+ set->sockets[i] = NULL;
+ }
+ } else {
+ free(set);
+ set = NULL;
+ }
+ }
+ return(set);
+}
+
+/* Add a socket to a set of sockets to be checked for available data */
+int SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock)
+{
+ if ( sock != NULL ) {
+ if ( set->numsockets == set->maxsockets ) {
+ SDLNet_SetError("socketset is full");
+ return(-1);
+ }
+ set->sockets[set->numsockets++] = (struct SDLNet_Socket *)sock;
+ }
+ return(set->numsockets);
+}
+
+/* Remove a socket from a set of sockets to be checked for available data */
+int SDLNet_DelSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock)
+{
+ int i;
+
+ if ( sock != NULL ) {
+ for ( i=0; i<set->numsockets; ++i ) {
+ if ( set->sockets[i] == (struct SDLNet_Socket *)sock ) {
+ break;
+ }
+ }
+ if ( i == set->numsockets ) {
+ SDLNet_SetError("socket not found in socketset");
+ return(-1);
+ }
+ --set->numsockets;
+ for ( ; i<set->numsockets; ++i ) {
+ set->sockets[i] = set->sockets[i+1];
+ }
+ }
+ return(set->numsockets);
+}
+
+/* This function checks to see if data is available for reading on the
+ given set of sockets. If 'timeout' is 0, it performs a quick poll,
+ otherwise the function returns when either data is available for
+ reading, or the timeout in milliseconds has elapsed, which ever occurs
+ first. This function returns the number of sockets ready for reading,
+ or -1 if there was an error with the select() system call.
+*/
+#ifdef MACOS_OPENTRANSPORT
+int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
+{
+Uint32 stop;
+int numReady;
+
+ /* Loop, polling the network devices */
+
+ stop = SDL_GetTicks() + timeout;
+
+ do
+ {
+ OTResult status;
+ size_t numBytes;
+ int i;
+
+ numReady = 0;
+
+ for (i = set->numsockets-1;i >= 0;--i)
+ {
+ status = OTLook( set->sockets[i]->channel );
+ if( status > 0 )
+ {
+ switch( status )
+ {
+ case T_UDERR:
+ OTRcvUDErr( set->sockets[i]->channel , nil);
+ break;
+ case T_DISCONNECT:
+ OTRcvDisconnect( set->sockets[i]->channel, nil );
+ break;
+ case T_ORDREL:
+ OTRcvOrderlyDisconnect(set->sockets[i]->channel );
+ break;
+ case T_CONNECT:
+ OTRcvConnect( set->sockets[i]->channel, nil );
+ break;
+
+
+ default:
+ set->sockets[i]->ready = 1;
+ ++numReady;
+ }
+ }
+ else if( OTCountDataBytes(set->sockets[i]->channel, &numBytes ) != kOTNoDataErr )
+ {
+ set->sockets[i]->ready = 1;
+ ++numReady;
+ }
+ else
+ set->sockets[i]->ready = 0;
+ }
+
+ } while (!numReady && (SDL_GetTicks() < stop));
+
+ return(numReady);
+}
+#else
+int SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout)
+{
+ int i;
+ SOCKET maxfd;
+ int retval;
+ struct timeval tv;
+ fd_set mask;
+
+ /* Find the largest file descriptor */
+ maxfd = 0;
+ for ( i=set->numsockets-1; i>=0; --i ) {
+ if ( set->sockets[i]->channel > maxfd ) {
+ maxfd = set->sockets[i]->channel;
+ }
+ }
+
+ /* Check the file descriptors for available data */
+ do {
+ errno = 0;
+
+ /* Set up the mask of file descriptors */
+ FD_ZERO(&mask);
+ for ( i=set->numsockets-1; i>=0; --i ) {
+ FD_SET(set->sockets[i]->channel, &mask);
+ }
+
+ /* Set up the timeout */
+ tv.tv_sec = timeout/1000;
+ tv.tv_usec = (timeout%1000)*1000;
+
+ /* Look! */
+ retval = select(maxfd+1, &mask, NULL, NULL, &tv);
+ } while ( errno == EINTR );
+
+ /* Mark all file descriptors ready that have data available */
+ if ( retval > 0 ) {
+ for ( i=set->numsockets-1; i>=0; --i ) {
+ if ( FD_ISSET(set->sockets[i]->channel, &mask) ) {
+ set->sockets[i]->ready = 1;
+ }
+ }
+ }
+ return(retval);
+}
+#endif /* MACOS_OPENTRANSPORT */
+
+/* Free a set of sockets allocated by SDL_NetAllocSocketSet() */
+extern void SDLNet_FreeSocketSet(SDLNet_SocketSet set)
+{
+ if ( set ) {
+ free(set->sockets);
+ free(set);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/SDLnetsys.h Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,84 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDLnetsys.h 1720 2005-11-23 07:57:10Z icculus $ */
+
+/* Include normal system headers */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#ifdef macintosh
+#ifndef USE_GUSI_SOCKETS
+#define MACOS_OPENTRANSPORT
+//#error Open Transport driver is broken
+#endif
+#endif /* macintosh */
+
+/* Include system network headers */
+#ifdef MACOS_OPENTRANSPORT
+#include <OpenTransport.h>
+#include <OpenTptInternet.h>
+#else
+#if defined(__WIN32__) || defined(WIN32)
+#define __USE_W32_SOCKETS
+#include <windows.h>
+#else /* UNIX */
+#ifdef __OS2__
+#include <types.h>
+#include <sys/ioctl.h>
+#endif
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <netinet/in.h>
+#ifndef __BEOS__
+#include <arpa/inet.h>
+#endif
+#ifdef linux /* FIXME: what other platforms have this? */
+#include <netinet/tcp.h>
+#endif
+#include <netdb.h>
+#include <sys/socket.h>
+#endif /* WIN32 */
+#endif /* Open Transport */
+
+/* System-dependent definitions */
+#ifdef MACOS_OPENTRANSPORT
+//#define closesocket OTCloseProvider
+#define closesocket OTSndOrderlyDisconnect
+#define SOCKET EndpointRef
+#define INVALID_SOCKET kOTInvalidEndpointRef
+#else
+#ifndef __USE_W32_SOCKETS
+#ifdef __OS2__
+#define closesocket soclose
+#else /* !__OS2__ */
+#define closesocket close
+#endif /* __OS2__ */
+#define SOCKET int
+#define INVALID_SOCKET -1
+#define SOCKET_ERROR -1
+#endif /* __USE_W32_SOCKETS */
+#endif /* Open Transport */
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/sdl_net/include/SDL_net.h Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,444 @@
+/*
+ SDL_net: An example cross-platform network library for use with SDL
+ Copyright (C) 1997-2004 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+
+/* $Id: SDL_net.h 3281 2007-07-15 05:58:56Z slouken $ */
+
+#ifndef _SDL_NET_H
+#define _SDL_NET_H
+
+#include "SDL.h"
+#include "SDL_endian.h"
+#include "SDL_version.h"
+#include "begin_code.h"
+
+
+
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
+*/
+#define SDL_NET_MAJOR_VERSION 1
+#define SDL_NET_MINOR_VERSION 2
+#define SDL_NET_PATCHLEVEL 7
+
+/* This macro can be used to fill a version structure with the compile-time
+ * version of the SDL_net library.
+ */
+#define SDL_NET_VERSION(X) \
+{ \
+ (X)->major = SDL_NET_MAJOR_VERSION; \
+ (X)->minor = SDL_NET_MINOR_VERSION; \
+ (X)->patch = SDL_NET_PATCHLEVEL; \
+}
+
+/* This function gets the version of the dynamically linked SDL_net library.
+ it should NOT be used to fill a version structure, instead you should
+ use the SDL_NET_VERSION() macro.
+ */
+extern DECLSPEC const SDL_version * SDLCALL SDLNet_Linked_Version(void);
+
+/* Initialize/Cleanup the network API
+ SDL must be initialized before calls to functions in this library,
+ because this library uses utility functions from the SDL library.
+*/
+extern DECLSPEC int SDLCALL SDLNet_Init(void);
+extern DECLSPEC void SDLCALL SDLNet_Quit(void);
+
+/***********************************************************************/
+/* IPv4 hostname resolution API */
+/***********************************************************************/
+
+typedef struct {
+ Uint32 host; /* 32-bit IPv4 host address */
+ Uint16 port; /* 16-bit protocol port */
+} IPaddress;
+
+/* Resolve a host name and port to an IP address in network form.
+ If the function succeeds, it will return 0.
+ If the host couldn't be resolved, the host portion of the returned
+ address will be INADDR_NONE, and the function will return -1.
+ If 'host' is NULL, the resolved host will be set to INADDR_ANY.
+ */
+#ifndef INADDR_ANY
+#define INADDR_ANY 0x00000000
+#endif
+#ifndef INADDR_NONE
+#define INADDR_NONE 0xFFFFFFFF
+#endif
+#ifndef INADDR_BROADCAST
+#define INADDR_BROADCAST 0xFFFFFFFF
+#endif
+extern DECLSPEC int SDLCALL SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port);
+
+/* Resolve an ip address to a host name in canonical form.
+ If the ip couldn't be resolved, this function returns NULL,
+ otherwise a pointer to a static buffer containing the hostname
+ is returned. Note that this function is not thread-safe.
+*/
+extern DECLSPEC const char * SDLCALL SDLNet_ResolveIP(IPaddress *ip);
+
+
+/***********************************************************************/
+/* TCP network API */
+/***********************************************************************/
+
+typedef struct _TCPsocket *TCPsocket;
+
+/* Open a TCP network socket
+ If ip.host is INADDR_NONE or INADDR_ANY, this creates a local server
+ socket on the given port, otherwise a TCP connection to the remote
+ host and port is attempted. The address passed in should already be
+ swapped to network byte order (addresses returned from
+ SDLNet_ResolveHost() are already in the correct form).
+ The newly created socket is returned, or NULL if there was an error.
+*/
+extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Open(IPaddress *ip);
+
+/* Accept an incoming connection on the given server socket.
+ The newly created socket is returned, or NULL if there was an error.
+*/
+extern DECLSPEC TCPsocket SDLCALL SDLNet_TCP_Accept(TCPsocket server);
+
+/* Get the IP address of the remote system associated with the socket.
+ If the socket is a server socket, this function returns NULL.
+*/
+extern DECLSPEC IPaddress * SDLCALL SDLNet_TCP_GetPeerAddress(TCPsocket sock);
+
+/* Send 'len' bytes of 'data' over the non-server socket 'sock'
+ This function returns the actual amount of data sent. If the return value
+ is less than the amount of data sent, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+extern DECLSPEC int SDLCALL SDLNet_TCP_Send(TCPsocket sock, const void *data,
+ int len);
+
+/* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
+ and store them in the buffer pointed to by 'data'.
+ This function returns the actual amount of data received. If the return
+ value is less than or equal to zero, then either the remote connection was
+ closed, or an unknown socket error occurred.
+*/
+extern DECLSPEC int SDLCALL SDLNet_TCP_Recv(TCPsocket sock, void *data, int maxlen);
+
+/* Close a TCP network socket */
+extern DECLSPEC void SDLCALL SDLNet_TCP_Close(TCPsocket sock);
+
+
+/***********************************************************************/
+/* UDP network API */
+/***********************************************************************/
+
+/* The maximum channels on a a UDP socket */
+#define SDLNET_MAX_UDPCHANNELS 32
+/* The maximum addresses bound to a single UDP socket channel */
+#define SDLNET_MAX_UDPADDRESSES 4
+
+typedef struct _UDPsocket *UDPsocket;
+typedef struct {
+ int channel; /* The src/dst channel of the packet */
+ Uint8 *data; /* The packet data */
+ int len; /* The length of the packet data */
+ int maxlen; /* The size of the data buffer */
+ int status; /* packet status after sending */
+ IPaddress address; /* The source/dest address of an incoming/outgoing packet */
+} UDPpacket;
+
+/* Allocate/resize/free a single UDP packet 'size' bytes long.
+ The new packet is returned, or NULL if the function ran out of memory.
+ */
+extern DECLSPEC UDPpacket * SDLCALL SDLNet_AllocPacket(int size);
+extern DECLSPEC int SDLCALL SDLNet_ResizePacket(UDPpacket *packet, int newsize);
+extern DECLSPEC void SDLCALL SDLNet_FreePacket(UDPpacket *packet);
+
+/* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
+ each 'size' bytes long.
+ A pointer to the first packet in the array is returned, or NULL if the
+ function ran out of memory.
+ */
+extern DECLSPEC UDPpacket ** SDLCALL SDLNet_AllocPacketV(int howmany, int size);
+extern DECLSPEC void SDLCALL SDLNet_FreePacketV(UDPpacket **packetV);
+
+
+/* Open a UDP network socket
+ If 'port' is non-zero, the UDP socket is bound to a local port.
+ The 'port' should be given in native byte order, but is used
+ internally in network (big endian) byte order, in addresses, etc.
+ This allows other systems to send to this socket via a known port.
+*/
+extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port);
+
+/* Bind the address 'address' to the requested channel on the UDP socket.
+ If the channel is -1, then the first unbound channel will be bound with
+ the given address as it's primary address.
+ If the channel is already bound, this new address will be added to the
+ list of valid source addresses for packets arriving on the channel.
+ If the channel is not already bound, then the address becomes the primary
+ address, to which all outbound packets on the channel are sent.
+ This function returns the channel which was bound, or -1 on error.
+*/
+extern DECLSPEC int SDLCALL SDLNet_UDP_Bind(UDPsocket sock, int channel, IPaddress *address);
+
+/* Unbind all addresses from the given channel */
+extern DECLSPEC void SDLCALL SDLNet_UDP_Unbind(UDPsocket sock, int channel);
+
+/* Get the primary IP address of the remote system associated with the
+ socket and channel. If the channel is -1, then the primary IP port
+ of the UDP socket is returned -- this is only meaningful for sockets
+ opened with a specific port.
+ If the channel is not bound and not -1, this function returns NULL.
+ */
+extern DECLSPEC IPaddress * SDLCALL SDLNet_UDP_GetPeerAddress(UDPsocket sock, int channel);
+
+/* Send a vector of packets to the the channels specified within the packet.
+ If the channel specified in the packet is -1, the packet will be sent to
+ the address in the 'src' member of the packet.
+ Each packet will be updated with the status of the packet after it has
+ been sent, -1 if the packet send failed.
+ This function returns the number of packets sent.
+*/
+extern DECLSPEC int SDLCALL SDLNet_UDP_SendV(UDPsocket sock, UDPpacket **packets, int npackets);
+
+/* Send a single packet to the specified channel.
+ If the channel specified in the packet is -1, the packet will be sent to
+ the address in the 'src' member of the packet.
+ The packet will be updated with the status of the packet after it has
+ been sent.
+ This function returns 1 if the packet was sent, or 0 on error.
+
+ NOTE:
+ The maximum size of the packet is limited by the MTU (Maximum Transfer Unit)
+ of the transport medium. It can be as low as 250 bytes for some PPP links,
+ and as high as 1500 bytes for ethernet.
+*/
+extern DECLSPEC int SDLCALL SDLNet_UDP_Send(UDPsocket sock, int channel, UDPpacket *packet);
+
+/* Receive a vector of pending packets from the UDP socket.
+ The returned packets contain the source address and the channel they arrived
+ on. If they did not arrive on a bound channel, the the channel will be set
+ to -1.
+ The channels are checked in highest to lowest order, so if an address is
+ bound to multiple channels, the highest channel with the source address
+ bound will be returned.
+ This function returns the number of packets read from the network, or -1
+ on error. This function does not block, so can return 0 packets pending.
+*/
+extern DECLSPEC int SDLCALL SDLNet_UDP_RecvV(UDPsocket sock, UDPpacket **packets);
+
+/* Receive a single packet from the UDP socket.
+ The returned packet contains the source address and the channel it arrived
+ on. If it did not arrive on a bound channel, the the channel will be set
+ to -1.
+ The channels are checked in highest to lowest order, so if an address is
+ bound to multiple channels, the highest channel with the source address
+ bound will be returned.
+ This function returns the number of packets read from the network, or -1
+ on error. This function does not block, so can return 0 packets pending.
+*/
+extern DECLSPEC int SDLCALL SDLNet_UDP_Recv(UDPsocket sock, UDPpacket *packet);
+
+/* Close a UDP network socket */
+extern DECLSPEC void SDLCALL SDLNet_UDP_Close(UDPsocket sock);
+
+
+/***********************************************************************/
+/* Hooks for checking sockets for available data */
+/***********************************************************************/
+
+typedef struct _SDLNet_SocketSet *SDLNet_SocketSet;
+
+/* Any network socket can be safely cast to this socket type */
+typedef struct {
+ int ready;
+} *SDLNet_GenericSocket;
+
+/* Allocate a socket set for use with SDLNet_CheckSockets()
+ This returns a socket set for up to 'maxsockets' sockets, or NULL if
+ the function ran out of memory.
+ */
+extern DECLSPEC SDLNet_SocketSet SDLCALL SDLNet_AllocSocketSet(int maxsockets);
+
+/* Add a socket to a set of sockets to be checked for available data */
+#define SDLNet_TCP_AddSocket(set, sock) \
+ SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock)
+#define SDLNet_UDP_AddSocket(set, sock) \
+ SDLNet_AddSocket(set, (SDLNet_GenericSocket)sock)
+extern DECLSPEC int SDLCALL SDLNet_AddSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
+
+/* Remove a socket from a set of sockets to be checked for available data */
+#define SDLNet_TCP_DelSocket(set, sock) \
+ SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
+#define SDLNet_UDP_DelSocket(set, sock) \
+ SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
+extern DECLSPEC int SDLCALL SDLNet_DelSocket(SDLNet_SocketSet set, SDLNet_GenericSocket sock);
+
+/* This function checks to see if data is available for reading on the
+ given set of sockets. If 'timeout' is 0, it performs a quick poll,
+ otherwise the function returns when either data is available for
+ reading, or the timeout in milliseconds has elapsed, which ever occurs
+ first. This function returns the number of sockets ready for reading,
+ or -1 if there was an error with the select() system call.
+*/
+extern DECLSPEC int SDLCALL SDLNet_CheckSockets(SDLNet_SocketSet set, Uint32 timeout);
+
+/* After calling SDLNet_CheckSockets(), you can use this function on a
+ socket that was in the socket set, to find out if data is available
+ for reading.
+*/
+#define SDLNet_SocketReady(sock) \
+ ((sock != NULL) && ((SDLNet_GenericSocket)sock)->ready)
+
+/* Free a set of sockets allocated by SDL_NetAllocSocketSet() */
+extern DECLSPEC void SDLCALL SDLNet_FreeSocketSet(SDLNet_SocketSet set);
+
+
+/***********************************************************************/
+/* Platform-independent data conversion functions */
+/***********************************************************************/
+
+/* Write a 16/32 bit value to network packet buffer */
+extern DECLSPEC void SDLCALL SDLNet_Write16(Uint16 value, void *area);
+extern DECLSPEC void SDLCALL SDLNet_Write32(Uint32 value, void *area);
+
+/* Read a 16/32 bit value from network packet buffer */
+extern DECLSPEC Uint16 SDLCALL SDLNet_Read16(void *area);
+extern DECLSPEC Uint32 SDLCALL SDLNet_Read32(void *area);
+
+/***********************************************************************/
+/* Error reporting functions */
+/***********************************************************************/
+
+/* We'll use SDL's functions for error reporting */
+#define SDLNet_SetError SDL_SetError
+#define SDLNet_GetError SDL_GetError
+
+/* I'm eventually going to try to disentangle SDL_net from SDL, thus making
+ SDL_net an independent X-platform networking toolkit. Not today though....
+
+extern no_parse_DECLSPEC void SDLCALL SDLNet_SetError(const char *fmt, ...);
+extern no_parse_DECLSPEC char * SDLCALL SDLNet_GetError(void);
+*/
+
+
+/* Inline macro functions to read/write network data */
+
+/* Warning, some systems have data access alignment restrictions */
+#if defined(sparc) || defined(mips)
+#define SDL_DATA_ALIGNED 1
+#endif
+#ifndef SDL_DATA_ALIGNED
+#define SDL_DATA_ALIGNED 0
+#endif
+
+/* Write a 16 bit value to network packet buffer */
+#if !SDL_DATA_ALIGNED
+#define SDLNet_Write16(value, areap) \
+ (*(Uint16 *)(areap) = SDL_SwapBE16(value))
+#else
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+#define SDLNet_Write16(value, areap) \
+do \
+{ \
+ Uint8 *area = (Uint8 *)(areap); \
+ area[0] = (value >> 8) & 0xFF; \
+ area[1] = value & 0xFF; \
+} while ( 0 )
+#else
+#define SDLNet_Write16(value, areap) \
+do \
+{ \
+ Uint8 *area = (Uint8 *)(areap); \
+ area[1] = (value >> 8) & 0xFF; \
+ area[0] = value & 0xFF; \
+} while ( 0 )
+#endif
+#endif /* !SDL_DATA_ALIGNED */
+
+/* Write a 32 bit value to network packet buffer */
+#if !SDL_DATA_ALIGNED
+#define SDLNet_Write32(value, areap) \
+ *(Uint32 *)(areap) = SDL_SwapBE32(value);
+#else
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+#define SDLNet_Write32(value, areap) \
+do \
+{ \
+ Uint8 *area = (Uint8 *)(areap); \
+ area[0] = (value >> 24) & 0xFF; \
+ area[1] = (value >> 16) & 0xFF; \
+ area[2] = (value >> 8) & 0xFF; \
+ area[3] = value & 0xFF; \
+} while ( 0 )
+#else
+#define SDLNet_Write32(value, areap) \
+do \
+{ \
+ Uint8 *area = (Uint8 *)(areap); \
+ area[3] = (value >> 24) & 0xFF; \
+ area[2] = (value >> 16) & 0xFF; \
+ area[1] = (value >> 8) & 0xFF; \
+ area[0] = value & 0xFF; \
+} while ( 0 )
+#endif
+#endif /* !SDL_DATA_ALIGNED */
+
+/* Read a 16 bit value from network packet buffer */
+#if !SDL_DATA_ALIGNED
+#define SDLNet_Read16(areap) \
+ (SDL_SwapBE16(*(Uint16 *)(areap)))
+#else
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+#define SDLNet_Read16(areap) \
+ ((((Uint8 *)areap)[0] << 8) | ((Uint8 *)areap)[1] << 0)
+#else
+#define SDLNet_Read16(areap) \
+ ((((Uint8 *)areap)[1] << 8) | ((Uint8 *)areap)[0] << 0)
+#endif
+#endif /* !SDL_DATA_ALIGNED */
+
+/* Read a 32 bit value from network packet buffer */
+#if !SDL_DATA_ALIGNED
+#define SDLNet_Read32(areap) \
+ (SDL_SwapBE32(*(Uint32 *)(areap)))
+#else
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+#define SDLNet_Read32(areap) \
+ ((((Uint8 *)areap)[0] << 24) | (((Uint8 *)areap)[1] << 16) | \
+ (((Uint8 *)areap)[2] << 8) | ((Uint8 *)areap)[3] << 0)
+#else
+#define SDLNet_Read32(areap) \
+ ((((Uint8 *)areap)[3] << 24) | (((Uint8 *)areap)[2] << 16) | \
+ (((Uint8 *)areap)[1] << 8) | ((Uint8 *)areap)[0] << 0)
+#endif
+#endif /* !SDL_DATA_ALIGNED */
+
+#ifdef MACOS_OPENTRANSPORT
+#endif
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_NET_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/src/Android.mk Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := main
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../SDL/include
+
+# Add your application source files here...
+LOCAL_SRC_FILES := ../SDL/src/main/android/SDL_android_main.cpp hedgewars_main.c
+
+LOCAL_SHARED_LIBRARIES := SDL
+
+LOCAL_LDLIBS := -llog -lGLESv1_CM
+
+include $(BUILD_SHARED_LIBRARY)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/jni/src/hedgewars_main.c Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,40 @@
+
+#include "android/log.h"
+#include "SDL.h"
+#include "dlfcn.h"
+#include "GLES/gl.h"
+
+#define TAG "HWEngine Loader"
+
+typedef (*HWEngine_Game)(char**);
+
+main(int argc, char *argv[]){
+ void *handle;
+ char *error;
+ HWEngine_Game Game;
+
+
+ __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine being loaded");
+ handle = dlopen("libhwengine.so", RTLD_NOW|RTLD_GLOBAL);
+ if(!handle){
+ __android_log_print(ANDROID_LOG_INFO, "foo", dlerror());
+ __android_log_print(ANDROID_LOG_INFO, "foo", "error dlopen");
+ exit(EXIT_FAILURE);
+ }
+ dlerror();
+
+ __android_log_print(ANDROID_LOG_INFO, TAG, "HWEngine successfully loaded..");
+
+
+ Game = (HWEngine_Game) dlsym(handle,"Game");
+ if((error = dlerror()) != NULL){
+ __android_log_print(ANDROID_LOG_INFO, "foo", error);
+ __android_log_print(ANDROID_LOG_INFO, "foo", "error dlsym");
+ exit(EXIT_FAILURE);
+ }
+ __android_log_print(ANDROID_LOG_INFO, "foo", "dlsym succeeded");
+ Game(argv);
+ __android_log_print(ANDROID_LOG_INFO, "foo", "Game() succeeded");
+
+ dlclose(handle);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/local.properties Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/home/richard/SoftDev/android/android-sdk-linux_86
Binary file project_files/Android-build/SDL-android-project/res/drawable-hdpi/icon.png has changed
Binary file project_files/Android-build/SDL-android-project/res/drawable-ldpi/icon.png has changed
Binary file project_files/Android-build/SDL-android-project/res/drawable-mdpi/hwengine.ico has changed
Binary file project_files/Android-build/SDL-android-project/res/drawable-mdpi/icon.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/layout/main.xml Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello World, SDLActivity"
+ />
+</LinearLayout>
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/res/values/strings.xml Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">SDL App</string>
+</resources>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/SDLActivity.java Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,513 @@
+package org.hedgewars;
+
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.egl.EGLContext;
+import javax.microedition.khronos.egl.EGLDisplay;
+import javax.microedition.khronos.egl.EGLSurface;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.PixelFormat;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.media.AudioFormat;
+import android.media.AudioManager;
+import android.media.AudioTrack;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+import android.view.View;
+
+
+/**
+ SDL Activity
+ */
+public class SDLActivity extends Activity {
+
+ // Main components
+ private static SDLActivity mSingleton;
+ public static SDLSurface mSurface;
+
+ // Audio
+ private static Thread mAudioThread;
+ private static AudioTrack mAudioTrack;
+
+ // Load the .so
+ static {
+
+ System.loadLibrary("SDL");
+ System.loadLibrary("SDL_image");
+ System.loadLibrary("mikmod");
+ System.loadLibrary("SDL_net");
+ System.loadLibrary("SDL_mixer");
+ System.loadLibrary("SDL_ttf");
+ System.loadLibrary("hwengine");
+ System.loadLibrary("main");
+ }
+
+ // Setup
+ protected void onCreate(Bundle savedInstanceState) {
+ //Log.v("SDL", "onCreate()");
+ super.onCreate(savedInstanceState);
+
+ // So we can call stuff from static callbacks
+ mSingleton = this;
+
+ // Set up the surface
+ mSurface = new SDLSurface(getApplication());
+ setContentView(mSurface);
+ SurfaceHolder holder = mSurface.getHolder();
+ holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
+ }
+
+ // Events
+ protected void onPause() {
+ //Log.v("SDL", "onPause()");
+ super.onPause();
+ }
+
+ protected void onResume() {
+ //Log.v("SDL", "onResume()");
+ super.onResume();
+ }
+
+ // Messages from the SDLMain thread
+ static int COMMAND_CHANGE_TITLE = 1;
+
+ // Handler for the messages
+ Handler commandHandler = new Handler() {
+ public void handleMessage(Message msg) {
+ if (msg.arg1 == COMMAND_CHANGE_TITLE) {
+ setTitle((String)msg.obj);
+ }
+ }
+ };
+
+ // Send a message from the SDLMain thread
+ void sendCommand(int command, Object data) {
+ Message msg = commandHandler.obtainMessage();
+ msg.arg1 = command;
+ msg.obj = data;
+ commandHandler.sendMessage(msg);
+ }
+
+ // C functions we call
+ public static native void nativeInit(String[] argv);
+ public static native void nativeQuit();
+ public static native void onNativeResize(int x, int y, int format);
+ public static native void onNativeKeyDown(int keycode);
+ public static native void onNativeKeyUp(int keycode);
+ public static native void onNativeTouch(int action, float x,
+ float y, float p);
+ public static native void onNativeAccel(float x, float y, float z);
+ public static native void nativeRunAudioThread();
+
+
+ // Java functions called from C
+
+ public static boolean createGLContext(int majorVersion, int minorVersion) {
+ return mSurface.initEGL(majorVersion, minorVersion);
+ }
+
+ public static void flipBuffers() {
+ mSurface.flipEGL();
+ }
+
+ public static void setActivityTitle(String title) {
+ // Called from SDLMain() thread and can't directly affect the view
+ mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
+ }
+
+ // Audio
+ private static Object buf;
+
+ public static Object audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
+ int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
+ int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
+ int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
+
+ Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
+
+ // Let the user pick a larger buffer if they really want -- but ye
+ // gods they probably shouldn't, the minimums are horrifyingly high
+ // latency already
+ desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
+
+ mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
+ channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
+
+ audioStartThread();
+
+ Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
+
+ if (is16Bit) {
+ buf = new short[desiredFrames * (isStereo ? 2 : 1)];
+ } else {
+ buf = new byte[desiredFrames * (isStereo ? 2 : 1)];
+ }
+ return buf;
+ }
+
+ public static void audioStartThread() {
+ mAudioThread = new Thread(new Runnable() {
+ public void run() {
+ mAudioTrack.play();
+ nativeRunAudioThread();
+ }
+ });
+
+ // I'd take REALTIME if I could get it!
+ mAudioThread.setPriority(Thread.MAX_PRIORITY);
+ mAudioThread.start();
+ }
+
+ public static void audioWriteShortBuffer(short[] buffer) {
+ for (int i = 0; i < buffer.length; ) {
+ int result = mAudioTrack.write(buffer, i, buffer.length - i);
+ if (result > 0) {
+ i += result;
+ } else if (result == 0) {
+ try {
+ Thread.sleep(1);
+ } catch(InterruptedException e) {
+ // Nom nom
+ }
+ } else {
+ Log.w("SDL", "SDL audio: error return from write(short)");
+ return;
+ }
+ }
+ }
+
+ public static void audioWriteByteBuffer(byte[] buffer) {
+ for (int i = 0; i < buffer.length; ) {
+ int result = mAudioTrack.write(buffer, i, buffer.length - i);
+ if (result > 0) {
+ i += result;
+ } else if (result == 0) {
+ try {
+ Thread.sleep(1);
+ } catch(InterruptedException e) {
+ // Nom nom
+ }
+ } else {
+ Log.w("SDL", "SDL audio: error return from write(short)");
+ return;
+ }
+ }
+ }
+
+ public static void audioQuit() {
+ if (mAudioThread != null) {
+ try {
+ mAudioThread.join();
+ } catch(Exception e) {
+ Log.v("SDL", "Problem stopping audio thread: " + e);
+ }
+ mAudioThread = null;
+
+ //Log.v("SDL", "Finished waiting for audio thread");
+ }
+
+ if (mAudioTrack != null) {
+ mAudioTrack.stop();
+ mAudioTrack = null;
+ }
+ }
+}
+
+/**
+ Simple nativeInit() runnable
+ */
+class SDLMain implements Runnable {
+ private int surfaceWidth, surfaceHeight;
+ public SDLMain(int width, int height){
+ surfaceWidth = width;
+ surfaceHeight = height;
+ }
+ public void run() {
+ // Runs SDL_main()
+
+ SDLActivity.nativeInit(new String[]{ "0", String.valueOf(surfaceWidth), String.valueOf(surfaceHeight), "0", "null", "xeli", "1", "1", "1", "0", "/sdcard/bla.hwd", "/sdcard/Data"});
+
+ //Log.v("SDL", "SDL thread terminated");
+ }
+}
+
+
+/**
+ SDLSurface. This is what we draw on, so we need to know when it's created
+ in order to do anything useful.
+
+ Because of this, that's where we set up the SDL thread
+ */
+class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
+View.OnKeyListener, View.OnTouchListener, SensorEventListener {
+
+ // This is what SDL runs in. It invokes SDL_main(), eventually
+ private Thread mSDLThread;
+
+ // EGL private objects
+ private EGLContext mEGLContext;
+ private EGLSurface mEGLSurface;
+ private EGLDisplay mEGLDisplay;
+
+ // Sensors
+ private static SensorManager mSensorManager;
+
+ // Startup
+ public SDLSurface(Context context) {
+ super(context);
+ getHolder().addCallback(this);
+
+ setFocusable(true);
+ setFocusableInTouchMode(true);
+ requestFocus();
+ setOnKeyListener(this);
+ setOnTouchListener(this);
+
+ mSensorManager = (SensorManager)context.getSystemService("sensor");
+ }
+
+ // Called when we have a valid drawing surface
+ public void surfaceCreated(SurfaceHolder holder) {
+ //Log.v("SDL", "surfaceCreated()");
+
+ enableSensor(Sensor.TYPE_ACCELEROMETER, true);
+ }
+
+ // Called when we lose the surface
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ //Log.v("SDL", "surfaceDestroyed()");
+
+ // Send a quit message to the application
+ SDLActivity.nativeQuit();
+
+ // Now wait for the SDL thread to quit
+ if (mSDLThread != null) {
+ try {
+ mSDLThread.join();
+ } catch(Exception e) {
+ Log.v("SDL", "Problem stopping thread: " + e);
+ }
+ mSDLThread = null;
+
+ //Log.v("SDL", "Finished waiting for SDL thread");
+ }
+
+ enableSensor(Sensor.TYPE_ACCELEROMETER, false);
+ }
+
+ // Called when the surface is resized
+ public void surfaceChanged(SurfaceHolder holder,
+ int format, int width, int height) {
+ Log.d("SDL", "surfaceChanged()"+ width + " + " + height);
+
+ int sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565 by default
+ switch (format) {
+ case PixelFormat.A_8:
+ Log.v("SDL", "pixel format A_8");
+ break;
+ case PixelFormat.LA_88:
+ Log.v("SDL", "pixel format LA_88");
+ break;
+ case PixelFormat.L_8:
+ Log.v("SDL", "pixel format L_8");
+ break;
+ case PixelFormat.RGBA_4444:
+ Log.v("SDL", "pixel format RGBA_4444");
+ sdlFormat = 0x85421002; // SDL_PIXELFORMAT_RGBA4444
+ break;
+ case PixelFormat.RGBA_5551:
+ Log.v("SDL", "pixel format RGBA_5551");
+ sdlFormat = 0x85441002; // SDL_PIXELFORMAT_RGBA5551
+ break;
+ case PixelFormat.RGBA_8888:
+ Log.v("SDL", "pixel format RGBA_8888");
+ sdlFormat = 0x86462004; // SDL_PIXELFORMAT_RGBA8888
+ break;
+ case PixelFormat.RGBX_8888:
+ Log.v("SDL", "pixel format RGBX_8888");
+ sdlFormat = 0x86262004; // SDL_PIXELFORMAT_RGBX8888
+ break;
+ case PixelFormat.RGB_332:
+ Log.v("SDL", "pixel format RGB_332");
+ sdlFormat = 0x84110801; // SDL_PIXELFORMAT_RGB332
+ break;
+ case PixelFormat.RGB_565:
+ Log.v("SDL", "pixel format RGB_565");
+ sdlFormat = 0x85151002; // SDL_PIXELFORMAT_RGB565
+ break;
+ case PixelFormat.RGB_888:
+ Log.v("SDL", "pixel format RGB_888");
+ // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead?
+ sdlFormat = 0x86161804; // SDL_PIXELFORMAT_RGB888
+ break;
+ default:
+ Log.v("SDL", "pixel format unknown " + format);
+ break;
+ }
+ SDLActivity.onNativeResize(width, height, sdlFormat);
+
+ // Now start up the C app thread
+ if (mSDLThread == null) {
+ mSDLThread = new Thread(new SDLMain(width, height), "SDLThread");
+ mSDLThread.start();
+ }
+ }
+
+ // unused
+ public void onDraw(Canvas canvas) {}
+
+
+ // EGL functions
+ public boolean initEGL(int majorVersion, int minorVersion) {
+ Log.v("SDL", "Starting up OpenGL ES " + majorVersion + "." + minorVersion);
+
+ try {
+ EGL10 egl = (EGL10)EGLContext.getEGL();
+
+ EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+
+ int[] version = new int[2];
+ egl.eglInitialize(dpy, version);
+
+ int EGL_OPENGL_ES_BIT = 1;
+ int EGL_OPENGL_ES2_BIT = 4;
+ int renderableType = 0;
+ if (majorVersion == 2) {
+ renderableType = EGL_OPENGL_ES2_BIT;
+ } else if (majorVersion == 1) {
+ renderableType = EGL_OPENGL_ES_BIT;
+ }
+ int[] configSpec = {
+ //EGL10.EGL_DEPTH_SIZE, 16,
+ EGL10.EGL_RENDERABLE_TYPE, renderableType,
+ EGL10.EGL_NONE
+ };
+ EGLConfig[] configs = new EGLConfig[1];
+ int[] num_config = new int[1];
+ if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) {
+ Log.e("SDL", "No EGL config available");
+ return false;
+ }
+ EGLConfig config = configs[0];
+
+ EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, null);
+ if (ctx == EGL10.EGL_NO_CONTEXT) {
+ Log.e("SDL", "Couldn't create context");
+ return false;
+ }
+
+ EGLSurface surface = egl.eglCreateWindowSurface(dpy, config, this, null);
+ if (surface == EGL10.EGL_NO_SURFACE) {
+ Log.e("SDL", "Couldn't create surface");
+ return false;
+ }
+
+ if (!egl.eglMakeCurrent(dpy, surface, surface, ctx)) {
+ Log.e("SDL", "Couldn't make context current");
+ return false;
+ }
+
+ mEGLContext = ctx;
+ mEGLDisplay = dpy;
+ mEGLSurface = surface;
+
+ } catch(Exception e) {
+ Log.v("SDL", e + "");
+ for (StackTraceElement s : e.getStackTrace()) {
+ Log.v("SDL", s.toString());
+ }
+ }
+
+ return true;
+ }
+
+ // EGL buffer flip
+ public void flipEGL() {
+ try {
+ EGL10 egl = (EGL10)EGLContext.getEGL();
+
+ egl.eglWaitNative(EGL10.EGL_NATIVE_RENDERABLE, null);
+
+ // drawing here
+
+ egl.eglWaitGL();
+
+ egl.eglSwapBuffers(mEGLDisplay, mEGLSurface);
+
+
+ } catch(Exception e) {
+ Log.v("SDL", "flipEGL(): " + e);
+ for (StackTraceElement s : e.getStackTrace()) {
+ Log.v("SDL", s.toString());
+ }
+ }
+ }
+
+ // Key events
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+
+ if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ //Log.v("SDL", "key down: " + keyCode);
+ SDLActivity.onNativeKeyDown(keyCode);
+ return true;
+ }
+ else if (event.getAction() == KeyEvent.ACTION_UP) {
+ //Log.v("SDL", "key up: " + keyCode);
+ SDLActivity.onNativeKeyUp(keyCode);
+ return true;
+ }
+
+ return false;
+ }
+
+ // Touch events
+ public boolean onTouch(View v, MotionEvent event) {
+
+ int action = event.getAction();
+ float x = event.getX();
+ float y = event.getY();
+ float p = event.getPressure();
+ // TODO: Anything else we need to pass?
+ SDLActivity.onNativeTouch(action, x, y, p);
+ return true;
+ }
+
+ // Sensor events
+ public void enableSensor(int sensortype, boolean enabled) {
+ // TODO: This uses getDefaultSensor - what if we have >1 accels?
+ if (enabled) {
+ mSensorManager.registerListener(this,
+ mSensorManager.getDefaultSensor(sensortype),
+ SensorManager.SENSOR_DELAY_GAME, null);
+ } else {
+ mSensorManager.unregisterListener(this,
+ mSensorManager.getDefaultSensor(sensortype));
+ }
+ }
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ // TODO
+ }
+
+ public void onSensorChanged(SensorEvent event) {
+ if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
+ SDLActivity.onNativeAccel(event.values[0],
+ event.values[1],
+ event.values[2]);
+ }
+ }
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/complete_build Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,29 @@
+#! /bin/bash
+
+#USER DEFINES
+ANDROID_NDK=/home/richard/SoftDev/android/android-ndk-r5b
+
+#END USER DEFINES
+
+cd SDL-android-project
+$ANDROID_NDK/ndk-build
+if [ $? -ne 0 ]
+then
+ echo "Failed to execute $ANDROID_NDK/ndk-build"
+ exit 1
+fi
+cd ..
+make -f Makefile.android
+if [ $? -ne 0 ]
+then
+ echo "Failed to execute make -f Makefile.android"
+ exit 1
+fi
+cd SDL-android-project
+ant install
+if [ $? -ne 0 ]
+then
+ echo "Failed to execute ant install"
+ exit 1
+fi
+exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/config.inc Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,26 @@
+(*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * 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; version 2 of the License
+ *
+ * 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
+ *)
+
+(*
+ * config.inc contains constants that are determined and set
+ * by the build system at compile time,
+ * based on the contents of config.inc.in
+ *)
+const cNetProtoVersion = -1;
+ cVersionString = 'android-0.1';
+ cLuaLibrary = 'liblua-5.1.so';
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/gles11.pp Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,1103 @@
+
+{$mode objfpc}
+unit gles11;
+interface
+
+{
+ Automatically converted by H2Pas 1.0.0 from gl.hh
+ The following command line parameters were used:
+ -P
+ -l
+ GLESv1_CM
+ -o
+ gles11.pp
+ -D
+ gl.hh
+}
+
+ procedure init;
+
+ const
+ External_library='GLESv1_CM'; {Setup as you need}
+
+ Type
+
+// khronos_int32_t = int32_t;
+// khronos_uint32_t = uint32_t;
+// khronos_int64_t = int64_t;
+// khronos_uint64_t = uint64_t;
+
+ khronos_int32_t = longint;
+ khronos_uint32_t = longword;
+ khronos_int64_t = Int64;
+ khronos_uint64_t = QWord;
+ khronos_int8_t = char;
+ khronos_uint8_t = byte;
+ khronos_int16_t = smallint;
+ khronos_uint16_t = word;
+ khronos_intptr_t = longint;
+ khronos_uintptr_t = dword;
+ khronos_ssize_t = longint;
+ khronos_usize_t = dword;
+ khronos_float_t = single;
+
+ GLvoid = pointer;
+ GLenum = dword;
+ GLboolean = byte;
+ GLbitfield = dword;
+ GLshort = smallint;
+ GLint = longint;
+ GLsizei = longint;
+ GLushort = word;
+ GLuint = dword;
+
+ GLbyte = khronos_int8_t;
+ GLubyte = khronos_uint8_t;
+ GLfloat = khronos_float_t;
+ GLclampf = khronos_float_t;
+ GLfixed = khronos_int32_t;
+ GLclampx = khronos_int32_t;
+ GLintptr = khronos_intptr_t;
+ GLsizeiptr = khronos_ssize_t;
+
+ PGLboolean = ^GLboolean;
+ PGLfixed = ^GLfixed;
+ PGLfloat = ^GLfloat;
+ PGLint = ^GLint;
+ PGLuint = ^GLuint;
+ PGLvoid = ^GLvoid;
+ PGLubyte = ^GLubyte;
+{$IFDEF FPC}
+{$PACKRECORDS C}
+{$ENDIF}
+
+ const
+// GL_API = KHRONOS_APICALL;
+{$define KHRONOS_APIENTRY}
+ GL_DIRECT_TEXTURE_2D_QUALCOMM = $7E80;
+
+ {*********************************************************** }
+ { OpenGL ES core versions }
+
+ const
+ GL_VERSION_ES_CM_1_0 = 1;
+ GL_VERSION_ES_CL_1_0 = 1;
+ GL_VERSION_ES_CM_1_1 = 1;
+ GL_VERSION_ES_CL_1_1 = 1;
+ { ClearBufferMask }
+ GL_DEPTH_BUFFER_BIT = $00000100;
+ GL_STENCIL_BUFFER_BIT = $00000400;
+ GL_COLOR_BUFFER_BIT = $00004000;
+ { Boolean }
+ GL_FALSE = 0;
+ GL_TRUE = 1;
+ { BeginMode }
+ GL_POINTS = $0000;
+ GL_LINES = $0001;
+ GL_LINE_LOOP = $0002;
+ GL_LINE_STRIP = $0003;
+ GL_TRIANGLES = $0004;
+ GL_TRIANGLE_STRIP = $0005;
+ GL_TRIANGLE_FAN = $0006;
+ { AlphaFunction }
+ GL_NEVER = $0200;
+ GL_LESS = $0201;
+ GL_EQUAL = $0202;
+ GL_LEQUAL = $0203;
+ GL_GREATER = $0204;
+ GL_NOTEQUAL = $0205;
+ GL_GEQUAL = $0206;
+ GL_ALWAYS = $0207;
+ { BlendingFactorDest }
+ GL_ZERO = 0;
+ GL_ONE = 1;
+ GL_SRC_COLOR = $0300;
+ GL_ONE_MINUS_SRC_COLOR = $0301;
+ GL_SRC_ALPHA = $0302;
+ GL_ONE_MINUS_SRC_ALPHA = $0303;
+ GL_DST_ALPHA = $0304;
+ GL_ONE_MINUS_DST_ALPHA = $0305;
+ { BlendingFactorSrc }
+ { GL_ZERO }
+ { GL_ONE }
+ GL_DST_COLOR = $0306;
+ GL_ONE_MINUS_DST_COLOR = $0307;
+ GL_SRC_ALPHA_SATURATE = $0308;
+ { GL_SRC_ALPHA }
+ { GL_ONE_MINUS_SRC_ALPHA }
+ { GL_DST_ALPHA }
+ { GL_ONE_MINUS_DST_ALPHA }
+ { ClipPlaneName }
+ GL_CLIP_PLANE0 = $3000;
+ GL_CLIP_PLANE1 = $3001;
+ GL_CLIP_PLANE2 = $3002;
+ GL_CLIP_PLANE3 = $3003;
+ GL_CLIP_PLANE4 = $3004;
+ GL_CLIP_PLANE5 = $3005;
+ { ColorMaterialFace }
+ { GL_FRONT_AND_BACK }
+ { ColorMaterialParameter }
+ { GL_AMBIENT_AND_DIFFUSE }
+ { ColorPointerType }
+ { GL_UNSIGNED_BYTE }
+ { GL_FLOAT }
+ { GL_FIXED }
+ { CullFaceMode }
+ GL_FRONT = $0404;
+ GL_BACK = $0405;
+ GL_FRONT_AND_BACK = $0408;
+ { DepthFunction }
+ { GL_NEVER }
+ { GL_LESS }
+ { GL_EQUAL }
+ { GL_LEQUAL }
+ { GL_GREATER }
+ { GL_NOTEQUAL }
+ { GL_GEQUAL }
+ { GL_ALWAYS }
+ { EnableCap }
+ GL_FOG = $0B60;
+ GL_LIGHTING = $0B50;
+ GL_TEXTURE_2D = $0DE1;
+ GL_CULL_FACE = $0B44;
+ GL_ALPHA_TEST = $0BC0;
+ GL_BLEND = $0BE2;
+ GL_COLOR_LOGIC_OP = $0BF2;
+ GL_DITHER = $0BD0;
+ GL_STENCIL_TEST = $0B90;
+ GL_DEPTH_TEST = $0B71;
+ { GL_LIGHT0 }
+ { GL_LIGHT1 }
+ { GL_LIGHT2 }
+ { GL_LIGHT3 }
+ { GL_LIGHT4 }
+ { GL_LIGHT5 }
+ { GL_LIGHT6 }
+ { GL_LIGHT7 }
+ GL_POINT_SMOOTH = $0B10;
+ GL_LINE_SMOOTH = $0B20;
+ GL_SCISSOR_TEST = $0C11;
+ GL_COLOR_MATERIAL = $0B57;
+ GL_NORMALIZE = $0BA1;
+ GL_RESCALE_NORMAL = $803A;
+ GL_POLYGON_OFFSET_FILL = $8037;
+ GL_VERTEX_ARRAY = $8074;
+ GL_NORMAL_ARRAY = $8075;
+ GL_COLOR_ARRAY = $8076;
+ GL_TEXTURE_COORD_ARRAY = $8078;
+ GL_MULTISAMPLE = $809D;
+ GL_SAMPLE_ALPHA_TO_COVERAGE = $809E;
+ GL_SAMPLE_ALPHA_TO_ONE = $809F;
+ GL_SAMPLE_COVERAGE = $80A0;
+ { ErrorCode }
+ GL_NO_ERROR = 0;
+ GL_INVALID_ENUM = $0500;
+ GL_INVALID_VALUE = $0501;
+ GL_INVALID_OPERATION = $0502;
+ GL_STACK_OVERFLOW = $0503;
+ GL_STACK_UNDERFLOW = $0504;
+ GL_OUT_OF_MEMORY = $0505;
+ { FogMode }
+ { GL_LINEAR }
+ GL_EXP = $0800;
+ GL_EXP2 = $0801;
+ { FogParameter }
+ GL_FOG_DENSITY = $0B62;
+ GL_FOG_START = $0B63;
+ GL_FOG_END = $0B64;
+ GL_FOG_MODE = $0B65;
+ GL_FOG_COLOR = $0B66;
+ { FrontFaceDirection }
+ GL_CW = $0900;
+ GL_CCW = $0901;
+ { GetPName }
+ GL_CURRENT_COLOR = $0B00;
+ GL_CURRENT_NORMAL = $0B02;
+ GL_CURRENT_TEXTURE_COORDS = $0B03;
+ GL_POINT_SIZE = $0B11;
+ GL_POINT_SIZE_MIN = $8126;
+ GL_POINT_SIZE_MAX = $8127;
+ GL_POINT_FADE_THRESHOLD_SIZE = $8128;
+ GL_POINT_DISTANCE_ATTENUATION = $8129;
+ GL_SMOOTH_POINT_SIZE_RANGE = $0B12;
+ GL_LINE_WIDTH = $0B21;
+ GL_SMOOTH_LINE_WIDTH_RANGE = $0B22;
+ GL_ALIASED_POINT_SIZE_RANGE = $846D;
+ GL_ALIASED_LINE_WIDTH_RANGE = $846E;
+ GL_CULL_FACE_MODE = $0B45;
+ GL_FRONT_FACE = $0B46;
+ GL_SHADE_MODEL = $0B54;
+ GL_DEPTH_RANGE = $0B70;
+ GL_DEPTH_WRITEMASK = $0B72;
+ GL_DEPTH_CLEAR_VALUE = $0B73;
+ GL_DEPTH_FUNC = $0B74;
+ GL_STENCIL_CLEAR_VALUE = $0B91;
+ GL_STENCIL_FUNC = $0B92;
+ GL_STENCIL_VALUE_MASK = $0B93;
+ GL_STENCIL_FAIL = $0B94;
+ GL_STENCIL_PASS_DEPTH_FAIL = $0B95;
+ GL_STENCIL_PASS_DEPTH_PASS = $0B96;
+ GL_STENCIL_REF = $0B97;
+ GL_STENCIL_WRITEMASK = $0B98;
+ GL_MATRIX_MODE = $0BA0;
+ GL_VIEWPORT = $0BA2;
+ GL_MODELVIEW_STACK_DEPTH = $0BA3;
+ GL_PROJECTION_STACK_DEPTH = $0BA4;
+ GL_TEXTURE_STACK_DEPTH = $0BA5;
+ GL_MODELVIEW_MATRIX = $0BA6;
+ GL_PROJECTION_MATRIX = $0BA7;
+ GL_TEXTURE_MATRIX = $0BA8;
+ GL_ALPHA_TEST_FUNC = $0BC1;
+ GL_ALPHA_TEST_REF = $0BC2;
+ GL_BLEND_DST = $0BE0;
+ GL_BLEND_SRC = $0BE1;
+ GL_LOGIC_OP_MODE = $0BF0;
+ GL_SCISSOR_BOX = $0C10;
+// GL_SCISSOR_TEST = $0C11;
+ GL_COLOR_CLEAR_VALUE = $0C22;
+ GL_COLOR_WRITEMASK = $0C23;
+ GL_UNPACK_ALIGNMENT = $0CF5;
+ GL_PACK_ALIGNMENT = $0D05;
+ GL_MAX_LIGHTS = $0D31;
+ GL_MAX_CLIP_PLANES = $0D32;
+ GL_MAX_TEXTURE_SIZE = $0D33;
+ GL_MAX_MODELVIEW_STACK_DEPTH = $0D36;
+ GL_MAX_PROJECTION_STACK_DEPTH = $0D38;
+ GL_MAX_TEXTURE_STACK_DEPTH = $0D39;
+ GL_MAX_VIEWPORT_DIMS = $0D3A;
+ GL_MAX_TEXTURE_UNITS = $84E2;
+ GL_SUBPIXEL_BITS = $0D50;
+ GL_RED_BITS = $0D52;
+ GL_GREEN_BITS = $0D53;
+ GL_BLUE_BITS = $0D54;
+ GL_ALPHA_BITS = $0D55;
+ GL_DEPTH_BITS = $0D56;
+ GL_STENCIL_BITS = $0D57;
+ GL_POLYGON_OFFSET_UNITS = $2A00;
+// GL_POLYGON_OFFSET_FILL = $8037;
+ GL_POLYGON_OFFSET_FACTOR = $8038;
+ GL_TEXTURE_BINDING_2D = $8069;
+ GL_VERTEX_ARRAY_SIZE = $807A;
+ GL_VERTEX_ARRAY_TYPE = $807B;
+ GL_VERTEX_ARRAY_STRIDE = $807C;
+ GL_NORMAL_ARRAY_TYPE = $807E;
+ GL_NORMAL_ARRAY_STRIDE = $807F;
+ GL_COLOR_ARRAY_SIZE = $8081;
+ GL_COLOR_ARRAY_TYPE = $8082;
+ GL_COLOR_ARRAY_STRIDE = $8083;
+ GL_TEXTURE_COORD_ARRAY_SIZE = $8088;
+ GL_TEXTURE_COORD_ARRAY_TYPE = $8089;
+ GL_TEXTURE_COORD_ARRAY_STRIDE = $808A;
+ GL_VERTEX_ARRAY_POINTER = $808E;
+ GL_NORMAL_ARRAY_POINTER = $808F;
+ GL_COLOR_ARRAY_POINTER = $8090;
+ GL_TEXTURE_COORD_ARRAY_POINTER = $8092;
+ GL_SAMPLE_BUFFERS = $80A8;
+ GL_SAMPLES = $80A9;
+ GL_SAMPLE_COVERAGE_VALUE = $80AA;
+ GL_SAMPLE_COVERAGE_INVERT = $80AB;
+ { GetTextureParameter }
+ { GL_TEXTURE_MAG_FILTER }
+ { GL_TEXTURE_MIN_FILTER }
+ { GL_TEXTURE_WRAP_S }
+ { GL_TEXTURE_WRAP_T }
+ GL_NUM_COMPRESSED_TEXTURE_FORMATS = $86A2;
+ GL_COMPRESSED_TEXTURE_FORMATS = $86A3;
+ { HintMode }
+ GL_DONT_CARE = $1100;
+ GL_FASTEST = $1101;
+ GL_NICEST = $1102;
+ { HintTarget }
+ GL_PERSPECTIVE_CORRECTION_HINT = $0C50;
+ GL_POINT_SMOOTH_HINT = $0C51;
+ GL_LINE_SMOOTH_HINT = $0C52;
+ GL_FOG_HINT = $0C54;
+ GL_GENERATE_MIPMAP_HINT = $8192;
+ { LightModelParameter }
+ GL_LIGHT_MODEL_AMBIENT = $0B53;
+ GL_LIGHT_MODEL_TWO_SIDE = $0B52;
+ { LightParameter }
+ GL_AMBIENT = $1200;
+ GL_DIFFUSE = $1201;
+ GL_SPECULAR = $1202;
+ GL_POSITION = $1203;
+ GL_SPOT_DIRECTION = $1204;
+ GL_SPOT_EXPONENT = $1205;
+ GL_SPOT_CUTOFF = $1206;
+ GL_CONSTANT_ATTENUATION = $1207;
+ GL_LINEAR_ATTENUATION = $1208;
+ GL_QUADRATIC_ATTENUATION = $1209;
+ { DataType }
+ GL_BYTE = $1400;
+ GL_UNSIGNED_BYTE = $1401;
+ GL_SHORT = $1402;
+ GL_UNSIGNED_SHORT = $1403;
+ GL_FLOAT = $1406;
+ GL_FIXED = $140C;
+ { LogicOp }
+ GL_CLEAR = $1500;
+ GL_AND = $1501;
+ GL_AND_REVERSE = $1502;
+ GL_COPY = $1503;
+ GL_AND_INVERTED = $1504;
+ GL_NOOP = $1505;
+ GL_XOR = $1506;
+ GL_OR = $1507;
+ GL_NOR = $1508;
+ GL_EQUIV = $1509;
+ GL_INVERT = $150A;
+ GL_OR_REVERSE = $150B;
+ GL_COPY_INVERTED = $150C;
+ GL_OR_INVERTED = $150D;
+ GL_NAND = $150E;
+ GL_SET = $150F;
+ { MaterialFace }
+ { GL_FRONT_AND_BACK }
+ { MaterialParameter }
+ GL_EMISSION = $1600;
+ GL_SHININESS = $1601;
+ GL_AMBIENT_AND_DIFFUSE = $1602;
+ { GL_AMBIENT }
+ { GL_DIFFUSE }
+ { GL_SPECULAR }
+ { MatrixMode }
+ GL_MODELVIEW = $1700;
+ GL_PROJECTION = $1701;
+ GL_TEXTURE = $1702;
+ { NormalPointerType }
+ { GL_BYTE }
+ { GL_SHORT }
+ { GL_FLOAT }
+ { GL_FIXED }
+ { PixelFormat }
+ GL_ALPHA = $1906;
+ GL_RGB = $1907;
+ GL_RGBA = $1908;
+ GL_LUMINANCE = $1909;
+ GL_LUMINANCE_ALPHA = $190A;
+ { PixelStoreParameter }
+// GL_UNPACK_ALIGNMENT = $0CF5;
+// GL_PACK_ALIGNMENT = $0D05;
+ { PixelType }
+ { GL_UNSIGNED_BYTE }
+ GL_UNSIGNED_SHORT_4_4_4_4 = $8033;
+ GL_UNSIGNED_SHORT_5_5_5_1 = $8034;
+ GL_UNSIGNED_SHORT_5_6_5 = $8363;
+ { ShadingModel }
+ GL_FLAT = $1D00;
+ GL_SMOOTH = $1D01;
+ { StencilFunction }
+ { GL_NEVER }
+ { GL_LESS }
+ { GL_EQUAL }
+ { GL_LEQUAL }
+ { GL_GREATER }
+ { GL_NOTEQUAL }
+ { GL_GEQUAL }
+ { GL_ALWAYS }
+ { StencilOp }
+ { GL_ZERO }
+ GL_KEEP = $1E00;
+ GL_REPLACE = $1E01;
+ GL_INCR = $1E02;
+ GL_DECR = $1E03;
+ { GL_INVERT }
+ { StringName }
+ GL_VENDOR = $1F00;
+ GL_RENDERER = $1F01;
+ GL_VERSION = $1F02;
+ GL_EXTENSIONS = $1F03;
+ { TexCoordPointerType }
+ { GL_SHORT }
+ { GL_FLOAT }
+ { GL_FIXED }
+ { GL_BYTE }
+ { TextureEnvMode }
+ GL_MODULATE = $2100;
+ GL_DECAL = $2101;
+ { GL_BLEND }
+ GL_ADD = $0104;
+ { GL_REPLACE }
+ { TextureEnvParameter }
+ GL_TEXTURE_ENV_MODE = $2200;
+ GL_TEXTURE_ENV_COLOR = $2201;
+ { TextureEnvTarget }
+ GL_TEXTURE_ENV = $2300;
+ { TextureMagFilter }
+ GL_NEAREST = $2600;
+ GL_LINEAR = $2601;
+ { TextureMinFilter }
+ { GL_NEAREST }
+ { GL_LINEAR }
+ GL_NEAREST_MIPMAP_NEAREST = $2700;
+ GL_LINEAR_MIPMAP_NEAREST = $2701;
+ GL_NEAREST_MIPMAP_LINEAR = $2702;
+ GL_LINEAR_MIPMAP_LINEAR = $2703;
+ { TextureParameterName }
+ GL_TEXTURE_MAG_FILTER = $2800;
+ GL_TEXTURE_MIN_FILTER = $2801;
+ GL_TEXTURE_WRAP_S = $2802;
+ GL_TEXTURE_WRAP_T = $2803;
+ GL_GENERATE_MIPMAP = $8191;
+ { TextureTarget }
+ { GL_TEXTURE_2D }
+ { TextureUnit }
+ GL_TEXTURE0 = $84C0;
+ GL_TEXTURE1 = $84C1;
+ GL_TEXTURE2 = $84C2;
+ GL_TEXTURE3 = $84C3;
+ GL_TEXTURE4 = $84C4;
+ GL_TEXTURE5 = $84C5;
+ GL_TEXTURE6 = $84C6;
+ GL_TEXTURE7 = $84C7;
+ GL_TEXTURE8 = $84C8;
+ GL_TEXTURE9 = $84C9;
+ GL_TEXTURE10 = $84CA;
+ GL_TEXTURE11 = $84CB;
+ GL_TEXTURE12 = $84CC;
+ GL_TEXTURE13 = $84CD;
+ GL_TEXTURE14 = $84CE;
+ GL_TEXTURE15 = $84CF;
+ GL_TEXTURE16 = $84D0;
+ GL_TEXTURE17 = $84D1;
+ GL_TEXTURE18 = $84D2;
+ GL_TEXTURE19 = $84D3;
+ GL_TEXTURE20 = $84D4;
+ GL_TEXTURE21 = $84D5;
+ GL_TEXTURE22 = $84D6;
+ GL_TEXTURE23 = $84D7;
+ GL_TEXTURE24 = $84D8;
+ GL_TEXTURE25 = $84D9;
+ GL_TEXTURE26 = $84DA;
+ GL_TEXTURE27 = $84DB;
+ GL_TEXTURE28 = $84DC;
+ GL_TEXTURE29 = $84DD;
+ GL_TEXTURE30 = $84DE;
+ GL_TEXTURE31 = $84DF;
+ GL_ACTIVE_TEXTURE = $84E0;
+ GL_CLIENT_ACTIVE_TEXTURE = $84E1;
+ { TextureWrapMode }
+ GL_REPEAT = $2901;
+ GL_CLAMP_TO_EDGE = $812F;
+ { VertexPointerType }
+ { GL_SHORT }
+ { GL_FLOAT }
+ { GL_FIXED }
+ { GL_BYTE }
+ { LightName }
+ GL_LIGHT0 = $4000;
+ GL_LIGHT1 = $4001;
+ GL_LIGHT2 = $4002;
+ GL_LIGHT3 = $4003;
+ GL_LIGHT4 = $4004;
+ GL_LIGHT5 = $4005;
+ GL_LIGHT6 = $4006;
+ GL_LIGHT7 = $4007;
+ { Buffer Objects }
+ GL_ARRAY_BUFFER = $8892;
+ GL_ELEMENT_ARRAY_BUFFER = $8893;
+ GL_ARRAY_BUFFER_BINDING = $8894;
+ GL_ELEMENT_ARRAY_BUFFER_BINDING = $8895;
+ GL_VERTEX_ARRAY_BUFFER_BINDING = $8896;
+ GL_NORMAL_ARRAY_BUFFER_BINDING = $8897;
+ GL_COLOR_ARRAY_BUFFER_BINDING = $8898;
+ GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = $889A;
+ GL_STATIC_DRAW = $88E4;
+ GL_DYNAMIC_DRAW = $88E8;
+ GL_BUFFER_SIZE = $8764;
+ GL_BUFFER_USAGE = $8765;
+ { Texture combine + dot3 }
+ GL_SUBTRACT = $84E7;
+ GL_COMBINE = $8570;
+ GL_COMBINE_RGB = $8571;
+ GL_COMBINE_ALPHA = $8572;
+ GL_RGB_SCALE = $8573;
+ GL_ADD_SIGNED = $8574;
+ GL_INTERPOLATE = $8575;
+ GL_CONSTANT = $8576;
+ GL_PRIMARY_COLOR = $8577;
+ GL_PREVIOUS = $8578;
+ GL_OPERAND0_RGB = $8590;
+ GL_OPERAND1_RGB = $8591;
+ GL_OPERAND2_RGB = $8592;
+ GL_OPERAND0_ALPHA = $8598;
+ GL_OPERAND1_ALPHA = $8599;
+ GL_OPERAND2_ALPHA = $859A;
+ GL_ALPHA_SCALE = $0D1C;
+ GL_SRC0_RGB = $8580;
+ GL_SRC1_RGB = $8581;
+ GL_SRC2_RGB = $8582;
+ GL_SRC0_ALPHA = $8588;
+ GL_SRC1_ALPHA = $8589;
+ GL_SRC2_ALPHA = $858A;
+ GL_DOT3_RGB = $86AE;
+ GL_DOT3_RGBA = $86AF;
+ {------------------------------------------------------------------------*
+ * required OES extension tokens
+ *------------------------------------------------------------------------ }
+ { OES_read_format }
+ GL_IMPLEMENTATION_COLOR_READ_TYPE_OES = $8B9A;
+ GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES = $8B9B;
+ { GL_OES_compressed_paletted_texture }
+ GL_PALETTE4_RGB8_OES = $8B90;
+ GL_PALETTE4_RGBA8_OES = $8B91;
+ GL_PALETTE4_R5_G6_B5_OES = $8B92;
+ GL_PALETTE4_RGBA4_OES = $8B93;
+ GL_PALETTE4_RGB5_A1_OES = $8B94;
+ GL_PALETTE8_RGB8_OES = $8B95;
+ GL_PALETTE8_RGBA8_OES = $8B96;
+ GL_PALETTE8_R5_G6_B5_OES = $8B97;
+ GL_PALETTE8_RGBA4_OES = $8B98;
+ GL_PALETTE8_RGB5_A1_OES = $8B99;
+ { OES_point_size_array }
+ GL_POINT_SIZE_ARRAY_OES = $8B9C;
+ GL_POINT_SIZE_ARRAY_TYPE_OES = $898A;
+ GL_POINT_SIZE_ARRAY_STRIDE_OES = $898B;
+ GL_POINT_SIZE_ARRAY_POINTER_OES = $898C;
+ GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES = $8B9F;
+ { GL_OES_point_sprite }
+ GL_POINT_SPRITE_OES = $8861;
+ GL_COORD_REPLACE_OES = $8862;
+ {*********************************************************** }
+ { Available only in Common profile }
+
+ var
+ glAlphaFunc : procedure(func:GLenum; ref:GLclampf);cdecl;
+ glClearColor : procedure(red:GLclampf; green:GLclampf; blue:GLclampf; alpha:GLclampf);cdecl;
+ glClearDepthf : procedure(depth:GLclampf);cdecl;
+(* Const before type ignored *)
+ glClipPlanef : procedure(plane:GLenum; equation:pGLfloat);cdecl;
+ glColor4f : procedure(red:GLfloat; green:GLfloat; blue:GLfloat; alpha:GLfloat);cdecl;
+ glDepthRangef : procedure(zNear:GLclampf; zFar:GLclampf);cdecl;
+ glFogf : procedure(pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glFogfv : procedure(pname:GLenum; params:pGLfloat);cdecl;
+ glFrustumf : procedure(left:GLfloat; right:GLfloat; bottom:GLfloat; top:GLfloat; zNear:GLfloat;
+ zFar:GLfloat);cdecl;
+ glGetClipPlanef : procedure(pname:GLenum; eqn:array of GLfloat);cdecl;
+ glGetFloatv : procedure(pname:GLenum; params:pGLfloat);cdecl;
+ glGetLightfv : procedure(light:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glGetMaterialfv : procedure(face:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glGetTexEnvfv : procedure(env:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glGetTexParameterfv : procedure(target:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glLightModelf : procedure(pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glLightModelfv : procedure(pname:GLenum; params:pGLfloat);cdecl;
+ glLightf : procedure(light:GLenum; pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glLightfv : procedure(light:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glLineWidth : procedure(width:GLfloat);cdecl;
+(* Const before type ignored *)
+ glLoadMatrixf : procedure(m:pGLfloat);cdecl;
+ glMaterialf : procedure(face:GLenum; pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glMaterialfv : procedure(face:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+(* Const before type ignored *)
+ glMultMatrixf : procedure(m:pGLfloat);cdecl;
+ glMultiTexCoord4f : procedure(target:GLenum; s:GLfloat; t:GLfloat; r:GLfloat; q:GLfloat);cdecl;
+ glNormal3f : procedure(nx:GLfloat; ny:GLfloat; nz:GLfloat);cdecl;
+ glOrthof : procedure(left:GLfloat; right:GLfloat; bottom:GLfloat; top:GLfloat; zNear:GLfloat;
+ zFar:GLfloat);cdecl;
+ glPointParameterf : procedure(pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glPointParameterfv : procedure(pname:GLenum; params:pGLfloat);cdecl;
+ glPointSize : procedure(size:GLfloat);cdecl;
+ glPolygonOffset : procedure(factor:GLfloat; units:GLfloat);cdecl;
+ glRotatef : procedure(angle:GLfloat; x:GLfloat; y:GLfloat; z:GLfloat);cdecl;
+ glScalef : procedure(x:GLfloat; y:GLfloat; z:GLfloat);cdecl;
+ glTexEnvf : procedure(target:GLenum; pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glTexEnvfv : procedure(target:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glTexParameterf : procedure(target:GLenum; pname:GLenum; param:GLfloat);cdecl;
+(* Const before type ignored *)
+ glTexParameterfv : procedure(target:GLenum; pname:GLenum; params:pGLfloat);cdecl;
+ glTranslatef : procedure(x:GLfloat; y:GLfloat; z:GLfloat);cdecl;
+ { Available in both Common and Common-Lite profiles }
+ glActiveTexture : procedure(texture:GLenum);cdecl;
+ glAlphaFuncx : procedure(func:GLenum; ref:GLclampx);cdecl;
+ glBindBuffer : procedure(target:GLenum; buffer:GLuint);cdecl;
+ glBindTexture : procedure(target:GLenum; texture:GLuint);cdecl;
+ glBlendFunc : procedure(sfactor:GLenum; dfactor:GLenum);cdecl;
+(* Const before type ignored *)
+ glBufferData : procedure(target:GLenum; size:GLsizeiptr; data:pGLvoid; usage:GLenum);cdecl;
+(* Const before type ignored *)
+ glBufferSubData : procedure(target:GLenum; offset:GLintptr; size:GLsizeiptr; data:pGLvoid);cdecl;
+ glClear : procedure(mask:GLbitfield);cdecl;
+ glClearColorx : procedure(red:GLclampx; green:GLclampx; blue:GLclampx; alpha:GLclampx);cdecl;
+ glClearDepthx : procedure(depth:GLclampx);cdecl;
+ glClearStencil : procedure(s:GLint);cdecl;
+ glClientActiveTexture : procedure(texture:GLenum);cdecl;
+(* Const before type ignored *)
+ glClipPlanex : procedure(plane:GLenum; equation:pGLfixed);cdecl;
+ glColor4ub : procedure(red:GLubyte; green:GLubyte; blue:GLubyte; alpha:GLubyte);cdecl;
+ glColor4x : procedure(red:GLfixed; green:GLfixed; blue:GLfixed; alpha:GLfixed);cdecl;
+ glColorMask : procedure(red:GLboolean; green:GLboolean; blue:GLboolean; alpha:GLboolean);cdecl;
+(* Const before type ignored *)
+ glColorPointer : procedure(size:GLint; _type:GLenum; stride:GLsizei; pointer:pGLvoid);cdecl;
+(* Const before type ignored *)
+ glCompressedTexImage2D : procedure(target:GLenum; level:GLint; internalformat:GLenum; width:GLsizei; height:GLsizei;
+ border:GLint; imageSize:GLsizei; data:pGLvoid);cdecl;
+(* Const before type ignored *)
+ glCompressedTexSubImage2D : procedure(target:GLenum; level:GLint; xoffset:GLint; yoffset:GLint; width:GLsizei;
+ height:GLsizei; format:GLenum; imageSize:GLsizei; data:pGLvoid);cdecl;
+ glCopyTexImage2D : procedure(target:GLenum; level:GLint; internalformat:GLenum; x:GLint; y:GLint;
+ width:GLsizei; height:GLsizei; border:GLint);cdecl;
+ glCopyTexSubImage2D : procedure(target:GLenum; level:GLint; xoffset:GLint; yoffset:GLint; x:GLint;
+ y:GLint; width:GLsizei; height:GLsizei);cdecl;
+ glCullFace : procedure(mode:GLenum);cdecl;
+(* Const before type ignored *)
+ glDeleteBuffers : procedure(n:GLsizei; buffers:pGLuint);cdecl;
+(* Const before type ignored *)
+ glDeleteTextures : procedure(n:GLsizei; textures:pGLuint);cdecl;
+ glDepthFunc : procedure(func:GLenum);cdecl;
+ glDepthMask : procedure(flag:GLboolean);cdecl;
+ glDepthRangex : procedure(zNear:GLclampx; zFar:GLclampx);cdecl;
+ glDisable : procedure(cap:GLenum);cdecl;
+ glDisableClientState : procedure(arry:GLenum);cdecl;
+ glDrawArrays : procedure(mode:GLenum; first:GLint; count:GLsizei);cdecl;
+(* Const before type ignored *)
+ glDrawElements : procedure(mode:GLenum; count:GLsizei; _type:GLenum; indices:pGLvoid);cdecl;
+ glEnable : procedure(cap:GLenum);cdecl;
+ glEnableClientState : procedure(arry:GLenum);cdecl;
+ glFinish : procedure;cdecl;
+ glFlush : procedure;cdecl;
+ glFogx : procedure(pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glFogxv : procedure(pname:GLenum; params:pGLfixed);cdecl;
+ glFrontFace : procedure(mode:GLenum);cdecl;
+ glFrustumx : procedure(left:GLfixed; right:GLfixed; bottom:GLfixed; top:GLfixed; zNear:GLfixed;
+ zFar:GLfixed);cdecl;
+ glGetBooleanv : procedure(pname:GLenum; params:pGLboolean);cdecl;
+ glGetBufferParameteriv : procedure(target:GLenum; pname:GLenum; params:pGLint);cdecl;
+ glGetClipPlanex : procedure(pname:GLenum; eqn:array of GLfixed);cdecl;
+ glGenBuffers : procedure(n:GLsizei; buffers:pGLuint);cdecl;
+ glGenTextures : procedure(n:GLsizei; textures:pGLuint);cdecl;
+ glGetError : function:GLenum;cdecl;
+ glGetFixedv : procedure(pname:GLenum; params:pGLfixed);cdecl;
+ glGetIntegerv : procedure(pname:GLenum; params:pGLint);cdecl;
+ glGetLightxv : procedure(light:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glGetMaterialxv : procedure(face:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glGetPointerv : procedure(pname:GLenum; params:Ppointer);cdecl;
+(* Const before type ignored *)
+ glGetString : function(name:GLenum):PGLubyte;cdecl;
+ glGetTexEnviv : procedure(env:GLenum; pname:GLenum; params:pGLint);cdecl;
+ glGetTexEnvxv : procedure(env:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glGetTexParameteriv : procedure(target:GLenum; pname:GLenum; params:pGLint);cdecl;
+ glGetTexParameterxv : procedure(target:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glHint : procedure(target:GLenum; mode:GLenum);cdecl;
+ glIsBuffer : function(buffer:GLuint):GLboolean;cdecl;
+ glIsEnabled : function(cap:GLenum):GLboolean;cdecl;
+ glIsTexture : function(texture:GLuint):GLboolean;cdecl;
+ glLightModelx : procedure(pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glLightModelxv : procedure(pname:GLenum; params:pGLfixed);cdecl;
+ glLightx : procedure(light:GLenum; pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glLightxv : procedure(light:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glLineWidthx : procedure(width:GLfixed);cdecl;
+ glLoadIdentity : procedure;cdecl;
+(* Const before type ignored *)
+ glLoadMatrixx : procedure(m:pGLfixed);cdecl;
+ glLogicOp : procedure(opcode:GLenum);cdecl;
+ glMaterialx : procedure(face:GLenum; pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glMaterialxv : procedure(face:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+ glMatrixMode : procedure(mode:GLenum);cdecl;
+(* Const before type ignored *)
+ glMultMatrixx : procedure(m:pGLfixed);cdecl;
+ glMultiTexCoord4x : procedure(target:GLenum; s:GLfixed; t:GLfixed; r:GLfixed; q:GLfixed);cdecl;
+ glNormal3x : procedure(nx:GLfixed; ny:GLfixed; nz:GLfixed);cdecl;
+(* Const before type ignored *)
+ glNormalPointer : procedure(_type:GLenum; stride:GLsizei; pointer:pGLvoid);cdecl;
+ glOrthox : procedure(left:GLfixed; right:GLfixed; bottom:GLfixed; top:GLfixed; zNear:GLfixed;
+ zFar:GLfixed);cdecl;
+ glPixelStorei : procedure(pname:GLenum; param:GLint);cdecl;
+ glPointParameterx : procedure(pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glPointParameterxv : procedure(pname:GLenum; params:pGLfixed);cdecl;
+ glPointSizex : procedure(size:GLfixed);cdecl;
+ glPolygonOffsetx : procedure(factor:GLfixed; units:GLfixed);cdecl;
+ glPopMatrix : procedure;cdecl;
+ glPushMatrix : procedure;cdecl;
+ glReadPixels : procedure(x:GLint; y:GLint; width:GLsizei; height:GLsizei; format:GLenum;
+ _type:GLenum; pixels:pGLvoid);cdecl;
+ glRotatex : procedure(angle:GLfixed; x:GLfixed; y:GLfixed; z:GLfixed);cdecl;
+ glSampleCoverage : procedure(value:GLclampf; invert:GLboolean);cdecl;
+ glSampleCoveragex : procedure(value:GLclampx; invert:GLboolean);cdecl;
+ glScalex : procedure(x:GLfixed; y:GLfixed; z:GLfixed);cdecl;
+ glScissor : procedure(x:GLint; y:GLint; width:GLsizei; height:GLsizei);cdecl;
+ glShadeModel : procedure(mode:GLenum);cdecl;
+ glStencilFunc : procedure(func:GLenum; ref:GLint; mask:GLuint);cdecl;
+ glStencilMask : procedure(mask:GLuint);cdecl;
+ glStencilOp : procedure(fail:GLenum; zfail:GLenum; zpass:GLenum);cdecl;
+(* Const before type ignored *)
+ glTexCoordPointer : procedure(size:GLint; _type:GLenum; stride:GLsizei; pointer:pGLvoid);cdecl;
+ glTexEnvi : procedure(target:GLenum; pname:GLenum; param:GLint);cdecl;
+ glTexEnvx : procedure(target:GLenum; pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glTexEnviv : procedure(target:GLenum; pname:GLenum; params:pGLint);cdecl;
+(* Const before type ignored *)
+ glTexEnvxv : procedure(target:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+(* Const before type ignored *)
+ glTexImage2D : procedure(target:GLenum; level:GLint; internalformat:GLint; width:GLsizei; height:GLsizei;
+ border:GLint; format:GLenum; _type:GLenum; pixels:pGLvoid);cdecl;
+ glTexParameteri : procedure(target:GLenum; pname:GLenum; param:GLint);cdecl;
+ glTexParameterx : procedure(target:GLenum; pname:GLenum; param:GLfixed);cdecl;
+(* Const before type ignored *)
+ glTexParameteriv : procedure(target:GLenum; pname:GLenum; params:pGLint);cdecl;
+(* Const before type ignored *)
+ glTexParameterxv : procedure(target:GLenum; pname:GLenum; params:pGLfixed);cdecl;
+(* Const before type ignored *)
+ glTexSubImage2D : procedure(target:GLenum; level:GLint; xoffset:GLint; yoffset:GLint; width:GLsizei;
+ height:GLsizei; format:GLenum; _type:GLenum; pixels:pGLvoid);cdecl;
+ glTranslatex : procedure(x:GLfixed; y:GLfixed; z:GLfixed);cdecl;
+(* Const before type ignored *)
+ glVertexPointer : procedure(size:GLint; _type:GLenum; stride:GLsizei; pointer:pGLvoid);cdecl;
+ glViewport : procedure(x:GLint; y:GLint; width:GLsizei; height:GLsizei);cdecl;
+ {------------------------------------------------------------------------*
+ * Required OES extension functions
+ *------------------------------------------------------------------------ }
+ { GL_OES_read_format }
+
+ const
+ GL_OES_read_format = 1;
+ { GL_OES_compressed_paletted_texture }
+ GL_OES_compressed_paletted_texture = 1;
+ { GL_OES_point_size_array }
+ GL_OES_point_size_array = 1;
+(* Const before type ignored *)
+
+ var
+ glPointSizePointerOES : procedure(_type:GLenum; stride:GLsizei; pointer:pGLvoid);cdecl;
+ { GL_OES_point_sprite }
+
+ const
+ GL_OES_point_sprite = 1;
+
+implementation
+
+ uses
+ SysUtils, dynlibs;
+
+ var
+ hlib : tlibhandle;
+
+
+ procedure Freegles11;
+ begin
+// FreeLibrary(hlib);
+ glAlphaFunc:=nil;
+ glClearColor:=nil;
+ glClearDepthf:=nil;
+ glClipPlanef:=nil;
+ glColor4f:=nil;
+ glDepthRangef:=nil;
+ glFogf:=nil;
+ glFogfv:=nil;
+ glFrustumf:=nil;
+ glGetClipPlanef:=nil;
+ glGetFloatv:=nil;
+ glGetLightfv:=nil;
+ glGetMaterialfv:=nil;
+ glGetTexEnvfv:=nil;
+ glGetTexParameterfv:=nil;
+ glLightModelf:=nil;
+ glLightModelfv:=nil;
+ glLightf:=nil;
+ glLightfv:=nil;
+ glLineWidth:=nil;
+ glLoadMatrixf:=nil;
+ glMaterialf:=nil;
+ glMaterialfv:=nil;
+ glMultMatrixf:=nil;
+ glMultiTexCoord4f:=nil;
+ glNormal3f:=nil;
+ glOrthof:=nil;
+ glPointParameterf:=nil;
+ glPointParameterfv:=nil;
+ glPointSize:=nil;
+ glPolygonOffset:=nil;
+ glRotatef:=nil;
+ glScalef:=nil;
+ glTexEnvf:=nil;
+ glTexEnvfv:=nil;
+ glTexParameterf:=nil;
+ glTexParameterfv:=nil;
+ glTranslatef:=nil;
+ glActiveTexture:=nil;
+ glAlphaFuncx:=nil;
+ glBindBuffer:=nil;
+ glBindTexture:=nil;
+ glBlendFunc:=nil;
+ glBufferData:=nil;
+ glBufferSubData:=nil;
+ glClear:=nil;
+ glClearColorx:=nil;
+ glClearDepthx:=nil;
+ glClearStencil:=nil;
+ glClientActiveTexture:=nil;
+ glClipPlanex:=nil;
+ glColor4ub:=nil;
+ glColor4x:=nil;
+ glColorMask:=nil;
+ glColorPointer:=nil;
+ glCompressedTexImage2D:=nil;
+ glCompressedTexSubImage2D:=nil;
+ glCopyTexImage2D:=nil;
+ glCopyTexSubImage2D:=nil;
+ glCullFace:=nil;
+ glDeleteBuffers:=nil;
+ glDeleteTextures:=nil;
+ glDepthFunc:=nil;
+ glDepthMask:=nil;
+ glDepthRangex:=nil;
+ glDisable:=nil;
+ glDisableClientState:=nil;
+ glDrawArrays:=nil;
+ glDrawElements:=nil;
+ glEnable:=nil;
+ glEnableClientState:=nil;
+ glFinish:=nil;
+ glFlush:=nil;
+ glFogx:=nil;
+ glFogxv:=nil;
+ glFrontFace:=nil;
+ glFrustumx:=nil;
+ glGetBooleanv:=nil;
+ glGetBufferParameteriv:=nil;
+ glGetClipPlanex:=nil;
+ glGenBuffers:=nil;
+ glGenTextures:=nil;
+ glGetError:=nil;
+ glGetFixedv:=nil;
+ glGetIntegerv:=nil;
+ glGetLightxv:=nil;
+ glGetMaterialxv:=nil;
+ glGetPointerv:=nil;
+ glGetString:=nil;
+ glGetTexEnviv:=nil;
+ glGetTexEnvxv:=nil;
+ glGetTexParameteriv:=nil;
+ glGetTexParameterxv:=nil;
+ glHint:=nil;
+ glIsBuffer:=nil;
+ glIsEnabled:=nil;
+ glIsTexture:=nil;
+ glLightModelx:=nil;
+ glLightModelxv:=nil;
+ glLightx:=nil;
+ glLightxv:=nil;
+ glLineWidthx:=nil;
+ glLoadIdentity:=nil;
+ glLoadMatrixx:=nil;
+ glLogicOp:=nil;
+ glMaterialx:=nil;
+ glMaterialxv:=nil;
+ glMatrixMode:=nil;
+ glMultMatrixx:=nil;
+ glMultiTexCoord4x:=nil;
+ glNormal3x:=nil;
+ glNormalPointer:=nil;
+ glOrthox:=nil;
+ glPixelStorei:=nil;
+ glPointParameterx:=nil;
+ glPointParameterxv:=nil;
+ glPointSizex:=nil;
+ glPolygonOffsetx:=nil;
+ glPopMatrix:=nil;
+ glPushMatrix:=nil;
+ glReadPixels:=nil;
+ glRotatex:=nil;
+ glSampleCoverage:=nil;
+ glSampleCoveragex:=nil;
+ glScalex:=nil;
+ glScissor:=nil;
+ glShadeModel:=nil;
+ glStencilFunc:=nil;
+ glStencilMask:=nil;
+ glStencilOp:=nil;
+ glTexCoordPointer:=nil;
+ glTexEnvi:=nil;
+ glTexEnvx:=nil;
+ glTexEnviv:=nil;
+ glTexEnvxv:=nil;
+ glTexImage2D:=nil;
+ glTexParameteri:=nil;
+ glTexParameterx:=nil;
+ glTexParameteriv:=nil;
+ glTexParameterxv:=nil;
+ glTexSubImage2D:=nil;
+ glTranslatex:=nil;
+ glVertexPointer:=nil;
+ glViewport:=nil;
+ glPointSizePointerOES:=nil;
+ end;
+
+
+ procedure Loadgles11(lib : pchar);
+ begin
+ Freegles11;
+ hlib:=LoadLibrary(lib);
+ if hlib=0 then
+ begin
+ raise Exception.Create(format('Could not load library: %s',[lib]));
+ end;
+ pointer(glAlphaFunc):=GetProcAddress(hlib,'glAlphaFunc');
+ pointer(glClearColor):=GetProcAddress(hlib,'glClearColor');
+ pointer(glClearDepthf):=GetProcAddress(hlib,'glClearDepthf');
+ pointer(glClipPlanef):=GetProcAddress(hlib,'glClipPlanef');
+ pointer(glColor4f):=GetProcAddress(hlib,'glColor4f');
+ pointer(glDepthRangef):=GetProcAddress(hlib,'glDepthRangef');
+ pointer(glFogf):=GetProcAddress(hlib,'glFogf');
+ pointer(glFogfv):=GetProcAddress(hlib,'glFogfv');
+ pointer(glFrustumf):=GetProcAddress(hlib,'glFrustumf');
+ pointer(glGetClipPlanef):=GetProcAddress(hlib,'glGetClipPlanef');
+ pointer(glGetFloatv):=GetProcAddress(hlib,'glGetFloatv');
+ pointer(glGetLightfv):=GetProcAddress(hlib,'glGetLightfv');
+ pointer(glGetMaterialfv):=GetProcAddress(hlib,'glGetMaterialfv');
+ pointer(glGetTexEnvfv):=GetProcAddress(hlib,'glGetTexEnvfv');
+ pointer(glGetTexParameterfv):=GetProcAddress(hlib,'glGetTexParameterfv');
+ pointer(glLightModelf):=GetProcAddress(hlib,'glLightModelf');
+ pointer(glLightModelfv):=GetProcAddress(hlib,'glLightModelfv');
+ pointer(glLightf):=GetProcAddress(hlib,'glLightf');
+ pointer(glLightfv):=GetProcAddress(hlib,'glLightfv');
+ pointer(glLineWidth):=GetProcAddress(hlib,'glLineWidth');
+ pointer(glLoadMatrixf):=GetProcAddress(hlib,'glLoadMatrixf');
+ pointer(glMaterialf):=GetProcAddress(hlib,'glMaterialf');
+ pointer(glMaterialfv):=GetProcAddress(hlib,'glMaterialfv');
+ pointer(glMultMatrixf):=GetProcAddress(hlib,'glMultMatrixf');
+ pointer(glMultiTexCoord4f):=GetProcAddress(hlib,'glMultiTexCoord4f');
+ pointer(glNormal3f):=GetProcAddress(hlib,'glNormal3f');
+ pointer(glOrthof):=GetProcAddress(hlib,'glOrthof');
+ pointer(glPointParameterf):=GetProcAddress(hlib,'glPointParameterf');
+ pointer(glPointParameterfv):=GetProcAddress(hlib,'glPointParameterfv');
+ pointer(glPointSize):=GetProcAddress(hlib,'glPointSize');
+ pointer(glPolygonOffset):=GetProcAddress(hlib,'glPolygonOffset');
+ pointer(glRotatef):=GetProcAddress(hlib,'glRotatef');
+ pointer(glScalef):=GetProcAddress(hlib,'glScalef');
+ pointer(glTexEnvf):=GetProcAddress(hlib,'glTexEnvf');
+ pointer(glTexEnvfv):=GetProcAddress(hlib,'glTexEnvfv');
+ pointer(glTexParameterf):=GetProcAddress(hlib,'glTexParameterf');
+ pointer(glTexParameterfv):=GetProcAddress(hlib,'glTexParameterfv');
+ pointer(glTranslatef):=GetProcAddress(hlib,'glTranslatef');
+ pointer(glActiveTexture):=GetProcAddress(hlib,'glActiveTexture');
+ pointer(glAlphaFuncx):=GetProcAddress(hlib,'glAlphaFuncx');
+ pointer(glBindBuffer):=GetProcAddress(hlib,'glBindBuffer');
+ pointer(glBindTexture):=GetProcAddress(hlib,'glBindTexture');
+ pointer(glBlendFunc):=GetProcAddress(hlib,'glBlendFunc');
+ pointer(glBufferData):=GetProcAddress(hlib,'glBufferData');
+ pointer(glBufferSubData):=GetProcAddress(hlib,'glBufferSubData');
+ pointer(glClear):=GetProcAddress(hlib,'glClear');
+ pointer(glClearColorx):=GetProcAddress(hlib,'glClearColorx');
+ pointer(glClearDepthx):=GetProcAddress(hlib,'glClearDepthx');
+ pointer(glClearStencil):=GetProcAddress(hlib,'glClearStencil');
+ pointer(glClientActiveTexture):=GetProcAddress(hlib,'glClientActiveTexture');
+ pointer(glClipPlanex):=GetProcAddress(hlib,'glClipPlanex');
+ pointer(glColor4ub):=GetProcAddress(hlib,'glColor4ub');
+ pointer(glColor4x):=GetProcAddress(hlib,'glColor4x');
+ pointer(glColorMask):=GetProcAddress(hlib,'glColorMask');
+ pointer(glColorPointer):=GetProcAddress(hlib,'glColorPointer');
+ pointer(glCompressedTexImage2D):=GetProcAddress(hlib,'glCompressedTexImage2D');
+ pointer(glCompressedTexSubImage2D):=GetProcAddress(hlib,'glCompressedTexSubImage2D');
+ pointer(glCopyTexImage2D):=GetProcAddress(hlib,'glCopyTexImage2D');
+ pointer(glCopyTexSubImage2D):=GetProcAddress(hlib,'glCopyTexSubImage2D');
+ pointer(glCullFace):=GetProcAddress(hlib,'glCullFace');
+ pointer(glDeleteBuffers):=GetProcAddress(hlib,'glDeleteBuffers');
+ pointer(glDeleteTextures):=GetProcAddress(hlib,'glDeleteTextures');
+ pointer(glDepthFunc):=GetProcAddress(hlib,'glDepthFunc');
+ pointer(glDepthMask):=GetProcAddress(hlib,'glDepthMask');
+ pointer(glDepthRangex):=GetProcAddress(hlib,'glDepthRangex');
+ pointer(glDisable):=GetProcAddress(hlib,'glDisable');
+ pointer(glDisableClientState):=GetProcAddress(hlib,'glDisableClientState');
+ pointer(glDrawArrays):=GetProcAddress(hlib,'glDrawArrays');
+ pointer(glDrawElements):=GetProcAddress(hlib,'glDrawElements');
+ pointer(glEnable):=GetProcAddress(hlib,'glEnable');
+ pointer(glEnableClientState):=GetProcAddress(hlib,'glEnableClientState');
+ pointer(glFinish):=GetProcAddress(hlib,'glFinish');
+ pointer(glFlush):=GetProcAddress(hlib,'glFlush');
+ pointer(glFogx):=GetProcAddress(hlib,'glFogx');
+ pointer(glFogxv):=GetProcAddress(hlib,'glFogxv');
+ pointer(glFrontFace):=GetProcAddress(hlib,'glFrontFace');
+ pointer(glFrustumx):=GetProcAddress(hlib,'glFrustumx');
+ pointer(glGetBooleanv):=GetProcAddress(hlib,'glGetBooleanv');
+ pointer(glGetBufferParameteriv):=GetProcAddress(hlib,'glGetBufferParameteriv');
+ pointer(glGetClipPlanex):=GetProcAddress(hlib,'glGetClipPlanex');
+ pointer(glGenBuffers):=GetProcAddress(hlib,'glGenBuffers');
+ pointer(glGenTextures):=GetProcAddress(hlib,'glGenTextures');
+ pointer(glGetError):=GetProcAddress(hlib,'glGetError');
+ pointer(glGetFixedv):=GetProcAddress(hlib,'glGetFixedv');
+ pointer(glGetIntegerv):=GetProcAddress(hlib,'glGetIntegerv');
+ pointer(glGetLightxv):=GetProcAddress(hlib,'glGetLightxv');
+ pointer(glGetMaterialxv):=GetProcAddress(hlib,'glGetMaterialxv');
+ pointer(glGetPointerv):=GetProcAddress(hlib,'glGetPointerv');
+ pointer(glGetString):=GetProcAddress(hlib,'glGetString');
+ pointer(glGetTexEnviv):=GetProcAddress(hlib,'glGetTexEnviv');
+ pointer(glGetTexEnvxv):=GetProcAddress(hlib,'glGetTexEnvxv');
+ pointer(glGetTexParameteriv):=GetProcAddress(hlib,'glGetTexParameteriv');
+ pointer(glGetTexParameterxv):=GetProcAddress(hlib,'glGetTexParameterxv');
+ pointer(glHint):=GetProcAddress(hlib,'glHint');
+ pointer(glIsBuffer):=GetProcAddress(hlib,'glIsBuffer');
+ pointer(glIsEnabled):=GetProcAddress(hlib,'glIsEnabled');
+ pointer(glIsTexture):=GetProcAddress(hlib,'glIsTexture');
+ pointer(glLightModelx):=GetProcAddress(hlib,'glLightModelx');
+ pointer(glLightModelxv):=GetProcAddress(hlib,'glLightModelxv');
+ pointer(glLightx):=GetProcAddress(hlib,'glLightx');
+ pointer(glLightxv):=GetProcAddress(hlib,'glLightxv');
+ pointer(glLineWidthx):=GetProcAddress(hlib,'glLineWidthx');
+ pointer(glLoadIdentity):=GetProcAddress(hlib,'glLoadIdentity');
+ pointer(glLoadMatrixx):=GetProcAddress(hlib,'glLoadMatrixx');
+ pointer(glLogicOp):=GetProcAddress(hlib,'glLogicOp');
+ pointer(glMaterialx):=GetProcAddress(hlib,'glMaterialx');
+ pointer(glMaterialxv):=GetProcAddress(hlib,'glMaterialxv');
+ pointer(glMatrixMode):=GetProcAddress(hlib,'glMatrixMode');
+ pointer(glMultMatrixx):=GetProcAddress(hlib,'glMultMatrixx');
+ pointer(glMultiTexCoord4x):=GetProcAddress(hlib,'glMultiTexCoord4x');
+ pointer(glNormal3x):=GetProcAddress(hlib,'glNormal3x');
+ pointer(glNormalPointer):=GetProcAddress(hlib,'glNormalPointer');
+ pointer(glOrthox):=GetProcAddress(hlib,'glOrthox');
+ pointer(glPixelStorei):=GetProcAddress(hlib,'glPixelStorei');
+ pointer(glPointParameterx):=GetProcAddress(hlib,'glPointParameterx');
+ pointer(glPointParameterxv):=GetProcAddress(hlib,'glPointParameterxv');
+ pointer(glPointSizex):=GetProcAddress(hlib,'glPointSizex');
+ pointer(glPolygonOffsetx):=GetProcAddress(hlib,'glPolygonOffsetx');
+ pointer(glPopMatrix):=GetProcAddress(hlib,'glPopMatrix');
+ pointer(glPushMatrix):=GetProcAddress(hlib,'glPushMatrix');
+ pointer(glReadPixels):=GetProcAddress(hlib,'glReadPixels');
+ pointer(glRotatex):=GetProcAddress(hlib,'glRotatex');
+ pointer(glSampleCoverage):=GetProcAddress(hlib,'glSampleCoverage');
+ pointer(glSampleCoveragex):=GetProcAddress(hlib,'glSampleCoveragex');
+ pointer(glScalex):=GetProcAddress(hlib,'glScalex');
+ pointer(glScissor):=GetProcAddress(hlib,'glScissor');
+ pointer(glShadeModel):=GetProcAddress(hlib,'glShadeModel');
+ pointer(glStencilFunc):=GetProcAddress(hlib,'glStencilFunc');
+ pointer(glStencilMask):=GetProcAddress(hlib,'glStencilMask');
+ pointer(glStencilOp):=GetProcAddress(hlib,'glStencilOp');
+ pointer(glTexCoordPointer):=GetProcAddress(hlib,'glTexCoordPointer');
+ pointer(glTexEnvi):=GetProcAddress(hlib,'glTexEnvi');
+ pointer(glTexEnvx):=GetProcAddress(hlib,'glTexEnvx');
+ pointer(glTexEnviv):=GetProcAddress(hlib,'glTexEnviv');
+ pointer(glTexEnvxv):=GetProcAddress(hlib,'glTexEnvxv');
+ pointer(glTexImage2D):=GetProcAddress(hlib,'glTexImage2D');
+ pointer(glTexParameteri):=GetProcAddress(hlib,'glTexParameteri');
+ pointer(glTexParameterx):=GetProcAddress(hlib,'glTexParameterx');
+ pointer(glTexParameteriv):=GetProcAddress(hlib,'glTexParameteriv');
+ pointer(glTexParameterxv):=GetProcAddress(hlib,'glTexParameterxv');
+ pointer(glTexSubImage2D):=GetProcAddress(hlib,'glTexSubImage2D');
+ pointer(glTranslatex):=GetProcAddress(hlib,'glTranslatex');
+ pointer(glVertexPointer):=GetProcAddress(hlib,'glVertexPointer');
+ pointer(glViewport):=GetProcAddress(hlib,'glViewport');
+ pointer(glPointSizePointerOES):=GetProcAddress(hlib,'glPointSizePointerOES');
+ end;
+
+procedure init;
+begin
+ Loadgles11('libGLESv1_CM.so');
+end;
+
+
+initialization
+ Loadgles11('gles11');
+finalization
+ Freegles11;
+
+end.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/project_files/Android-build/pushToDevice Tue Jun 28 17:57:54 2011 +0200
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+adb push ./out/libhwengine.so /sdcard/libhwengine.so
+adb shell "su -c \"cat /sdcard/libhwengine.so > /data/data/org.hedgewars/lib/libhwengine.so \""
+