Skip to content

Commit 1b1d4f8

Browse files
committed
Merge commit '4334abd7ffac0cab8d02d0ab1a01f97fb18a81c3' into HEAD
2 parents 4b6678c + 4334abd commit 1b1d4f8

File tree

375 files changed

+76620
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+76620
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Google Play Games C++ SDK Samples for Android
2+
=============================================
3+
4+
Copyright (C) 2014 Google Inc.
5+
6+
<h2>Contents</h2>
7+
8+
These samples illustrate how to use Google Play Game Services with your Android game.
9+
10+
* **CollectAllTheStarsNative**: Demonstrates how to use the Saved Games feature to save game data. The sample signs the user in, synchronizes their data from a named game save, and then updates the UI to reflect the saved game state.
11+
12+
* **TrivialQuestNative**: Demonstrates how to use the Events and Quests features of Google Play Game Services. The sample displays a sign-in button and four buttons to simulate killing monsters. Clicking a button generates an event, and sends it to Google Play Game Services to track what the player is doing in the game.
13+
14+
* **minimalist**: Demonstrates a minimal use case for the Google Play Game Services API.
15+
16+
* **TbmpSkeletonNative**: A trivial, turn-based multiplayer game. Many players can play together in this thrilling game, in which they send a shared gamestate string back and forth until someone finishes or cancels, or the second-to-last player leaves. Be the last one standing!
17+
18+
* **Teapots**: Demonstrates use of the Leaderboard and Achievement APIs.
19+
20+
**Note:** In samples with corresponding counterparts for iOS and Web (particularly, CollectAllTheStars and TypeANumber), the player can play a game seamlessly across phones of different platforms. For example, you can play some levels of CollectAllTheStars on your Android device, and then pick up your iOS device and continue where you left off! TypeANumber shows your achievements and leaderboards on all platforms; when you make progress on one platform, that progress is reflected on the other devices, as well.
21+
22+
<h2>How to run a sample</h2>
23+
To use these samples, you need the Google Play Game Services C++ SDK, which you
24+
can [download from here](https://developers.google.com/games/services/downloads/).
25+
26+
After downloading the archive, unzip it to the `./gpg-cpp-sdk` directory. Then, follow [these directions](https://developers.google.com/games/services/cpp/GettingStartedNativeClient).
27+
28+
<h2>Acknowledgment</h2>
29+
Some of these samples use the following open-source project:
30+
JASONCPP: https://github.com/open-source-parsers/jsoncpp
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
8+
<classpathentry kind="output" path="bin/classes"/>
9+
</classpath>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?fileVersion 4.0.0?>
3+
4+
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
5+
<storageModule moduleId="org.eclipse.cdt.core.settings">
6+
<cconfiguration id="com.android.toolchain.gcc.181210820">
7+
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.android.toolchain.gcc.181210820" moduleId="org.eclipse.cdt.core.settings" name="Default">
8+
<externalSettings/>
9+
<extensions>
10+
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
11+
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12+
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
13+
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
14+
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
15+
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
16+
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
17+
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
18+
</extensions>
19+
</storageModule>
20+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
21+
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.android.toolchain.gcc.181210820" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
22+
<folderInfo id="com.android.toolchain.gcc.181210820.966105379" name="/" resourcePath="">
23+
<toolChain id="com.android.toolchain.gcc.123930559" name="com.android.toolchain.gcc" superClass="com.android.toolchain.gcc">
24+
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="com.android.targetPlatform.111947863" isAbstract="false" superClass="com.android.targetPlatform"/>
25+
<builder id="com.android.builder.1884536907" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder">
26+
<outputEntries>
27+
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="obj"/>
28+
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="libs"/>
29+
</outputEntries>
30+
</builder>
31+
<tool id="com.android.gcc.compiler.480131119" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
32+
<inputType id="com.android.gcc.inputType.1326305680" superClass="com.android.gcc.inputType"/>
33+
</tool>
34+
</toolChain>
35+
</folderInfo>
36+
<sourceEntries>
37+
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="jni"/>
38+
</sourceEntries>
39+
</configuration>
40+
</storageModule>
41+
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
42+
</cconfiguration>
43+
</storageModule>
44+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
45+
<project id="CollectAllTheStarsNativeActivity.null.833469648" name="CollectAllTheStarsNativeActivity"/>
46+
</storageModule>
47+
<storageModule moduleId="scannerConfiguration">
48+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
49+
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.181210820;com.android.toolchain.gcc.181210820.966105379;com.android.gcc.compiler.480131119;com.android.gcc.inputType.1326305680">
50+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.android.AndroidPerProjectProfile"/>
51+
</scannerConfigBuildInfo>
52+
</storageModule>
53+
</cproject>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CollectAllTheStarsNativeActivity</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
<dictionary>
13+
<key>?children?</key>
14+
<value>?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\||</value>
15+
</dictionary>
16+
<dictionary>
17+
<key>?name?</key>
18+
<value></value>
19+
</dictionary>
20+
<dictionary>
21+
<key>org.eclipse.cdt.make.core.append_environment</key>
22+
<value>true</value>
23+
</dictionary>
24+
<dictionary>
25+
<key>org.eclipse.cdt.make.core.buildArguments</key>
26+
<value></value>
27+
</dictionary>
28+
<dictionary>
29+
<key>org.eclipse.cdt.make.core.buildCommand</key>
30+
<value>ndk-build</value>
31+
</dictionary>
32+
<dictionary>
33+
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
34+
<value>clean</value>
35+
</dictionary>
36+
<dictionary>
37+
<key>org.eclipse.cdt.make.core.contents</key>
38+
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
39+
</dictionary>
40+
<dictionary>
41+
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
42+
<value>false</value>
43+
</dictionary>
44+
<dictionary>
45+
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
46+
<value>true</value>
47+
</dictionary>
48+
<dictionary>
49+
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
50+
<value>true</value>
51+
</dictionary>
52+
<dictionary>
53+
<key>org.eclipse.cdt.make.core.stopOnError</key>
54+
<value>true</value>
55+
</dictionary>
56+
<dictionary>
57+
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
58+
<value>true</value>
59+
</dictionary>
60+
</arguments>
61+
</buildCommand>
62+
<buildCommand>
63+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
64+
<arguments>
65+
</arguments>
66+
</buildCommand>
67+
<buildCommand>
68+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
69+
<arguments>
70+
</arguments>
71+
</buildCommand>
72+
<buildCommand>
73+
<name>org.eclipse.jdt.core.javabuilder</name>
74+
<arguments>
75+
</arguments>
76+
</buildCommand>
77+
<buildCommand>
78+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
79+
<arguments>
80+
</arguments>
81+
</buildCommand>
82+
<buildCommand>
83+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
84+
<triggers>full,incremental,</triggers>
85+
<arguments>
86+
</arguments>
87+
</buildCommand>
88+
</buildSpec>
89+
<natures>
90+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
91+
<nature>org.eclipse.jdt.core.javanature</nature>
92+
<nature>org.eclipse.cdt.core.cnature</nature>
93+
<nature>org.eclipse.cdt.core.ccnature</nature>
94+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
95+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
96+
</natures>
97+
</projectDescription>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.google.example.games.catt3"
3+
android:versionCode="1"
4+
android:versionName="1.0" >
5+
6+
<uses-sdk
7+
android:minSdkVersion="11"
8+
android:targetSdkVersion="19" />
9+
10+
<uses-feature android:glEsVersion="0x00020000" >
11+
</uses-feature>
12+
13+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
14+
</uses-permission>
15+
16+
<application
17+
android:name="com.google.example.games.catt3.CollectAllTheStarsApplication"
18+
android:allowBackup="true"
19+
android:hasCode="true"
20+
android:icon="@drawable/ic_launcher"
21+
android:label="@string/app_name"
22+
android:theme="@style/AppTheme" >
23+
<meta-data
24+
android:name="com.google.android.gms.version"
25+
android:value="@integer/google_play_services_version" />
26+
<meta-data
27+
android:name="com.google.android.gms.games.APP_ID"
28+
android:value="@string/app_id" />
29+
30+
<!--
31+
Our activity is the built-in NativeActivity framework class.
32+
This will take care of integrating with our NDK code.
33+
-->
34+
<activity
35+
android:name="com.google.example.games.catt3.CollectAllTheStarsNativeActivity"
36+
android:label="@string/app_name"
37+
android:configChanges="orientation"
38+
android:screenOrientation="portrait">
39+
40+
<!-- Tell NativeActivity the name of or .so -->
41+
<meta-data
42+
android:name="android.app.lib_name"
43+
android:value="CollectAllTheStarsNativeActivity" />
44+
45+
<intent-filter>
46+
<action android:name="android.intent.action.MAIN" />
47+
48+
<category android:name="android.intent.category.LAUNCHER" />
49+
</intent-filter>
50+
</activity>
51+
</application>
52+
</manifest>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Google Play game services - CollectAllTheStarsNative C++ Samples
2+
===========================================
3+
Copyright (C) 2013 Google Inc.
4+
5+
<h2>Contents</h2>
6+
7+
CollectAllTheStarsNative: The sample demonstrates how to use Snapshot feature with C++ code with Google Play game services native SDK.
8+
9+
<h2>How to run a sample</h2>
10+
11+
1. Set up the project in Developer Console. For more info:
12+
13+
https://developers.google.com/games/services/console/enabling
14+
15+
Note your package name and the APP ID of the project.
16+
17+
1. Enable Turn-based multiplayer setting in Saved Games
18+
(see the ones that the sample needs in its res/values/ids.xml)
19+
20+
<h3>Eclipse settings</h3>
21+
22+
1. Start Eclipse
23+
1. Import the Google Play Services library project (available for download through the SDK manager):
24+
1. Click **File | Import | Android | Existing Android Code into Workspace**
25+
1. Select `SDK/extras/google/google_play_services/google_play_services_lib` (where `SDK` stands for the path where you installed your Android SDK)
26+
1. Click **Finish**
27+
1. Import the sample
28+
1. Go into the project properties window for that project (right-click, **Properties**) and check that this project has a reference to the `google_play_services_lib` project.
29+
1. IMPORTANT: replace package name and jni functions in the project.
30+
e.g. Change Java_com_google_example_games_catt3_CollectAllTheStarsNativeActivity_nativeOnActivityResult() function name to
31+
Java_YOUR_PACKAGE_NAME_CollectAllTheStarsNativeActivity_nativeOnActivityResult()
32+
33+
Your project should now compile. However, don't run it yet, since you still need to adjust your game's IDs
34+
in order for the sample(s) to work.
35+
36+
Now jump to the *Modify IDs, compile and run* section and continue to follow the instructions there.
37+
38+
<h3>Modify IDs, compile and run</h3>
39+
40+
To set up a sample:
41+
42+
1. Change the package name from com.google.example.games.\* to your own package name
43+
(the same one you registered in Developer Console!). To do that, open **AndroidManifest.xml** and put
44+
your package name in the "package" attribute of the **manifest** tag. You will need to
45+
fix some of the references (particularly to the generated R class) because of the package name
46+
change. Ctrl+Shift+O in Eclipse (and Alt+Enter in Android Studio) should take care of most of the work.
47+
1. Modify res/values/strings.xml and place your IDs there, as given by the
48+
Developer Console (create the leaderboards and achievements necessary for
49+
the sample, if any). Remember that the App ID is only the *numerical* portion
50+
of your client ID, so use `123456789012` and not `123456789012.apps.gooogleusercontent.com`.
51+
1. Compile and run.
52+
53+
IMPORTANT: make sure to sign your apk with the same certificate
54+
as the one whose fingerprint you configured on Developer Console, otherwise
55+
you will see errors.
56+
57+
IMPORTANT: if you are testing an unpublished game, make sure that the account you intend
58+
to sign in with (the account on the test device) is listed as a tester in the
59+
project on your Developer Console setup (check the list in the "Testing"
60+
section), otherwise the server will act as though your project did not exist and
61+
return errors.
62+
63+
<h2>Support</h2>
64+
65+
First of all, take a look at our [troubleshooting guide](https://developers.google.com/games/services/android/troubleshooting). Most setup issues can be solved by following this guide.
66+
67+
If your question is not answered by the troubleshooting guide, we encourage you to post your question to [stackoverflow.com](stackoverflow.com). Our team answers questions there reguarly.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
//
3+
// ShaderPlain.fsh
4+
//
5+
6+
#define USE_PHONG (1)
7+
8+
uniform lowp vec3 vMaterialAmbient;
9+
uniform mediump vec4 vMaterialSpecular;
10+
11+
varying lowp vec4 colorDiffuse;
12+
13+
#if USE_PHONG
14+
uniform highp vec3 vLight0;
15+
varying mediump vec3 position;
16+
varying mediump vec3 normal;
17+
#else
18+
varying lowp vec4 colorSpecular;
19+
#endif
20+
21+
/*
22+
Standard phong fragment shader implementation.
23+
Take object space light position and normal, derive a specular intensity.
24+
*/
25+
void main() {
26+
#if USE_PHONG
27+
mediump vec3
28+
halfVector = normalize(-vLight0 + position);
29+
mediump
30+
float NdotH = max(dot(normalize(normal), halfVector), 0.0);
31+
mediump
32+
float fPower = vMaterialSpecular.w;
33+
mediump
34+
float specular = pow(NdotH, fPower);
35+
36+
lowp vec4
37+
colorSpecular = vec4(vMaterialSpecular.xyz * specular, 1);
38+
gl_FragColor = colorDiffuse + colorSpecular;
39+
#else
40+
gl_FragColor = colorDiffuse + colorSpecular;
41+
#endif
42+
}

0 commit comments

Comments
 (0)