├── Resources
├── res
│ └── .gitkeep
├── CloseNormal.png
├── HelloWorld.png
├── CloseSelected.png
└── fonts
│ └── Marker Felt.ttf
├── .cocos-project.json
├── proj.wp8-xaml
├── AppComponent
│ ├── src
│ │ ├── pch.cpp
│ │ ├── pch.h
│ │ ├── EditBoxEvent.cpp
│ │ ├── EditBoxEvent.h
│ │ ├── DirectXHelper.h
│ │ ├── Direct3DContentProvider.h
│ │ ├── Direct3DContentProvider.cpp
│ │ ├── Cocos2dRenderer.h
│ │ ├── DirectXBase.h
│ │ ├── Direct3DInterop.h
│ │ ├── Cocos2dRenderer.cpp
│ │ ├── Direct3DInterop.cpp
│ │ └── DirectXBase.cpp
│ └── ModelViewerComponent.vcxproj.filters
├── App
│ ├── SplashScreenImage.jpg
│ ├── Assets
│ │ ├── AlignmentGrid.png
│ │ ├── ApplicationIcon.png
│ │ └── Tiles
│ │ │ ├── IconicTileSmall.png
│ │ │ ├── FlipCycleTileLarge.png
│ │ │ ├── FlipCycleTileSmall.png
│ │ │ ├── FlipCycleTileMedium.png
│ │ │ └── IconicTileMediumLarge.png
│ ├── Properties
│ │ ├── AppManifest.xml
│ │ ├── AssemblyInfo.cs
│ │ └── WMAppManifest.xml
│ ├── LocalizedStrings.cs
│ ├── App.xaml
│ ├── EditBox.xaml
│ ├── MainPage.xaml
│ ├── Resources
│ │ ├── AppResources.Designer.cs
│ │ └── AppResources.resx
│ ├── EditBox.xaml.cs
│ ├── ModelViewer.csproj
│ └── MainPage.xaml.cs
└── ModelViewer.sln
├── .gitmodules
├── proj.win32
├── res
│ └── game.ico
├── build-cfg.json
├── main.h
├── resource.h
├── main.cpp
├── ModelViewer.vcxproj.user
├── ModelViewer.vcxproj.filters
├── game.rc
├── ModelViewer.sln
└── ModelViewer.vcxproj
├── proj.ios_mac
├── ios
│ ├── Default.png
│ ├── Icon-29.png
│ ├── Icon-40.png
│ ├── Icon-50.png
│ ├── Icon-57.png
│ ├── Icon-58.png
│ ├── Icon-72.png
│ ├── Icon-76.png
│ ├── Icon-80.png
│ ├── Icon-100.png
│ ├── Icon-114.png
│ ├── Icon-120.png
│ ├── Icon-144.png
│ ├── Icon-152.png
│ ├── Default@2x.png
│ ├── Default-568h@2x.png
│ ├── Default-667h@2x.png
│ ├── Default-736h@3x.png
│ ├── AppController.h
│ ├── Prefix.pch
│ ├── main.m
│ ├── RootViewController.h
│ ├── RootViewController.mm
│ ├── Info.plist
│ └── AppController.mm
└── mac
│ ├── Icon.icns
│ ├── Prefix.pch
│ ├── Info.plist
│ └── main.cpp
├── proj.android
├── res
│ ├── drawable-hdpi
│ │ └── icon.png
│ ├── drawable-ldpi
│ │ └── icon.png
│ ├── drawable-mdpi
│ │ └── icon.png
│ └── values
│ │ └── strings.xml
├── .settings
│ ├── org.eclipse.ltk.core.refactoring.prefs
│ ├── org.eclipse.cdt.core.prefs
│ └── org.eclipse.cdt.codan.core.prefs
├── build-cfg.json
├── jni
│ ├── Application.mk
│ ├── hellocpp
│ │ └── main.cpp
│ └── Android.mk
├── project.properties
├── .classpath
├── ant.properties
├── proguard-project.txt
├── src
│ └── org
│ │ └── cocos2dx
│ │ └── cpp
│ │ └── AppActivity.java
├── AndroidManifest.xml
├── build.xml
├── .project
└── build_native.py
├── .gitignore
├── proj.linux
└── main.cpp
├── README.md
├── Classes
├── AppDelegate.h
├── HelloWorldScene.h
├── AppDelegate.cpp
└── HelloWorldScene.cpp
└── CMakeLists.txt
/Resources/res/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.cocos-project.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_type": "cpp"
3 | }
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/pch.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "cocos2d"]
2 | path = cocos2d
3 | url = https://github.com/cocos2d/cocos2d-x
4 |
--------------------------------------------------------------------------------
/proj.win32/res/game.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.win32/res/game.ico
--------------------------------------------------------------------------------
/Resources/CloseNormal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/Resources/CloseNormal.png
--------------------------------------------------------------------------------
/Resources/HelloWorld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/Resources/HelloWorld.png
--------------------------------------------------------------------------------
/Resources/CloseSelected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/Resources/CloseSelected.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Default.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-29.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-40.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-50.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-57.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-58.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-72.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-76.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-80.png
--------------------------------------------------------------------------------
/proj.ios_mac/mac/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/mac/Icon.icns
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-100.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-114.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-120.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-144.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Icon-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Icon-152.png
--------------------------------------------------------------------------------
/Resources/fonts/Marker Felt.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/Resources/fonts/Marker Felt.ttf
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Default@2x.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Default-568h@2x.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Default-667h@2x.png
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.ios_mac/ios/Default-736h@3x.png
--------------------------------------------------------------------------------
/proj.android/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.android/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/proj.android/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.android/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/proj.android/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.android/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/SplashScreenImage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/SplashScreenImage.jpg
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/AlignmentGrid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/AlignmentGrid.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/ApplicationIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/ApplicationIcon.png
--------------------------------------------------------------------------------
/proj.android/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ModelViewer
4 |
5 |
--------------------------------------------------------------------------------
/proj.win32/build-cfg.json:
--------------------------------------------------------------------------------
1 | {
2 | "copy_resources": [
3 | {
4 | "from": "../Resources",
5 | "to": ""
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------
/proj.android/.settings/org.eclipse.ltk.core.refactoring.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
3 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/Tiles/IconicTileSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/Tiles/IconicTileSmall.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileLarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileLarge.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileSmall.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileMedium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/Tiles/FlipCycleTileMedium.png
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Assets/Tiles/IconicTileMediumLarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/songchengjiang/cocos2d-x-ModelViewer/HEAD/proj.wp8-xaml/App/Assets/Tiles/IconicTileMediumLarge.png
--------------------------------------------------------------------------------
/proj.android/.settings/org.eclipse.cdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | environment/project/0.1230402123/append=true
3 | environment/project/0.1230402123/appendContributed=true
4 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/pch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "targetver.h"
4 |
5 | #ifndef WIN32_LEAN_AND_MEAN
6 | #define WIN32_LEAN_AND_MEAN
7 | #endif
8 |
9 | #include
10 | #include "cocos2d.h"
11 | #include "cocos-ext.h"
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/proj.ios_mac/mac/Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
9 | #ifdef __cplusplus
10 | #include "cocos2d.h"
11 | #endif
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Compiled Dynamic libraries
8 | *.so
9 | *.dylib
10 | *.dll
11 |
12 | # Compiled Static libraries
13 | *.lai
14 | *.la
15 | *.a
16 | *.lib
17 |
18 | # Executables
19 | *.exe
20 | *.out
21 | *.app
22 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/AppController.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @class RootViewController;
4 |
5 | @interface AppController : NSObject {
6 | UIWindow *window;
7 | }
8 |
9 | @property(nonatomic, readonly) RootViewController* viewController;
10 |
11 | @end
12 |
13 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'iphone' target in the 'iphone' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #import
8 | #endif
9 |
10 | #ifdef __cplusplus
11 | #include "cocos2d.h"
12 | #endif
--------------------------------------------------------------------------------
/proj.ios_mac/ios/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | int main(int argc, char *argv[]) {
4 |
5 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
6 | int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
7 | [pool release];
8 | return retVal;
9 | }
10 |
--------------------------------------------------------------------------------
/proj.android/build-cfg.json:
--------------------------------------------------------------------------------
1 | {
2 | "ndk_module_path" :[
3 | "../cocos2d",
4 | "../cocos2d/cocos",
5 | "../cocos2d/external"
6 | ],
7 | "copy_resources": [
8 | {
9 | "from": "../Resources",
10 | "to": ""
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/proj.win32/main.h:
--------------------------------------------------------------------------------
1 | #ifndef __MAIN_H__
2 | #define __MAIN_H__
3 |
4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
5 |
6 | // Windows Header Files:
7 | #include
8 | #include
9 |
10 | // C RunTime Header Files
11 | #include "CCStdC.h"
12 |
13 | #endif // __MAIN_H__
14 |
--------------------------------------------------------------------------------
/proj.linux/main.cpp:
--------------------------------------------------------------------------------
1 | #include "../Classes/AppDelegate.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | USING_NS_CC;
9 |
10 | int main(int argc, char **argv)
11 | {
12 | // create the application instance
13 | AppDelegate app;
14 | return Application::getInstance()->run();
15 | }
16 |
--------------------------------------------------------------------------------
/proj.android/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_STL := c++_static
2 | NDK_TOOLCHAIN_VERSION=clang
3 |
4 | APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
5 | APP_LDFLAGS := -latomic
6 |
7 |
8 | ifeq ($(NDK_DEBUG),1)
9 | APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
10 | APP_OPTIM := debug
11 | else
12 | APP_CPPFLAGS += -DNDEBUG
13 | APP_OPTIM := release
14 | endif
15 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/LocalizedStrings.cs:
--------------------------------------------------------------------------------
1 | using PhoneDirect3DXamlAppInterop.Resources;
2 |
3 | namespace PhoneDirect3DXamlAppInterop
4 | {
5 | ///
6 | /// Provides access to string resources.
7 | ///
8 | public class LocalizedStrings
9 | {
10 | private static AppResources _localizedResources = new AppResources();
11 |
12 | public AppResources LocalizedResources { get { return _localizedResources; } }
13 | }
14 | }
--------------------------------------------------------------------------------
/proj.android/jni/hellocpp/main.cpp:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "cocos2d.h"
3 | #include "platform/android/jni/JniHelper.h"
4 | #include
5 | #include
6 |
7 | #define LOG_TAG "main"
8 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
9 |
10 | using namespace cocos2d;
11 |
12 | void cocos_android_app_init (JNIEnv* env, jobject thiz) {
13 | LOGD("cocos_android_app_init");
14 | AppDelegate *pAppDelegate = new AppDelegate();
15 | }
16 |
--------------------------------------------------------------------------------
/proj.android/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-10
12 |
13 | android.library.reference.1=../cocos2d/cocos/platform/android/java
14 |
--------------------------------------------------------------------------------
/proj.android/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/proj.win32/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by game.RC
4 | //
5 |
6 | #define IDS_PROJNAME 100
7 | #define IDR_TESTJS 100
8 |
9 | #define ID_FILE_NEW_WINDOW 32771
10 |
11 | // Next default values for new objects
12 | //
13 | #ifdef APSTUDIO_INVOKED
14 | #ifndef APSTUDIO_READONLY_SYMBOLS
15 | #define _APS_NEXT_RESOURCE_VALUE 201
16 | #define _APS_NEXT_CONTROL_VALUE 1000
17 | #define _APS_NEXT_SYMED_VALUE 101
18 | #define _APS_NEXT_COMMAND_VALUE 32775
19 | #endif
20 | #endif
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## ModelViewer version 0.1 ##
2 | It is for cocos2d-x after version v3.5 beta0
3 |
4 | View .c3t/.c3b Model
5 |
6 | View .pu (ParticleUniverse File Format: http://www.fxpression.com/)
7 |
8 | Source code is here,
9 | https://github.com/songchengjiang/cocos2d-x-ModelViewer
10 |
11 | USAGE:
12 |
13 | Command line
14 | WIN/MAC:
15 | cd [path of ModelViewer]
16 | ./ModelViewer MODELFILEPATH or PUFILEPATH
17 |
18 | Note:
19 | LEFT_MOUSE_BUTTON --- Rotate Camera
20 |
21 | RIGHT_MOUSE_BUTTON --- Translate Camera
22 |
23 | MIDDLE_MOUSE_BUTTON --- Scale Camera
24 |
25 | SPACE_KEYBOARD --- Reset Camera
--------------------------------------------------------------------------------
/proj.android/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
6 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
7 | $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
8 |
9 | LOCAL_MODULE := cocos2dcpp_shared
10 |
11 | LOCAL_MODULE_FILENAME := libcocos2dcpp
12 |
13 | LOCAL_SRC_FILES := hellocpp/main.cpp \
14 | ../../Classes/AppDelegate.cpp \
15 | ../../Classes/HelloWorldScene.cpp
16 |
17 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
18 |
19 | LOCAL_STATIC_LIBRARIES := cocos2dx_static
20 |
21 | include $(BUILD_SHARED_LIBRARY)
22 |
23 | $(call import-module,.)
24 |
--------------------------------------------------------------------------------
/proj.win32/main.cpp:
--------------------------------------------------------------------------------
1 | #include "main.h"
2 | #include "AppDelegate.h"
3 | #include "cocos2d.h"
4 |
5 | USING_NS_CC;
6 |
7 | int APIENTRY _tWinMain(HINSTANCE hInstance,
8 | HINSTANCE hPrevInstance,
9 | LPTSTR lpCmdLine,
10 | int nCmdShow)
11 | {
12 | UNREFERENCED_PARAMETER(hPrevInstance);
13 | UNREFERENCED_PARAMETER(lpCmdLine);
14 |
15 | std::wstring cmdline(lpCmdLine);
16 | std::string path;
17 | for (auto iter : cmdline){
18 | if (iter == '\\')
19 | iter = '/';
20 |
21 | path.push_back(iter);
22 | }
23 | // create the application instance
24 | AppDelegate app(path);
25 | return Application::getInstance()->run();
26 | }
27 |
--------------------------------------------------------------------------------
/proj.android/ant.properties:
--------------------------------------------------------------------------------
1 | # This file is used to override default values used by the Ant build system.
2 | #
3 | # This file must be checked into Version Control Systems, as it is
4 | # integral to the build system of your project.
5 |
6 | # This file is only used by the Ant script.
7 |
8 | # You can use this to override default values such as
9 | # 'source.dir' for the location of your java source folder and
10 | # 'out.dir' for the location of your output folder.
11 |
12 | # You can also use it define how the release builds are signed by declaring
13 | # the following properties:
14 | # 'key.store' for the location of your keystore and
15 | # 'key.alias' for the name of the key to use.
16 | # The password will be asked during the build when you use the 'release' target.
17 |
18 |
--------------------------------------------------------------------------------
/proj.win32/ModelViewer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(ProjectDir)..\Resources
5 | WindowsLocalDebugger
6 | D:/Develop/cocos2d-x/tests/cpp-tests/Resources/Particle3D/scripts/blackHole.pu
7 |
8 |
9 | $(ProjectDir)..\Resources
10 | WindowsLocalDebugger
11 |
12 |
--------------------------------------------------------------------------------
/proj.android/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Classes/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #ifndef _APP_DELEGATE_H_
2 | #define _APP_DELEGATE_H_
3 |
4 | #include "cocos2d.h"
5 |
6 | /**
7 | @brief The cocos2d Application.
8 |
9 | The reason for implement as private inheritance is to hide some interface call by Director.
10 | */
11 | class AppDelegate : private cocos2d::Application
12 | {
13 | public:
14 | AppDelegate(const std::string &filePath);
15 | virtual ~AppDelegate();
16 |
17 | virtual void initGLContextAttrs();
18 |
19 | /**
20 | @brief Implement Director and Scene init code here.
21 | @return true Initialize success, app continue.
22 | @return false Initialize failed, app terminate.
23 | */
24 | virtual bool applicationDidFinishLaunching();
25 |
26 | /**
27 | @brief The function be called when the application enter background
28 | @param the pointer of the application
29 | */
30 | virtual void applicationDidEnterBackground();
31 |
32 | /**
33 | @brief The function be called when the application enter foreground
34 | @param the pointer of the application
35 | */
36 | virtual void applicationWillEnterForeground();
37 |
38 | private:
39 |
40 | std::string _modelFilePath;
41 | };
42 |
43 | #endif // _APP_DELEGATE_H_
44 |
45 |
--------------------------------------------------------------------------------
/proj.win32/ModelViewer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {84a8ebd7-7cf0-47f6-b75e-d441df67da40}
6 |
7 |
8 | {715254bc-d70b-4ec5-bf29-467dd3ace079}
9 |
10 |
11 | {bb6c862e-70e9-49d9-81b7-3829a6f50471}
12 |
13 |
14 |
15 |
16 | win32
17 |
18 |
19 |
20 |
21 |
22 |
23 | win32
24 |
25 |
26 |
27 |
28 |
29 |
30 | resource
31 |
32 |
33 |
--------------------------------------------------------------------------------
/proj.ios_mac/mac/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIconFile
10 | Icon
11 | CFBundleIdentifier
12 | org.cocos2dx.ModelViewer
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ${PRODUCT_NAME}
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSApplicationCategoryType
26 | public.app-category.games
27 | LSMinimumSystemVersion
28 | ${MACOSX_DEPLOYMENT_TARGET}
29 | NSHumanReadableCopyright
30 | Copyright © 2013. All rights reserved.
31 | NSMainNibFile
32 | MainMenu
33 | NSPrincipalClass
34 | NSApplication
35 |
36 |
37 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/EditBox.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/RootViewController.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) 2013-2014 Chukong Technologies Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #import
27 |
28 |
29 | @interface RootViewController : UIViewController {
30 |
31 | }
32 | - (BOOL) prefersStatusBarHidden;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/proj.ios_mac/mac/main.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #include "AppDelegate.h"
26 | #include "cocos2d.h"
27 |
28 | USING_NS_CC;
29 |
30 | int main(int argc, char *argv[])
31 | {
32 | if (argc < 2) return -1;
33 | AppDelegate app(argv[1]);
34 | return Application::getInstance()->run();
35 | }
36 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("PhoneDirect3DXamlAppInterop")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("PhoneDirect3DXamlAppInterop")]
14 | [assembly: AssemblyCopyright("Copyright © 2012")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("e9152507-1b95-4fca-9d7f-444a024ccb98")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Revision and Build Numbers
34 | // by using the '*' as shown below:
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
38 |
--------------------------------------------------------------------------------
/proj.android/src/org/cocos2dx/cpp/AppActivity.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2008-2010 Ricardo Quesada
3 | Copyright (c) 2010-2012 cocos2d-x.org
4 | Copyright (c) 2011 Zynga Inc.
5 | Copyright (c) 2013-2014 Chukong Technologies Inc.
6 |
7 | http://www.cocos2d-x.org
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.
26 | ****************************************************************************/
27 | package org.cocos2dx.cpp;
28 |
29 | import org.cocos2dx.lib.Cocos2dxActivity;
30 |
31 | public class AppActivity extends Cocos2dxActivity {
32 | }
33 |
--------------------------------------------------------------------------------
/proj.android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/EditBoxEvent.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2014 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #include "EditBoxEvent.h"
26 |
27 | using namespace Platform;
28 |
29 | namespace PhoneDirect3DXamlAppComponent
30 | {
31 | EditBoxEvent::EditBoxEvent( Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler^ handle ):
32 | m_sender(sender),
33 | m_args(arg),
34 | m_handler(handle)
35 | {
36 |
37 | }
38 |
39 | void EditBoxEvent::execute()
40 | {
41 | if(m_handler.Get())
42 | {
43 | m_handler.Get()->Invoke(m_sender.Get(), m_args.Get());
44 | }
45 | }
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/Classes/HelloWorldScene.h:
--------------------------------------------------------------------------------
1 | #ifndef __MODELVIEWER_SCENE_H__
2 | #define __MODELVIEWER_SCENE_H__
3 |
4 | #include "cocos2d.h"
5 |
6 | class ModelViewer : public cocos2d::Layer
7 | {
8 | public:
9 | // there's no 'id' in cpp, so we recommend returning the class instance pointer
10 | static cocos2d::Scene* createScene(const std::string &filePath);
11 |
12 | // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
13 | virtual bool init();
14 |
15 | void loadModelOrParticle(const std::string &filePath);
16 | void setCamera();
17 |
18 | // implement the "static create()" method manually
19 | CREATE_FUNC(ModelViewer);
20 |
21 | CC_CONSTRUCTOR_ACCESS:
22 | ModelViewer();
23 | virtual ~ModelViewer();
24 |
25 | protected:
26 |
27 | void loadModel(const std::string &filePath);
28 | void loadParticle(const std::string &filePath);
29 |
30 | void onTouchsMovedThis(const std::vector &touchs, cocos2d::Event *event);
31 | void onMouseScrollThis(cocos2d::Event* event);
32 | void onMouseMovedThis(cocos2d::Event* event);
33 | void onKeyPressedThis(cocos2d::EventKeyboard::KeyCode keycode, cocos2d::Event *event);
34 |
35 | void trackball( cocos2d::Vec3 & axis, float & angle, float p1x, float p1y, float p2x, float p2y );
36 | float tb_project_to_sphere( float r, float x, float y );
37 |
38 | void updateCameraTransform();
39 | void resetCamera();
40 | void getFileExtension(const char *file_name,char *extension);
41 | private:
42 |
43 | cocos2d::Camera *_camera;
44 | cocos2d::Layer *_layer;
45 |
46 | float _orginDistance;
47 | cocos2d::Vec3 _orginCenter;
48 |
49 | float _distance;
50 | float _trackballSize;
51 | cocos2d::Quaternion _rotation;
52 | cocos2d::Vec3 _center;
53 | cocos2d::Vec2 _preMouseLocation;
54 | };
55 |
56 | #endif // __HELLOWORLD_SCENE_H__
57 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/EditBoxEvent.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2014 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #ifndef __EditBoxEVENT_H__
26 | #define __EditBoxEVENT_H__
27 |
28 | #include "InputEvent.h"
29 | #include
30 |
31 |
32 | namespace PhoneDirect3DXamlAppComponent
33 | {
34 | class EditBoxEvent : public cocos2d::InputEvent
35 | {
36 | public:
37 | EditBoxEvent(Platform::Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler^ handle);
38 |
39 | virtual void execute();
40 |
41 | private:
42 | Platform::Agile m_sender;
43 | Platform::Agile m_args;
44 | Platform::Agile^> m_handler;
45 | };
46 | }
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/Classes/AppDelegate.cpp:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "HelloWorldScene.h"
3 |
4 | USING_NS_CC;
5 |
6 | AppDelegate::AppDelegate(const std::string &filePath)
7 | : _modelFilePath(filePath)
8 | {
9 |
10 | }
11 |
12 | AppDelegate::~AppDelegate()
13 | {
14 | }
15 |
16 | //if you want a different context,just modify the value of glContextAttrs
17 | //it will takes effect on all platforms
18 | void AppDelegate::initGLContextAttrs()
19 | {
20 | //set OpenGL context attributions,now can only set six attributions:
21 | //red,green,blue,alpha,depth,stencil
22 | GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
23 |
24 | GLView::setGLContextAttrs(glContextAttrs);
25 | }
26 |
27 | bool AppDelegate::applicationDidFinishLaunching() {
28 | // initialize director
29 | auto director = Director::getInstance();
30 | auto glview = director->getOpenGLView();
31 | if(!glview) {
32 | glview = GLViewImpl::create("ModelViewer");
33 | director->setOpenGLView(glview);
34 | }
35 |
36 | // turn on display FPS
37 | director->setDisplayStats(true);
38 |
39 | // set FPS. the default value is 1.0/60 if you don't call this
40 | director->setAnimationInterval(1.0 / 60);
41 |
42 | // create a scene. it's an autorelease object
43 | auto scene = ModelViewer::createScene(_modelFilePath);
44 |
45 | // run
46 | director->runWithScene(scene);
47 |
48 | return true;
49 | }
50 |
51 | // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
52 | void AppDelegate::applicationDidEnterBackground() {
53 | Director::getInstance()->stopAnimation();
54 |
55 | // if you use SimpleAudioEngine, it must be pause
56 | // SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
57 | }
58 |
59 | // this function will be called when the app is active again
60 | void AppDelegate::applicationWillEnterForeground() {
61 | Director::getInstance()->startAnimation();
62 |
63 | // if you use SimpleAudioEngine, it must resume here
64 | // SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
65 | }
66 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Properties/WMAppManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Assets\ApplicationIcon.png
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Assets\Tiles\FlipCycleTileSmall.png
20 | 0
21 | Assets\Tiles\FlipCycleTileMedium.png
22 | PhoneDirect3DXamlAppInterop
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/DirectXHelper.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | //// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
27 | //// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
28 | //// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
29 | //// PARTICULAR PURPOSE.
30 | ////
31 | //// Copyright (c) Microsoft Corporation. All rights reserved
32 |
33 | #pragma once
34 |
35 |
36 | // This header defines helper utilities to make DirectX APIs work with exceptions.
37 | namespace DX
38 | {
39 | inline void ThrowIfFailed(HRESULT hr)
40 | {
41 | if (FAILED(hr))
42 | {
43 | // Set a breakpoint on this line to catch DX API errors.
44 | throw Platform::Exception::CreateException(hr);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/proj.win32/game.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #include "resource.h"
4 |
5 | #define APSTUDIO_READONLY_SYMBOLS
6 | /////////////////////////////////////////////////////////////////////////////
7 | //
8 | // Generated from the TEXTINCLUDE 2 resource.
9 | //
10 | #define APSTUDIO_HIDDEN_SYMBOLS
11 | #include "windows.h"
12 | #undef APSTUDIO_HIDDEN_SYMBOLS
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (U.S.) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | #ifdef _WIN32
21 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
22 | #pragma code_page(1252)
23 | #endif //_WIN32
24 |
25 | #ifdef APSTUDIO_INVOKED
26 | /////////////////////////////////////////////////////////////////////////////
27 | //
28 | // TEXTINCLUDE
29 | //
30 |
31 | 1 TEXTINCLUDE
32 | BEGIN
33 | "resource.h\0"
34 | END
35 |
36 | #endif // APSTUDIO_INVOKED
37 |
38 | /////////////////////////////////////////////////////////////////////////////
39 | //
40 | // Icon
41 | //
42 |
43 | // Icon with lowest ID value placed first to ensure application icon
44 | // remains consistent on all systems.
45 | GLFW_ICON ICON "res\\game.ico"
46 |
47 | /////////////////////////////////////////////////////////////////////////////
48 | //
49 | // Version
50 | //
51 |
52 | VS_VERSION_INFO VERSIONINFO
53 | FILEVERSION 1,0,0,1
54 | PRODUCTVERSION 1,0,0,1
55 | FILEFLAGSMASK 0x3fL
56 | #ifdef _DEBUG
57 | FILEFLAGS 0x1L
58 | #else
59 | FILEFLAGS 0x0L
60 | #endif
61 | FILEOS 0x4L
62 | FILETYPE 0x2L
63 | FILESUBTYPE 0x0L
64 | BEGIN
65 | BLOCK "StringFileInfo"
66 | BEGIN
67 | BLOCK "040904B0"
68 | BEGIN
69 | VALUE "CompanyName", "\0"
70 | VALUE "FileDescription", "game Module\0"
71 | VALUE "FileVersion", "1, 0, 0, 1\0"
72 | VALUE "InternalName", "game\0"
73 | VALUE "LegalCopyright", "Copyright \0"
74 | VALUE "OriginalFilename", "game.exe\0"
75 | VALUE "ProductName", "game Module\0"
76 | VALUE "ProductVersion", "1, 0, 0, 1\0"
77 | END
78 | END
79 | BLOCK "VarFileInfo"
80 | BEGIN
81 | VALUE "Translation", 0x0409, 0x04B0
82 | END
83 | END
84 |
85 | /////////////////////////////////////////////////////////////////////////////
86 | #endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
87 |
--------------------------------------------------------------------------------
/proj.win32/ModelViewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModelViewer", "ModelViewer.vcxproj", "{76A39BB2-9B84-4C65-98A5-654D86B86F2A}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}
7 | EndProjectSection
8 | EndProject
9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\cocos2d\cocos\2d\libcocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}"
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\cocos2d\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}"
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos2d\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}"
14 | EndProject
15 | Global
16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
17 | Debug|Win32 = Debug|Win32
18 | Release|Win32 = Release|Win32
19 | EndGlobalSection
20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
21 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.ActiveCfg = Debug|Win32
22 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Debug|Win32.Build.0 = Debug|Win32
23 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.ActiveCfg = Release|Win32
24 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}.Release|Win32.Build.0 = Release|Win32
25 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32
26 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32
27 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32
28 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32
29 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32
30 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32
31 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32
32 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32
33 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32
34 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32
35 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32
36 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Direct3DContentProvider.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include "Direct3DInterop.h"
33 |
34 | class Direct3DContentProvider : public Microsoft::WRL::RuntimeClass<
35 | Microsoft::WRL::RuntimeClassFlags,
36 | ABI::Windows::Phone::Graphics::Interop::IDrawingSurfaceBackgroundContentProvider,
37 | IDrawingSurfaceBackgroundContentProviderNative>
38 | {
39 | public:
40 | Direct3DContentProvider(PhoneDirect3DXamlAppComponent::Direct3DInterop^ controller);
41 |
42 | // IDrawingSurfaceContentProviderNative
43 | HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device);
44 | void STDMETHODCALLTYPE Disconnect();
45 |
46 | HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize);
47 | HRESULT STDMETHODCALLTYPE Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView);
48 |
49 | private:
50 | PhoneDirect3DXamlAppComponent::Direct3DInterop^ m_controller;
51 | Microsoft::WRL::ComPtr m_host;
52 | };
53 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Direct3DContentProvider.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #include "Direct3DContentProvider.h"
27 | #include "Direct3DInterop.h"
28 |
29 | using namespace PhoneDirect3DXamlAppComponent;
30 |
31 | Direct3DContentProvider::Direct3DContentProvider(Direct3DInterop^ controller) :
32 | m_controller(controller)
33 | {
34 | m_controller->RequestAdditionalFrame += ref new RequestAdditionalFrameHandler([=] ()
35 | {
36 | if (m_host)
37 | {
38 | m_host->RequestAdditionalFrame();
39 | }
40 | });
41 | }
42 |
43 | // IDrawingSurfaceContentProviderNative interface
44 | HRESULT Direct3DContentProvider::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
45 | {
46 | m_host = host;
47 |
48 | return m_controller->Connect(host, device);
49 | }
50 |
51 | void Direct3DContentProvider::Disconnect()
52 | {
53 | m_controller->Disconnect();
54 | m_host = nullptr;
55 | }
56 |
57 | HRESULT Direct3DContentProvider::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize)
58 | {
59 | return m_controller->PrepareResources(presentTargetTime, desiredRenderTargetSize);
60 | }
61 |
62 | HRESULT Direct3DContentProvider::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
63 | {
64 | return m_controller->Draw(device, context, renderTargetView);
65 | }
66 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/ModelViewerComponent.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | src
6 |
7 |
8 | src
9 |
10 |
11 | src
12 |
13 |
14 | src
15 |
16 |
17 | src
18 |
19 |
20 | Classes
21 |
22 |
23 | Classes
24 |
25 |
26 | src
27 |
28 |
29 |
30 |
31 | src
32 |
33 |
34 | src
35 |
36 |
37 | src
38 |
39 |
40 | src
41 |
42 |
43 | src
44 |
45 |
46 | src
47 |
48 |
49 | Classes
50 |
51 |
52 | Classes
53 |
54 |
55 | src
56 |
57 |
58 |
59 |
60 | {ddb0f381-1dc4-44a0-ab28-0f672a551265}
61 |
62 |
63 | {6fcff44b-bb9f-4ed9-8553-558855bc91e3}
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Cocos2dRenderer.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 | #pragma once
26 |
27 | #include "InputEvent.h"
28 | #include "DirectXBase.h"
29 |
30 | class AppDelegate;
31 |
32 | ref class Cocos2dRenderer sealed : public DirectXBase
33 | {
34 | public:
35 | Cocos2dRenderer(Windows::Graphics::Display::DisplayOrientations orientation);
36 |
37 | // Direct3DBase methods.
38 | virtual void OnOrientationChanged(Windows::Graphics::Display::DisplayOrientations orientation) override;
39 | virtual bool OnRender() override;
40 | virtual void CreateGLResources() override;
41 |
42 | void OnBackButton();
43 | void OnKeyPressed(Platform::String^ text);
44 | void OnCocos2dKeyEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent event);
45 | void SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate);
46 | void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate);
47 | void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate);
48 | void SetXamlOpenURLDelegate(PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ delegate);
49 |
50 | Windows::Foundation::IAsyncAction^ OnSuspending();
51 | void Connect();
52 | void Disconnect();
53 |
54 | protected:
55 | virtual void OnUpdateDevice() override;
56 |
57 | private:
58 |
59 | bool m_loadingComplete;
60 | bool mInitialized;
61 |
62 | PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ m_delegate;
63 | PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
64 | PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
65 | PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ m_openURLDelegate;
66 |
67 | // The AppDelegate for the Cocos2D app
68 | AppDelegate* mApp;
69 | Windows::Graphics::Display::DisplayOrientations m_orientation;
70 | };
71 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/DirectXBase.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include "EGL/egl.h"
31 | #include "EGL/eglext.h"
32 | #include "EGL/eglplatform.h"
33 | #include "GLES2/gl2.h"
34 | #include "GLES2/gl2ext.h"
35 | #include "winrtangle.h"
36 |
37 | // Helper class that initializes DirectX APIs for 3D rendering.
38 | ref class DirectXBase abstract
39 | {
40 | internal:
41 | DirectXBase();
42 |
43 | virtual void Initialize();
44 | virtual void CreateDeviceResources();
45 | virtual void SetDevice(ID3D11Device1* device);
46 | virtual void UpdateDevice(ID3D11Device1* device, ID3D11DeviceContext1* context, ID3D11RenderTargetView* renderTargetView);
47 | virtual void UpdateForWindowSizeChange(float width, float height);
48 | virtual void CreateWindowSizeDependentResources();
49 | virtual void OnOrientationChanged(Windows::Graphics::Display::DisplayOrientations orientation);
50 |
51 | virtual void CreateGLResources() = 0;
52 |
53 | void Render();
54 |
55 | protected:
56 |
57 | // return true if eglSwapBuffers was called by OnRender
58 | virtual bool OnRender() = 0;
59 | virtual void OnUpdateDevice() = 0;
60 | void CloseAngle();
61 |
62 | protected private:
63 | // Direct3D Objects.
64 | ID3D11Device1* m_device;
65 |
66 | D3D_FEATURE_LEVEL m_featureLevel;
67 |
68 | bool InitializeAngle(ID3D11Device1* device, ID3D11DeviceContext1* context, ID3D11RenderTargetView* renderTargetView);
69 |
70 | // Cached renderer properties.
71 | Windows::Foundation::Size m_renderTargetSize;
72 | Windows::Foundation::Rect m_windowBounds;
73 | Windows::Graphics::Display::DisplayOrientations m_orientation;
74 |
75 | // Angle EGL
76 | bool m_bAngleInitialized;
77 | EGLDisplay m_eglDisplay;
78 | EGLContext m_eglContext;
79 | EGLSurface m_eglSurface;
80 | Microsoft::WRL::ComPtr m_eglWindow;
81 | Microsoft::WRL::ComPtr m_eglPhoneWindow;
82 | DirectX::XMMATRIX m_orientationMatrix;
83 | float m_aspectRatio;
84 | };
85 |
--------------------------------------------------------------------------------
/proj.android/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
29 |
30 |
31 |
40 |
41 |
42 |
43 |
47 |
48 |
60 |
61 |
62 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Resources/AppResources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34014
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace PhoneDirect3DXamlAppInterop.Resources {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class AppResources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal AppResources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneDirect3DXamlAppInterop.Resources.AppResources", typeof(AppResources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to MY APPLICATION.
65 | ///
66 | public static string ApplicationTitle {
67 | get {
68 | return ResourceManager.GetString("ApplicationTitle", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to LeftToRight.
74 | ///
75 | public static string ResourceFlowDirection {
76 | get {
77 | return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to en-US.
83 | ///
84 | public static string ResourceLanguage {
85 | get {
86 | return ResourceManager.GetString("ResourceLanguage", resourceCulture);
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/RootViewController.mm:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) 2013-2014 Chukong Technologies Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #import "RootViewController.h"
27 | #import "cocos2d.h"
28 | #import "platform/ios/CCEAGLView-ios.h"
29 |
30 | @implementation RootViewController
31 |
32 | /*
33 | // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
34 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
35 | if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
36 | // Custom initialization
37 | }
38 | return self;
39 | }
40 | */
41 |
42 | /*
43 | // Implement loadView to create a view hierarchy programmatically, without using a nib.
44 | - (void)loadView {
45 | }
46 | */
47 |
48 | /*
49 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
50 | - (void)viewDidLoad {
51 | [super viewDidLoad];
52 | }
53 |
54 | */
55 | // Override to allow orientations other than the default portrait orientation.
56 | // This method is deprecated on ios6
57 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
58 | return UIInterfaceOrientationIsLandscape( interfaceOrientation );
59 | }
60 |
61 | // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
62 | - (NSUInteger) supportedInterfaceOrientations{
63 | #ifdef __IPHONE_6_0
64 | return UIInterfaceOrientationMaskAllButUpsideDown;
65 | #endif
66 | }
67 |
68 | - (BOOL) shouldAutorotate {
69 | return YES;
70 | }
71 |
72 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
73 | [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
74 |
75 | auto glview = cocos2d::Director::getInstance()->getOpenGLView();
76 |
77 | if (glview)
78 | {
79 | CCEAGLView *eaglview = (CCEAGLView*) glview->getEAGLView();
80 |
81 | if (eaglview)
82 | {
83 | CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
84 | cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height);
85 | }
86 | }
87 | }
88 |
89 | //fix not hide status on ios7
90 | - (BOOL)prefersStatusBarHidden
91 | {
92 | return YES;
93 | }
94 |
95 | - (void)didReceiveMemoryWarning {
96 | // Releases the view if it doesn't have a superview.
97 | [super didReceiveMemoryWarning];
98 |
99 | // Release any cached data, images, etc that aren't in use.
100 | }
101 |
102 | - (void)viewDidUnload {
103 | [super viewDidUnload];
104 | // Release any retained subviews of the main view.
105 | // e.g. self.myOutlet = nil;
106 | }
107 |
108 |
109 | - (void)dealloc {
110 | [super dealloc];
111 | }
112 |
113 |
114 | @end
115 |
--------------------------------------------------------------------------------
/proj.android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ModelViewer
4 |
5 |
6 | libcocos2dx
7 |
8 |
9 |
10 | com.android.ide.eclipse.adt.ResourceManagerBuilder
11 |
12 |
13 |
14 |
15 | com.android.ide.eclipse.adt.PreCompilerBuilder
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javabuilder
21 |
22 |
23 |
24 |
25 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
26 | clean,full,incremental,
27 |
28 |
29 | ?children?
30 | ?children?=?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\||
31 |
32 |
33 | ?name?
34 |
35 |
36 |
37 | org.eclipse.cdt.make.core.append_environment
38 | true
39 |
40 |
41 | org.eclipse.cdt.make.core.autoBuildTarget
42 | all
43 |
44 |
45 | org.eclipse.cdt.make.core.buildArguments
46 | ${ProjDirPath}/build_native.py -b release
47 |
48 |
49 | org.eclipse.cdt.make.core.buildCommand
50 | python
51 |
52 |
53 | org.eclipse.cdt.make.core.buildLocation
54 | ${ProjDirPath}
55 |
56 |
57 | org.eclipse.cdt.make.core.cleanBuildTarget
58 | clean
59 |
60 |
61 | org.eclipse.cdt.make.core.contents
62 | org.eclipse.cdt.make.core.activeConfigSettings
63 |
64 |
65 | org.eclipse.cdt.make.core.enableAutoBuild
66 | false
67 |
68 |
69 | org.eclipse.cdt.make.core.enableCleanBuild
70 | true
71 |
72 |
73 | org.eclipse.cdt.make.core.enableFullBuild
74 | true
75 |
76 |
77 | org.eclipse.cdt.make.core.fullBuildTarget
78 | all
79 |
80 |
81 | org.eclipse.cdt.make.core.stopOnError
82 | true
83 |
84 |
85 | org.eclipse.cdt.make.core.useDefaultBuildCmd
86 | false
87 |
88 |
89 |
90 |
91 | com.android.ide.eclipse.adt.ApkBuilder
92 |
93 |
94 |
95 |
96 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
97 | full,incremental,
98 |
99 |
100 |
101 |
102 |
103 | com.android.ide.eclipse.adt.AndroidNature
104 | org.eclipse.jdt.core.javanature
105 | org.eclipse.cdt.core.cnature
106 | org.eclipse.cdt.core.ccnature
107 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
108 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
109 |
110 |
111 |
112 | Classes
113 | 2
114 | $%7BPARENT-1-PROJECT_LOC%7D/Classes
115 |
116 |
117 | cocos2d
118 | 2
119 | $%7BPARENT-1-PROJECT_LOC%7D/cocos2d
120 |
121 |
122 | libcocos2d
123 | 2
124 | PARENT-1-PROJECT_LOC/cocos2d/cocos/platform/android/java/src
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Direct3DInterop.h:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include "Cocos2dRenderer.h"
33 | #include "InputEvent.h"
34 | #include
35 |
36 |
37 | namespace PhoneDirect3DXamlAppComponent
38 | {
39 |
40 | public delegate void RequestAdditionalFrameHandler();
41 |
42 | [Windows::Foundation::Metadata::WebHostHidden]
43 | public ref class Direct3DInterop sealed : public Windows::Phone::Input::Interop::IDrawingSurfaceManipulationHandler
44 | {
45 | public:
46 | Direct3DInterop(Windows::Graphics::Display::DisplayOrientations orientation);
47 |
48 | Windows::Phone::Graphics::Interop::IDrawingSurfaceBackgroundContentProvider^ CreateContentProvider();
49 |
50 | // IDrawingSurfaceManipulationHandler
51 | virtual void SetManipulationHost(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ manipulationHost);
52 |
53 | event RequestAdditionalFrameHandler^ RequestAdditionalFrame;
54 |
55 |
56 | void UpdateForWindowSizeChange(float width, float height);
57 | Windows::Foundation::IAsyncAction^ OnSuspending();
58 |
59 | void OnBackKeyPress();
60 | void OnCocos2dKeyEvent(Cocos2dKeyEvent key);
61 | void OnCocos2dKeyEvent(Cocos2dKeyEvent key, Platform::String^ text);
62 | void OnCocos2dEditboxEvent(Platform::Object^ sender, Platform::String^ args, Windows::Foundation::EventHandler^ handler);
63 | void OnOrientationChanged(Windows::Graphics::Display::DisplayOrientations orientation);
64 | void OnCocos2dOpenURL(Platform::String^ url);
65 |
66 | property Windows::Graphics::Display::DisplayOrientations WindowOrientation;
67 | property Windows::Foundation::Size WindowBounds;
68 |
69 | void SetCocos2dEventDelegate(Cocos2dEventDelegate^ delegate);
70 | void SetCocos2dMessageBoxDelegate(Cocos2dMessageBoxDelegate ^ delegate);
71 | void SetCocos2dEditBoxDelegate(Cocos2dEditBoxDelegate ^ delegate);
72 | void SetCocos2dOpenURLDelegate(Cocos2dOpenURLDelegate ^ delegate);
73 |
74 |
75 | protected:
76 | // Event Handlers
77 | void OnPointerPressed(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
78 | void OnPointerMoved(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
79 | void OnPointerReleased(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
80 |
81 | internal:
82 | HRESULT Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device);
83 | void Disconnect();
84 | HRESULT PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize);
85 | HRESULT Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView);
86 | bool SendCocos2dEvent(Cocos2dEvent event);
87 |
88 | private:
89 | Cocos2dRenderer^ m_renderer;
90 | Windows::Graphics::Display::DisplayOrientations mCurrentOrientation;
91 |
92 |
93 | Cocos2dEventDelegate^ m_delegate;
94 | Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
95 | Cocos2dEditBoxDelegate^ m_editBoxDelegate;
96 | Cocos2dOpenURLDelegate^ m_openURLDelegate;
97 |
98 | };
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | Icon-57.png
13 | CFBundleIconFiles
14 |
15 | Icon-29
16 | Icon-80
17 | Icon-58
18 | Icon-120
19 | Icon.png
20 | Icon@2x.png
21 | Icon-57.png
22 | Icon-114.png
23 | Icon-72.png
24 | Icon-144.png
25 |
26 | CFBundleIconFiles~ipad
27 |
28 | Icon-29
29 | Icon-50
30 | Icon-58
31 | Icon-80
32 | Icon-40
33 | Icon-100
34 | Icon-152
35 | Icon-76
36 | Icon-120
37 | Icon.png
38 | Icon@2x.png
39 | Icon-57.png
40 | Icon-114.png
41 | Icon-72.png
42 | Icon-144.png
43 |
44 | CFBundleIdentifier
45 | org.cocos2dx.ModelViewer
46 | CFBundleInfoDictionaryVersion
47 | 6.0
48 | CFBundleName
49 | ${PRODUCT_NAME}
50 | CFBundlePackageType
51 | APPL
52 | CFBundleShortVersionString
53 |
54 | CFBundleSignature
55 | ????
56 | CFBundleVersion
57 | 1.0
58 | UILaunchImages
59 |
60 |
61 | UILaunchImageMinimumOSVersion
62 | 8.0
63 | UILaunchImageName
64 | Default
65 | UILaunchImageOrientation
66 | Portrait
67 | UILaunchImageSize
68 | {320, 480}
69 |
70 |
71 | UILaunchImageMinimumOSVersion
72 | 8.0
73 | UILaunchImageName
74 | Default
75 | UILaunchImageOrientation
76 | Landscape
77 | UILaunchImageSize
78 | {320, 480}
79 |
80 |
81 | UILaunchImageMinimumOSVersion
82 | 8.0
83 | UILaunchImageName
84 | Default-568h
85 | UILaunchImageOrientation
86 | Portrait
87 | UILaunchImageSize
88 | {320, 568}
89 |
90 |
91 | UILaunchImageMinimumOSVersion
92 | 8.0
93 | UILaunchImageName
94 | Default-568h
95 | UILaunchImageOrientation
96 | Landscape
97 | UILaunchImageSize
98 | {320, 568}
99 |
100 |
101 | UILaunchImageMinimumOSVersion
102 | 8.0
103 | UILaunchImageName
104 | Default-667h
105 | UILaunchImageOrientation
106 | Portrait
107 | UILaunchImageSize
108 | {375, 667}
109 |
110 |
111 | UILaunchImageMinimumOSVersion
112 | 8.0
113 | UILaunchImageName
114 | Default-667h
115 | UILaunchImageOrientation
116 | Landscape
117 | UILaunchImageSize
118 | {375, 667}
119 |
120 |
121 | UILaunchImageMinimumOSVersion
122 | 8.0
123 | UILaunchImageName
124 | Default-736h
125 | UILaunchImageOrientation
126 | Portrait
127 | UILaunchImageSize
128 | {414, 736}
129 |
130 |
131 | UILaunchImageMinimumOSVersion
132 | 8.0
133 | UILaunchImageName
134 | Default-736h
135 | UILaunchImageOrientation
136 | Landscape
137 | UILaunchImageSize
138 | {414, 736}
139 |
140 |
141 | LSRequiresIPhoneOS
142 |
143 | UIAppFonts
144 |
145 | UIPrerenderedIcon
146 |
147 | UISupportedInterfaceOrientations
148 |
149 | UIInterfaceOrientationLandscapeRight
150 | UIInterfaceOrientationLandscapeLeft
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/proj.ios_mac/ios/AppController.mm:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2010 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | #import "AppController.h"
26 | #import "platform/ios/CCEAGLView-ios.h"
27 | #import "cocos2d.h"
28 | #import "AppDelegate.h"
29 | #import "RootViewController.h"
30 |
31 | @implementation AppController
32 |
33 | #pragma mark -
34 | #pragma mark Application lifecycle
35 |
36 | // cocos2d application instance
37 | static AppDelegate s_sharedApplication;
38 |
39 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
40 |
41 | cocos2d::Application *app = cocos2d::Application::getInstance();
42 | app->initGLContextAttrs();
43 | cocos2d::GLViewImpl::convertAttrs();
44 |
45 | // Override point for customization after application launch.
46 |
47 | // Add the view controller's view to the window and display.
48 | window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
49 |
50 | // Init the CCEAGLView
51 | CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
52 | pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
53 | depthFormat: cocos2d::GLViewImpl::_depthFormat
54 | preserveBackbuffer: NO
55 | sharegroup: nil
56 | multiSampling: NO
57 | numberOfSamples: 0 ];
58 |
59 | // Use RootViewController manage CCEAGLView
60 | _viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
61 | _viewController.wantsFullScreenLayout = YES;
62 | _viewController.view = eaglView;
63 |
64 | // Set RootViewController to window
65 | if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
66 | {
67 | // warning: addSubView doesn't work on iOS6
68 | [window addSubview: _viewController.view];
69 | }
70 | else
71 | {
72 | // use this method on ios6
73 | [window setRootViewController:_viewController];
74 | }
75 |
76 | [window makeKeyAndVisible];
77 |
78 | [[UIApplication sharedApplication] setStatusBarHidden:true];
79 |
80 | // IMPORTANT: Setting the GLView should be done after creating the RootViewController
81 | cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
82 | cocos2d::Director::getInstance()->setOpenGLView(glview);
83 |
84 | app->run();
85 |
86 | return YES;
87 | }
88 |
89 |
90 | - (void)applicationWillResignActive:(UIApplication *)application {
91 | /*
92 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
93 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
94 | */
95 | //We don't need to call this method any more. It will interupt user defined game pause&resume logic
96 | /* cocos2d::Director::getInstance()->pause(); */
97 | }
98 |
99 | - (void)applicationDidBecomeActive:(UIApplication *)application {
100 | /*
101 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
102 | */
103 | //We don't need to call this method any more. It will interupt user defined game pause&resume logic
104 | /* cocos2d::Director::getInstance()->resume(); */
105 | }
106 |
107 | - (void)applicationDidEnterBackground:(UIApplication *)application {
108 | /*
109 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
110 | If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
111 | */
112 | cocos2d::Application::getInstance()->applicationDidEnterBackground();
113 | }
114 |
115 | - (void)applicationWillEnterForeground:(UIApplication *)application {
116 | /*
117 | Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
118 | */
119 | cocos2d::Application::getInstance()->applicationWillEnterForeground();
120 | }
121 |
122 | - (void)applicationWillTerminate:(UIApplication *)application {
123 | /*
124 | Called when the application is about to terminate.
125 | See also applicationDidEnterBackground:.
126 | */
127 | }
128 |
129 |
130 | #pragma mark -
131 | #pragma mark Memory management
132 |
133 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
134 | /*
135 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
136 | */
137 | }
138 |
139 |
140 | - (void)dealloc {
141 | [window release];
142 | [super dealloc];
143 | }
144 |
145 |
146 | @end
147 |
--------------------------------------------------------------------------------
/proj.android/build_native.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # build_native.py
3 | # Build native codes
4 |
5 |
6 | import sys
7 | import os, os.path
8 | import shutil
9 | from optparse import OptionParser
10 |
11 | def get_num_of_cpu():
12 | ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
13 | '''
14 | try:
15 | platform = sys.platform
16 | if platform == 'win32':
17 | if 'NUMBER_OF_PROCESSORS' in os.environ:
18 | return int(os.environ['NUMBER_OF_PROCESSORS'])
19 | else:
20 | return 1
21 | else:
22 | from numpy.distutils import cpuinfo
23 | return cpuinfo.cpu._getNCPUs()
24 | except Exception:
25 | print "Can't know cpuinfo, use default 1 cpu"
26 | return 1
27 |
28 | def check_environment_variables_sdk():
29 | ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building
30 | '''
31 |
32 | try:
33 | SDK_ROOT = os.environ['ANDROID_SDK_ROOT']
34 | except Exception:
35 | print "ANDROID_SDK_ROOT not defined. Please define ANDROID_SDK_ROOT in your environment"
36 | sys.exit(1)
37 |
38 | return SDK_ROOT
39 |
40 | def check_environment_variables():
41 | ''' Checking the environment NDK_ROOT, which will be used for building
42 | '''
43 |
44 | try:
45 | NDK_ROOT = os.environ['NDK_ROOT']
46 | except Exception:
47 | print "NDK_ROOT not defined. Please define NDK_ROOT in your environment"
48 | sys.exit(1)
49 |
50 | return NDK_ROOT
51 |
52 | def select_toolchain_version():
53 | '''Because ndk-r8e uses gcc4.6 as default. gcc4.6 doesn't support c++11. So we should select gcc4.7 when
54 | using ndk-r8e. But gcc4.7 is removed in ndk-r9, so we should determine whether gcc4.7 exist.
55 | Conclution:
56 | ndk-r8e -> use gcc4.7
57 | ndk-r9 -> use gcc4.8
58 | '''
59 |
60 | ndk_root = check_environment_variables()
61 | if os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.8")):
62 | os.environ['NDK_TOOLCHAIN_VERSION'] = '4.8'
63 | print "The Selected NDK toolchain version was 4.8 !"
64 | elif os.path.isdir(os.path.join(ndk_root,"toolchains/arm-linux-androideabi-4.7")):
65 | os.environ['NDK_TOOLCHAIN_VERSION'] = '4.7'
66 | print "The Selected NDK toolchain version was 4.7 !"
67 | else:
68 | print "Couldn't find the gcc toolchain."
69 | exit(1)
70 |
71 | def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode):
72 |
73 | ndk_path = os.path.join(ndk_root, "ndk-build")
74 |
75 | num_of_cpu = get_num_of_cpu()
76 |
77 | if ndk_build_param == None:
78 | command = '%s -j%d -C %s NDK_DEBUG=%d' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug')
79 | else:
80 | command = '%s -j%d -C %s NDK_DEBUG=%d %s' % (ndk_path, num_of_cpu, app_android_root, build_mode=='debug', ' '.join(str(e) for e in ndk_build_param))
81 | if os.system(command) != 0:
82 | raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
83 | elif android_platform is not None:
84 | sdk_tool_path = os.path.join(sdk_root, "tools/android")
85 | cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java")
86 | command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path)
87 | if os.system(command) != 0:
88 | raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!")
89 | command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root)
90 | if os.system(command) != 0:
91 | raise Exception("update project [ " + app_android_root + " ] fails!")
92 | buildfile_path = os.path.join(app_android_root, "build.xml")
93 | command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root)
94 | os.system(command)
95 |
96 | def copy_files(src, dst):
97 |
98 | for item in os.listdir(src):
99 | path = os.path.join(src, item)
100 | # Android can not package the file that ends with ".gz"
101 | if not item.startswith('.') and not item.endswith('.gz') and os.path.isfile(path):
102 | shutil.copy(path, dst)
103 | if os.path.isdir(path):
104 | new_dst = os.path.join(dst, item)
105 | os.mkdir(new_dst)
106 | copy_files(path, new_dst)
107 |
108 | def copy_resources(app_android_root):
109 |
110 | # remove app_android_root/assets if it exists
111 | assets_dir = os.path.join(app_android_root, "assets")
112 | if os.path.isdir(assets_dir):
113 | shutil.rmtree(assets_dir)
114 |
115 | # copy resources
116 | os.mkdir(assets_dir)
117 | resources_dir = os.path.join(app_android_root, "../Resources")
118 | if os.path.isdir(resources_dir):
119 | copy_files(resources_dir, assets_dir)
120 |
121 | def build(ndk_build_param,android_platform,build_mode):
122 |
123 | ndk_root = check_environment_variables()
124 | sdk_root = None
125 | select_toolchain_version()
126 |
127 | current_dir = os.path.dirname(os.path.realpath(__file__))
128 | cocos_root = os.path.join(current_dir, "../cocos2d")
129 |
130 | app_android_root = current_dir
131 | copy_resources(app_android_root)
132 |
133 | if android_platform is not None:
134 | sdk_root = check_environment_variables_sdk()
135 | if android_platform.isdigit():
136 | android_platform = 'android-'+android_platform
137 | else:
138 | print 'please use vaild android platform'
139 | exit(1)
140 |
141 | if build_mode is None:
142 | build_mode = 'debug'
143 | elif build_mode != 'release':
144 | build_mode = 'debug'
145 |
146 | do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
147 |
148 | # -------------- main --------------
149 | if __name__ == '__main__':
150 |
151 | parser = OptionParser()
152 | parser.add_option("-n", "--ndk", dest="ndk_build_param", help='parameter for ndk-build', action="append")
153 | parser.add_option("-p", "--platform", dest="android_platform",
154 | help='parameter for android-update.Without the parameter,the script just build dynamic library for project. Valid android-platform are:[10|11|12|13|14|15|16|17|18|19]')
155 | parser.add_option("-b", "--build", dest="build_mode",
156 | help='the build mode for java project,debug[default] or release.Get more information,please refer to http://developer.android.com/tools/building/building-cmdline.html')
157 | (opts, args) = parser.parse_args()
158 |
159 | build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
160 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/Resources/AppResources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | MY APPLICATION
122 |
123 |
124 | LeftToRight
125 | Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language
126 |
127 |
128 | en-US
129 | Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.
130 |
131 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Cocos2dRenderer.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #include "Cocos2dRenderer.h"
27 | #include "cocos2d.h"
28 | #include "CCApplication.h"
29 | #include "CCGLViewImpl-wp8.h"
30 | #include "AppDelegate.h"
31 | #include
32 |
33 | using namespace Concurrency;
34 | using namespace DirectX;
35 | using namespace Microsoft::WRL;
36 | using namespace Windows::Foundation;
37 | using namespace Windows::UI::Core;
38 | using namespace PhoneDirect3DXamlAppComponent;
39 |
40 | USING_NS_CC;
41 |
42 | Cocos2dRenderer::Cocos2dRenderer(Windows::Graphics::Display::DisplayOrientations orientation): mInitialized(false), m_loadingComplete(false), m_delegate(nullptr), m_messageBoxDelegate(nullptr)
43 | {
44 | mApp = new AppDelegate();
45 | m_orientation = orientation;
46 | }
47 |
48 | // Creates and restores Cocos2d-x after DirectX and Angle contexts are created or updated
49 | void Cocos2dRenderer::CreateGLResources()
50 | {
51 | auto director = cocos2d::Director::getInstance();
52 |
53 | if(!mInitialized)
54 | {
55 | mInitialized = true;
56 | GLViewImpl* glview = GLViewImpl::create("Test Cpp");
57 | glview->Create(m_eglDisplay, m_eglContext, m_eglSurface, m_renderTargetSize.Width, m_renderTargetSize.Height,m_orientation);
58 | director->setOpenGLView(glview);
59 | glview->SetXamlEventDelegate(m_delegate);
60 | glview->SetXamlMessageBoxDelegate(m_messageBoxDelegate);
61 | glview->SetXamlEditBoxDelegate(m_editBoxDelegate);
62 | CCApplication::getInstance()->run();
63 | }
64 | else
65 | {
66 | cocos2d::GL::invalidateStateCache();
67 | cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
68 | cocos2d::DrawPrimitives::init();
69 | cocos2d::VolatileTextureMgr::reloadAllTextures();
70 | cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
71 | director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
72 | cocos2d::Application::getInstance()->applicationWillEnterForeground();
73 | director->setGLDefaultValues();
74 | }
75 |
76 | m_loadingComplete = true;
77 | }
78 |
79 | void Cocos2dRenderer::Connect()
80 | {
81 |
82 | }
83 |
84 | // purge Cocos2d-x gl GL resourses since the DirectX/Angle Context has been lost
85 | void Cocos2dRenderer::Disconnect()
86 | {
87 | Application::getInstance()->applicationDidEnterBackground();
88 | cocos2d::EventCustom backgroundEvent(EVENT_COME_TO_BACKGROUND);
89 | cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&backgroundEvent);
90 | CloseAngle();
91 | m_loadingComplete = false;
92 | }
93 |
94 | // save your game state here
95 | IAsyncAction^ Cocos2dRenderer::OnSuspending()
96 | {
97 | return create_async([]() {
98 | // save your game state here
99 | });
100 | }
101 |
102 |
103 | void Cocos2dRenderer::OnUpdateDevice()
104 | {
105 | //GLView* glview = GLView::sharedOpenGLView();
106 | GLViewImpl::sharedOpenGLView()->UpdateDevice(m_eglDisplay, m_eglContext, m_eglSurface);
107 | }
108 |
109 | void Cocos2dRenderer::OnOrientationChanged(Windows::Graphics::Display::DisplayOrientations orientation)
110 | {
111 | DirectXBase::OnOrientationChanged(orientation);
112 | GLViewImpl::sharedOpenGLView()->UpdateOrientation(orientation);
113 | }
114 |
115 | // return true if eglSwapBuffers was called by OnRender()
116 | bool Cocos2dRenderer::OnRender()
117 | {
118 | if(m_loadingComplete)
119 | {
120 | //GLView* glview = GLView::sharedOpenGLView();
121 | GLViewImpl::sharedOpenGLView()->Render();
122 | return true; // eglSwapBuffers was called by glview->Render();
123 | }
124 | return false;
125 | }
126 |
127 | void Cocos2dRenderer::OnKeyPressed(Platform::String^ text)
128 | {
129 | char szUtf8[8] = {0};
130 | int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)text->Data(), 1, szUtf8, sizeof(szUtf8), NULL, NULL);
131 | IMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
132 | }
133 |
134 | void Cocos2dRenderer::OnCocos2dKeyEvent(Cocos2dKeyEvent event)
135 | {
136 | switch(event)
137 | {
138 | case Cocos2dKeyEvent::Escape:
139 | //Director::getInstance()()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
140 | break;
141 | case Cocos2dKeyEvent::Back:
142 | IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
143 | break;
144 | case Cocos2dKeyEvent::Enter:
145 | //SetFocus(false);
146 | IMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
147 | break;
148 | default:
149 | break;
150 | }
151 |
152 | }
153 |
154 | void Cocos2dRenderer::SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate)
155 | {
156 | m_delegate = delegate;
157 | GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
158 | if(eglView)
159 | {
160 | eglView->SetXamlEventDelegate(delegate);
161 | }
162 | }
163 |
164 | void Cocos2dRenderer::SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate)
165 | {
166 | m_messageBoxDelegate = delegate;
167 | GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
168 | if(eglView)
169 | {
170 | eglView->SetXamlMessageBoxDelegate(delegate);
171 | }
172 | }
173 |
174 | void Cocos2dRenderer::SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate)
175 | {
176 | m_editBoxDelegate = delegate;
177 | GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
178 | if(eglView)
179 | {
180 | eglView->SetXamlEditBoxDelegate(delegate);
181 | }
182 | }
183 |
184 | void Cocos2dRenderer::SetXamlOpenURLDelegate(PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ delegate)
185 | {
186 | m_openURLDelegate = delegate;
187 | Application* app = Application::getInstance();
188 | if (app)
189 | {
190 | app->SetXamlOpenURLDelegate(delegate);
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/Direct3DInterop.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 | #include "Direct3DInterop.h"
26 | #include "Direct3DContentProvider.h"
27 | #include "EditBoxEvent.h"
28 | #include "cocos2d.h"
29 |
30 | using namespace Windows::Foundation;
31 | using namespace Windows::UI::Core;
32 | using namespace Windows::UI::Input;
33 | using namespace Microsoft::WRL;
34 | using namespace Windows::Phone::Graphics::Interop;
35 | using namespace Windows::Phone::Input::Interop;
36 | using namespace Windows::Graphics::Display;
37 | using namespace DirectX;
38 | using namespace PhoneDirect3DXamlAppComponent;
39 |
40 | namespace PhoneDirect3DXamlAppComponent
41 | {
42 |
43 | Direct3DInterop::Direct3DInterop(Windows::Graphics::Display::DisplayOrientations orientation)
44 | : mCurrentOrientation(orientation), m_delegate(nullptr)
45 | {
46 | m_renderer = ref new Cocos2dRenderer(mCurrentOrientation);
47 | }
48 |
49 | IDrawingSurfaceBackgroundContentProvider^ Direct3DInterop::CreateContentProvider()
50 | {
51 | ComPtr provider = Make(this);
52 | return reinterpret_cast(provider.Get());
53 | }
54 |
55 |
56 | // Interface With Direct3DContentProvider
57 | HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device)
58 | {
59 | return S_OK;
60 | }
61 |
62 | void Direct3DInterop::Disconnect()
63 | {
64 | m_renderer->Disconnect();
65 | }
66 |
67 | // IDrawingSurfaceManipulationHandler
68 | void Direct3DInterop::SetManipulationHost(DrawingSurfaceManipulationHost^ manipulationHost)
69 | {
70 | manipulationHost->PointerPressed +=
71 | ref new TypedEventHandler(this, &Direct3DInterop::OnPointerPressed);
72 |
73 | manipulationHost->PointerMoved +=
74 | ref new TypedEventHandler(this, &Direct3DInterop::OnPointerMoved);
75 |
76 | manipulationHost->PointerReleased +=
77 | ref new TypedEventHandler(this, &Direct3DInterop::OnPointerReleased);
78 | }
79 |
80 | void Direct3DInterop::UpdateForWindowSizeChange(float width, float height)
81 | {
82 | m_renderer->UpdateForWindowSizeChange(width, height);
83 | }
84 |
85 |
86 | IAsyncAction^ Direct3DInterop::OnSuspending()
87 | {
88 | return m_renderer->OnSuspending();
89 | }
90 |
91 | void Direct3DInterop::OnBackKeyPress()
92 | {
93 | cocos2d::GLViewImpl::sharedOpenGLView()->QueueBackKeyPress();
94 | }
95 |
96 | // Pointer Event Handlers. We need to queue up pointer events to pass them to the drawing thread
97 | void Direct3DInterop::OnPointerPressed(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
98 | {
99 | cocos2d::GLViewImpl::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerPressed, args);
100 | }
101 |
102 | void Direct3DInterop::OnPointerMoved(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
103 | {
104 | cocos2d::GLViewImpl::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerMoved, args);
105 | }
106 |
107 | void Direct3DInterop::OnPointerReleased(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
108 | {
109 | cocos2d::GLViewImpl::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerReleased, args);
110 | }
111 |
112 | void Direct3DInterop::OnOrientationChanged(Windows::Graphics::Display::DisplayOrientations orientation)
113 | {
114 | std::shared_ptr e(new cocos2d::CustomInputEvent([this, orientation]()
115 | {
116 | m_renderer->OnOrientationChanged(orientation);
117 | }));
118 | cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
119 | }
120 |
121 | void Direct3DInterop::OnCocos2dKeyEvent(Cocos2dKeyEvent key)
122 | {
123 | std::shared_ptr e(new cocos2d::KeyboardEvent(key));
124 | cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
125 | }
126 |
127 |
128 | void Direct3DInterop::OnCocos2dKeyEvent(Cocos2dKeyEvent key, Platform::String^ text)
129 | {
130 | std::shared_ptr e(new cocos2d::KeyboardEvent(key,text));
131 | cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
132 | }
133 |
134 |
135 | void Direct3DInterop::OnCocos2dEditboxEvent(Object^ sender, Platform::String^ args, Windows::Foundation::EventHandler^ handler)
136 | {
137 | std::shared_ptr e(new EditBoxEvent(sender, args, handler));
138 | cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
139 | }
140 |
141 | void Direct3DInterop::OnCocos2dOpenURL(Platform::String^ url)
142 | {
143 | m_openURLDelegate->Invoke(url);
144 | }
145 |
146 |
147 |
148 |
149 | HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize)
150 | {
151 | desiredRenderTargetSize->width = WindowBounds.Width;
152 | desiredRenderTargetSize->height = WindowBounds.Height;
153 | return S_OK;
154 | }
155 |
156 | HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView)
157 | {
158 | m_renderer->UpdateDevice(device, context, renderTargetView);
159 |
160 | cocos2d::GLViewImpl::sharedOpenGLView()->ProcessEvents();
161 | m_renderer->Render();
162 | RequestAdditionalFrame();
163 | return S_OK;
164 | }
165 |
166 | void Direct3DInterop::SetCocos2dEventDelegate(Cocos2dEventDelegate^ delegate)
167 | {
168 | m_delegate = delegate;
169 | m_renderer->SetXamlEventDelegate(delegate);
170 | }
171 |
172 | void Direct3DInterop::SetCocos2dMessageBoxDelegate(Cocos2dMessageBoxDelegate ^ delegate)
173 | {
174 | m_messageBoxDelegate = delegate;
175 | m_renderer->SetXamlMessageBoxDelegate(delegate);
176 | }
177 |
178 | void Direct3DInterop::SetCocos2dEditBoxDelegate(Cocos2dEditBoxDelegate ^ delegate)
179 | {
180 | m_editBoxDelegate = delegate;
181 | m_renderer->SetXamlEditBoxDelegate(delegate);
182 | }
183 |
184 | void Direct3DInterop::SetCocos2dOpenURLDelegate(Cocos2dOpenURLDelegate ^ delegate)
185 | {
186 | m_openURLDelegate = delegate;
187 | m_renderer->SetXamlOpenURLDelegate(delegate);
188 | }
189 |
190 |
191 | bool Direct3DInterop::SendCocos2dEvent(Cocos2dEvent event)
192 | {
193 | Platform::String^ str;
194 | if(m_delegate)
195 | {
196 | m_delegate->Invoke(event, str);
197 | return true;
198 | }
199 | return false;
200 | }
201 |
202 | }
203 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/EditBox.xaml.cs:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2014 cocos2d-x.org
3 |
4 | http://www.cocos2d-x.org
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 | ****************************************************************************/
24 |
25 | using System;
26 | using System.Collections.Generic;
27 | using System.Linq;
28 | using System.Net;
29 | using System.Windows;
30 | using System.Windows.Controls;
31 | using System.Windows.Navigation;
32 | using Microsoft.Phone.Controls;
33 | using Microsoft.Phone.Shell;
34 | using PhoneDirect3DXamlAppComponent;
35 | using System.Windows.Media;
36 | using System.Windows.Input;
37 |
38 | namespace PhoneDirect3DXamlAppInterop
39 | {
40 | public partial class EditBox : UserControl
41 | {
42 | private MainPage m_mainPage = null;
43 | private String m_strText = "";
44 | private String m_strPlaceholder = "";
45 | private bool bIsFocus = false;
46 | private int m_inputFlag = 0;
47 | private Control m_textinput = null;
48 |
49 | public void initTextinput(int maxLen, int inputMode)
50 | {
51 | if (m_inputFlag == 0)
52 | {
53 | // kEditBoxInputFlagPassword
54 | PasswordBox pwdBox = new PasswordBox();
55 | pwdBox.MaxLength = maxLen < 0 ? 0 : maxLen;
56 | pwdBox.Password = m_strText;
57 | pwdBox.GotFocus += pwdBox_GotFocus;
58 | m_textinput = pwdBox;
59 | }
60 | else
61 | {
62 | TextBox textbox = new TextBox();
63 | textbox.MaxLength = maxLen < 0 ? 0 : maxLen;
64 | SetInputScope(textbox, inputMode);
65 | textbox.TextChanged += textinput_TextChanged;
66 | textbox.GotFocus += textinput_GotFocus;
67 | textbox.LostFocus += textinput_LostFocus;
68 | m_textinput = textbox;
69 | }
70 | m_textinput.Margin = new System.Windows.Thickness(0, 0, 220, 0);
71 | m_textinput.Height = 72.0;
72 | m_textinput.TabIndex = 0;
73 | m_textinput.VerticalAlignment = VerticalAlignment.Top;
74 | m_textinput.KeyDown += OnKeyDownHandler;
75 | this.LayoutRoot.Children.Add(m_textinput);
76 | }
77 |
78 | void pwdBox_GotFocus(object sender, RoutedEventArgs e)
79 | {
80 | ((PasswordBox)m_textinput).SelectAll();
81 | }
82 |
83 | public EditBox(MainPage page, String strPlaceholder, String strText, int maxLen, int inputMode, int inputFlag)
84 | {
85 | m_mainPage = page;
86 | InitializeComponent();
87 | m_strText = strText;
88 | m_strPlaceholder = strPlaceholder;
89 | m_inputFlag = inputFlag;
90 | initTextinput(maxLen, inputMode);
91 | this.Loaded += EditBox_Loaded;
92 | }
93 |
94 | void EditBox_Loaded(object sender, RoutedEventArgs e)
95 | {
96 | m_textinput.Focus();
97 | }
98 |
99 | void textinput_LostFocus(object sender, RoutedEventArgs e)
100 | {
101 | // TextBox.LostFocus
102 | TextBox curBox = (TextBox)m_textinput;
103 | bIsFocus = false;
104 | m_strText = curBox.Text;
105 | string strText = "";
106 | strText = curBox.Text;
107 | if (strText == "" && m_inputFlag != 0)
108 | {
109 | curBox.Text = m_strPlaceholder;
110 | }
111 | }
112 |
113 | void textinput_GotFocus(object sender, RoutedEventArgs e)
114 | {
115 | // TextBox.GotFocus
116 | TextBox curBox = (TextBox)m_textinput;
117 | bIsFocus = true;
118 | curBox.Text = m_strText;
119 | curBox.Select(curBox.Text.Length, 0);
120 | }
121 |
122 | private void OnKeyDownHandler(object sender, System.Windows.Input.KeyEventArgs e)
123 | {
124 | switch (e.Key)
125 | {
126 | case Key.Enter:
127 | Done_Click(sender, null);
128 | e.Handled = true;
129 | break;
130 | default:
131 | break;
132 | }
133 | }
134 |
135 | private void Done_Click(object sender, RoutedEventArgs e)
136 | {
137 | m_mainPage.OnSelectText(sender, m_inputFlag == 0 ? ((PasswordBox)m_textinput).Password : m_strText);
138 | ((Grid)this.Parent).Children.Remove(this);
139 | }
140 |
141 | private void Cancel_Click(object sender, RoutedEventArgs e)
142 | {
143 | ((Grid)this.Parent).Children.Remove(this);
144 | }
145 |
146 | private void textinput_TextChanged(object sender, TextChangedEventArgs e)
147 | {
148 | // TextBox.textinput_TextChanged
149 | if (bIsFocus)
150 | m_strText = ((TextBox)m_textinput).Text;
151 | }
152 |
153 | private void SetInputScope(TextBox curBox, int inputMode)
154 | {
155 | // TextBox.SetInputScope
156 | InputScope inputScope = new InputScope();
157 | InputScopeName name = new InputScopeName();
158 |
159 | switch (inputMode)
160 | {
161 | case 0:// kEditBoxInputModeAny
162 | name.NameValue = InputScopeNameValue.Default;
163 | break;
164 | case 1:// kEditBoxInputModeEmailAddr
165 | name.NameValue = InputScopeNameValue.EmailNameOrAddress;
166 | break;
167 | case 2:// kEditBoxInputModeNumeric
168 | name.NameValue = InputScopeNameValue.Number;
169 | break;
170 | case 3:// kEditBoxInputModePhoneNumber
171 | name.NameValue = InputScopeNameValue.TelephoneNumber;
172 | break;
173 | case 4:// kEditBoxInputModeUrl
174 | name.NameValue = InputScopeNameValue.Url;
175 | break;
176 | case 5:// kEditBoxInputModeDecimal
177 | name.NameValue = InputScopeNameValue.Digits;
178 | break;
179 | case 6:// kEditBoxInputModeSingleLine
180 | name.NameValue = InputScopeNameValue.Default;
181 | break;
182 | default:
183 | name.NameValue = InputScopeNameValue.Default;
184 | break;
185 | }
186 |
187 | inputScope.Names.Add(name);
188 | curBox.InputScope = inputScope;
189 | }
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/ModelViewer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.20506
7 | 2.0
8 | {83CC88FE-7E79-4E1E-A129-742987130B5C}
9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | PhoneDirect3DXamlAppInterop
13 | PhoneDirect3DXamlAppInterop
14 | WindowsPhone
15 | v8.0
16 | $(TargetFrameworkVersion)
17 | true
18 |
19 |
20 | true
21 | true
22 | PhoneDirect3DXamlAppInterop_$(Configuration)_$(Platform).xap
23 | Properties\AppManifest.xml
24 | PhoneDirect3DXamlAppInterop.App
25 | true
26 | 11.0
27 | true
28 |
29 |
30 | true
31 | full
32 | false
33 | Bin\Debug
34 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
35 | true
36 | true
37 | prompt
38 | 4
39 |
40 |
41 | pdbonly
42 | true
43 | Bin\Release
44 | TRACE;SILVERLIGHT;WINDOWS_PHONE
45 | true
46 | true
47 | prompt
48 | 4
49 |
50 |
51 | true
52 | full
53 | false
54 | Bin\x86\Debug
55 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
56 | true
57 | true
58 | prompt
59 | 4
60 |
61 |
62 | pdbonly
63 | true
64 | Bin\x86\Release
65 | TRACE;SILVERLIGHT;WINDOWS_PHONE
66 | true
67 | true
68 | prompt
69 | 4
70 |
71 |
72 | true
73 | full
74 | false
75 | Bin\ARM\Debug
76 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
77 | true
78 | true
79 | prompt
80 | 4
81 |
82 |
83 | pdbonly
84 | true
85 | Bin\ARM\Release
86 | TRACE;SILVERLIGHT;WINDOWS_PHONE
87 | true
88 | true
89 | prompt
90 | 4
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | True
100 | True
101 | AppResources.resx
102 |
103 |
104 |
105 |
106 | Assets\Resources\fonts\Marker Felt.ttf
107 | PreserveNewest
108 |
109 |
110 |
111 | Designer
112 |
113 |
114 |
115 |
116 | Assets\Resources\CloseNormal.png
117 |
118 |
119 | Assets\Resources\CloseSelected.png
120 |
121 |
122 | Assets\Resources\HelloWorld.png
123 |
124 |
125 |
126 | PreserveNewest
127 |
128 |
129 | PreserveNewest
130 |
131 |
132 | PreserveNewest
133 |
134 |
135 | PreserveNewest
136 |
137 |
138 | PreserveNewest
139 |
140 |
141 | PreserveNewest
142 |
143 |
144 |
145 |
146 |
147 | ModelViewerComponent
148 |
149 |
150 |
151 |
152 | PublicResXFileCodeGenerator
153 | AppResources.Designer.cs
154 |
155 |
156 |
157 |
158 | MSBuild:Compile
159 | Designer
160 |
161 |
162 | MSBuild:Compile
163 | Designer
164 |
165 |
166 | MSBuild:Compile
167 | Designer
168 |
169 |
170 |
171 |
172 |
173 |
181 |
182 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/App/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | #if DEBUG
2 | #define DISPLAY_MEMORY
3 | #endif
4 |
5 | using System;
6 | using System.ComponentModel;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Net;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Navigation;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Animation;
17 | using System.Windows.Shapes;
18 | using Microsoft.Phone.Controls;
19 | using PhoneDirect3DXamlAppComponent;
20 | using System.Threading;
21 | using System.Diagnostics;
22 | using System.Threading.Tasks;
23 | using Microsoft.Phone.Shell;
24 | using Windows.UI.Input;
25 | using System.Windows.Threading;
26 | using Microsoft.Phone.Info;
27 | using Windows.Graphics.Display;
28 | using Microsoft.Phone.Tasks;
29 |
30 | namespace PhoneDirect3DXamlAppInterop
31 | {
32 | public partial class MainPage : PhoneApplicationPage
33 | {
34 | private Direct3DInterop m_d3dInterop = null;
35 | private DispatcherTimer m_timer;
36 |
37 | // event handler for CCEditBox
38 | private event EventHandler m_receiveHandler;
39 |
40 | // invisible XAML TextBox for Cocos2d-x keyboard input
41 | TextBox m_textBox = null;
42 |
43 | // Constructor
44 | public MainPage()
45 | {
46 | InitializeComponent();
47 | #if DISPLAY_MEMORY
48 | StartTimer();
49 | #else
50 | MemoryDisplay.Visibility = Visibility.Collapsed;
51 | #endif
52 | }
53 |
54 | override protected void OnOrientationChanged(OrientationChangedEventArgs args)
55 | {
56 | base.OnOrientationChanged(args);
57 | if (m_d3dInterop != null)
58 | {
59 | DisplayOrientations orientation = ConvertToNativeOrientation(args.Orientation);
60 | m_d3dInterop.OnOrientationChanged(orientation);
61 | }
62 | }
63 |
64 | private static DisplayOrientations ConvertToNativeOrientation(PageOrientation xamlOrientation)
65 | {
66 | switch (xamlOrientation)
67 | {
68 | case PageOrientation.Portrait:
69 | case PageOrientation.PortraitUp:
70 | return DisplayOrientations.Portrait;
71 | case PageOrientation.PortraitDown:
72 | return DisplayOrientations.PortraitFlipped;
73 | case PageOrientation.Landscape:
74 | case PageOrientation.LandscapeLeft:
75 | return DisplayOrientations.Landscape;
76 | case PageOrientation.LandscapeRight:
77 | return DisplayOrientations.LandscapeFlipped;
78 | default:
79 | return DisplayOrientations.Landscape;
80 | }
81 | }
82 |
83 | private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
84 | {
85 | if (m_d3dInterop == null)
86 | {
87 | PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty);
88 | DisplayOrientations displayOrientation = ConvertToNativeOrientation(pageOrientation);
89 |
90 | m_d3dInterop = new Direct3DInterop(displayOrientation);
91 |
92 | // Set WindowBounds to size of DrawingSurface
93 | m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
94 | (float)Application.Current.Host.Content.ActualWidth,
95 | (float)Application.Current.Host.Content.ActualHeight
96 | );
97 |
98 | // Hook-up native component to DrawingSurfaceBackgroundGrid
99 | DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider());
100 | DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);
101 |
102 | // Hook-up Cocos2d-x delegates
103 | m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent);
104 | m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent);
105 | m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox);
106 | m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL);
107 | }
108 | }
109 |
110 | // called when the user presses the back button on the device
111 | protected override void OnBackKeyPress(CancelEventArgs e)
112 | {
113 | m_d3dInterop.OnBackKeyPress();
114 | // cocos2d-x will async send Cocos2dEvent.TerminateApp event if it is time to exit app.
115 | // We do not want to exit now, so we set e.Cancel to true.
116 | e.Cancel = true;
117 | }
118 |
119 | public void OnKeyDown(object sender, KeyEventArgs e)
120 | {
121 | ModifierKeys modifiers = Keyboard.Modifiers;
122 |
123 | switch (e.Key)
124 | {
125 | case Key.Escape:
126 | m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Escape);
127 | e.Handled = true;
128 | break;
129 | case Key.Back:
130 | m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Back);
131 | e.Handled = true;
132 | break;
133 | case Key.Enter:
134 | m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Enter);
135 | e.Handled = true;
136 | break;
137 | default:
138 | break;
139 | }
140 | }
141 |
142 | public void OnKeyUp(object sender, KeyEventArgs e)
143 | {
144 | m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Text, m_textBox.Text);
145 | m_textBox.Text = "";
146 | }
147 |
148 | public void OnTextChanged(object sender, TextChangedEventArgs e)
149 | {
150 | m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Text, m_textBox.Text);
151 | }
152 |
153 | // Called by the Cocos2d-x C++ engine to display a MessageBox
154 | public void OnCocos2dMessageBoxEvent(String title, String text)
155 | {
156 | Dispatcher.BeginInvoke(() =>
157 | {
158 | MessageBox.Show(text, title, MessageBoxButton.OK);
159 | });
160 | }
161 |
162 | // events called by the Cocos2d-x C++ engine to be handled by C#
163 | public void OnCocos2dEvent(Cocos2dEvent theEvent, String text)
164 | {
165 | Dispatcher.BeginInvoke(() =>
166 | {
167 | switch (theEvent)
168 | {
169 | case Cocos2dEvent.TerminateApp:
170 | Application.Current.Terminate();
171 | break;
172 |
173 | case Cocos2dEvent.ShowKeyboard:
174 | if (m_textBox == null)
175 | {
176 | m_textBox = new TextBox();
177 | m_textBox.Opacity = 0.0;
178 | m_textBox.Width = 1;
179 | m_textBox.Height = 1;
180 | m_textBox.KeyDown += OnKeyDown;
181 | m_textBox.TextChanged += OnTextChanged;
182 | DrawingSurfaceBackground.Children.Add(m_textBox);
183 | }
184 | m_textBox.Text = text;
185 | m_textBox.SelectionLength = 0;
186 | m_textBox.SelectionStart = int.MaxValue;
187 | m_textBox.Focus();
188 | break;
189 |
190 | case Cocos2dEvent.HideKeyboard:
191 | if (m_textBox != null)
192 | {
193 | DrawingSurfaceBackground.Children.Remove(m_textBox);
194 | }
195 | m_textBox = null;
196 | break;
197 | }
198 | });
199 | }
200 |
201 | // Called by the Cocos2d-x C++ engine to display a CCEditBox
202 | public void OpenEditBox(String strPlaceHolder, string strText, int maxLength, int inputMode, int inputFlag, EventHandler receiveHandler)
203 | {
204 | m_receiveHandler = receiveHandler;
205 | Deployment.Current.Dispatcher.BeginInvoke(() =>
206 | {
207 | EditBox editbox = new EditBox(this, strPlaceHolder, strText, maxLength, inputMode, inputFlag);
208 | DrawingSurfaceBackground.Children.Add(editbox);
209 | });
210 | }
211 |
212 | public void OnSelectText(object sender, String str)
213 | {
214 | if (m_d3dInterop != null && m_receiveHandler != null)
215 | {
216 | m_d3dInterop.OnCocos2dEditboxEvent(sender, str, m_receiveHandler);
217 | }
218 | }
219 |
220 | public void OpenURL(String url)
221 | {
222 | WebBrowserTask webBrowserTask = new WebBrowserTask();
223 | webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
224 | webBrowserTask.Show();
225 | }
226 |
227 | private void StartTimer()
228 | {
229 | m_timer = new DispatcherTimer();
230 | m_timer.Interval = new TimeSpan(0, 0, 1);
231 | m_timer.Tick += new EventHandler(TimerTick);
232 | m_timer.Start();
233 | }
234 |
235 | private void TimerTick(object sender, EventArgs e)
236 | {
237 | try
238 | {
239 | // These are TextBlock controls that are created in the page’s XAML file.
240 | float value = DeviceStatus.ApplicationCurrentMemoryUsage / (1024.0f * 1024.0f);
241 | MemoryTextBlock.Text = value.ToString();
242 | value = DeviceStatus.ApplicationPeakMemoryUsage / (1024.0f * 1024.0f);
243 | PeakMemoryTextBlock.Text = value.ToString();
244 | }
245 | catch (Exception ex)
246 | {
247 | MemoryTextBlock.Text = ex.Message;
248 | }
249 | }
250 | }
251 | }
--------------------------------------------------------------------------------
/proj.android/.settings/org.eclipse.cdt.codan.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning
3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
4 | org.eclipse.cdt.codan.checkers.errreturnvalue=-Error
5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
6 | org.eclipse.cdt.codan.checkers.noreturn=-Error
7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=-Error
9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=-Error
11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=-Error
15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=-Error
21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=-Error
25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=-Error
27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=-Error
29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=-Error
31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=-Error
33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=-Error
35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=-Error
37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=-Error
43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=-Error
45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=-Error
47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=-Error
59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=-Error
67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
68 | useParentScope=false
69 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/AppComponent/src/DirectXBase.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | Copyright (c) 2013 cocos2d-x.org
3 | Copyright (c) Microsoft Open Technologies, Inc.
4 |
5 | http://www.cocos2d-x.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy
8 | of this software and associated documentation files (the "Software"), to deal
9 | in the Software without restriction, including without limitation the rights
10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom the Software is
12 | furnished to do so, subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in
15 | all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | THE SOFTWARE.
24 | ****************************************************************************/
25 |
26 | #include "DirectXBase.h"
27 | #include "DirectXHelper.h"
28 |
29 | using namespace DirectX;
30 | using namespace Microsoft::WRL;
31 | using namespace Windows::Foundation;
32 | using namespace Windows::Graphics::Display;
33 |
34 | // Constructor.
35 | DirectXBase::DirectXBase()
36 | : m_bAngleInitialized(false)
37 | , m_eglDisplay(nullptr)
38 | , m_eglSurface(nullptr)
39 | , m_eglContext(nullptr)
40 | , m_eglWindow(nullptr)
41 | , m_eglPhoneWindow(nullptr)
42 | , m_device(nullptr)
43 | {
44 | }
45 |
46 | // Initialize the Direct3D resources required to run.
47 | void DirectXBase::Initialize()
48 | {
49 | }
50 |
51 | // These are the resources that depend on the device.
52 | void DirectXBase::CreateDeviceResources()
53 | {
54 | }
55 |
56 | void DirectXBase::SetDevice(ID3D11Device1* device)
57 | {
58 | if(m_device)
59 | {
60 | m_device->Release();
61 | m_device = nullptr;
62 | }
63 |
64 | m_device = nullptr;
65 | }
66 |
67 | void DirectXBase::UpdateDevice(ID3D11Device1* device, ID3D11DeviceContext1* context, ID3D11RenderTargetView* renderTargetView)
68 | {
69 | if (m_device != device)
70 | {
71 | CloseAngle();
72 | device->AddRef();
73 | m_device = device;
74 |
75 | CreateDeviceResources();
76 |
77 | // Force call to CreateWindowSizeDependentResources
78 | m_renderTargetSize.Width = -1;
79 | m_renderTargetSize.Height = -1;
80 | }
81 |
82 | m_featureLevel = device->GetFeatureLevel();
83 |
84 |
85 | ComPtr renderTargetViewResource;
86 | renderTargetView->GetResource(&renderTargetViewResource);
87 |
88 | ComPtr backBuffer;
89 | DX::ThrowIfFailed(
90 | renderTargetViewResource.As(&backBuffer)
91 | );
92 |
93 | // Cache the rendertarget dimensions in our helper class for convenient use.
94 | D3D11_TEXTURE2D_DESC backBufferDesc;
95 | backBuffer->GetDesc(&backBufferDesc);
96 |
97 | if (m_renderTargetSize.Width != static_cast(backBufferDesc.Width) ||
98 | m_renderTargetSize.Height != static_cast(backBufferDesc.Height))
99 | {
100 | m_renderTargetSize.Width = static_cast(backBufferDesc.Width);
101 | m_renderTargetSize.Height = static_cast(backBufferDesc.Height);
102 | CreateWindowSizeDependentResources();
103 | }
104 |
105 | if(!m_bAngleInitialized)
106 | {
107 | InitializeAngle(device, context, renderTargetView);
108 | CreateGLResources();
109 | }
110 | else
111 | {
112 | m_eglPhoneWindow->Update(device, context, renderTargetView);
113 | }
114 |
115 | OnUpdateDevice();
116 | }
117 |
118 |
119 | void DirectXBase::UpdateForWindowSizeChange(float width, float height)
120 | {
121 | if (width != m_windowBounds.Width || height != m_windowBounds.Height)
122 | {
123 | m_windowBounds.Width = width;
124 | m_windowBounds.Height = height;
125 | }
126 | }
127 |
128 | // Allocate all memory resources that depend on the window size.
129 | void DirectXBase::CreateWindowSizeDependentResources()
130 | {
131 |
132 |
133 | }
134 |
135 | void DirectXBase::OnOrientationChanged(DisplayOrientations orientation)
136 | {
137 | switch(orientation)
138 | {
139 | case DisplayOrientations::Portrait:
140 | m_orientationMatrix = XMMatrixIdentity();
141 | m_aspectRatio = m_renderTargetSize.Width / m_renderTargetSize.Height;
142 | break;
143 |
144 | case DisplayOrientations::PortraitFlipped:
145 | m_orientationMatrix = XMMatrixRotationZ(XM_PI);
146 | m_aspectRatio = m_renderTargetSize.Width / m_renderTargetSize.Height;
147 | break;
148 |
149 | case DisplayOrientations::Landscape:
150 | m_orientationMatrix = XMMatrixRotationZ(-XM_PIDIV2);
151 | m_aspectRatio = m_renderTargetSize.Height / m_renderTargetSize.Width;
152 | break;
153 |
154 | case DisplayOrientations::LandscapeFlipped:
155 | m_orientationMatrix = XMMatrixRotationZ(XM_PIDIV2);
156 | m_aspectRatio = m_renderTargetSize.Height / m_renderTargetSize.Width;
157 | break;
158 | }
159 | }
160 |
161 | void DirectXBase::Render()
162 | {
163 | if(!OnRender())
164 | {
165 | eglSwapBuffers(m_eglDisplay, m_eglSurface);
166 | }
167 | }
168 |
169 | void DirectXBase::CloseAngle()
170 | {
171 | eglMakeCurrent(NULL, NULL, NULL, NULL);
172 |
173 | if(m_eglPhoneWindow != nullptr)
174 | {
175 | m_eglPhoneWindow->Update(nullptr, nullptr, nullptr);
176 | }
177 |
178 | if(m_eglDisplay && m_eglContext)
179 | {
180 | eglDestroyContext(m_eglDisplay, m_eglContext);
181 | m_eglContext = nullptr;
182 | }
183 |
184 | if(m_eglDisplay && m_eglSurface)
185 | {
186 | eglDestroySurface(m_eglDisplay, m_eglSurface);
187 | m_eglSurface = nullptr;
188 | }
189 |
190 | if(m_eglDisplay)
191 | {
192 | eglTerminate(m_eglDisplay);
193 | m_eglDisplay = nullptr;
194 | }
195 |
196 | if(m_device)
197 | {
198 | m_device->Release();
199 | m_device = nullptr;
200 | }
201 |
202 | m_eglPhoneWindow = nullptr;
203 | m_eglWindow = nullptr;
204 |
205 | m_bAngleInitialized = false;
206 | }
207 |
208 | bool DirectXBase::InitializeAngle(ID3D11Device1* d3dDevice, ID3D11DeviceContext1* d3dContext, ID3D11RenderTargetView* d3dRenderTargetView)
209 | {
210 | // setup EGL
211 | EGLint configAttribList[] = {
212 | EGL_RED_SIZE, 8,
213 | EGL_GREEN_SIZE, 8,
214 | EGL_BLUE_SIZE, 8,
215 | EGL_ALPHA_SIZE, 8,
216 | EGL_DEPTH_SIZE, 8,
217 | EGL_STENCIL_SIZE, 8,
218 | EGL_SAMPLE_BUFFERS, 0,
219 | EGL_NONE
220 | };
221 | EGLint surfaceAttribList[] = {
222 | EGL_NONE, EGL_NONE
223 | };
224 |
225 | EGLint numConfigs;
226 | EGLint majorVersion;
227 | EGLint minorVersion;
228 | EGLDisplay display;
229 | EGLContext context;
230 | EGLSurface surface;
231 | EGLConfig config;
232 | EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
233 |
234 | // we need to select the correct DirectX feature level depending on the platform
235 | // default is D3D_FEATURE_LEVEL_9_3 Windows Phone 8.0
236 | ANGLE_D3D_FEATURE_LEVEL featureLevel = ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_3;
237 |
238 | switch(m_featureLevel)
239 | {
240 | case ANGLE_D3D_FEATURE_LEVEL_9_3:
241 | featureLevel = ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_3;
242 | break;
243 |
244 | case ANGLE_D3D_FEATURE_LEVEL_9_2:
245 | featureLevel = ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_2;
246 | break;
247 |
248 | case ANGLE_D3D_FEATURE_LEVEL_9_1:
249 | featureLevel = ANGLE_D3D_FEATURE_LEVEL::ANGLE_D3D_FEATURE_LEVEL_9_1;
250 | break;
251 | }
252 |
253 | if(m_eglPhoneWindow == nullptr)
254 | {
255 | DX::ThrowIfFailed(
256 | CreateWinPhone8XamlWindow(&m_eglPhoneWindow)
257 | );
258 | }
259 |
260 | m_eglPhoneWindow->Update(d3dDevice, d3dContext, d3dRenderTargetView);
261 |
262 | ComPtr u;
263 | HRESULT r = m_eglPhoneWindow.As(&u);
264 |
265 | if(m_eglWindow == nullptr)
266 | { DX::ThrowIfFailed(
267 | CreateWinrtEglWindow(u.Get(), featureLevel, m_eglWindow.GetAddressOf())
268 | );
269 | }
270 |
271 |
272 | display = eglGetDisplay(m_eglWindow);
273 | if(display == EGL_NO_DISPLAY){
274 | //ofLogError("ofAppWinRTWindow") << "couldn't get EGL display";
275 | return false;
276 | }
277 |
278 | if(!eglInitialize(display, &majorVersion, &minorVersion)){
279 | //ofLogError("ofAppWinRTWindow") << "failed to initialize EGL";
280 | return false;
281 | }
282 |
283 | // Get configs
284 | if ( !eglGetConfigs(display, NULL, 0, &numConfigs) ){
285 | //ofLogError("ofAppWinRTWindow") << "failed to get configurations";
286 | return false;
287 | }
288 |
289 | // Choose config
290 | if(!eglChooseConfig(display, configAttribList, &config, 1, &numConfigs)){
291 | //ofLogError("ofAppWinRTWindow") << "failed to choose configuration";
292 | return false;
293 | }
294 |
295 | // Create a surface
296 | surface = eglCreateWindowSurface(display, config, m_eglWindow, surfaceAttribList);
297 | if(surface == EGL_NO_SURFACE){
298 | //ofLogError("ofAppWinRTWindow") << "failed to create EGL window surface";
299 | return false;
300 | }
301 |
302 | // Create a GL context
303 | context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
304 | if(context == EGL_NO_CONTEXT){
305 | //ofLogError("ofAppWinRTWindow") << "failed to create EGL context";
306 | return false;
307 | }
308 |
309 | // Make the context current
310 | if (!eglMakeCurrent(display, surface, surface, context)){
311 | //ofLogError("ofAppWinRTWindow") << "failed to make EGL context current";
312 | return false;
313 | }
314 |
315 | m_eglDisplay = display;
316 | m_eglSurface = surface;
317 | m_eglContext = context;
318 |
319 | m_bAngleInitialized = true;
320 | return true;
321 | }
322 |
--------------------------------------------------------------------------------
/proj.wp8-xaml/ModelViewer.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio 2013
3 | VisualStudioVersion = 12.0.30723.0
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelViewer", "App\ModelViewer.csproj", "{83CC88FE-7E79-4E1E-A129-742987130B5C}"
6 | EndProject
7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModelViewerComponent", "AppComponent\ModelViewerComponent.vcxproj", "{60EC6889-C3C4-45AD-A006-47D9EE689212}"
8 | EndProject
9 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{1CD6A64E-A2B6-49BC-A5DC-25122C07166A}"
10 | EndProject
11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Box2D", "..\cocos2d\external\Box2D\proj.wp8\Box2D.vcxproj", "{C55734A3-702C-4FA1-B950-32C8E169302F}"
12 | EndProject
13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos2d\cocos\editor-support\spine\proj.wp8\libSpine.vcxproj", "{7D4FC6EB-9497-4804-98F3-3EAEDC896154}"
14 | EndProject
15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_wp8", "..\cocos2d\cocos\2d\libcocos2d_wp8.vcxproj", "{7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Debug|ARM = Debug|ARM
21 | Debug|Mixed Platforms = Debug|Mixed Platforms
22 | Debug|Win32 = Debug|Win32
23 | Debug|x86 = Debug|x86
24 | Release|Any CPU = Release|Any CPU
25 | Release|ARM = Release|ARM
26 | Release|Mixed Platforms = Release|Mixed Platforms
27 | Release|Win32 = Release|Win32
28 | Release|x86 = Release|x86
29 | EndGlobalSection
30 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
31 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
34 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|ARM.ActiveCfg = Debug|ARM
35 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|ARM.Build.0 = Debug|ARM
36 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|ARM.Deploy.0 = Debug|ARM
37 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
38 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Mixed Platforms.Build.0 = Debug|x86
39 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
40 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Win32.ActiveCfg = Debug|x86
41 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Win32.Build.0 = Debug|x86
42 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|Win32.Deploy.0 = Debug|x86
43 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|x86.ActiveCfg = Debug|x86
44 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|x86.Build.0 = Debug|x86
45 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Debug|x86.Deploy.0 = Debug|x86
46 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
47 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Any CPU.Build.0 = Release|Any CPU
48 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Any CPU.Deploy.0 = Release|Any CPU
49 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|ARM.ActiveCfg = Release|ARM
50 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|ARM.Build.0 = Release|ARM
51 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|ARM.Deploy.0 = Release|ARM
52 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Mixed Platforms.ActiveCfg = Release|x86
53 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Mixed Platforms.Build.0 = Release|x86
54 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Mixed Platforms.Deploy.0 = Release|x86
55 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Win32.ActiveCfg = Release|x86
56 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Win32.Build.0 = Release|x86
57 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|Win32.Deploy.0 = Release|x86
58 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|x86.ActiveCfg = Release|x86
59 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|x86.Build.0 = Release|x86
60 | {83CC88FE-7E79-4E1E-A129-742987130B5C}.Release|x86.Deploy.0 = Release|x86
61 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|Any CPU.ActiveCfg = Debug|Win32
62 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|ARM.ActiveCfg = Debug|ARM
63 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|ARM.Build.0 = Debug|ARM
64 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
65 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|Mixed Platforms.Build.0 = Debug|Win32
66 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|Win32.ActiveCfg = Debug|Win32
67 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|Win32.Build.0 = Debug|Win32
68 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|x86.ActiveCfg = Debug|Win32
69 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Debug|x86.Build.0 = Debug|Win32
70 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|Any CPU.ActiveCfg = Release|Win32
71 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|ARM.ActiveCfg = Release|ARM
72 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|ARM.Build.0 = Release|ARM
73 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|Mixed Platforms.ActiveCfg = Release|Win32
74 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|Mixed Platforms.Build.0 = Release|Win32
75 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|Win32.ActiveCfg = Release|Win32
76 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|Win32.Build.0 = Release|Win32
77 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|x86.ActiveCfg = Release|Win32
78 | {60EC6889-C3C4-45AD-A006-47D9EE689212}.Release|x86.Build.0 = Release|Win32
79 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|Any CPU.ActiveCfg = Debug|Win32
80 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|ARM.ActiveCfg = Debug|ARM
81 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|ARM.Build.0 = Debug|ARM
82 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
83 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
84 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|Win32.ActiveCfg = Debug|Win32
85 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|Win32.Build.0 = Debug|Win32
86 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|x86.ActiveCfg = Debug|Win32
87 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Debug|x86.Build.0 = Debug|Win32
88 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|Any CPU.ActiveCfg = Release|Win32
89 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|ARM.ActiveCfg = Release|ARM
90 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|ARM.Build.0 = Release|ARM
91 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|Mixed Platforms.ActiveCfg = Release|Win32
92 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|Mixed Platforms.Build.0 = Release|Win32
93 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|Win32.ActiveCfg = Release|Win32
94 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|Win32.Build.0 = Release|Win32
95 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|x86.ActiveCfg = Release|Win32
96 | {C55734A3-702C-4FA1-B950-32C8E169302F}.Release|x86.Build.0 = Release|Win32
97 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|Any CPU.ActiveCfg = Debug|Win32
98 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|ARM.ActiveCfg = Debug|ARM
99 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|ARM.Build.0 = Debug|ARM
100 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
101 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|Mixed Platforms.Build.0 = Debug|Win32
102 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|Win32.ActiveCfg = Debug|Win32
103 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|Win32.Build.0 = Debug|Win32
104 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|x86.ActiveCfg = Debug|Win32
105 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Debug|x86.Build.0 = Debug|Win32
106 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|Any CPU.ActiveCfg = Release|Win32
107 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|ARM.ActiveCfg = Release|ARM
108 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|ARM.Build.0 = Release|ARM
109 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|Mixed Platforms.ActiveCfg = Release|Win32
110 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|Mixed Platforms.Build.0 = Release|Win32
111 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|Win32.ActiveCfg = Release|Win32
112 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|Win32.Build.0 = Release|Win32
113 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|x86.ActiveCfg = Release|Win32
114 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154}.Release|x86.Build.0 = Release|Win32
115 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|Any CPU.ActiveCfg = Debug|Win32
116 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|ARM.ActiveCfg = Debug|ARM
117 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|ARM.Build.0 = Debug|ARM
118 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
119 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|Mixed Platforms.Build.0 = Debug|Win32
120 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|Win32.ActiveCfg = Debug|Win32
121 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|Win32.Build.0 = Debug|Win32
122 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|x86.ActiveCfg = Debug|Win32
123 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Debug|x86.Build.0 = Debug|Win32
124 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|Any CPU.ActiveCfg = Release|Win32
125 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|ARM.ActiveCfg = Release|ARM
126 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|ARM.Build.0 = Release|ARM
127 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|Mixed Platforms.ActiveCfg = Release|Win32
128 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|Mixed Platforms.Build.0 = Release|Win32
129 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|Win32.ActiveCfg = Release|Win32
130 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|Win32.Build.0 = Release|Win32
131 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|x86.ActiveCfg = Release|Win32
132 | {7C5DBC42-27F6-4978-AABC-02BA77E2A7F0}.Release|x86.Build.0 = Release|Win32
133 | EndGlobalSection
134 | GlobalSection(SolutionProperties) = preSolution
135 | HideSolutionNode = FALSE
136 | EndGlobalSection
137 | GlobalSection(NestedProjects) = preSolution
138 | {C55734A3-702C-4FA1-B950-32C8E169302F} = {1CD6A64E-A2B6-49BC-A5DC-25122C07166A}
139 | {7D4FC6EB-9497-4804-98F3-3EAEDC896154} = {1CD6A64E-A2B6-49BC-A5DC-25122C07166A}
140 | EndGlobalSection
141 | EndGlobal
142 |
--------------------------------------------------------------------------------
/proj.win32/ModelViewer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {76A39BB2-9B84-4C65-98A5-654D86B86F2A}
15 | test_win32
16 | Win32Proj
17 |
18 |
19 |
20 | Application
21 | Unicode
22 | true
23 | v100
24 | v110
25 | v110_xp
26 | v120
27 | v120_xp
28 |
29 |
30 | Application
31 | Unicode
32 | v100
33 | v110
34 | v110_xp
35 | v120
36 | v120_xp
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | <_ProjectFileVersion>10.0.40219.1
54 | $(SolutionDir)$(Configuration).win32\
55 | $(Configuration).win32\
56 | true
57 | $(SolutionDir)$(Configuration).win32\
58 | $(Configuration).win32\
59 | false
60 | AllRules.ruleset
61 |
62 |
63 | AllRules.ruleset
64 |
65 |
66 |
67 |
68 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)
69 |
70 |
71 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath)
72 |
73 |
74 |
75 | Disabled
76 | $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories)
77 | WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
78 | false
79 | EnableFastChecks
80 | MultiThreadedDebugDLL
81 |
82 |
83 | Level3
84 | EditAndContinue
85 | 4267;4251;4244;%(DisableSpecificWarnings)
86 | true
87 |
88 |
89 | %(AdditionalDependencies)
90 | $(OutDir)$(ProjectName).exe
91 | $(OutDir);%(AdditionalLibraryDirectories)
92 | true
93 | Windows
94 | MachineX86
95 |
96 |
97 |
98 |
99 |
100 |
101 | if not exist "$(OutDir)" mkdir "$(OutDir)"
102 | xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)"
103 |
104 |
105 |
106 |
107 | MaxSpeed
108 | true
109 | $(EngineRoot);$(EngineRoot)cocos\audio\include;$(EngineRoot)external;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;..\Classes;..;%(AdditionalIncludeDirectories)
110 | WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
111 | MultiThreadedDLL
112 | true
113 |
114 |
115 | Level3
116 | ProgramDatabase
117 | 4267;4251;4244;%(DisableSpecificWarnings)
118 | true
119 |
120 |
121 | libcurl_imp.lib;websockets.lib;%(AdditionalDependencies)
122 | $(OutDir)$(ProjectName).exe
123 | $(OutDir);%(AdditionalLibraryDirectories)
124 | true
125 | Windows
126 | true
127 | true
128 | MachineX86
129 |
130 |
131 |
132 |
133 |
134 |
135 | if not exist "$(OutDir)" mkdir "$(OutDir)"
136 | xcopy /Y /Q "$(EngineRoot)external\websockets\prebuilt\win32\*.*" "$(OutDir)"
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | {98a51ba8-fc3a-415b-ac8f-8c7bd464e93e}
152 | false
153 |
154 |
155 | {b7c2a162-dec9-4418-972e-240ab3cbfcae}
156 |
157 |
158 | {929480e7-23c0-4df6-8456-096d71547116}
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8)
2 |
3 | set(APP_NAME MyGame)
4 | project (${APP_NAME})
5 |
6 | include(cocos2d/cmake/BuildHelpers.CMakeLists.txt)
7 |
8 | option(DEBUG_MODE "Debug or release?" ON)
9 |
10 | if(DEBUG_MODE)
11 | set(CMAKE_BUILD_TYPE DEBUG)
12 | else(DEBUG_MODE)
13 | set(CMAKE_BUILD_TYPE RELEASE)
14 | endif(DEBUG_MODE)
15 |
16 | if (MSVC)
17 | set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1")
18 | set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
19 |
20 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
21 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
22 |
23 | elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
24 | set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
25 | set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
26 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -std=c99")
27 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11 -stdlib=libc++ -Wno-deprecated-declarations -Wno-reorder")
28 |
29 | elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
30 | set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
31 | set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
32 |
33 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
34 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder")
35 | endif()
36 |
37 | # architecture
38 | if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
39 | set(ARCH_DIR "64-bit")
40 | else()
41 | set(ARCH_DIR "32-bit")
42 | endif()
43 |
44 | if( APPLE AND IOS )
45 | include_directories(Classes)
46 | set(GAME_SRC
47 | proj.ios_mac/ios/main.m
48 | proj.ios_mac/ios/RootViewController.mm
49 | proj.ios_mac/ios/AppController.mm
50 | Classes/AppDelegate.cpp
51 | Classes/HelloWorldScene.cpp
52 | )
53 | set(GAME_HEADERS
54 | Classes/AppDelegate.h
55 | Classes/HelloWorldScene.h
56 | proj.ios_mac/ios/RootViewController.h
57 | proj.ios_mac/ios/AppController.h
58 | )
59 | elseif(APPLE) #desktop
60 | include_directories(Classes)
61 | include(Classes/CMakeLists.txt)
62 | set(GAME_SRC
63 | proj.ios_mac/mac/main.cpp
64 | Classes/AppDelegate.cpp
65 | Classes/HelloWorldScene.cpp
66 | )
67 | set(GAME_HEADERS
68 | Classes/AppDelegate.h
69 | Classes/HelloWorldScene.h
70 | )
71 | elseif( UNIX AND NOT APPLE) #assume linux
72 | set(GAME_SRC
73 | proj.linux/main.cpp
74 | Classes/AppDelegate.cpp
75 | Classes/HelloWorldScene.cpp
76 | )
77 | elseif ( WIN32 )
78 | set(GAME_SRC
79 | proj.win32/main.cpp
80 | proj.win32/main.h
81 | proj.win32/resource.h
82 | Classes/AppDelegate.cpp
83 | Classes/HelloWorldScene.cpp
84 | )
85 | endif()
86 |
87 | set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)
88 | if (WIN32)
89 | include_directories(
90 | ${COCOS2D_ROOT}
91 | ${COCOS2D_ROOT}/cocos
92 | ${COCOS2D_ROOT}/cocos/audio/include
93 | ${COCOS2D_ROOT}/cocos/2d
94 | ${COCOS2D_ROOT}/cocos/2d/renderer
95 | ${COCOS2D_ROOT}/cocos/2d/platform
96 | ${COCOS2D_ROOT}/cocos/2d/platform/desktop
97 | ${COCOS2D_ROOT}/cocos/2d/platform/win32
98 | ${COCOS2D_ROOT}/cocos/base
99 | ${COCOS2D_ROOT}/cocos/deprecated
100 | ${COCOS2D_ROOT}/cocos/physics
101 | ${COCOS2D_ROOT}/cocos/editor-support
102 | ${COCOS2D_ROOT}/cocos/math
103 | ${COCOS2D_ROOT}/extensions
104 | ${COCOS2D_ROOT}/external
105 | ${COCOS2D_ROOT}/external/edtaa3func
106 | ${COCOS2D_ROOT}/external/jpeg/include/win32
107 | ${COCOS2D_ROOT}/external/png/include/win32
108 | ${COCOS2D_ROOT}/external/tiff/include/win32
109 | ${COCOS2D_ROOT}/external/webp/include/win32
110 | ${COCOS2D_ROOT}/external/curl/include/win32
111 | ${COCOS2D_ROOT}/external/tinyxml2
112 | ${COCOS2D_ROOT}/external/unzip
113 | ${COCOS2D_ROOT}/external/sqlite3/include
114 | ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
115 | ${COCOS2D_ROOT}/external/freetype2/include/win32
116 | ${COCOS2D_ROOT}/external/websockets/include/win32
117 | ${COCOS2D_ROOT}/external/spidermonkey/include/win32
118 | ${COCOS2D_ROOT}/external/glfw3/include/win32
119 | ${COCOS2D_ROOT}/external/win32-specific/gles/include/OGLES
120 | ${COCOS2D_ROOT}/external/win32-specific/icon/include
121 | ${COCOS2D_ROOT}/external/win32-specific/zlib/include
122 | ${COCOS2D_ROOT}/external/xxhash
123 | )
124 | link_directories(
125 | /usr/local/lib
126 | ${COCOS2D_ROOT}/external/png/prebuilt/win32
127 | ${COCOS2D_ROOT}/external/jpeg/prebuilt/win32
128 | ${COCOS2D_ROOT}/external/tiff/prebuilt/win32
129 | ${COCOS2D_ROOT}/external/glfw3/prebuilt/win32
130 | ${COCOS2D_ROOT}/external/webp/prebuilt/win32
131 | ${COCOS2D_ROOT}/external/curl/prebuilt/win32
132 | ${COCOS2D_ROOT}/external/sqlite3/libraries/win32
133 | ${COCOS2D_ROOT}/external/freetype2/prebuilt/win32
134 | ${COCOS2D_ROOT}/external/websockets/prebuilt/win32
135 | ${COCOS2D_ROOT}/external/spidermonkey/prebuilt/win32
136 | ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt
137 | ${COCOS2D_ROOT}/external/win32-specific/icon/prebuilt
138 | ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt
139 | )
140 |
141 | elseif(UNIX) #assumed linux
142 | include_directories(
143 | /usr/local/include/GLFW
144 | /usr/include/GLFW
145 | ${COCOS2D_ROOT}
146 | ${COCOS2D_ROOT}/cocos
147 | ${COCOS2D_ROOT}/cocos/audio/include
148 | ${COCOS2D_ROOT}/cocos/platform
149 | ${COCOS2D_ROOT}/cocos/platform/desktop
150 | ${COCOS2D_ROOT}/cocos/platform/linux
151 | ${COCOS2D_ROOT}/cocos/editor-support
152 | ${COCOS2D_ROOT}/extensions
153 | ${COCOS2D_ROOT}/external
154 | ${COCOS2D_ROOT}/external/edtaa3func
155 | ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
156 | ${COCOS2D_ROOT}/external/jpeg/include/linux
157 | ${COCOS2D_ROOT}/external/tiff/include/linux
158 | ${COCOS2D_ROOT}/external/webp/include/linux
159 | ${COCOS2D_ROOT}/external/tinyxml2
160 | ${COCOS2D_ROOT}/external/unzip
161 | ${COCOS2D_ROOT}/external/freetype2/include/linux
162 | ${COCOS2D_ROOT}/external/websockets/include/linux
163 | ${COCOS2D_ROOT}/external/spidermonkey/include/linux
164 | ${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR}
165 | ${COCOS2D_ROOT}/external/xxhash
166 | )
167 | elseif(APPLE AND IOS)
168 | include_directories(
169 | /usr/local/include/GLFW
170 | /usr/include/GLFW
171 | ${COCOS2D_ROOT}
172 | ${COCOS2D_ROOT}/cocos
173 | ${COCOS2D_ROOT}/cocos/audio/include
174 | ${COCOS2D_ROOT}/cocos/platform
175 | ${COCOS2D_ROOT}/cocos/platform/ios
176 | ${COCOS2D_ROOT}/cocos/editor-support
177 | ${COCOS2D_ROOT}/extensions
178 | ${COCOS2D_ROOT}/external
179 | ${COCOS2D_ROOT}/external/edtaa3func
180 | ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
181 | ${COCOS2D_ROOT}/external/jpeg/include/ios
182 | ${COCOS2D_ROOT}/external/tiff/include/ios
183 | ${COCOS2D_ROOT}/external/webp/include/ios
184 | ${COCOS2D_ROOT}/external/tinyxml2
185 | ${COCOS2D_ROOT}/external/unzip
186 | ${COCOS2D_ROOT}/external/freetype2/include/ios
187 | ${COCOS2D_ROOT}/external/websockets/include/ios
188 | ${COCOS2D_ROOT}/external/spidermonkey/include/liniosux
189 | ${COCOS2D_ROOT}/external/xxhash
190 | )
191 | elseif(APPLE)
192 | include_directories(
193 | /usr/local/include/GLFW
194 | /usr/include/GLFW
195 | ${COCOS2D_ROOT}
196 | ${COCOS2D_ROOT}/cocos
197 | ${COCOS2D_ROOT}/cocos/audio/include
198 | ${COCOS2D_ROOT}/cocos/platform
199 | ${COCOS2D_ROOT}/cocos/platform/mac
200 | ${COCOS2D_ROOT}/cocos/editor-support
201 | ${COCOS2D_ROOT}/extensions
202 | ${COCOS2D_ROOT}/external
203 | ${COCOS2D_ROOT}/external/edtaa3func
204 | ${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
205 | ${COCOS2D_ROOT}/external/jpeg/include/mac
206 | ${COCOS2D_ROOT}/external/tiff/include/mac
207 | ${COCOS2D_ROOT}/external/webp/include/mac
208 | ${COCOS2D_ROOT}/external/tinyxml2
209 | ${COCOS2D_ROOT}/external/unzip
210 | ${COCOS2D_ROOT}/external/freetype2/include/mac
211 | ${COCOS2D_ROOT}/external/websockets/include/mac
212 | ${COCOS2D_ROOT}/external/spidermonkey/include/liniosux
213 | ${COCOS2D_ROOT}/external/xxhash
214 | )
215 | endif()
216 |
217 | if(NOT APPLE)
218 | ADD_DEFINITIONS(-DLINUX)
219 | endif()
220 |
221 | if(LINUX)
222 | link_directories(
223 | /usr/local/lib
224 | ${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR}
225 | ${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR}
226 | ${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR}
227 | ${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR}
228 | ${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR}
229 | ${COCOS2D_ROOT}/external/spidermonkey/prebuilt/linux/${ARCH_DIR}
230 | ${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
231 | ${COCOS2D_ROOT}/external/chipmunk/prebuilt/linux/${ARCH_DIR}
232 | )
233 | elseif(APPLE AND IOS)
234 | link_directories(
235 | /usr/local/lib
236 | ${COCOS2D_ROOT}/external/jpeg/prebuilt/ios
237 | ${COCOS2D_ROOT}/external/tiff/prebuilt/ios
238 | ${COCOS2D_ROOT}/external/webp/prebuilt/ios
239 | ${COCOS2D_ROOT}/external/freetype2/prebuilt/ios
240 | ${COCOS2D_ROOT}/external/websockets/prebuilt/ios
241 | ${COCOS2D_ROOT}/external/chipmunk/prebuilt/ios
242 | )
243 | elseif(APPLE)
244 | if(IOS)
245 | link_directories(
246 | /usr/local/lib
247 | ${COCOS2D_ROOT}/external/jpeg/prebuilt/ios
248 | ${COCOS2D_ROOT}/external/tiff/prebuilt/ios
249 | ${COCOS2D_ROOT}/external/webp/prebuilt/ios
250 | ${COCOS2D_ROOT}/external/freetype2/prebuilt/ios
251 | ${COCOS2D_ROOT}/external/websockets/prebuilt/ios
252 | ${COCOS2D_ROOT}/external/chipmunk/prebuilt/ios
253 | )
254 | else()
255 | link_directories(
256 | /usr/local/lib
257 | ${COCOS2D_ROOT}/external/jpeg/prebuilt/mac
258 | ${COCOS2D_ROOT}/external/tiff/prebuilt/mac
259 | ${COCOS2D_ROOT}/external/webp/prebuilt/mac
260 | ${COCOS2D_ROOT}/external/freetype2/prebuilt/mac
261 | ${COCOS2D_ROOT}/external/websockets/prebuilt/mac
262 | ${COCOS2D_ROOT}/external/chipmunk/prebuilt/mac
263 | )
264 | endif()
265 | endif()
266 |
267 | # build for 3rd party libraries
268 | if(LINUX OR APPLE)
269 | add_subdirectory(${COCOS2D_ROOT}/external/Box2D)
270 | add_subdirectory(${COCOS2D_ROOT}/external/unzip)
271 | add_subdirectory(${COCOS2D_ROOT}/external/xxhash)
272 | add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)
273 | endif()
274 |
275 | # libcocos2d
276 | add_subdirectory(${COCOS2D_ROOT}/cocos)
277 |
278 | if(GAME_HEADERS)
279 | add_executable(${APP_NAME} ${GAME_SRC} ${GAME_HEADERS})
280 | else()
281 | add_executable(${APP_NAME} ${GAME_SRC})
282 | endif()
283 |
284 | target_link_libraries(${APP_NAME} cocos2d)
285 |
286 | set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")
287 |
288 | set_target_properties(${APP_NAME} PROPERTIES
289 | RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")
290 |
291 | if ( WIN32 )
292 | #also copying dlls to binary directory for the executable to run
293 | pre_build(${APP_NAME}
294 | COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
295 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
296 | COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/gles/prebuilt/glew32.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
297 | COMMAND ${CMAKE_COMMAND} -E copy ${COCOS2D_ROOT}/external/win32-specific/zlib/prebuilt/zlib1.dll ${APP_BIN_DIR}/${CMAKE_BUILD_TYPE}
298 | )
299 | else()
300 | pre_build(${APP_NAME}
301 | COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
302 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
303 | )
304 |
305 | endif()
306 |
--------------------------------------------------------------------------------
/Classes/HelloWorldScene.cpp:
--------------------------------------------------------------------------------
1 | #include "HelloWorldScene.h"
2 |
3 | USING_NS_CC;
4 | //include for particle
5 | #include "Particle3D/CCParticle3DEmitter.h"
6 | #include "Particle3D/CCParticle3DAffector.h"
7 | #include "Particle3D/CCParticle3DRender.h"
8 | #include "Particle3D/ParticleUniverse/ParticleRenders/CCPUParticle3DRender.h"
9 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DPointEmitter.h"
10 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DBoxEmitter.h"
11 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DCircleEmitter.h"
12 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DLineEmitter.h"
13 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DPositionEmitter.h"
14 | #include "Particle3D/ParticleUniverse/ParticleEmitters/CCPUParticle3DSphereSurfaceEmitter.h"
15 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DAlignAffector.h"
16 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DBoxCollider.h"
17 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DColorAffector.h"
18 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DGravityAffector.h"
19 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DScaleAffector.h"
20 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DFlockCenteringAffector.h"
21 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DForceFieldAffector.h"
22 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DLinearForceAffector.h"
23 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DParticleFollower.h"
24 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DPathFollower.h"
25 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DPlaneCollider.h"
26 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DRandomiser.h"
27 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DSineForceAffector.h"
28 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DTextureRotator.h"
29 | #include "Particle3D/ParticleUniverse/ParticleAffectors/CCPUParticle3DVortexAffector.h"
30 | #include "Particle3D/ParticleUniverse/CCPUParticleSystem3D.h"
31 | #include "Particle3D/ParticleUniverse/CCPUParticle3DScriptCompiler.h"
32 |
33 |
34 |
35 | Scene* ModelViewer::createScene(const std::string &filePath)
36 | {
37 |
38 | ////add search path for the Particle
39 | //FileUtils::getInstance()->addSearchPath("materials");
40 | //FileUtils::getInstance()->addSearchPath("scripts");
41 |
42 | // 'scene' is an autorelease object
43 | auto scene = Scene::create();
44 |
45 | // 'layer' is an autorelease object
46 | auto layer = ModelViewer::create();
47 | layer->loadModelOrParticle(filePath);
48 | layer->setCamera();
49 | layer->resetCamera();
50 |
51 | // add layer as a child to scene
52 | scene->addChild(layer);
53 |
54 | // return the scene
55 | return scene;
56 | }
57 |
58 | // on "init" you need to initialize your instance
59 | bool ModelViewer::init()
60 | {
61 | //////////////////////////////
62 | // 1. super init first
63 | if ( !Layer::init() )
64 | {
65 | return false;
66 | }
67 |
68 | auto listenertouch = EventListenerTouchAllAtOnce::create();
69 | listenertouch->onTouchesMoved = CC_CALLBACK_2(ModelViewer::onTouchsMovedThis, this);
70 | _eventDispatcher->addEventListenerWithSceneGraphPriority(listenertouch, this);
71 |
72 | auto listenermouse= EventListenerMouse::create();
73 | listenermouse->onMouseScroll = CC_CALLBACK_1(ModelViewer::onMouseScrollThis, this);
74 | listenermouse->onMouseMove = CC_CALLBACK_1(ModelViewer::onMouseMovedThis, this);
75 | _eventDispatcher->addEventListenerWithSceneGraphPriority(listenermouse, this);
76 |
77 | auto listenerkeyboard= EventListenerKeyboard::create();
78 | listenerkeyboard->onKeyPressed = CC_CALLBACK_2(ModelViewer::onKeyPressedThis, this);
79 | _eventDispatcher->addEventListenerWithSceneGraphPriority(listenerkeyboard, this);
80 |
81 | _layer = Layer::create();
82 | _layer->retain();
83 | addChild(_layer);
84 |
85 | return true;
86 | }
87 |
88 | void ModelViewer::loadModelOrParticle( const std::string &filePath )
89 | {
90 | char extension [32];
91 | getFileExtension(filePath.c_str(),extension);
92 | if(strcmp(extension,"c3b")==0 ||strcmp(extension,"c3t")==0 )
93 | {
94 | loadModel(filePath);
95 | }else if(strcmp(extension,"pu")==0 )
96 | {
97 | loadParticle(filePath);
98 | }
99 | }
100 |
101 | ModelViewer::ModelViewer()
102 | : _camera(nullptr)
103 | , _layer(nullptr)
104 | , _orginDistance(0.0f)
105 | , _distance(0.0f)
106 | , _trackballSize(1.0f)
107 | {
108 |
109 | }
110 |
111 | ModelViewer::~ModelViewer()
112 | {
113 | if (_layer)
114 | _layer->release();
115 |
116 | if (_camera)
117 | _camera->release();
118 | }
119 |
120 | void ModelViewer::onTouchsMovedThis( const std::vector &touchs, Event *event )
121 | {
122 | if (!touchs.empty())
123 | {
124 | Size visibleSize = Director::getInstance()->getVisibleSize();
125 | Vec2 prelocation = touchs[0]->getPreviousLocationInView();
126 | Vec2 location = touchs[0]->getLocationInView();
127 | location.x = 2.0 * (location.x) / (visibleSize.width) - 1.0f;
128 | location.y = 2.0 * (visibleSize.height - location.y) / (visibleSize.height) - 1.0f;
129 | prelocation.x = 2.0 * (prelocation.x) / (visibleSize.width) - 1.0f;
130 | prelocation.y = 2.0 * (visibleSize.height - prelocation.y) / (visibleSize.height) - 1.0f;
131 |
132 | Vec3 axes;
133 | float angle;
134 | trackball(axes, angle, prelocation.x, prelocation.y, location.x, location.y);
135 | Quaternion quat(axes, angle);
136 | _rotation = quat * _rotation;
137 |
138 | updateCameraTransform();
139 | }
140 | }
141 |
142 | void ModelViewer::onMouseScrollThis( Event* event )
143 | {
144 | EventMouse *em = dynamic_cast(event);
145 | if (em)
146 | {
147 | _distance += em->getScrollY() * _orginDistance * 0.01f;
148 |
149 | updateCameraTransform();
150 | }
151 | }
152 |
153 | void ModelViewer::onMouseMovedThis( Event* event )
154 | {
155 | EventMouse *em = dynamic_cast(event);
156 | if (em)
157 | {
158 | if (em->getMouseButton() == GLFW_MOUSE_BUTTON_RIGHT)
159 | {
160 | Size visibleSize = Director::getInstance()->getVisibleSize();
161 | Vec2 delta = (em->getLocation() - _preMouseLocation);
162 | Mat4 rot;
163 | Mat4::createRotation(_rotation, &rot);
164 | _center += rot * -Vec3(delta.x / visibleSize.width, (-delta.y) / visibleSize.height, 0.0f) * _orginDistance * 0.1f;
165 | updateCameraTransform();
166 | }
167 |
168 | _preMouseLocation = em->getLocation();
169 | }
170 | }
171 |
172 | float ModelViewer::tb_project_to_sphere( float r, float x, float y )
173 | {
174 | float d, t, z;
175 | d = sqrt(x*x + y*y);
176 | if (d < r * 0.70710678118654752440)
177 | {
178 | z = sqrt(r*r - d*d);
179 | }
180 | else
181 | {
182 | t = r / 1.41421356237309504880;
183 | z = t*t / d;
184 | }
185 | return z;
186 | }
187 |
188 | void ModelViewer::trackball( cocos2d::Vec3 & axis, float & angle, float p1x, float p1y, float p2x, float p2y )
189 | {
190 | Mat4 rotation_matrix;
191 | Mat4::createRotation(_rotation, &rotation_matrix);
192 |
193 | Vec3 uv = rotation_matrix * Vec3(0.0f,1.0f,0.0f);
194 | Vec3 sv = rotation_matrix * Vec3(1.0f,0.0f,0.0f);
195 | Vec3 lv = rotation_matrix * Vec3(0.0f,0.0f,-1.0f);
196 |
197 | Vec3 p1 = sv * p1x + uv * p1y - lv * tb_project_to_sphere(_trackballSize, p1x, p1y);
198 | Vec3 p2 = sv * p2x + uv * p2y - lv * tb_project_to_sphere(_trackballSize, p2x, p2y);
199 |
200 | Vec3::cross(p2, p1, &axis);
201 | axis.normalize();
202 |
203 | float t = (p2 - p1).length() / (2.0 * _trackballSize);
204 |
205 | if (t > 1.0) t = 1.0;
206 | if (t < -1.0) t = -1.0;
207 | angle = asin(t);
208 | }
209 |
210 | void ModelViewer::updateCameraTransform()
211 | {
212 | Mat4 trans, rot, center;
213 | Mat4::createTranslation(Vec3(0.0f, 0.0f, _distance), &trans);
214 | Mat4::createRotation(_rotation, &rot);
215 | Mat4::createTranslation(_center, ¢er);
216 | Mat4 result = center * rot * trans;
217 | _camera->setNodeToParentTransform(result);
218 | }
219 |
220 | void ModelViewer::onKeyPressedThis( EventKeyboard::KeyCode keycode, Event *event )
221 | {
222 | switch (keycode)
223 | {
224 | case EventKeyboard::KeyCode::KEY_SPACE:
225 | {
226 | resetCamera();
227 | }
228 | break;
229 | default:
230 | break;
231 | }
232 | }
233 |
234 | void ModelViewer::resetCamera()
235 | {
236 | _distance = _orginDistance;
237 | _center = _orginCenter;
238 | _rotation.set(0.0f, 0.0f, 0.0f, 1.0f);
239 | _camera->setPosition3D(_orginCenter + Vec3(0.0f, 0.0f, _orginDistance));
240 | _camera->lookAt(_orginCenter, Vec3(0.0f, 1.0f, 0.0f));
241 | }
242 |
243 | void ModelViewer::setCamera()
244 | {
245 | Size visibleSize = Director::getInstance()->getVisibleSize();
246 | _camera = Camera::createPerspective(60.0f, (GLfloat)visibleSize.width/visibleSize.height, 1.0f, _orginDistance * 5.0f);
247 | _camera->setCameraFlag(CameraFlag::USER1);
248 | _camera->setPosition3D(Vec3(0.0f, 0.0f, 10.0f));
249 | _camera->lookAt(Vec3(0.0f, 0.0f, 0.0f), Vec3(0.0f, 1.0f, 0.0f));
250 | _camera->retain();
251 | _camera->setCameraMask((unsigned short)CameraFlag::USER1);
252 | _layer->addChild(_camera);
253 | }
254 |
255 | void ModelViewer::loadModel(const std::string &filePath)
256 | {
257 | Sprite3D *sprite = Sprite3D::create(filePath);
258 | if (sprite)
259 | {
260 | auto animation = Animation3D::create(filePath);
261 | if (animation)
262 | {
263 | auto animate = Animate3D::create(animation);
264 | sprite->runAction(RepeatForever::create(animate));
265 | }
266 |
267 | AABB aabb = sprite->getAABB();
268 | Vec3 corners[8];
269 | aabb.getCorners(corners);
270 | //temporary method, replace it
271 | if (abs(corners[3].x) == 99999.0f && abs(corners[3].y) == 99999.0f && abs(corners[3].z) == 99999.0f)
272 | {
273 | _orginCenter = Vec3(0.0f, 0.0f, 0.0f);
274 | _orginDistance = 100.0f;
275 | }
276 | else
277 | {
278 | float radius = (corners[0] - corners[5]).length();
279 | _orginCenter = aabb.getCenter();
280 | _orginDistance = radius;
281 | }
282 | sprite->setCameraMask((unsigned short)CameraFlag::USER1);
283 | _layer->addChild(sprite);
284 | }
285 |
286 | }
287 |
288 | void ModelViewer::loadParticle(const std::string &filePath)
289 | {
290 | auto rootps = PUParticleSystem3D::create(filePath);
291 | rootps->setCameraMask((unsigned short)CameraFlag::USER1);
292 | rootps->startParticleSystem();
293 | _orginCenter = Vec3(0.0f, 0.0f, 0.0f);
294 | _orginDistance = 50.0f;
295 | _layer->addChild(rootps);
296 | }
297 |
298 | void ModelViewer::getFileExtension(const char *file_name,char *extension)
299 | {
300 | int i=0,length;
301 | length=strlen(file_name);
302 | while(file_name[i])
303 | {
304 | if(file_name[i]=='.')
305 | break;
306 | i++;
307 | }
308 | if(i