merge cocos

This commit is contained in:
yangxiao 2014-10-30 11:56:20 +08:00
commit 77aebb657d
209 changed files with 5444 additions and 1872 deletions

1
.gitignore vendored
View File

@ -36,6 +36,7 @@ ipch/
*.opensdf
SubmissionInfo
Generated Files
AppPackages
# Ignore files build by ndk and eclipse
libs/

19
AUTHORS
View File

@ -938,6 +938,7 @@ Developers:
Fixed compiling error on WP8.
Added method for custom precompiled shader program loading on WP8
Enable screen orientation change handling on WP8
Enabled GLProgramState restoring on render recreated on WP8
chareice
Make `setup.py` work on zsh
@ -1032,6 +1033,21 @@ Developers:
coldfog
Fix bug that ActionManagerEx::initWithBinary can only load one UI animation
timur-losev
Fix a bug that GLProgramCache::addGLProgram() can not replace existing program
TimothyZhang
Fixed a potential memory leak in GLProgram::setGLProgram()
ahlwong
Fix Label Kerning on Single Characters
Svenito
Add greater than operator to Vec2
liamcindy
update ui button size changed logic
Retired Core Developers:
WenSheng Yang
@ -1044,9 +1060,6 @@ Retired Core Developers:
RongHong Huang (flyingpaper)
Author of cocos2d-xna and spent all his time on wp7.
timur-losev
Fix a bug that GLProgramCache::addGLProgram() can not replace existing program
Cocos2d-x can not grow so fast without the active community.
Thanks to all developers who report & trace bugs, discuss the engine usage in forum & QQ groups!

View File

@ -1,3 +1,15 @@
cocos2d-x-3.3 ??
[NEW] Vec2: added greater than operator
[FIX] Cocos console: compile failure on windows if using VS express version
[FIX] GrawNode: drawPoint() may cause crash
[FIX] GLProgramCache: doesn't release old program with the same key before adding a new one
[FIX] GLProgramState: enabled GLProgramState restoring on render recreated on WP8
[FIX] Label: label shifting when outline feature enabled
[FIX] Label: when applying additionalKerning to a Label that displays a string with only 1 character, the character is shifted
[FIX] Sprite3D: did not create attached sprite from cache
[FIX] WP/WinRT: Windows 8.1 universal app support; `UIEditBox` support
cocos2d-x-3.3-rc0 Oct.21 2014
[NEW] 3d: added light support: direction light, point light, spot light and ambient light
[NEW] Added ClippingRectangleNode

View File

@ -0,0 +1,228 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libcocos2d", "libcocos2d", "{B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Shared", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems", "{5D6F020F-7E72-4494-90A0-2DF11D235DF9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.Windows", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Windows\libcocos2d_8_1.Windows.vcxproj", "{9335005F-678E-4E8E-9B84-50037216AEC8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d_8_1.WindowsPhone", "..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.WindowsPhone\libcocos2d_8_1.WindowsPhone.vcxproj", "{22F3B9DF-1209-4574-8331-003966F562BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cpp-tests", "cpp-tests", "{572742C5-9322-4548-AB8B-96C3750A1B5D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests.Shared", "..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems", "{BE3A1791-5BCE-4CEA-92CD-0E2D86DDE27A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests.Windows", "..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Windows\cpp-tests.Windows.vcxproj", "{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-tests.WindowsPhone", "..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.WindowsPhone\cpp-tests.WindowsPhone.vcxproj", "{15247C71-5289-4913-B88F-E253CC353720}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{85630454-74EA-4B5B-9B62-0E459B4476CB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libbox2d", "libbox2d", "{B3D1A3D5-9F54-43AF-9322-230B53242B78}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.Shared", "..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems", "{4A3C6BA8-C227-498B-AA21-40BDA27B461F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.Windows", "..\external\Box2D\proj.win8.1-universal\libbox2d.Windows\libbox2d.Windows.vcxproj", "{3B26A12D-3A44-47EA-82D2-282660FC844D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d.WindowsPhone", "..\external\Box2D\proj.win8.1-universal\libbox2d.WindowsPhone\libbox2d.WindowsPhone.vcxproj", "{22F798D8-BFFF-4754-996F-A5395343D5EC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libSpine", "libSpine", "{6FEB795C-C98C-4C8C-A88B-A35DEE205348}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.Shared", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems", "{ADAFD00D-A0D6-46EF-9F0B-EA2880BFE1DE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.Windows", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Windows\libSpine.Windows.vcxproj", "{F3550FE0-C795-44F6-8FEB-093EB68143AE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine.WindowsPhone", "..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.WindowsPhone\libSpine.WindowsPhone.vcxproj", "{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cpp-empty-test", "cpp-empty-test", "{B70EF25E-E352-4020-BCDF-388973E44637}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp.Shared", "..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems", "{A3AD93E4-0B2F-4C58-9181-69BED2E42E3E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp.Windows", "..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Windows\HelloCpp.Windows.vcxproj", "{79A8FCDA-4B12-4DD1-B676-FF148D651638}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloCpp.WindowsPhone", "..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.WindowsPhone\HelloCpp.WindowsPhone.vcxproj", "{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{9335005f-678e-4e8e-9b84-50037216aec8}*SharedItemsImports = 4
..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems*{15247c71-5289-4913-b88f-e253cc353720}*SharedItemsImports = 4
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{a3ad93e4-0b2f-4c58-9181-69bed2e42e3e}*SharedItemsImports = 9
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{cc1da216-a80d-4be4-b309-acb6af313aff}*SharedItemsImports = 4
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{4a3c6ba8-c227-498b-aa21-40bda27b461f}*SharedItemsImports = 9
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{79a8fcda-4b12-4dd1-b676-ff148d651638}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{adafd00d-a0d6-46ef-9f0b-ea2880bfe1de}*SharedItemsImports = 9
..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems*{be3a1791-5bce-4cea-92cd-0e2d86dde27a}*SharedItemsImports = 9
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{5d6f020f-7e72-4494-90a0-2df11d235df9}*SharedItemsImports = 9
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{3b26a12d-3a44-47ea-82d2-282660fc844d}*SharedItemsImports = 4
..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Shared\libcocos2d_8_1.Shared.vcxitems*{22f3b9df-1209-4574-8331-003966f562bf}*SharedItemsImports = 4
..\external\Box2D\proj.win8.1-universal\libbox2d.Shared\libbox2d.Shared.vcxitems*{22f798d8-bfff-4754-996f-a5395343d5ec}*SharedItemsImports = 4
..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Shared\libSpine.Shared.vcxitems*{f3550fe0-c795-44f6-8feb-093eb68143ae}*SharedItemsImports = 4
..\tests\cpp-tests\proj.win8.1-universal\cpp-tests.Shared\cpp-tests.Shared.vcxitems*{f2bae06b-caae-43ee-b21b-57fa48db04fa}*SharedItemsImports = 4
..\tests\cpp-empty-test\proj.win8.1-universal\HelloCpp.Shared\HelloCpp.Shared.vcxitems*{396fe85e-bb05-4b92-bccb-f89aed4ea41a}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|ARM = Release|ARM
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|ARM.ActiveCfg = Debug|ARM
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|ARM.Build.0 = Debug|ARM
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|Win32.ActiveCfg = Debug|Win32
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|Win32.Build.0 = Debug|Win32
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|x64.ActiveCfg = Debug|x64
{9335005F-678E-4E8E-9B84-50037216AEC8}.Debug|x64.Build.0 = Debug|x64
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|ARM.ActiveCfg = Release|ARM
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|ARM.Build.0 = Release|ARM
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|Win32.ActiveCfg = Release|Win32
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|Win32.Build.0 = Release|Win32
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|x64.ActiveCfg = Release|x64
{9335005F-678E-4E8E-9B84-50037216AEC8}.Release|x64.Build.0 = Release|x64
{22F3B9DF-1209-4574-8331-003966F562BF}.Debug|ARM.ActiveCfg = Debug|ARM
{22F3B9DF-1209-4574-8331-003966F562BF}.Debug|ARM.Build.0 = Debug|ARM
{22F3B9DF-1209-4574-8331-003966F562BF}.Debug|Win32.ActiveCfg = Debug|Win32
{22F3B9DF-1209-4574-8331-003966F562BF}.Debug|Win32.Build.0 = Debug|Win32
{22F3B9DF-1209-4574-8331-003966F562BF}.Debug|x64.ActiveCfg = Debug|Win32
{22F3B9DF-1209-4574-8331-003966F562BF}.Release|ARM.ActiveCfg = Release|ARM
{22F3B9DF-1209-4574-8331-003966F562BF}.Release|ARM.Build.0 = Release|ARM
{22F3B9DF-1209-4574-8331-003966F562BF}.Release|Win32.ActiveCfg = Release|Win32
{22F3B9DF-1209-4574-8331-003966F562BF}.Release|Win32.Build.0 = Release|Win32
{22F3B9DF-1209-4574-8331-003966F562BF}.Release|x64.ActiveCfg = Release|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|ARM.ActiveCfg = Debug|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|ARM.Build.0 = Debug|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|ARM.Deploy.0 = Debug|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|Win32.ActiveCfg = Debug|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|Win32.Build.0 = Debug|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|Win32.Deploy.0 = Debug|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|x64.ActiveCfg = Debug|x64
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|x64.Build.0 = Debug|x64
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Debug|x64.Deploy.0 = Debug|x64
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|ARM.ActiveCfg = Release|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|ARM.Build.0 = Release|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|ARM.Deploy.0 = Release|ARM
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|Win32.ActiveCfg = Release|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|Win32.Build.0 = Release|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|Win32.Deploy.0 = Release|Win32
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|x64.ActiveCfg = Release|x64
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|x64.Build.0 = Release|x64
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA}.Release|x64.Deploy.0 = Release|x64
{15247C71-5289-4913-B88F-E253CC353720}.Debug|ARM.ActiveCfg = Debug|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Debug|ARM.Build.0 = Debug|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Debug|ARM.Deploy.0 = Debug|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Debug|Win32.ActiveCfg = Debug|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Debug|Win32.Build.0 = Debug|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Debug|Win32.Deploy.0 = Debug|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Debug|x64.ActiveCfg = Debug|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Release|ARM.ActiveCfg = Release|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Release|ARM.Build.0 = Release|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Release|ARM.Deploy.0 = Release|ARM
{15247C71-5289-4913-B88F-E253CC353720}.Release|Win32.ActiveCfg = Release|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Release|Win32.Build.0 = Release|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Release|Win32.Deploy.0 = Release|Win32
{15247C71-5289-4913-B88F-E253CC353720}.Release|x64.ActiveCfg = Release|Win32
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|ARM.ActiveCfg = Debug|ARM
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|ARM.Build.0 = Debug|ARM
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|Win32.ActiveCfg = Debug|Win32
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|Win32.Build.0 = Debug|Win32
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|x64.ActiveCfg = Debug|x64
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Debug|x64.Build.0 = Debug|x64
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|ARM.ActiveCfg = Release|ARM
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|ARM.Build.0 = Release|ARM
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|Win32.ActiveCfg = Release|Win32
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|Win32.Build.0 = Release|Win32
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|x64.ActiveCfg = Release|x64
{3B26A12D-3A44-47EA-82D2-282660FC844D}.Release|x64.Build.0 = Release|x64
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|ARM.ActiveCfg = Debug|ARM
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|ARM.Build.0 = Debug|ARM
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|Win32.ActiveCfg = Debug|Win32
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|Win32.Build.0 = Debug|Win32
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Debug|x64.ActiveCfg = Debug|Win32
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|ARM.ActiveCfg = Release|ARM
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|ARM.Build.0 = Release|ARM
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|Win32.ActiveCfg = Release|Win32
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|Win32.Build.0 = Release|Win32
{22F798D8-BFFF-4754-996F-A5395343D5EC}.Release|x64.ActiveCfg = Release|Win32
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|ARM.ActiveCfg = Debug|ARM
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|ARM.Build.0 = Debug|ARM
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|Win32.ActiveCfg = Debug|Win32
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|Win32.Build.0 = Debug|Win32
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|x64.ActiveCfg = Debug|x64
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Debug|x64.Build.0 = Debug|x64
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|ARM.ActiveCfg = Release|ARM
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|ARM.Build.0 = Release|ARM
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|Win32.ActiveCfg = Release|Win32
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|Win32.Build.0 = Release|Win32
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|x64.ActiveCfg = Release|x64
{F3550FE0-C795-44F6-8FEB-093EB68143AE}.Release|x64.Build.0 = Release|x64
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|ARM.ActiveCfg = Debug|ARM
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|ARM.Build.0 = Debug|ARM
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|Win32.ActiveCfg = Debug|Win32
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|Win32.Build.0 = Debug|Win32
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Debug|x64.ActiveCfg = Debug|Win32
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|ARM.ActiveCfg = Release|ARM
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|ARM.Build.0 = Release|ARM
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|Win32.ActiveCfg = Release|Win32
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|Win32.Build.0 = Release|Win32
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF}.Release|x64.ActiveCfg = Release|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|ARM.ActiveCfg = Debug|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|ARM.Build.0 = Debug|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|ARM.Deploy.0 = Debug|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|Win32.ActiveCfg = Debug|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|Win32.Build.0 = Debug|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|Win32.Deploy.0 = Debug|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|x64.ActiveCfg = Debug|x64
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|x64.Build.0 = Debug|x64
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Debug|x64.Deploy.0 = Debug|x64
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|ARM.ActiveCfg = Release|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|ARM.Build.0 = Release|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|ARM.Deploy.0 = Release|ARM
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|Win32.ActiveCfg = Release|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|Win32.Build.0 = Release|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|Win32.Deploy.0 = Release|Win32
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|x64.ActiveCfg = Release|x64
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|x64.Build.0 = Release|x64
{79A8FCDA-4B12-4DD1-B676-FF148D651638}.Release|x64.Deploy.0 = Release|x64
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|ARM.ActiveCfg = Debug|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|ARM.Build.0 = Debug|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|ARM.Deploy.0 = Debug|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|Win32.ActiveCfg = Debug|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|Win32.Build.0 = Debug|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|Win32.Deploy.0 = Debug|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Debug|x64.ActiveCfg = Debug|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|ARM.ActiveCfg = Release|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|ARM.Build.0 = Release|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|ARM.Deploy.0 = Release|ARM
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|Win32.ActiveCfg = Release|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|Win32.Build.0 = Release|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|Win32.Deploy.0 = Release|Win32
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5D6F020F-7E72-4494-90A0-2DF11D235DF9} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}
{9335005F-678E-4E8E-9B84-50037216AEC8} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}
{22F3B9DF-1209-4574-8331-003966F562BF} = {B3F299D4-B4CA-4F0B-8BE2-FB328483BC13}
{BE3A1791-5BCE-4CEA-92CD-0E2D86DDE27A} = {572742C5-9322-4548-AB8B-96C3750A1B5D}
{F2BAE06B-CAAE-43EE-B21B-57FA48DB04FA} = {572742C5-9322-4548-AB8B-96C3750A1B5D}
{15247C71-5289-4913-B88F-E253CC353720} = {572742C5-9322-4548-AB8B-96C3750A1B5D}
{B3D1A3D5-9F54-43AF-9322-230B53242B78} = {85630454-74EA-4B5B-9B62-0E459B4476CB}
{4A3C6BA8-C227-498B-AA21-40BDA27B461F} = {B3D1A3D5-9F54-43AF-9322-230B53242B78}
{3B26A12D-3A44-47EA-82D2-282660FC844D} = {B3D1A3D5-9F54-43AF-9322-230B53242B78}
{22F798D8-BFFF-4754-996F-A5395343D5EC} = {B3D1A3D5-9F54-43AF-9322-230B53242B78}
{6FEB795C-C98C-4C8C-A88B-A35DEE205348} = {85630454-74EA-4B5B-9B62-0E459B4476CB}
{ADAFD00D-A0D6-46EF-9F0B-EA2880BFE1DE} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348}
{F3550FE0-C795-44F6-8FEB-093EB68143AE} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348}
{CC1DA216-A80D-4BE4-B309-ACB6AF313AFF} = {6FEB795C-C98C-4C8C-A88B-A35DEE205348}
{A3AD93E4-0B2F-4C58-9181-69BED2E42E3E} = {B70EF25E-E352-4020-BCDF-388973E44637}
{79A8FCDA-4B12-4DD1-B676-FF148D651638} = {B70EF25E-E352-4020-BCDF-388973E44637}
{396FE85E-BB05-4B92-BCCB-F89AED4EA41A} = {B70EF25E-E352-4020-BCDF-388973E44637}
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

View File

@ -234,6 +234,7 @@
<ClInclude Include="..\..\..\cocos\2d\CCAnimation.h" />
<ClInclude Include="..\..\..\cocos\2d\CCAnimationCache.h" />
<ClInclude Include="..\..\..\cocos\2d\CCAtlasNode.h" />
<ClInclude Include="..\..\..\cocos\2d\CCCamera.h" />
<ClInclude Include="..\..\..\cocos\2d\CCClippingNode.h" />
<ClInclude Include="..\..\..\cocos\2d\CCComponent.h" />
<ClInclude Include="..\..\..\cocos\2d\CCComponentContainer.h" />
@ -256,6 +257,7 @@
<ClInclude Include="..\..\..\cocos\2d\CCLabelTextFormatter.h" />
<ClInclude Include="..\..\..\cocos\2d\CCLabelTTF.h" />
<ClInclude Include="..\..\..\cocos\2d\CCLayer.h" />
<ClInclude Include="..\..\..\cocos\2d\CCLight.h" />
<ClInclude Include="..\..\..\cocos\2d\CCMenu.h" />
<ClInclude Include="..\..\..\cocos\2d\CCMenuItem.h" />
<ClInclude Include="..\..\..\cocos\2d\CCMotionStreak.h" />
@ -287,7 +289,6 @@
<ClInclude Include="..\..\..\cocos\base\atitc.h" />
<ClInclude Include="..\..\..\cocos\base\base64.h" />
<ClInclude Include="..\..\..\cocos\base\CCAutoreleasePool.h" />
<ClInclude Include="..\..\..\cocos\base\CCCamera.h" />
<ClInclude Include="..\..\..\cocos\base\ccCArray.h" />
<ClInclude Include="..\..\..\cocos\base\ccConfig.h" />
<ClInclude Include="..\..\..\cocos\base\CCConfiguration.h" />
@ -318,7 +319,6 @@
<ClInclude Include="..\..\..\cocos\base\CCGameController.h" />
<ClInclude Include="..\..\..\cocos\base\CCIMEDelegate.h" />
<ClInclude Include="..\..\..\cocos\base\CCIMEDispatcher.h" />
<ClInclude Include="..\..\..\cocos\base\CCLight.h" />
<ClInclude Include="..\..\..\cocos\base\ccMacros.h" />
<ClInclude Include="..\..\..\cocos\base\CCMap.h" />
<ClInclude Include="..\..\..\cocos\base\CCNS.h" />
@ -432,6 +432,7 @@
<ClCompile Include="..\..\..\cocos\2d\CCAnimation.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCAnimationCache.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCAtlasNode.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCCamera.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCClippingNode.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCComponent.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCComponentContainer.cpp" />
@ -454,6 +455,7 @@
<ClCompile Include="..\..\..\cocos\2d\CCLabelTextFormatter.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCLabelTTF.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCLayer.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCLight.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCMenu.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCMenuItem.cpp" />
<ClCompile Include="..\..\..\cocos\2d\CCMotionStreak.cpp" />
@ -485,7 +487,6 @@
<ClCompile Include="..\..\..\cocos\base\atitc.cpp" />
<ClCompile Include="..\..\..\cocos\base\base64.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCAutoreleasePool.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCCamera.cpp" />
<ClCompile Include="..\..\..\cocos\base\ccCArray.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCConfiguration.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCConsole.cpp" />
@ -519,7 +520,6 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\..\cocos\base\CCIMEDispatcher.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCLight.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCNS.cpp" />
<ClCompile Include="..\..\..\cocos\base\CCProfiling.cpp" />
<ClCompile Include="..\..\..\cocos\base\ccRandom.cpp" />

View File

@ -94,9 +94,6 @@
<ClCompile Include="..\..\..\cocos\base\CCAutoreleasePool.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\base\CCCamera.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\base\ccCArray.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
@ -175,9 +172,6 @@
<ClCompile Include="..\..\..\cocos\base\CCIMEDispatcher.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\base\CCLight.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\base\CCNS.cpp">
<Filter>libcoco2d\base</Filter>
</ClCompile>
@ -583,6 +577,12 @@
<ClCompile Include="..\..\..\external\unzip\ioapi_mem.cpp">
<Filter>libcoco2d\external\unzip</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\2d\CCCamera.cpp">
<Filter>libcoco2d\2d</Filter>
</ClCompile>
<ClCompile Include="..\..\..\cocos\2d\CCLight.cpp">
<Filter>libcoco2d\2d</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="App.xaml.h" />
@ -615,9 +615,6 @@
<ClInclude Include="..\..\..\cocos\base\CCAutoreleasePool.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\base\CCCamera.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\base\ccCArray.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
@ -708,9 +705,6 @@
<ClInclude Include="..\..\..\cocos\base\CCIMEDispatcher.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\base\CCLight.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\base\ccMacros.h">
<Filter>libcoco2d\base</Filter>
</ClInclude>
@ -1155,6 +1149,12 @@
<ClInclude Include="..\..\..\external\unzip\ioapi_mem.h">
<Filter>libcoco2d\external\unzip</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\2d\CCCamera.h">
<Filter>libcoco2d\2d</Filter>
</ClInclude>
<ClInclude Include="..\..\..\cocos\2d\CCLight.h">
<Filter>libcoco2d\2d</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />

View File

@ -28,7 +28,6 @@ THE SOFTWARE.
#include "CCPrecompiledShaders.h"
using namespace Concurrency;
using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::UI::Core;

View File

@ -346,9 +346,8 @@ void DrawNode::onDraw(const Mat4 &transform, uint32_t flags)
// texcood
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
}
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _bufferCount);
CHECK_GL_ERROR_DEBUG();
@ -382,9 +381,7 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
}
glLineWidth(2);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLLine);
glDrawArrays(GL_LINES, 0, _bufferCountGLLine);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLLine);
CHECK_GL_ERROR_DEBUG();
@ -399,15 +396,28 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
glProgram->setUniformLocationWith4fv(glProgram->getUniformLocation("u_color"), (GLfloat*) &_pointColor.r, 1);
glProgram->setUniformLocationWith1f(glProgram->getUniformLocation("u_pointSize"), _pointSize);
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
if (_dirtyGLPoint)
{
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
_dirtyGLPoint = false;
}
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(_vaoGLPoint);
}
else
{
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
}
glDrawArrays(GL_POINTS, 0, _bufferCountGLPoint);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,_bufferCountGLPoint);
CHECK_GL_ERROR_DEBUG();
@ -415,6 +425,8 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Color4F &color)
{
ensureCapacityGLPoint(1);
V2F_C4B_T2F *point = (V2F_C4B_T2F*)(_bufferGLPoint + _bufferCountGLPoint);
V2F_C4B_T2F a = {position, Color4B(color), Tex2F(0.0, 0.0) };
*point = a;
@ -423,6 +435,7 @@ void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Colo
_pointColor = color;
_bufferCountGLPoint += 1;
_dirtyGLPoint = true;
}
void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, const Color4F &color)
@ -440,6 +453,7 @@ void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, con
_pointColor = color;
_bufferCountGLPoint += numberOfPoints;
_dirtyGLPoint = true;
}
void DrawNode::drawLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color)

View File

@ -67,7 +67,7 @@ FontAtlas::FontAtlas(Font &theFont)
auto outlineSize = fontTTf->getOutlineSize();
if(outlineSize > 0)
{
_commonLineHeight += 2 * outlineSize * CC_CONTENT_SCALE_FACTOR();
_commonLineHeight += 2 * outlineSize;
_currentPageDataSize *= 2;
}

View File

@ -95,12 +95,12 @@ FT_Library FontFreeType::getFTLibrary()
FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /* = 0 */)
: _fontRef(nullptr)
,_distanceFieldEnabled(distanceFieldEnabled)
,_outlineSize(outline)
,_outlineSize(0.0f)
,_stroker(nullptr)
{
if (_outlineSize > 0)
if (outline > 0)
{
_outlineSize *= CC_CONTENT_SCALE_FACTOR();
_outlineSize = outline * CC_CONTENT_SCALE_FACTOR();
FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker);
FT_Stroker_Set(_stroker,
(int)(_outlineSize * 64),
@ -328,8 +328,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
}
}
outRect.origin.x = bbox.xMin >> 6;
outRect.origin.y = - (bbox.yMax >> 6);
xAdvance += 2 * _outlineSize;
outRect.size.width = blendWidth;
outRect.size.height = blendHeight;

View File

@ -387,13 +387,16 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
log("WARNING: can't find letter definition in font file for letter: %c", c);
continue;
}
nextFontPositionX += charAdvance + kernings[i] + theLabel->_additionalKerning;
nextFontPositionX += charAdvance + kernings[i];
if (longestLine < nextFontPositionX)
{
longestLine = nextFontPositionX;
}
// check longest line before adding additional kerning
nextFontPositionX += theLabel->_additionalKerning;
}
float lastCharWidth = tempDefinition.width * contentScaleFactor;

View File

@ -195,7 +195,6 @@ void TextFieldTTF::insertText(const char * text, size_t len)
if (len > 0)
{
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8 && CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
if (_delegate && _delegate->onTextFieldInsertText(this, insert.c_str(), len))
{
// delegate doesn't want to insert text
@ -206,15 +205,6 @@ void TextFieldTTF::insertText(const char * text, size_t len)
std::string sText(_inputText);
sText.append(insert);
setString(sText);
#else
size_t existlen = _inputText.length();
if (_delegate && _delegate->onTextFieldInsertText(this, insert.c_str() + existlen, len - existlen))
{
// delegate doesn't want to insert text
return;
}
setString(insert);
#endif
}
if ((int)insert.npos == pos) {

View File

@ -115,7 +115,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\atitc.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\base64.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCAutoreleasePool.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCCamera.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccCArray.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccConfig.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCConfiguration.h" />
@ -146,7 +145,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCGameController.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDelegate.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCLight.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccMacros.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCMap.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.h" />
@ -328,6 +326,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\inet_ntop_winrt.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\InputEvent.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\InputEventTypes.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\Keyboard-winrt.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\pch.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\sha1.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\CCBatchCommand.h" />
@ -359,6 +358,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UICheckBox.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIDeprecated.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBox.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl-winrt.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIHBox.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIHelper.h" />
@ -397,6 +397,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCComponent.h" />
@ -420,6 +421,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCLabelTextFormatter.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCLabelTTF.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCLayer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCLight.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCMenu.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCMenuItem.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\CCMotionStreak.h" />
@ -532,7 +534,6 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\atitc.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\base64.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCAutoreleasePool.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCCamera.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccCArray.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCConfiguration.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCConsole.cpp" />
@ -559,13 +560,11 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCEventTouch.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccFPSImages.c">
<CompileAsWinRT>false</CompileAsWinRT>
<CompileAs>CompileAsCpp</CompileAs>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<ForcedIncludeFiles>
</ForcedIncludeFiles>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCIMEDispatcher.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCLight.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCNS.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\CCProfiling.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\base\ccRandom.cpp" />
@ -709,6 +708,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\CCWinRTUtils.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\inet_ntop_winrt.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\InputEvent.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\Keyboard-winrt.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\platform\winrt\pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
<ForcedIncludeFiles>
@ -742,7 +742,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UICheckBox.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIDeprecated.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBox.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl-stub.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIEditBox\UIEditBoxImpl-winrt.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIHBox.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIHelper.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\ui\UIImageView.cpp" />
@ -780,6 +780,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimation.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAnimationCache.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCAtlasNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCCamera.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCClippingRectangleNode.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCComponent.cpp" />
@ -803,6 +804,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCLabelTextFormatter.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCLabelTTF.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCLayer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCLight.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCMenu.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCMenuItem.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\CCMotionStreak.cpp" />
@ -867,8 +869,13 @@
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_PositionTextureColor_noMVP.vert" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_PositionTexture_uColor.frag" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_PositionTexture_uColor.vert" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_Position_uColor-no-gl_PointSize.vert">
<FileType>Document</FileType>
</None>
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_Position_uColor.frag" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\..\renderer\ccShader_Position_uColor.vert" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\cocos2d.def" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\libcocos2d.vcxproj.filters" />
<None Include="$(MSBuildThisFileDirectory)..\..\..\libcocos2d_wp8.vcxproj.filters" />
</ItemGroup>
</Project>

View File

@ -109,7 +109,7 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -127,7 +127,7 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -145,7 +145,7 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -163,7 +163,7 @@
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>$(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

View File

@ -69,7 +69,7 @@ public:
/**get mesh*/
Mesh* getMesh() const { return _meshes.at(0); }
/** get Mesh Count */
/** get mesh count */
ssize_t getMeshCount() const { return _meshes.size(); }
/**get skin*/

View File

@ -155,9 +155,8 @@ bool Director::init(void)
_renderer = new (std::nothrow) Renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
_console = new (std::nothrow) Console;
#endif
return true;
}
@ -181,9 +180,8 @@ Director::~Director(void)
delete _renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
delete _console;
#endif
CC_SAFE_RELEASE(_eventDispatcher);

View File

@ -128,8 +128,7 @@ bool ComAudio::serialize(void* r)
}
if (strcmp(className, "CCBackgroundAudio") == 0)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// no MP3 support for CC_PLATFORM_WP8
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
std::string::size_type pos = filePath.find(".mp3");
if (pos == filePath.npos)
{

View File

@ -133,7 +133,4 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\spine-cocos2dx.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\spine.h" />
</ItemGroup>
<ItemGroup>
<Text Include="$(MSBuildThisFileDirectory)..\..\CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -65,7 +65,4 @@
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\spine.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\spine-cocos2dx.h" />
</ItemGroup>
<ItemGroup>
<Text Include="$(MSBuildThisFileDirectory)..\..\CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -418,6 +418,15 @@ public:
* @return True if this vector is less than the given vector, false otherwise.
*/
inline bool operator<(const Vec2& v) const;
/**
* Determines if this vector is greater than the given vector.
*
* @param v The vector to compare against.
*
* @return True if this vector is greater than the given vector, false otherwise.
*/
inline bool operator>(const Vec2& v) const;
/**
* Determines if this vector is equal to the given vector.

View File

@ -82,6 +82,15 @@ inline bool Vec2::operator<(const Vec2& v) const
return x < v.x;
}
inline bool Vec2::operator>(const Vec2& v) const
{
if (x == v.x)
{
return y > v.y;
}
return x > v.x;
}
inline bool Vec2::operator==(const Vec2& v) const
{
return x==v.x && y==v.y;

View File

@ -0,0 +1,85 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "Cocos2dRenderer.h"
#include "AppDelegate.h"
#include "CCGLViewImpl-winrt.h"
#include "CCApplication.h"
#include "cocos2d.h"
// These are used by the shader compilation methods.
#include <vector>
#include <iostream>
#include <fstream>
using namespace Platform;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Graphics::Display;
USING_NS_CC;
Cocos2dRenderer::Cocos2dRenderer(const int width, const int height, CoreDispatcher^ dispatcher, Panel^ panel)
: mApp(nullptr)
, mWidth(width)
, mHeight(height)
, m_dispatcher(dispatcher)
, m_panel(panel)
{
mApp = new AppDelegate();
auto director = cocos2d::Director::getInstance();
GLViewImpl* glview = GLViewImpl::create("Test Cpp");
glview->setDispatcher(dispatcher);
glview->setPanel(panel);
glview->Create(static_cast<float>(width), static_cast<float>(height), DisplayOrientations::Landscape);
director->setOpenGLView(glview);
CCApplication::getInstance()->run();
}
Cocos2dRenderer::~Cocos2dRenderer()
{
delete mApp;
}
// Draws a basic triangle
void Cocos2dRenderer::Draw(GLsizei width, GLsizei height)
{
if (width != mWidth || height != mHeight)
{
mWidth = width;
mHeight = height;
GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(static_cast<float>(width), static_cast<float>(height));
}
GLViewImpl::sharedOpenGLView()->ProcessEvents();
GLViewImpl::sharedOpenGLView()->Render();
}
void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args)
{
GLViewImpl::sharedOpenGLView()->QueuePointerEvent(type, args);
}
void Cocos2dRenderer::QueueKeyBoardEvent(cocos2d::Cocos2dKeyEvent type, Windows::UI::Core::KeyEventArgs^ e)
{
//GLViewImpl::sharedOpenGLView()->QueuePointerEvent(type, e);
}

View File

@ -0,0 +1,47 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
#include <agile.h>
#include "cocos2d.h"
class AppDelegate;
namespace cocos2d
{
class Cocos2dRenderer
{
public:
Cocos2dRenderer(const int width, const int height, Windows::UI::Core::CoreDispatcher^ dispathcer, Windows::UI::Xaml::Controls::Panel^ panel);
~Cocos2dRenderer();
void Draw(GLsizei width, GLsizei height);
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
void QueueKeyBoardEvent(Cocos2dKeyEvent type, Windows::UI::Core::KeyEventArgs^ e);
private:
int mWidth;
int mHeight;
// The AppDelegate for the Cocos2D app
AppDelegate* mApp;
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
};
}

View File

@ -1,5 +1,22 @@
#include "pch.h"
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "OpenGLES.h"
using namespace Platform;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Foundation;
@ -36,8 +53,13 @@ void OpenGLES::Initialize()
// This can be used to configure D3D11. For example, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE could be used.
// This would ask the graphics card to use D3D11 Feature Level 9_3 instead of Feature Level 11_0+.
// On Windows Phone, this would allow the Phone Emulator to act more like the GPUs that are available on real Phone devices.
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE,
EGL_NONE,
#else
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_NONE,
#endif
};
const EGLint contextAttributes[] =

View File

@ -0,0 +1,52 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
// OpenGL ES includes
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
// EGL includes
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglplatform.h>
#include <angle_windowsstore.h>
class OpenGLES
{
public:
OpenGLES();
~OpenGLES();
EGLSurface CreateSurface(Windows::UI::Xaml::Controls::SwapChainPanel^ panel, const Windows::Foundation::Size* renderSurfaceSize);
void DestroySurface(const EGLSurface surface);
void MakeCurrent(const EGLSurface surface);
EGLBoolean SwapBuffers(const EGLSurface surface);
void Reset();
private:
void Initialize();
void Cleanup();
private:
EGLDisplay mEglDisplay;
EGLContext mEglContext;
EGLConfig mEglConfig;
};

View File

@ -0,0 +1,28 @@
<Page
x:Class="cocos2d.OpenGLESPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:cocos2d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<SwapChainPanel x:Name="swapChainPanel">
<Button x:Name="cocos2d_editbox" Visibility="Collapsed" Height="1">
<Button.Flyout>
<Flyout x:Name="cocos2d_editbox_flyout">
<Grid VerticalAlignment="Top" x:Name="cocos2d_editbox_grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<Button x:Name="cocos2d_editbox_done" Grid.Column="1" VerticalAlignment="Center">Done</Button>
<Button x:Name="cocos2d_editbox_cancel" Grid.Column="2" VerticalAlignment="Center">Cancel</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</SwapChainPanel>
</Page>

View File

@ -1,10 +1,40 @@
#include "pch.h"
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "App.xaml.h"
#include "OpenGLESPage.xaml.h"
using namespace cpp_tests;
using namespace cocos2d;
using namespace Platform;
using namespace Concurrency;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Graphics::Display;
using namespace Windows::System::Threading;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
OpenGLESPage::OpenGLESPage() :
OpenGLESPage(nullptr)
@ -16,7 +46,8 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
mOpenGLES(openGLES),
mRenderSurface(EGL_NO_SURFACE),
mCustomRenderSurfaceSize(0,0),
mUseCustomRenderSurfaceSize(false)
mUseCustomRenderSurfaceSize(false),
m_coreInput(nullptr)
{
InitializeComponent();
@ -31,7 +62,11 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
this->Loaded +=
ref new Windows::UI::Xaml::RoutedEventHandler(this, &OpenGLESPage::OnPageLoaded);
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
mSwapChainPanelSize = { swapChainPanel->RenderSize.Width, swapChainPanel->RenderSize.Height };
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
#else
// Disable all pointer visual feedback for better performance when touching.
// This is not supported on Windows Phone applications.
auto pointerVisualizationSettings = Windows::UI::Input::PointerVisualizationSettings::GetForCurrentView();
@ -39,7 +74,28 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;
#endif
mSwapChainPanelSize = { swapChainPanel->RenderSize.Width, swapChainPanel->RenderSize.Height };
// Register our SwapChainPanel to get independent input pointer events
auto workItemHandler = ref new WorkItemHandler([this](IAsyncAction ^)
{
// The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
m_coreInput = swapChainPanel->CreateCoreIndependentInputSource(
Windows::UI::Core::CoreInputDeviceTypes::Mouse |
Windows::UI::Core::CoreInputDeviceTypes::Touch |
Windows::UI::Core::CoreInputDeviceTypes::Pen
);
// Register for pointer events, which will be raised on the background thread.
m_coreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerPressed);
m_coreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerMoved);
m_coreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerReleased);
// Begin processing input messages as they're delivered.
m_coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
});
// Run task on a dedicated high priority background thread.
m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);
}
OpenGLESPage::~OpenGLESPage()
@ -55,6 +111,32 @@ void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::Rou
StartRenderLoop();
}
void OpenGLESPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerPressed, e);
}
}
void OpenGLESPage::OnPointerMoved(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerMoved, e);
}
}
void OpenGLESPage::OnPointerReleased(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerReleased, e);
}
}
void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
{
if (args->Visible && mRenderSurface != EGL_NO_SURFACE)
@ -143,21 +225,29 @@ void OpenGLESPage::StartRenderLoop()
return;
}
auto dispatcher = Windows::UI::Xaml::Window::Current->CoreWindow->Dispatcher;
// Create a task for rendering that will be run on a background thread.
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this](Windows::Foundation::IAsyncAction ^ action)
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action)
{
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
mOpenGLES->MakeCurrent(mRenderSurface);
HelloTriangleRenderer renderer;
GLsizei panelWidth = 0;
GLsizei panelHeight = 0;
GetSwapChainPanelSize(&panelWidth, &panelHeight);
if (m_renderer.get() == nullptr)
{
m_renderer = std::make_shared<Cocos2dRenderer>(panelWidth, panelHeight, dispatcher, swapChainPanel);
}
while (action->Status == Windows::Foundation::AsyncStatus::Started)
{
GLsizei panelWidth = 0;
GLsizei panelHeight = 0;
GetSwapChainPanelSize(&panelWidth, &panelHeight);
renderer.Draw(panelWidth, panelHeight);
m_renderer.get()->Draw(panelWidth, panelHeight);
// The call to eglSwapBuffers might not be successful (i.e. due to Device Lost)
// If the call fails, then we must reinitialize EGL and the GL resources.
@ -165,6 +255,7 @@ void OpenGLESPage::StartRenderLoop()
{
// XAML objects like the SwapChainPanel must only be manipulated on the UI thread.
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
//swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
{
RecoverFromLostDevice();
}, CallbackContext::Any));

View File

@ -0,0 +1,71 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
#include "OpenGLES.h"
#include "OpenGLESPage.g.h"
#include <memory>
#include "Cocos2dRenderer.h"
namespace cocos2d
{
public ref class OpenGLESPage sealed
{
public:
OpenGLESPage();
virtual ~OpenGLESPage();
internal:
OpenGLESPage(OpenGLES* openGLES);
private:
void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
void CreateRenderSurface();
void DestroyRenderSurface();
void RecoverFromLostDevice();
void StartRenderLoop();
void StopRenderLoop();
OpenGLES* mOpenGLES;
std::shared_ptr<cocos2d::Cocos2dRenderer> m_renderer;
Windows::Foundation::Size mSwapChainPanelSize;
Concurrency::critical_section mSwapChainPanelSizeCriticalSection;
Windows::Foundation::Size mCustomRenderSurfaceSize;
bool mUseCustomRenderSurfaceSize;
EGLSurface mRenderSurface; // This surface is associated with a swapChainPanel on the page
Concurrency::critical_section mRenderSurfaceCriticalSection;
Windows::Foundation::IAsyncAction^ mRenderLoopWorker;
// Track user input on a background worker thread.
Windows::Foundation::IAsyncAction^ m_inputLoopWorker;
Windows::UI::Core::CoreIndependentInputSource^ m_coreInput;
// Independent input handling functions.
void OnPointerPressed(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
void OnPointerMoved(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
void OnPointerReleased(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
};
}

View File

@ -0,0 +1,14 @@
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include <collection.h>
#include <ppltasks.h>
#include "cocos2d.h"
#include "cocos-ext.h"

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#include "platform/CCStdC.h"
#include "CCWinRTUtils.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER)
#include "platform/wp8/CCGLViewImpl-wp8.h"
#endif
@ -42,17 +42,9 @@ void MessageBox(const char * pszMsg, const char * pszTitle)
// Create the message dialog and set its content
Platform::String^ message = ref new Platform::String(CCUtf8ToUnicode(pszMsg, -1).c_str());
Platform::String^ title = ref new Platform::String(CCUtf8ToUnicode(pszTitle, -1).c_str());
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
Windows::UI::Popups::MessageDialog^ msg = ref new Windows::UI::Popups::MessageDialog(message, title);
// Set the command to be invoked when a user presses 'ESC'
msg->CancelCommandIndex = 1;
// Show the message dialog
msg->ShowAsync();
#else
#ifndef WP8_SHADER_COMPILER
GLViewImpl::sharedOpenGLView()->ShowMessageBox(title, message);
#endif
}

View File

@ -51,6 +51,7 @@ static Accelerometer^ sAccelerometer = nullptr;
void Device::setAccelerometerEnabled(bool isEnabled)
{
#ifndef WP8_SHADER_COMPILER
static Windows::Foundation::EventRegistrationToken sToken;
static bool sEnabled = false;
@ -91,7 +92,6 @@ void Device::setAccelerometerEnabled(bool isEnabled)
acc.z = reading->AccelerationZ;
acc.timestamp = 0;
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
auto orientation = GLViewImpl::sharedOpenGLView()->getDeviceOrientation();
switch (orientation)
@ -121,14 +121,12 @@ void Device::setAccelerometerEnabled(bool isEnabled)
acc.y = reading->AccelerationY;
break;
}
#endif
#ifndef WP8_SHADER_COMPILER
std::shared_ptr<cocos2d::InputEvent> event(new AccelerometerEvent(acc));
cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(event);
#endif
});
}
#endif
}
void Device::setAccelerometerInterval(float interval)

View File

@ -24,7 +24,6 @@ THE SOFTWARE.
****************************************************************************/
#include "CCGLViewImpl-winrt.h"
#include "deprecated/CCSet.h"
#include "base/ccMacros.h"
#include "base/CCDirector.h"
#include "base/CCTouch.h"
@ -40,7 +39,9 @@ using namespace Windows::Graphics::Display;
using namespace Windows::UI::Input;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::System;
using namespace Windows::UI::ViewManagement;
using namespace Windows::ApplicationModel;
@ -48,7 +49,6 @@ using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Platform;
using namespace Microsoft::WRL;
using namespace PhoneDirect3DXamlAppComponent;
NS_CC_BEGIN
@ -79,8 +79,6 @@ GLViewImpl::GLViewImpl()
, m_windowVisible(true)
, m_width(0)
, m_height(0)
, m_delegate(nullptr)
, m_messageBoxDelegate(nullptr)
, m_orientation(DisplayOrientations::Landscape)
{
s_pEglView = this;
@ -116,6 +114,16 @@ bool GLViewImpl::Create(float width, float height, DisplayOrientations orientati
return true;
}
void GLViewImpl::setDispatcher(Windows::UI::Core::CoreDispatcher^ dispatcher)
{
m_dispatcher = dispatcher;
}
void GLViewImpl::setPanel(Windows::UI::Xaml::Controls::Panel^ panel)
{
m_panel = panel;
}
void GLViewImpl::setIMEKeyboardState(bool bOpen)
@ -124,44 +132,55 @@ void GLViewImpl::setIMEKeyboardState(bool bOpen)
setIMEKeyboardState(bOpen, str);
}
bool GLViewImpl::ShowMessageBox(Platform::String^ title, Platform::String^ message)
{
if (m_dispatcher.Get())
{
m_dispatcher.Get()->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([title, message]()
{
// Show the message dialog
auto msg = ref new Windows::UI::Popups::MessageDialog(message, title);
// Set the command to be invoked when a user presses 'ESC'
msg->CancelCommandIndex = 1;
msg->ShowAsync();
}));
return true;
}
return false;
}
void GLViewImpl::setIMEKeyboardState(bool bOpen, std::string str)
{
if(m_delegate)
if(bOpen)
{
if(bOpen)
if (m_keyboard == nullptr)
{
m_delegate->Invoke(Cocos2dEvent::ShowKeyboard, stringToPlatformString(str));
m_keyboard = ref new KeyBoardWinRT(m_dispatcher.Get(), m_panel.Get());
}
else
m_keyboard->ShowKeyboard(PlatformStringFromString(str));
}
else
{
if (m_keyboard != nullptr)
{
m_delegate->Invoke(Cocos2dEvent::HideKeyboard, stringToPlatformString(str));
m_keyboard->HideKeyboard(PlatformStringFromString(str));
}
m_keyboard = nullptr;
}
}
Platform::String^ GLViewImpl::stringToPlatformString(std::string strSrc)
{
// to wide char
int strLen = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0);
wchar_t* wstr = new wchar_t[strLen + 1];
memset(wstr, 0, strLen + 1);
MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, wstr, strLen);
Platform::String^ strDst = ref new Platform::String(wstr);
delete[] wstr;
return strDst;
}
void GLViewImpl::swapBuffers()
{
//eglSwapBuffers(m_eglDisplay, m_eglSurface);
}
bool GLViewImpl::isOpenGLReady()
{
return true;
// TODO: need to revisit this
//return (m_eglDisplay && m_orientation != DisplayOrientations::None);
}
void GLViewImpl::end()
@ -184,7 +203,7 @@ void GLViewImpl::OnBackKeyPress()
std::string str;
if(m_delegate)
{
m_delegate->Invoke(Cocos2dEvent::TerminateApp, stringToPlatformString(str));
//m_delegate->Invoke(Cocos2dEvent::TerminateApp, stringToPlatformString(str));
}
}
@ -308,30 +327,6 @@ void GLViewImpl::OnRendering()
}
}
bool GLViewImpl::ShowMessageBox(Platform::String^ title, Platform::String^ message)
{
if(m_messageBoxDelegate)
{
m_messageBoxDelegate->Invoke(title, message);
return true;
}
return false;
}
bool GLViewImpl::OpenXamlEditBox(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler)
{
if(m_editBoxDelegate)
{
m_editBoxDelegate->Invoke(strPlaceHolder, strText, maxLength, inputMode, inputFlag, receiveHandler);
return true;
}
return false;
}
// called by orientation change from WP8 XAML
void GLViewImpl::UpdateOrientation(DisplayOrientations orientation)
{
@ -345,9 +340,12 @@ void GLViewImpl::UpdateOrientation(DisplayOrientations orientation)
// called by size change from WP8 XAML
void GLViewImpl::UpdateForWindowSizeChange(float width, float height)
{
m_width = width;
m_height = height;
UpdateWindowSize();
if (width != m_width || height != m_height)
{
m_width = width;
m_height = height;
UpdateWindowSize();
}
}
#if 0
@ -371,18 +369,9 @@ void GLViewImpl::UpdateWindowSize()
{
float width, height;
if(m_orientation == DisplayOrientations::Landscape || m_orientation == DisplayOrientations::LandscapeFlipped)
{
width = m_height;
height = m_width;
}
else
{
width = m_width;
height = m_height;
}
width = m_width;
height = m_height;
UpdateOrientationMatrix();
//CCSize designSize = getDesignResolutionSize();
if(!m_initialized)
@ -403,45 +392,15 @@ void GLViewImpl::UpdateWindowSize()
}
}
const Mat4& GLViewImpl::getOrientationMatrix() const
{
return m_orientationMatrix;
};
void GLViewImpl::UpdateOrientationMatrix()
{
kmMat4Identity(&m_orientationMatrix);
kmMat4Identity(&m_reverseOrientationMatrix);
switch(m_orientation)
{
case Windows::Graphics::Display::DisplayOrientations::PortraitFlipped:
kmMat4RotationZ(&m_orientationMatrix, static_cast<float>(M_PI));
kmMat4RotationZ(&m_reverseOrientationMatrix, static_cast<float>(-M_PI));
break;
case Windows::Graphics::Display::DisplayOrientations::Landscape:
kmMat4RotationZ(&m_orientationMatrix, static_cast<float>(-M_PI_2));
kmMat4RotationZ(&m_reverseOrientationMatrix, static_cast<float>(M_PI_2));
break;
case Windows::Graphics::Display::DisplayOrientations::LandscapeFlipped:
kmMat4RotationZ(&m_orientationMatrix, static_cast<float>(M_PI_2));
kmMat4RotationZ(&m_reverseOrientationMatrix, static_cast<float>(-M_PI_2));
break;
default:
break;
}
}
cocos2d::Vec2 GLViewImpl::TransformToOrientation(Windows::Foundation::Point p)
{
cocos2d::Vec2 returnValue;
float x = p.X;
float y = p.Y;
returnValue = Vec2(x, y);
#if 0
switch (m_orientation)
{
case DisplayOrientations::Portrait:
@ -458,6 +417,7 @@ cocos2d::Vec2 GLViewImpl::TransformToOrientation(Windows::Foundation::Point p)
returnValue = Vec2(m_height - y, x);
break;
}
#endif
float zoomFactor = GLViewImpl::sharedOpenGLView()->getFrameZoomFactor();
if(zoomFactor > 0.0f) {
@ -473,48 +433,23 @@ cocos2d::Vec2 GLViewImpl::TransformToOrientation(Windows::Foundation::Point p)
Vec2 GLViewImpl::GetPoint(PointerEventArgs^ args) {
return TransformToOrientation(args->CurrentPoint->Position);
}
void GLViewImpl::setViewPortInPoints(float x , float y , float w , float h)
{
switch(m_orientation)
{
case DisplayOrientations::Landscape:
case DisplayOrientations::LandscapeFlipped:
glViewport((GLint)(y * _scaleY + _viewPortRect.origin.y),
(GLint)(x * _scaleX + _viewPortRect.origin.x),
(GLsizei)(h * _scaleY),
(GLsizei)(w * _scaleX));
break;
default:
glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x),
(GLint)(y * _scaleY + _viewPortRect.origin.y),
(GLsizei)(w * _scaleX),
(GLsizei)(h * _scaleY));
}
glViewport((GLint) (x * _scaleX + _viewPortRect.origin.x),
(GLint) (y * _scaleY + _viewPortRect.origin.y),
(GLsizei) (w * _scaleX),
(GLsizei) (h * _scaleY));
}
void GLViewImpl::setScissorInPoints(float x , float y , float w , float h)
{
switch(m_orientation)
{
case DisplayOrientations::Landscape:
case DisplayOrientations::LandscapeFlipped:
glScissor((GLint)(y * _scaleX + _viewPortRect.origin.y),
(GLint)((_viewPortRect.size.width - ((x + w) * _scaleX)) + _viewPortRect.origin.x),
(GLsizei)(h * _scaleY),
(GLsizei)(w * _scaleX));
break;
default:
glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x),
(GLint)(y * _scaleY + _viewPortRect.origin.y),
(GLsizei)(w * _scaleX),
(GLsizei)(h * _scaleY));
}
glScissor((GLint) (x * _scaleX + _viewPortRect.origin.x),
(GLint) (y * _scaleY + _viewPortRect.origin.y),
(GLsizei) (w * _scaleX),
(GLsizei) (h * _scaleY));
}
void GLViewImpl::QueueBackKeyPress()

View File

@ -33,21 +33,16 @@ THE SOFTWARE.
#include <agile.h>
#include <string>
#include <wrl/client.h>
#include <d3d11_1.h>
#include <mutex>
#include <queue>
#include <agile.h>
#include <DirectXMath.h>
#include <Keyboard-winrt.h>
NS_CC_BEGIN
class GLViewImpl;
class CC_DLL GLViewImpl : public GLView
{
public:
@ -59,20 +54,20 @@ public:
virtual void swapBuffers();
virtual void setViewPortInPoints(float x , float y , float w , float h);
virtual void setScissorInPoints(float x , float y , float w , float h);
const Mat4& getOrientationMatrix() const;
const Mat4& getReverseOrientationMatrix () const {return m_reverseOrientationMatrix;};
Windows::Graphics::Display::DisplayOrientations getDeviceOrientation() {return m_orientation;};
Size getRenerTargetSize() const { return Size(m_width, m_height); }
virtual void setIMEKeyboardState(bool bOpen);
virtual void setIMEKeyboardState(bool bOpen, std::string str);
Platform::String^ stringToPlatformString(std::string strSrc);
void ShowKeyboard(Windows::Foundation::Rect r);
void HideKeyboard(Windows::Foundation::Rect r);
// WP8 XAML app
virtual bool Create(float width, float height, Windows::Graphics::Display::DisplayOrientations orientation);
virtual bool Create(float width, float height ,Windows::Graphics::Display::DisplayOrientations orientation);
void setDispatcher(Windows::UI::Core::CoreDispatcher^ dispatcher);
Windows::UI::Core::CoreDispatcher^ getDispatcher() {return m_dispatcher.Get();}
void setPanel(Windows::UI::Xaml::Controls::Panel^ panel);
Windows::UI::Xaml::Controls::Panel^ getPanel() {return m_panel.Get();}
void OnPointerPressed(Windows::UI::Core::PointerEventArgs^ args);
void OnPointerMoved(Windows::UI::Core::PointerEventArgs^ args);
@ -89,14 +84,9 @@ public:
void QueueBackKeyPress();
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
void GLViewImpl::QueueEvent(std::shared_ptr<InputEvent>& event);
void SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate) { m_delegate = delegate; };
void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate) { m_messageBoxDelegate = delegate; };
void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate) { m_editBoxDelegate = delegate; };
void QueueEvent(std::shared_ptr<InputEvent>& event);
bool ShowMessageBox(Platform::String^ title, Platform::String^ message);
bool OpenXamlEditBox(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
int Run();
void Render();
@ -116,9 +106,6 @@ public:
static GLViewImpl* sharedOpenGLView();
void ProcessEvents();
void AddPointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
protected:
GLViewImpl();
@ -144,8 +131,7 @@ private:
void OnRendering();
void UpdateWindowSize();
void UpdateOrientationMatrix();
cocos2d::Vec2 TransformToOrientation(Windows::Foundation::Point point);
cocos2d::Vec2 GetPoint(Windows::UI::Core::PointerEventArgs^ args);
@ -162,20 +148,20 @@ private:
bool m_lastPointValid;
bool m_windowClosed;
bool m_windowVisible;
Mat4 m_orientationMatrix;
Mat4 m_reverseOrientationMatrix;
bool m_running;
bool m_initialized;
PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ m_delegate;
PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
Cocos2dEventDelegate^ m_delegate;
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
Cocos2dEditBoxDelegate^ m_editBoxDelegate;
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
std::mutex mMutex;
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
KeyBoardWinRT^ m_keyboard;
};
NS_CC_END

View File

@ -32,6 +32,11 @@ THE SOFTWARE.
#include <ppltasks.h>
#include <sstream>
#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
#endif
NS_CC_BEGIN
using namespace Windows::Graphics::Display;
@ -153,6 +158,103 @@ std::string CC_DLL getDeviceIPAddresses()
return result.str();
}
#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8
Platform::Object^ findXamlElement(Platform::Object^ parent, Platform::String^ name)
{
if (parent == nullptr || name == nullptr || name->Length() == 0)
{
return nullptr;
}
FrameworkElement^ element = dynamic_cast<FrameworkElement^>(parent);
if (element == nullptr)
{
return nullptr;
}
if (element->Name == name)
{
return element;
}
Panel^ panel = dynamic_cast<Panel^>(element);
if (panel == nullptr)
{
return nullptr;
}
int count = panel->Children->Size;
for (int i = 0; i < count; i++)
{
auto result = findXamlElement(panel->Children->GetAt(i), name);
if (result != nullptr)
{
return result;
}
}
return nullptr;
}
bool removeXamlElement(Platform::Object^ parent, Platform::Object^ element)
{
Panel^ panel = dynamic_cast<Panel^>(parent);
if (panel == nullptr)
{
return false;
}
UIElement^ uiElement = dynamic_cast<UIElement^>(element);
if (uiElement == nullptr)
{
return false;
}
unsigned int index;
if (!panel->Children->IndexOf(uiElement, &index))
{
return false;
}
panel->Children->RemoveAt(index);
return true;
}
bool replaceXamlElement(Platform::Object^ parent, Platform::Object^ add, Platform::Object^ remove)
{
Panel^ panel = dynamic_cast<Panel^>(parent);
if (panel == nullptr)
{
return false;
}
UIElement^ addElement = dynamic_cast<UIElement^>(add);
if (addElement == nullptr)
{
return false;
}
UIElement^ removeElement = dynamic_cast<UIElement^>(remove);
if (removeElement == nullptr)
{
return false;
}
unsigned int index;
if (!panel->Children->IndexOf(removeElement, &index))
{
return false;
}
panel->Children->RemoveAt(index);
panel->Children->InsertAt(index, addElement);
return true;
}
#endif

View File

@ -40,6 +40,12 @@ NS_CC_BEGIN
std::wstring CC_DLL CCUtf8ToUnicode(const char * pszUtf8Str, unsigned len = -1);
std::string CC_DLL CCUnicodeToUtf8(const wchar_t* pwszStr);
#if CC_TARGET_PLATFORM != CC_PLATFORM_WP8
Platform::Object^ findXamlElement(Platform::Object^ parent, Platform::String^ name);
bool removeXamlElement(Platform::Object^ parent, Platform::Object^ element);
bool replaceXamlElement(Platform::Object^ parent, Platform::Object^ add, Platform::Object^ remove);
#endif
std::string PlatformStringToString(Platform::String^ s);
Platform::String^ PlatformStringFromString(const std::string& s);

View File

@ -24,6 +24,7 @@ THE SOFTWARE.
****************************************************************************/
#include "InputEvent.h"
#include "CCWinRTUtils.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
#include "CCGLViewImpl-wp8.h"
@ -35,9 +36,6 @@ THE SOFTWARE.
NS_CC_BEGIN
using namespace PhoneDirect3DXamlAppComponent;
AccelerometerEvent::AccelerometerEvent(const Acceleration& event)
: m_event(event)
{
@ -92,9 +90,11 @@ void KeyboardEvent::execute()
{
case Cocos2dKeyEvent::Text:
{
char szUtf8[256] = { 0 };
int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) m_text.Get()->Data(), -1, szUtf8, sizeof(szUtf8), NULL, NULL);
IMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen - 1);
std::wstring w(m_text.Get()->Data());
std::u16string s16(w.begin(),w.end());
std::string utf8String;
StringUtils::UTF16ToUTF8(s16, utf8String);
IMEDispatcher::sharedDispatcher()->dispatchInsertText(utf8String.c_str(), utf8String.size());
break;
}
@ -108,7 +108,6 @@ void KeyboardEvent::execute()
IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
break;
case Cocos2dKeyEvent::Enter:
//SetFocus(false);
IMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
break;
default:
@ -133,12 +132,27 @@ CustomInputEvent::CustomInputEvent(const std::function<void()>& fun)
: m_fun(fun)
{
}
void CustomInputEvent::execute()
{
m_fun();
}
UIEditBoxEvent::UIEditBoxEvent(Platform::Object^ sender, Platform::String^ text, Windows::Foundation::EventHandler<Platform::String^>^ handle)
: m_sender(sender)
, m_text(text)
, m_handler(handle)
{
}
void UIEditBoxEvent::execute()
{
if (m_handler.Get())
{
m_handler.Get()->Invoke(m_sender.Get(), m_text.Get());
}
}
NS_CC_END

View File

@ -30,17 +30,13 @@ THE SOFTWARE.
#include "InputEventTypes.h"
#include <agile.h>
namespace PhoneDirect3DXamlAppComponent
{
public delegate void Cocos2dEventDelegate(Cocos2dEvent event, Platform::String^ text);
public delegate void Cocos2dMessageBoxDelegate(Platform::String^ title, Platform::String^ text);
public delegate void Cocos2dEditBoxDelegate(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
public delegate void Cocos2dOpenURLDelegate(Platform::String^ url);
}
NS_CC_BEGIN
public delegate void Cocos2dEventDelegate(Cocos2dEvent event, Platform::String^ text);
public delegate void Cocos2dMessageBoxDelegate(Platform::String^ title, Platform::String^ text);
public delegate void Cocos2dEditBoxDelegate(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
public delegate void Cocos2dOpenURLDelegate(Platform::String^ url);
enum PointerEventType
{
PointerPressed,
@ -83,12 +79,12 @@ class CC_DLL KeyboardEvent : public InputEvent
{
public:
KeyboardEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent type);
KeyboardEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent type, Platform::String^ text);
KeyboardEvent(Cocos2dKeyEvent type);
KeyboardEvent(Cocos2dKeyEvent type, Platform::String^ text);
virtual void execute();
private:
PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent m_type;
Cocos2dKeyEvent m_type;
Platform::Agile<Platform::String> m_text;
};
@ -108,6 +104,19 @@ private:
std::function<void()> m_fun;
};
class UIEditBoxEvent : public cocos2d::InputEvent
{
public:
UIEditBoxEvent(Platform::Object^ sender, Platform::String^ text, Windows::Foundation::EventHandler<Platform::String^>^ handle);
virtual void execute();
private:
Platform::Agile<Platform::Object^> m_sender;
Platform::Agile<Platform::String^> m_text;
Platform::Agile<Windows::Foundation::EventHandler<Platform::String^>^> m_handler;
};
NS_CC_END
#endif // #ifndef __INPUT_EVENT__

View File

@ -27,8 +27,8 @@ THE SOFTWARE.
#define __INPUT_EVENT_TYPES__
namespace PhoneDirect3DXamlAppComponent
{
NS_CC_BEGIN
public enum class Cocos2dEvent
{
@ -46,7 +46,8 @@ public enum class Cocos2dKeyEvent : int
Enter
};
}
NS_CC_END
#endif // #ifndef __INPUT_EVENT_TYPES__

View File

@ -0,0 +1,157 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "Keyboard-winrt.h"
using namespace cocos2d;
using namespace Platform;
using namespace Concurrency;
using namespace Windows::System;
using namespace Windows::System::Threading;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input;
NS_CC_BEGIN
KeyBoardWinRT::KeyBoardWinRT()
{
}
KeyBoardWinRT::~KeyBoardWinRT()
{
}
KeyBoardWinRT::KeyBoardWinRT(Windows::UI::Core::CoreDispatcher^ dispatcher, Windows::UI::Xaml::Controls::Panel^ panel)
: m_dispatcher(dispatcher)
, m_panel(panel)
{
}
void KeyBoardWinRT::ShowKeyboard(Platform::String^ text)
{
if (m_dispatcher.Get() && m_panel.Get())
{
// run on main UI thread
m_dispatcher.Get()->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, text]()
{
if (m_textBox == nullptr)
{
m_textBox = ref new TextBox();
m_textBox->Opacity = 0.0;
m_textBox->Width = 1;
m_textBox->Height = 1;
m_textBox->AddHandler(UIElement::KeyDownEvent, ref new KeyEventHandler(this, &KeyBoardWinRT::OnKeyPressed), true);
m_textBox->AddHandler(UIElement::KeyUpEvent, ref new KeyEventHandler(this, &KeyBoardWinRT::OnKeyReleased), true);
m_textBox->TextChanged += ref new TextChangedEventHandler(this, &KeyBoardWinRT::OnTextChanged);
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
// Need to use InputScopeNameValue::Search to prevent auto-capitalize
m_textBox->InputScope = ref new InputScope();
auto n = m_textBox->InputScope->Names;
n->Append(ref new InputScopeName(InputScopeNameValue::Search));
#endif
m_panel.Get()->Children->Append(m_textBox);
}
m_textBox->SelectionLength = 0;
m_textBox->SelectionStart = 32768;
m_textBox->Focus(FocusState::Programmatic);
}));
}
}
void KeyBoardWinRT::HideKeyboard(Platform::String^ text)
{
if (m_dispatcher.Get() && m_panel.Get())
{
// run on main UI thread
m_dispatcher.Get()->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, text]()
{
if (m_textBox != nullptr)
{
unsigned int index;
if (m_panel->Children->IndexOf(m_textBox, &index))
{
m_panel->Children->RemoveAt(index);
}
}
m_textBox = nullptr;
}));
}
}
void KeyBoardWinRT::QueueKeyEvent(Cocos2dKeyEvent key)
{
std::shared_ptr<cocos2d::InputEvent> e(new cocos2d::KeyboardEvent(key));
cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
}
void KeyBoardWinRT::OnKeyPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ args)
{
switch (args->Key)
{
case VirtualKey::Escape:
QueueKeyEvent(Cocos2dKeyEvent::Escape);
args->Handled = true;
break;
case VirtualKey::Back:
QueueKeyEvent(Cocos2dKeyEvent::Back);
args->Handled = true;
break;
case VirtualKey::Enter:
QueueKeyEvent(Cocos2dKeyEvent::Enter);
args->Handled = true;
break;
default:
break;
}
}
void KeyBoardWinRT::OnTextChanged(Platform::Object^ sender, TextChangedEventArgs^ args)
{
auto text = m_textBox->Text;
if (text)
{
std::shared_ptr<cocos2d::InputEvent> e(new cocos2d::KeyboardEvent(Cocos2dKeyEvent::Text, text));
cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
m_textBox->Text = L"";
}
}
void KeyBoardWinRT::OnKeyReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ args)
{
//m_textBox->Text = L"";
}
NS_CC_END

View File

@ -0,0 +1,58 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include <agile.h>
NS_CC_BEGIN
ref class KeyBoardWinRT sealed
{
public:
KeyBoardWinRT();
virtual ~KeyBoardWinRT();
void ShowKeyboard(Platform::String^ text);
void HideKeyboard(Platform::String^ text);
internal:
KeyBoardWinRT(Windows::UI::Core::CoreDispatcher^ dispatcher, Windows::UI::Xaml::Controls::Panel^ panel);
private:
void QueueKeyEvent(Cocos2dKeyEvent key);
void OnKeyPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ args);
void OnKeyReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ args);
void OnTextChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::TextChangedEventArgs^ args);
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
Windows::UI::Xaml::Controls::TextBox^ m_textBox;
};
NS_CC_END

View File

@ -35,7 +35,6 @@ using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::UI::Core;
using namespace PhoneDirect3DXamlAppComponent;
USING_NS_CC;
@ -151,7 +150,7 @@ void Cocos2dRenderer::OnCocos2dKeyEvent(Cocos2dKeyEvent event)
}
void Cocos2dRenderer::SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate)
void Cocos2dRenderer::SetXamlEventDelegate(Cocos2dEventDelegate^ delegate)
{
m_delegate = delegate;
GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
@ -161,7 +160,7 @@ void Cocos2dRenderer::SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2
}
}
void Cocos2dRenderer::SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate)
void Cocos2dRenderer::SetXamlMessageBoxDelegate(Cocos2dMessageBoxDelegate^ delegate)
{
m_messageBoxDelegate = delegate;
GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
@ -171,7 +170,7 @@ void Cocos2dRenderer::SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::C
}
}
void Cocos2dRenderer::SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate)
void Cocos2dRenderer::SetXamlEditBoxDelegate(Cocos2dEditBoxDelegate^ delegate)
{
m_editBoxDelegate = delegate;
GLViewImpl* eglView = GLViewImpl::sharedOpenGLView();
@ -181,7 +180,7 @@ void Cocos2dRenderer::SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Coco
}
}
void Cocos2dRenderer::SetXamlOpenURLDelegate(PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ delegate)
void Cocos2dRenderer::SetXamlOpenURLDelegate(Cocos2dOpenURLDelegate^ delegate)
{
m_openURLDelegate = delegate;
Application* app = Application::getInstance();

View File

@ -41,11 +41,11 @@ public:
void OnBackButton();
void OnKeyPressed(Platform::String^ text);
void OnCocos2dKeyEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent event);
void SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate);
void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate);
void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate);
void SetXamlOpenURLDelegate(PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ delegate);
void OnCocos2dKeyEvent(cocos2d::Cocos2dKeyEvent event);
void SetXamlEventDelegate(cocos2d::Cocos2dEventDelegate^ delegate);
void SetXamlMessageBoxDelegate(cocos2d::Cocos2dMessageBoxDelegate^ delegate);
void SetXamlEditBoxDelegate(cocos2d::Cocos2dEditBoxDelegate^ delegate);
void SetXamlOpenURLDelegate(cocos2d::Cocos2dOpenURLDelegate^ delegate);
Windows::Foundation::IAsyncAction^ OnSuspending();
void Connect();
@ -59,10 +59,10 @@ private:
bool m_loadingComplete;
bool mInitialized;
PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ m_delegate;
PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
PhoneDirect3DXamlAppComponent::Cocos2dOpenURLDelegate^ m_openURLDelegate;
cocos2d::Cocos2dEventDelegate^ m_delegate;
cocos2d::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
cocos2d::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
cocos2d::Cocos2dOpenURLDelegate^ m_openURLDelegate;
// The AppDelegate for the Cocos2D app
AppDelegate* mApp;

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#include "Direct3DContentProvider.h"
#include "Direct3DInterop.h"
using namespace PhoneDirect3DXamlAppComponent;
using namespace cocos2d;
Direct3DContentProvider::Direct3DContentProvider(Direct3DInterop^ controller) :
m_controller(controller)

View File

@ -37,7 +37,7 @@ class Direct3DContentProvider : public Microsoft::WRL::RuntimeClass<
IDrawingSurfaceBackgroundContentProviderNative>
{
public:
Direct3DContentProvider(PhoneDirect3DXamlAppComponent::Direct3DInterop^ controller);
Direct3DContentProvider(cocos2d::Direct3DInterop^ controller);
// IDrawingSurfaceContentProviderNative
HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host, _In_ ID3D11Device1* device);
@ -47,6 +47,6 @@ public:
HRESULT STDMETHODCALLTYPE Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceContext1* context, _In_ ID3D11RenderTargetView* renderTargetView);
private:
PhoneDirect3DXamlAppComponent::Direct3DInterop^ m_controller;
cocos2d::Direct3DInterop^ m_controller;
Microsoft::WRL::ComPtr<IDrawingSurfaceRuntimeHostNative> m_host;
};

View File

@ -35,9 +35,8 @@ using namespace Windows::Phone::Graphics::Interop;
using namespace Windows::Phone::Input::Interop;
using namespace Windows::Graphics::Display;
using namespace DirectX;
using namespace PhoneDirect3DXamlAppComponent;
namespace PhoneDirect3DXamlAppComponent
namespace cocos2d
{
Direct3DInterop::Direct3DInterop(Windows::Graphics::Display::DisplayOrientations orientation)

View File

@ -34,7 +34,7 @@ THE SOFTWARE.
#include <DrawingSurfaceNative.h>
namespace PhoneDirect3DXamlAppComponent
namespace cocos2d
{
public delegate void RequestAdditionalFrameHandler();

View File

@ -26,9 +26,9 @@ THE SOFTWARE.
using namespace Platform;
namespace PhoneDirect3DXamlAppComponent
namespace cocos2d
{
EditBoxEvent::EditBoxEvent( Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler<Platform::String^>^ handle ):
EditBoxEvent::EditBoxEvent( Platform::Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler<Platform::String^>^ handle ):
m_sender(sender),
m_args(arg),
m_handler(handle)

View File

@ -29,7 +29,7 @@ THE SOFTWARE.
#include <agile.h>
namespace PhoneDirect3DXamlAppComponent
namespace cocos2d
{
class EditBoxEvent : public cocos2d::InputEvent
{

View File

@ -1,5 +1,5 @@
<Application
x:Class="PhoneDirect3DXamlAppInterop.App"
x:Class="cocos2d.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
@ -7,7 +7,7 @@
<!--Application Resources-->
<Application.Resources>
<local:LocalizedStrings xmlns:local="clr-namespace:PhoneDirect3DXamlAppInterop" x:Key="LocalizedStrings"/>
<local:LocalizedStrings xmlns:local="clr-namespace:cocos2d" x:Key="LocalizedStrings"/>
</Application.Resources>
<Application.ApplicationLifetimeObjects>

View File

@ -7,9 +7,8 @@ using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;
using PhoneDirect3DXamlAppInterop.Resources;
namespace PhoneDirect3DXamlAppInterop
namespace cocos2d
{
public partial class App : Application
{

View File

@ -1,4 +1,4 @@
<UserControl x:Class="PhoneDirect3DXamlAppInterop.EditBox"
<UserControl x:Class="cocos2d.EditBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

View File

@ -31,11 +31,10 @@ using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using PhoneDirect3DXamlAppComponent;
using System.Windows.Media;
using System.Windows.Input;
namespace PhoneDirect3DXamlAppInterop
namespace cocos2d
{
public partial class EditBox : UserControl
{

View File

@ -1,5 +1,5 @@
<phone:PhoneApplicationPage
x:Class="PhoneDirect3DXamlAppInterop.MainPage"
x:Class="cocos2d.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

View File

@ -16,7 +16,6 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using PhoneDirect3DXamlAppComponent;
using System.Threading;
using System.Diagnostics;
using System.Threading.Tasks;
@ -27,7 +26,7 @@ using Microsoft.Phone.Info;
using Windows.Graphics.Display;
using Microsoft.Phone.Tasks;
namespace PhoneDirect3DXamlAppInterop
namespace cocos2d
{
public partial class MainPage : PhoneApplicationPage
{
@ -141,13 +140,15 @@ namespace PhoneDirect3DXamlAppInterop
public void OnKeyUp(object sender, KeyEventArgs e)
{
m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Text, m_textBox.Text);
m_textBox.Text = "";
}
public void OnTextChanged(object sender, TextChangedEventArgs e)
{
m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Text, m_textBox.Text);
if (m_textBox.Text.Length > 0)
{
m_d3dInterop.OnCocos2dKeyEvent(Cocos2dKeyEvent.Text, m_textBox.Text);
m_textBox.Text = "";
}
}
// Called by the Cocos2d-x C++ engine to display a MessageBox
@ -181,7 +182,6 @@ namespace PhoneDirect3DXamlAppInterop
m_textBox.TextChanged += OnTextChanged;
DrawingSurfaceBackground.Children.Add(m_textBox);
}
m_textBox.Text = text;
m_textBox.SelectionLength = 0;
m_textBox.SelectionStart = int.MaxValue;
m_textBox.Focus();

View File

@ -49,7 +49,6 @@ using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Phone::UI::Core;
using namespace Platform;
using namespace Microsoft::WRL;
using namespace PhoneDirect3DXamlAppComponent;
NS_CC_BEGIN

View File

@ -95,9 +95,9 @@ public:
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
void GLViewImpl::QueueEvent(std::shared_ptr<InputEvent>& event);
void SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate) { m_delegate = delegate; };
void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate) { m_messageBoxDelegate = delegate; };
void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate) { m_editBoxDelegate = delegate; };
void SetXamlEventDelegate(Cocos2dEventDelegate^ delegate) { m_delegate = delegate; };
void SetXamlMessageBoxDelegate(Cocos2dMessageBoxDelegate^ delegate) { m_messageBoxDelegate = delegate; };
void SetXamlEditBoxDelegate(Cocos2dEditBoxDelegate^ delegate) { m_editBoxDelegate = delegate; };
bool ShowMessageBox(Platform::String^ title, Platform::String^ message);
bool OpenXamlEditBox(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
@ -178,9 +178,9 @@ private:
EGLDisplay m_eglDisplay;
EGLContext m_eglContext;
EGLSurface m_eglSurface;
PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ m_delegate;
PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
Cocos2dEventDelegate^ m_delegate;
Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
Cocos2dEditBoxDelegate^ m_editBoxDelegate;
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
std::mutex mMutex;

View File

@ -69,7 +69,7 @@ const unsigned char s_133478C5A874C1E6F59B418CE6C7C39F1AE0F873[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
2, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -86,7 +86,7 @@ const unsigned char s_133478C5A874C1E6F59B418CE6C7C39F1AE0F873[] = {
120, 116, 117, 114, 101, 48, 0, 0,
0, 0, 1, 0, 0, 0, 248, 3,
0, 0, 4, 5, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 11, 95,
74, 206, 145, 124, 32, 219, 67, 19,
@ -447,7 +447,7 @@ const unsigned char s_13E33F532157A58EC77EDE3B3112560A89D272B2[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 10, 0, 0, 0,
241, 141, 0, 0, 10, 0, 0, 0,
67, 67, 95, 80, 77, 97, 116, 114,
105, 120, 0, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0, 4, 0,
@ -456,7 +456,7 @@ const unsigned char s_13E33F532157A58EC77EDE3B3112560A89D272B2[] = {
116, 114, 105, 120, 0, 0, 0, 0,
0, 0, 0, 0, 204, 2, 0, 0,
164, 4, 0, 0, 0, 0, 0, 0,
63, 88, 0, 0, 0, 0, 0, 0,
182, 139, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
68, 88, 66, 67, 127, 145, 81, 72,
216, 190, 16, 61, 245, 231, 235, 249,
@ -767,7 +767,7 @@ const unsigned char s_1A69A7CC77C7C8FC62799B0513816EA41FBF3BFE[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
4, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -800,7 +800,7 @@ const unsigned char s_1A69A7CC77C7C8FC62799B0513816EA41FBF3BFE[] = {
116, 67, 111, 108, 111, 114, 0, 0,
0, 0, 3, 0, 0, 0, 208, 7,
0, 0, 4, 5, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 65, 106,
69, 173, 111, 248, 97, 165, 186, 90,
@ -1284,28 +1284,28 @@ const unsigned char s_2CF9793879165058483EFB4AD6FA9746ECD7DD2A[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 17, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 11, 0, 0,
0, 241, 141, 0, 0, 11, 0, 0,
0, 67, 67, 95, 77, 86, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
4, 0, 0, 0, 91, 139, 0, 0,
242, 141, 0, 0, 15, 0, 0, 0,
241, 141, 0, 0, 15, 0, 0, 0,
67, 67, 95, 78, 111, 114, 109, 97,
108, 77, 97, 116, 114, 105, 120, 0,
0, 0, 0, 255, 255, 255, 255, 4,
0, 0, 0, 3, 0, 0, 0, 92,
139, 0, 0, 242, 141, 0, 0, 10,
139, 0, 0, 241, 141, 0, 0, 10,
0, 0, 0, 67, 67, 95, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 7, 0, 0,
0, 4, 0, 0, 0, 81, 139, 0,
0, 242, 141, 0, 0, 26, 0, 0,
0, 241, 141, 0, 0, 26, 0, 0,
0, 117, 95, 80, 111, 105, 110, 116,
76, 105, 103, 104, 116, 83, 111, 117,
114, 99, 101, 80, 111, 115, 105, 116,
105, 111, 110, 1, 0, 0, 0, 255,
255, 255, 255, 11, 0, 0, 0, 1,
0, 0, 0, 81, 139, 0, 0, 242,
0, 0, 0, 81, 139, 0, 0, 241,
141, 0, 0, 25, 0, 0, 0, 117,
95, 83, 112, 111, 116, 76, 105, 103,
104, 116, 83, 111, 117, 114, 99, 101,
@ -1462,7 +1462,7 @@ const unsigned char s_2CF9793879165058483EFB4AD6FA9746ECD7DD2A[] = {
99, 111, 108, 111, 114, 0, 0, 0,
0, 16, 0, 0, 0, 236, 16, 0,
0, 124, 10, 0, 0, 0, 0, 0,
0, 63, 88, 0, 0, 0, 0, 0,
0, 182, 139, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 68, 88, 66, 67, 39, 224, 169,
185, 116, 156, 41, 157, 187, 9, 222,
@ -2413,7 +2413,7 @@ const unsigned char s_53938AB67AD93ABA0DDB87F3C9889304284E011E[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
2, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -2430,7 +2430,7 @@ const unsigned char s_53938AB67AD93ABA0DDB87F3C9889304284E011E[] = {
120, 116, 117, 114, 101, 48, 0, 0,
0, 0, 1, 0, 0, 0, 24, 4,
0, 0, 4, 5, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 200, 5,
103, 205, 248, 30, 69, 65, 32, 117,
@ -2795,7 +2795,7 @@ const unsigned char s_67837675F2BB48C0E926316F505FC1538228E0FA[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -2804,7 +2804,7 @@ const unsigned char s_67837675F2BB48C0E926316F505FC1538228E0FA[] = {
86, 80, 77, 97, 116, 114, 105, 120,
0, 0, 0, 0, 0, 0, 0, 0,
16, 4, 0, 0, 48, 5, 0, 0,
0, 0, 0, 0, 63, 88, 0, 0,
0, 0, 0, 0, 182, 139, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 68, 88, 66, 67,
79, 226, 72, 124, 94, 252, 37, 157,
@ -3177,35 +3177,35 @@ const unsigned char s_77D0755E06AA7AF59FAA6B003CA2363EDEB25C4C[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 18, 0, 0, 0, 92, 139,
0, 0, 242, 141, 0, 0, 11, 0,
0, 0, 241, 141, 0, 0, 11, 0,
0, 0, 67, 67, 95, 77, 86, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0,
0, 4, 0, 0, 0, 91, 139, 0,
0, 242, 141, 0, 0, 15, 0, 0,
0, 241, 141, 0, 0, 15, 0, 0,
0, 67, 67, 95, 78, 111, 114, 109,
97, 108, 77, 97, 116, 114, 105, 120,
0, 0, 0, 0, 255, 255, 255, 255,
4, 0, 0, 0, 3, 0, 0, 0,
92, 139, 0, 0, 242, 141, 0, 0,
92, 139, 0, 0, 241, 141, 0, 0,
10, 0, 0, 0, 67, 67, 95, 80,
77, 97, 116, 114, 105, 120, 0, 0,
0, 0, 255, 255, 255, 255, 7, 0,
0, 0, 4, 0, 0, 0, 81, 139,
0, 0, 242, 141, 0, 0, 26, 0,
0, 0, 241, 141, 0, 0, 26, 0,
0, 0, 117, 95, 80, 111, 105, 110,
116, 76, 105, 103, 104, 116, 83, 111,
117, 114, 99, 101, 80, 111, 115, 105,
116, 105, 111, 110, 1, 0, 0, 0,
255, 255, 255, 255, 11, 0, 0, 0,
1, 0, 0, 0, 81, 139, 0, 0,
242, 141, 0, 0, 25, 0, 0, 0,
241, 141, 0, 0, 25, 0, 0, 0,
117, 95, 83, 112, 111, 116, 76, 105,
103, 104, 116, 83, 111, 117, 114, 99,
101, 80, 111, 115, 105, 116, 105, 111,
110, 1, 0, 0, 0, 255, 255, 255,
255, 12, 0, 0, 0, 1, 0, 0,
0, 82, 139, 0, 0, 242, 141, 0,
0, 82, 139, 0, 0, 241, 141, 0,
0, 15, 0, 0, 0, 117, 95, 109,
97, 116, 114, 105, 120, 80, 97, 108,
101, 116, 116, 101, 180, 0, 0, 0,
@ -3968,7 +3968,7 @@ const unsigned char s_77D0755E06AA7AF59FAA6B003CA2363EDEB25C4C[] = {
99, 111, 108, 111, 114, 0, 0, 0,
0, 17, 0, 0, 0, 236, 16, 0,
0, 232, 19, 0, 0, 0, 0, 0,
0, 63, 88, 0, 0, 0, 0, 0,
0, 182, 139, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 68, 88, 66, 67, 39, 224, 169,
185, 116, 156, 41, 157, 187, 9, 222,
@ -5220,7 +5220,7 @@ const unsigned char s_78250E25D1929D4A842050738140787BE42541C6[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
3, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -5245,7 +5245,7 @@ const unsigned char s_78250E25D1929D4A842050738140787BE42541C6[] = {
108, 112, 104, 97, 95, 118, 97, 108,
117, 101, 0, 0, 0, 0, 2, 0,
0, 0, 36, 5, 0, 0, 4, 5,
0, 0, 0, 0, 0, 0, 63, 88,
0, 0, 0, 0, 0, 0, 182, 139,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 68, 88,
66, 67, 100, 113, 175, 29, 164, 71,
@ -5644,7 +5644,7 @@ const unsigned char s_7B67DD242152D35ACC079265FAD9D03DC98182DE[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
2, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 10, 0, 0, 0,
241, 141, 0, 0, 10, 0, 0, 0,
67, 67, 95, 80, 77, 97, 116, 114,
105, 120, 0, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0, 4, 0,
@ -5660,7 +5660,7 @@ const unsigned char s_7B67DD242152D35ACC079265FAD9D03DC98182DE[] = {
67, 95, 84, 101, 120, 116, 117, 114,
101, 48, 0, 0, 0, 0, 1, 0,
0, 0, 248, 3, 0, 0, 0, 5,
0, 0, 0, 0, 0, 0, 63, 88,
0, 0, 0, 0, 0, 0, 182, 139,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 68, 88,
66, 67, 11, 95, 74, 206, 145, 124,
@ -6020,7 +6020,7 @@ const unsigned char s_7CE5EE84ACB6110F7FA29152ECE3344CB6D6620D[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 3, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 12, 0, 0,
0, 241, 141, 0, 0, 12, 0, 0,
0, 67, 67, 95, 77, 86, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0,
@ -6044,7 +6044,7 @@ const unsigned char s_7CE5EE84ACB6110F7FA29152ECE3344CB6D6620D[] = {
99, 111, 108, 111, 114, 0, 0, 0,
0, 2, 0, 0, 0, 96, 4, 0,
0, 192, 4, 0, 0, 0, 0, 0,
0, 63, 88, 0, 0, 0, 0, 0,
0, 182, 139, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 68, 88, 66, 67, 157, 116, 105,
89, 118, 135, 249, 239, 42, 226, 184,
@ -6409,7 +6409,7 @@ const unsigned char s_7E1EEF397305D0BC2DCDBA4F2DAFBCBA1534E45C[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 2, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 12, 0, 0,
0, 241, 141, 0, 0, 12, 0, 0,
0, 67, 67, 95, 77, 86, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0,
@ -6425,7 +6425,7 @@ const unsigned char s_7E1EEF397305D0BC2DCDBA4F2DAFBCBA1534E45C[] = {
117, 95, 99, 111, 108, 111, 114, 0,
0, 0, 0, 1, 0, 0, 0, 52,
3, 0, 0, 40, 4, 0, 0, 0,
0, 0, 0, 63, 88, 0, 0, 0,
0, 0, 0, 182, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 68, 88, 66, 67, 153,
8, 62, 201, 202, 170, 111, 182, 149,
@ -6734,7 +6734,7 @@ const unsigned char s_847DBFDDA6EC09C57E4ED43012AE2FB5CAC7D8D5[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
3, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -6759,7 +6759,7 @@ const unsigned char s_847DBFDDA6EC09C57E4ED43012AE2FB5CAC7D8D5[] = {
111, 108, 111, 114, 0, 0, 0, 0,
2, 0, 0, 0, 240, 4, 0, 0,
4, 5, 0, 0, 0, 0, 0, 0,
63, 88, 0, 0, 0, 0, 0, 0,
182, 139, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
68, 88, 66, 67, 134, 66, 128, 226,
107, 172, 247, 161, 241, 207, 89, 240,
@ -7151,7 +7151,7 @@ const unsigned char s_92BE325B516F887D2C928EDE20ADF428DB01C038[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
3, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 10, 0, 0, 0,
241, 141, 0, 0, 10, 0, 0, 0,
67, 67, 95, 80, 77, 97, 116, 114,
105, 120, 0, 0, 0, 0, 255, 255,
255, 255, 0, 0, 0, 0, 4, 0,
@ -7176,7 +7176,7 @@ const unsigned char s_92BE325B516F887D2C928EDE20ADF428DB01C038[] = {
95, 118, 97, 108, 117, 101, 0, 0,
0, 0, 2, 0, 0, 0, 36, 5,
0, 0, 0, 5, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 100, 113,
175, 29, 164, 71, 177, 78, 120, 99,
@ -7574,28 +7574,28 @@ const unsigned char s_93D31E1668075AE4941C53441D7A9D0DE8F76331[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 16, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 11, 0, 0,
0, 241, 141, 0, 0, 11, 0, 0,
0, 67, 67, 95, 77, 86, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
4, 0, 0, 0, 91, 139, 0, 0,
242, 141, 0, 0, 15, 0, 0, 0,
241, 141, 0, 0, 15, 0, 0, 0,
67, 67, 95, 78, 111, 114, 109, 97,
108, 77, 97, 116, 114, 105, 120, 0,
0, 0, 0, 255, 255, 255, 255, 4,
0, 0, 0, 3, 0, 0, 0, 92,
139, 0, 0, 242, 141, 0, 0, 10,
139, 0, 0, 241, 141, 0, 0, 10,
0, 0, 0, 67, 67, 95, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 7, 0, 0,
0, 4, 0, 0, 0, 81, 139, 0,
0, 242, 141, 0, 0, 26, 0, 0,
0, 241, 141, 0, 0, 26, 0, 0,
0, 117, 95, 80, 111, 105, 110, 116,
76, 105, 103, 104, 116, 83, 111, 117,
114, 99, 101, 80, 111, 115, 105, 116,
105, 111, 110, 1, 0, 0, 0, 255,
255, 255, 255, 11, 0, 0, 0, 1,
0, 0, 0, 81, 139, 0, 0, 242,
0, 0, 0, 81, 139, 0, 0, 241,
141, 0, 0, 25, 0, 0, 0, 117,
95, 83, 112, 111, 116, 76, 105, 103,
104, 116, 83, 111, 117, 114, 99, 101,
@ -7744,7 +7744,7 @@ const unsigned char s_93D31E1668075AE4941C53441D7A9D0DE8F76331[] = {
117, 95, 99, 111, 108, 111, 114, 0,
0, 0, 0, 15, 0, 0, 0, 200,
15, 0, 0, 216, 9, 0, 0, 0,
0, 0, 0, 63, 88, 0, 0, 0,
0, 0, 0, 182, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 68, 88, 66, 67, 136,
158, 207, 210, 174, 144, 71, 116, 248,
@ -8640,12 +8640,12 @@ const unsigned char s_A130FCE93CA2E5D68468367D88D1D7BE357912E5[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 4, 0, 0, 0, 92, 139,
0, 0, 242, 141, 0, 0, 12, 0,
0, 0, 241, 141, 0, 0, 12, 0,
0, 0, 67, 67, 95, 77, 86, 80,
77, 97, 116, 114, 105, 120, 0, 0,
0, 0, 255, 255, 255, 255, 0, 0,
0, 0, 4, 0, 0, 0, 82, 139,
0, 0, 242, 141, 0, 0, 15, 0,
0, 0, 241, 141, 0, 0, 15, 0,
0, 0, 117, 95, 109, 97, 116, 114,
105, 120, 80, 97, 108, 101, 116, 116,
101, 180, 0, 0, 0, 255, 255, 255,
@ -9277,7 +9277,7 @@ const unsigned char s_A130FCE93CA2E5D68468367D88D1D7BE357912E5[] = {
99, 111, 108, 111, 114, 0, 0, 0,
0, 3, 0, 0, 0, 96, 4, 0,
0, 192, 13, 0, 0, 0, 0, 0,
0, 63, 88, 0, 0, 0, 0, 0,
0, 182, 139, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 68, 88, 66, 67, 157, 116, 105,
89, 118, 135, 249, 239, 42, 226, 184,
@ -9930,7 +9930,7 @@ const unsigned char s_A2377A827972A5466DA8637681045D32DA8A817D[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 3, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 12, 0, 0,
0, 241, 141, 0, 0, 12, 0, 0,
0, 67, 67, 95, 77, 86, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0,
@ -9954,7 +9954,7 @@ const unsigned char s_A2377A827972A5466DA8637681045D32DA8A817D[] = {
99, 111, 108, 111, 114, 0, 0, 0,
0, 2, 0, 0, 0, 96, 4, 0,
0, 144, 4, 0, 0, 0, 0, 0,
0, 63, 88, 0, 0, 0, 0, 0,
0, 182, 139, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 68, 88, 66, 67, 157, 116, 105,
89, 118, 135, 249, 239, 42, 226, 184,
@ -10314,7 +10314,7 @@ const unsigned char s_B5E27B4F3CF7236633255B28CBA530D6EE5CED86[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
3, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -10339,7 +10339,7 @@ const unsigned char s_B5E27B4F3CF7236633255B28CBA530D6EE5CED86[] = {
111, 108, 111, 114, 0, 0, 0, 0,
2, 0, 0, 0, 240, 5, 0, 0,
4, 5, 0, 0, 0, 0, 0, 0,
63, 88, 0, 0, 0, 0, 0, 0,
182, 139, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
68, 88, 66, 67, 223, 173, 203, 80,
172, 13, 170, 215, 168, 128, 228, 5,
@ -10761,7 +10761,7 @@ const unsigned char s_E2C7CE1244DE9C76688EFA9463B2A130B6A08893[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 92, 139, 0, 0, 242, 141,
0, 0, 92, 139, 0, 0, 241, 141,
0, 0, 12, 0, 0, 0, 67, 67,
95, 77, 86, 80, 77, 97, 116, 114,
105, 120, 0, 0, 0, 0, 255, 255,
@ -10771,7 +10771,7 @@ const unsigned char s_E2C7CE1244DE9C76688EFA9463B2A130B6A08893[] = {
77, 97, 116, 114, 105, 120, 0, 0,
0, 0, 0, 0, 0, 0, 204, 2,
0, 0, 144, 4, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 127, 145,
81, 72, 216, 190, 16, 61, 245, 231,
@ -11077,17 +11077,17 @@ const unsigned char s_E2D56227712263272BD5218FEA117CD06180F81B[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 3,
0, 0, 0, 92, 139, 0, 0, 242,
0, 0, 0, 92, 139, 0, 0, 241,
141, 0, 0, 12, 0, 0, 0, 67,
67, 95, 77, 86, 80, 77, 97, 116,
114, 105, 120, 0, 0, 0, 0, 255,
255, 255, 255, 0, 0, 0, 0, 4,
0, 0, 0, 82, 139, 0, 0, 242,
0, 0, 0, 82, 139, 0, 0, 241,
141, 0, 0, 7, 0, 0, 0, 117,
95, 99, 111, 108, 111, 114, 0, 0,
0, 0, 255, 255, 255, 255, 4, 0,
0, 0, 1, 0, 0, 0, 6, 20,
0, 0, 242, 141, 0, 0, 11, 0,
0, 0, 241, 141, 0, 0, 11, 0,
0, 0, 117, 95, 112, 111, 105, 110,
116, 83, 105, 122, 101, 0, 0, 0,
0, 255, 255, 255, 255, 5, 0, 0,
@ -11101,8 +11101,8 @@ const unsigned char s_E2D56227712263272BD5218FEA117CD06180F81B[] = {
117, 95, 112, 111, 105, 110, 116, 83,
105, 122, 101, 0, 0, 0, 0, 2,
0, 0, 0, 204, 2, 0, 0, 208,
4, 0, 0, 0, 0, 0, 0, 63,
88, 0, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 0, 0, 0, 182,
139, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 68,
88, 66, 67, 127, 145, 81, 72, 216,
190, 16, 61, 245, 231, 235, 249, 125,
@ -11419,7 +11419,7 @@ const unsigned char s_F46558C274182079784898CF4968CF431593D5E2[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0,
4, 0, 0, 0, 92, 139, 0, 0,
242, 141, 0, 0, 12, 0, 0, 0,
241, 141, 0, 0, 12, 0, 0, 0,
67, 67, 95, 77, 86, 80, 77, 97,
116, 114, 105, 120, 0, 0, 0, 0,
255, 255, 255, 255, 0, 0, 0, 0,
@ -11452,7 +11452,7 @@ const unsigned char s_F46558C274182079784898CF4968CF431593D5E2[] = {
116, 67, 111, 108, 111, 114, 0, 0,
0, 0, 3, 0, 0, 0, 108, 6,
0, 0, 4, 5, 0, 0, 0, 0,
0, 0, 63, 88, 0, 0, 0, 0,
0, 0, 182, 139, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 88, 66, 67, 47, 220,
115, 183, 137, 174, 141, 96, 204, 60,
@ -11891,7 +11891,7 @@ const unsigned char s_F6BA4519AF2653A53D57FB5D5508F0D8617105D6[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 2, 0, 0, 0, 92, 139, 0,
0, 242, 141, 0, 0, 12, 0, 0,
0, 241, 141, 0, 0, 12, 0, 0,
0, 67, 67, 95, 77, 86, 80, 77,
97, 116, 114, 105, 120, 0, 0, 0,
0, 255, 255, 255, 255, 0, 0, 0,
@ -11908,7 +11908,7 @@ const unsigned char s_F6BA4519AF2653A53D57FB5D5508F0D8617105D6[] = {
101, 120, 116, 117, 114, 101, 48, 0,
0, 0, 0, 1, 0, 0, 0, 156,
3, 0, 0, 144, 4, 0, 0, 0,
0, 0, 0, 63, 88, 0, 0, 0,
0, 0, 0, 182, 139, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 68, 88, 66, 67, 203,
117, 183, 110, 154, 52, 220, 70, 125,

View File

@ -45,13 +45,6 @@ THE SOFTWARE.
NS_CC_BEGIN
typedef struct _hashUniformEntry
{
GLvoid* value; // value
unsigned int location; // Key
UT_hash_handle hh; // hash entry
} tHashUniformEntry;
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest";
@ -136,7 +129,6 @@ GLProgram::GLProgram()
: _program(0)
, _vertShader(0)
, _fragShader(0)
, _hashForUniforms(nullptr)
, _flags()
{
memset(_builtInUniforms, 0, sizeof(_builtInUniforms));
@ -163,15 +155,11 @@ GLProgram::~GLProgram()
GL::deleteProgram(_program);
}
tHashUniformEntry *current_element, *tmp;
// Purge uniform hash
HASH_ITER(hh, _hashForUniforms, current_element, tmp)
for (auto e : _hashForUniforms)
{
HASH_DEL(_hashForUniforms, current_element);
free(current_element->value);
free(current_element);
free(e.second);
}
_hashForUniforms.clear();
}
bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
@ -222,7 +210,8 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
{
glAttachShader(_program, _fragShader);
}
_hashForUniforms = nullptr;
_hashForUniforms.clear();
CHECK_GL_ERROR_DEBUG();
@ -260,7 +249,7 @@ bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArr
haveProgram = CCPrecompiledShaders::getInstance()->loadProgram(_program, vShaderByteArray, fShaderByteArray);
CHECK_GL_ERROR_DEBUG();
_hashForUniforms = nullptr;
_hashForUniforms.clear();
CHECK_GL_ERROR_DEBUG();
@ -418,7 +407,9 @@ bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source
}
const GLchar *sources[] = {
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
(type == GL_VERTEX_SHADER ? "precision mediump float;\n precision mediump int;\n" : "precision mediump float;\n precision mediump int;\n"),
#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
(type == GL_VERTEX_SHADER ? "precision highp float;\n precision highp int;\n" : "precision mediump float;\n precision mediump int;\n"),
#endif
"uniform mat4 CC_PMatrix;\n"
@ -562,7 +553,7 @@ bool GLProgram::link()
_vertShader = _fragShader = 0;
#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
glGetProgramiv(_program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
@ -631,31 +622,23 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign
}
bool updated = true;
tHashUniformEntry *element = nullptr;
HASH_FIND_INT(_hashForUniforms, &location, element);
if (! element)
auto element = _hashForUniforms.find(location);
if (element == _hashForUniforms.end())
{
element = (tHashUniformEntry*)malloc( sizeof(*element) );
// key
element->location = location;
// value
element->value = malloc( bytes );
memcpy(element->value, data, bytes );
HASH_ADD_INT(_hashForUniforms, location, element);
GLvoid* value = malloc(bytes);
memcpy(value, data, bytes );
_hashForUniforms.insert(std::make_pair(location, value));
}
else
{
if (memcmp(element->value, data, bytes) == 0)
if (memcmp(element->second, data, bytes) == 0)
{
updated = false;
}
else
{
memcpy(element->value, data, bytes);
memcpy(element->second, data, bytes);
}
}
@ -921,17 +904,12 @@ void GLProgram::reset()
//GL::deleteProgram(_program);
_program = 0;
tHashUniformEntry *current_element, *tmp;
// Purge uniform hash
HASH_ITER(hh, _hashForUniforms, current_element, tmp)
for (auto e: _hashForUniforms)
{
HASH_DEL(_hashForUniforms, current_element);
free(current_element->value);
free(current_element);
free(e.second);
}
_hashForUniforms = nullptr;
_hashForUniforms.clear();
}
NS_CC_END

View File

@ -45,7 +45,6 @@ NS_CC_BEGIN
* @{
*/
struct _hashUniformEntry;
class GLProgram;
typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params);
@ -340,7 +339,6 @@ protected:
GLuint _vertShader;
GLuint _fragShader;
GLint _builtInUniforms[UNIFORM_MAX];
struct _hashUniformEntry* _hashForUniforms;
bool _hasShaderCompiler;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER)
@ -360,6 +358,7 @@ protected:
std::unordered_map<std::string, Uniform> _userUniforms;
std::unordered_map<std::string, VertexAttrib> _vertexAttribs;
std::unordered_map<GLint, GLvoid*> _hashForUniforms;
};
NS_CC_END

View File

@ -432,9 +432,16 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key)
void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key)
{
// release old one
auto prev = getProgram(key);
if( prev == program )
return;
_programs.erase(key);
CC_SAFE_RELEASE_NULL(prev);
if (program)
program->retain();
program->retain();
_programs[key] = program;
}

View File

@ -279,7 +279,7 @@ GLProgramState::GLProgramState()
, _textureUnitIndex(1)
, _uniformAttributeValueDirty(true)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
/** listen the event that renderer was recreated on Android/WP8 */
CCLOG("create rendererRecreatedListener for GLProgramState");
_backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
@ -289,7 +289,7 @@ GLProgramState::GLProgramState()
GLProgramState::~GLProgramState()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
#endif

View File

@ -217,8 +217,8 @@ protected:
int _textureUnitIndex;
uint32_t _vertexAttribsFlags;
GLProgram *_glprogram;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
EventListenerCustom* _backToForegroundlistener;
#endif
};

View File

@ -0,0 +1,43 @@
/*
* cocos2d for iPhone: http://www.cocos2d-iphone.org
*
* Copyright (c) 2011 Ricardo Quesada
* Copyright (c) 2012 Zynga Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
const char* ccPosition_uColor_vert = STRINGIFY(
attribute vec4 a_position;
uniform vec4 u_color;
uniform float u_pointSize;
\n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor;
\n#else\n
varying vec4 v_fragmentColor;
\n#endif\n
void main()
{
gl_Position = CC_MVPMatrix * a_position;
v_fragmentColor = u_color;
}
);

View File

@ -31,7 +31,12 @@ THE SOFTWARE.
NS_CC_BEGIN
//
#include "ccShader_Position_uColor.frag"
#ifdef CC_NO_GL_POINTSIZE
#include "ccShader_Position_uColor-no-gl_PointSize.vert"
#else
#include "ccShader_Position_uColor.vert"
#endif
//
#include "ccShader_PositionColor.frag"

View File

@ -47,10 +47,10 @@
-- @return BlendFunc#BlendFunc ret (return value: cc.BlendFunc)
--------------------------------
--
-- @function [parent=#Sprite3D] setCullFace
-- get mesh count
-- @function [parent=#Sprite3D] getMeshCount
-- @param self
-- @param #unsigned int cullFace
-- @return long#long ret (return value: long)
--------------------------------
-- remove attach node
@ -58,6 +58,12 @@
-- @param self
-- @param #string boneName
--------------------------------
--
-- @function [parent=#Sprite3D] setCullFace
-- @param self
-- @param #unsigned int cullFace
--------------------------------
-- get SubMeshState by index
-- @function [parent=#Sprite3D] getMeshByIndex

View File

@ -670,7 +670,7 @@ int lua_cocos2dx_3d_Sprite3D_getBlendFunc(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
int lua_cocos2dx_3d_Sprite3D_getMeshCount(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3D* cobj = nullptr;
@ -690,28 +690,26 @@ int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_getMeshCount'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
if (argc == 0)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Sprite3D:setCullFace");
if(!ok)
return 0;
cobj->setCullFace(arg0);
return 0;
ssize_t ret = cobj->getMeshCount();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFace",argc, 1);
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:getMeshCount",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_getMeshCount'.",&tolua_err);
#endif
return 0;
@ -762,6 +760,52 @@ int lua_cocos2dx_3d_Sprite3D_removeAttachNode(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_3d_Sprite3D_setCullFace(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Sprite3D* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Sprite3D*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
unsigned int arg0;
ok &= luaval_to_uint32(tolua_S, 2,&arg0, "cc.Sprite3D:setCullFace");
if(!ok)
return 0;
cobj->setCullFace(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3D:setCullFace",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_setCullFace'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_3d_Sprite3D_getMeshByIndex(lua_State* tolua_S)
{
int argc = 0;
@ -1017,8 +1061,9 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S)
tolua_function(tolua_S,"getMesh",lua_cocos2dx_3d_Sprite3D_getMesh);
tolua_function(tolua_S,"setLightMask",lua_cocos2dx_3d_Sprite3D_setLightMask);
tolua_function(tolua_S,"getBlendFunc",lua_cocos2dx_3d_Sprite3D_getBlendFunc);
tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_Sprite3D_setCullFace);
tolua_function(tolua_S,"getMeshCount",lua_cocos2dx_3d_Sprite3D_getMeshCount);
tolua_function(tolua_S,"removeAttachNode",lua_cocos2dx_3d_Sprite3D_removeAttachNode);
tolua_function(tolua_S,"setCullFace",lua_cocos2dx_3d_Sprite3D_setCullFace);
tolua_function(tolua_S,"getMeshByIndex",lua_cocos2dx_3d_Sprite3D_getMeshByIndex);
tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName);
tolua_function(tolua_S,"getSkeleton",lua_cocos2dx_3d_Sprite3D_getSkeleton);

View File

@ -59,6 +59,7 @@ int register_all_cocos2dx_3d(lua_State* tolua_S);
#endif // __cocos2dx_3d_h__

View File

@ -2922,7 +2922,7 @@ void ccvector_std_string_to_luaval(lua_State* L, const std::vector<std::string>&
int index = 1;
for (const std::string value : inValue)
for (const std::string& value : inValue)
{
lua_pushnumber(L, (lua_Number)index);
lua_pushstring(L, value.c_str());

View File

@ -194,16 +194,7 @@ void Button::ignoreContentAdaptWithSize(bool ignore)
{
if (_unifySize)
{
if (_scale9Enabled)
{
ProtectedNode::setContentSize(_customSize);
}
else
{
Size s = getVirtualRendererSize();
ProtectedNode::setContentSize(s);
}
onSizeChanged();
this->updateContentSize();
return;
}
if (!_scale9Enabled || (_scale9Enabled && !ignore))
@ -249,7 +240,17 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
updateFlippedY();
this->updateChildrenDisplayedRGBA();
updateContentSizeWithTextureSize(_normalTextureSize);
if (_unifySize )
{
if (!_scale9Enabled)
{
updateContentSizeWithTextureSize(this->getNormalSize());
}
}
else
{
updateContentSizeWithTextureSize(_normalTextureSize);
}
_normalTextureLoaded = true;
_normalTextureAdaptDirty = true;
}
@ -434,7 +435,15 @@ void Button::onPressStateChangedToNormal()
_buttonClickedRenderer->setScale(_pressedTextureScaleXInSize, _pressedTextureScaleYInSize);
_titleRenderer->stopAllActions();
_titleRenderer->runAction(zoomAction->clone());
if (_unifySize)
{
Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1, 1);
_titleRenderer->runAction(zoomTitleAction);
}
else
{
_titleRenderer->runAction(zoomAction->clone());
}
}
}
else
@ -449,8 +458,16 @@ void Button::onPressStateChangedToNormal()
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
if (_unifySize)
{
_titleRenderer->setScaleX(1.0f);
_titleRenderer->setScaleY(1.0f);
}
else
{
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
}
}
}
}
@ -474,6 +491,15 @@ void Button::onPressStateChangedToPressed()
_titleRenderer->stopAllActions();
//we must call zoomAction->clone here
_titleRenderer->runAction(zoomAction->clone());
if (_unifySize)
{
Action *zoomTitleAction = ScaleTo::create(ZOOM_ACTION_TIME_STEP, 1 + _zoomScale, 1 + _zoomScale);
_titleRenderer->runAction(zoomTitleAction);
}
else
{
_titleRenderer->runAction(zoomAction->clone());
}
}
}
else
@ -491,8 +517,16 @@ void Button::onPressStateChangedToPressed()
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize +_zoomScale, _normalTextureScaleYInSize + _zoomScale);
_titleRenderer->stopAllActions();
_titleRenderer->setScaleX(_normalTextureScaleXInSize + _zoomScale);
_titleRenderer->setScaleY(_normalTextureScaleYInSize + _zoomScale);
if (_unifySize)
{
_titleRenderer->setScaleX(1.0f + _zoomScale);
_titleRenderer->setScaleY(1.0f + _zoomScale);
}
else
{
_titleRenderer->setScaleX(_normalTextureScaleXInSize + _zoomScale);
_titleRenderer->setScaleY(_normalTextureScaleYInSize + _zoomScale);
}
}
}
}
@ -532,9 +566,23 @@ void Button::updateTitleLocation()
void Button::updateContentSize()
{
if (_ignoreSize) {
this->setContentSize(getVirtualRendererSize());
}
if (_unifySize)
{
if (_scale9Enabled)
{
ProtectedNode::setContentSize(_customSize);
}
else
{
Size s = getNormalSize();
ProtectedNode::setContentSize(s);
}
onSizeChanged();
return;
}
if (_ignoreSize) {
this->setContentSize(getVirtualRendererSize());
}
}
void Button::onSizeChanged()
@ -567,6 +615,10 @@ void Button::adaptRenderers()
Size Button::getVirtualRendererSize() const
{
if (_unifySize)
{
return this->getNormalSize();
}
Size titleSize = _titleRenderer->getContentSize();
if (!_normalTextureLoaded && _titleRenderer->getString().size() > 0) {
return titleSize;
@ -596,11 +648,8 @@ Node* Button::getVirtualRenderer()
void Button::normalTextureScaleChangedWithSize()
{
if (_unifySize)
{
_buttonNormalRenderer->setPreferredSize(_contentSize);
}
else if (_ignoreSize)
if (_ignoreSize && !_unifySize)
{
if (!_scale9Enabled)
{
@ -638,11 +687,8 @@ void Button::normalTextureScaleChangedWithSize()
void Button::pressedTextureScaleChangedWithSize()
{
if (_unifySize)
{
_buttonClickedRenderer->setPreferredSize(_contentSize);
}
else if (_ignoreSize)
if (_ignoreSize && !_unifySize)
{
if (!_scale9Enabled)
{
@ -679,11 +725,8 @@ void Button::pressedTextureScaleChangedWithSize()
void Button::disabledTextureScaleChangedWithSize()
{
if (_unifySize)
{
_buttonDisableRenderer->setPreferredSize(_contentSize);
}
else if (_ignoreSize)
if (_ignoreSize && !_unifySize)
{
if (!_scale9Enabled)
{
@ -784,9 +827,11 @@ void Button::setTitleFontName(const std::string& fontName)
{
_titleRenderer->requestSystemFontRefresh();
}
_titleRenderer->setSystemFontSize(_fontSize);
_type = FontType::SYSTEM;
}
_fontName = fontName;
this->updateContentSize();
}
Label* Button::getTitleRenderer()const
@ -829,6 +874,24 @@ void Button::copySpecialProperties(Widget *widget)
setPressedActionEnabled(button->_pressedActionEnabled);
setZoomScale(button->_zoomScale);
}
}
Size Button::getNormalSize() const
{
Size titleSize;
if (_titleRenderer != nullptr)
{
titleSize = _titleRenderer->getContentSize();
}
Size imageSize;
if (_buttonNormalRenderer != nullptr)
{
imageSize = _buttonNormalRenderer->getContentSize();
}
float width = titleSize.width > imageSize.width ? titleSize.width : imageSize.width;
float height = titleSize.height > imageSize.height ? titleSize.height : imageSize.height;
return Size(width,height);
}
}

View File

@ -234,6 +234,7 @@ protected:
virtual Widget* createCloneInstance() override;
virtual void copySpecialProperties(Widget* model) override;
virtual Size getNormalSize() const;
protected:
Scale9Sprite* _buttonNormalRenderer;
Scale9Sprite* _buttonClickedRenderer;

View File

@ -1,6 +1,6 @@
#include "UIEditBox.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID ) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS ) && (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) && (CC_TARGET_PLATFORM != CC_PLATFORM_TIZEN)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID ) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS ) && (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) && (CC_TARGET_PLATFORM != CC_PLATFORM_TIZEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
NS_CC_BEGIN

View File

@ -0,0 +1,583 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#include "UIEditBoxImpl-winrt.h"
#include "UIEditBox.h"
#include "CCGLViewImpl-winrt.h"
#include "base/CCScriptSupport.h"
#include "base/ccUTF8.h"
#include "2d/CCLabel.h"
#include "CCWinRTUtils.h"
using namespace Platform;
using namespace Concurrency;
using namespace Windows::System;
using namespace Windows::System::Threading;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::Foundation;
using namespace Windows::UI::ViewManagement;
NS_CC_BEGIN
namespace ui {
EditBoxWinRT::EditBoxWinRT()
{
}
EditBoxWinRT::~EditBoxWinRT()
{
}
EditBoxWinRT::EditBoxWinRT(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, EditBox::InputMode inputMode, EditBox::InputFlag inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler)
{
m_dispatcher = cocos2d::GLViewImpl::sharedOpenGLView()->getDispatcher();
m_panel = cocos2d::GLViewImpl::sharedOpenGLView()->getPanel();
m_strText = strText;
m_strPlaceholder = strPlaceHolder;
m_inputMode = inputMode;
m_inputFlag = inputFlag;
m_receiveHandler = receiveHandler;
m_maxLength = maxLength;
}
void EditBoxWinRT::OpenXamlEditBox(Platform::String^ strText)
{
if (m_dispatcher.Get() == nullptr || m_panel.Get() == nullptr)
{
return;
}
// must create XAML element on main UI thread
m_dispatcher.Get()->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this, strText]()
{
critical_section::scoped_lock lock(m_criticalSection);
m_strText = strText;
auto item = findXamlElement(m_panel.Get(), "cocos2d_editbox");
if (item != nullptr)
{
Controls::Button^ button = dynamic_cast<Controls::Button^>(item);
if (button)
{
m_flyout = dynamic_cast<Flyout^>(button->Flyout);
if (m_flyout)
{
if (m_inputFlag == EditBox::InputFlag::PASSWORD)
{
SetupPasswordBox();
}
else
{
SetupTextBox();
}
auto doneButton = findXamlElement(m_flyout->Content, "cocos2d_editbox_done");
if (doneButton != nullptr)
{
m_doneButton = dynamic_cast<Controls::Button^>(doneButton);
m_doneToken = m_doneButton->Click += ref new RoutedEventHandler(this, &EditBoxWinRT::Done);
}
auto cancelButton = findXamlElement(m_flyout->Content, "cocos2d_editbox_cancel");
if (cancelButton != nullptr)
{
m_cancelButton = dynamic_cast<Controls::Button^>(cancelButton);
m_cancelToken = m_cancelButton->Click += ref new RoutedEventHandler(this, &EditBoxWinRT::Cancel);
}
}
}
if (m_flyout)
{
auto inputPane = InputPane::GetForCurrentView();
m_hideKeyboardToken = inputPane->Hiding += ref new TypedEventHandler<InputPane^, InputPaneVisibilityEventArgs^>(this, &EditBoxWinRT::HideKeyboard);
m_closedToken = m_flyout->Closed += ref new EventHandler<Platform::Object^>(this, &EditBoxWinRT::Closed);
m_flyout->ShowAt(m_panel.Get());
}
}
}));
}
void EditBoxWinRT::Closed(Platform::Object^ sender, Platform::Object^ e)
{
critical_section::scoped_lock lock(m_criticalSection);
RemoveControls();
}
void EditBoxWinRT::Done(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
QueueText();
HideFlyout();
}
void EditBoxWinRT::Cancel(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
HideFlyout();
}
void EditBoxWinRT::HideKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args)
{
// we don't want to hide the flyout when the user hide the keyboard
//HideFlyout();
}
void EditBoxWinRT::HideFlyout()
{
critical_section::scoped_lock lock(m_criticalSection);
if (m_flyout)
{
m_flyout->Hide();
}
}
void EditBoxWinRT::RemoveControls()
{
if (m_dispatcher.Get() && m_panel.Get())
{
// run on main UI thread
m_dispatcher.Get()->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
{
critical_section::scoped_lock lock(m_criticalSection);
if (m_doneButton != nullptr)
{
m_doneButton->Click -= m_doneToken;
m_doneButton = nullptr;
}
if (m_cancelButton != nullptr)
{
m_cancelButton->Click -= m_cancelToken;
m_cancelButton = nullptr;
}
m_textBox = nullptr;
m_passwordBox = nullptr;
if (m_flyout != nullptr)
{
m_flyout->Closed -= m_closedToken;
m_flyout = nullptr;
}
auto inputPane = InputPane::GetForCurrentView();
inputPane->Hiding -= m_hideKeyboardToken;
}));
}
}
void EditBoxWinRT::RemoveTextBox()
{
auto g = findXamlElement(m_flyout->Content, "cocos2d_editbox_grid");
auto grid = dynamic_cast<Grid^>(g);
auto box = findXamlElement(m_flyout->Content, "cocos2d_editbox_textbox");
if (box)
{
removeXamlElement(grid, box);
}
}
void EditBoxWinRT::SetupTextBox()
{
RemoveTextBox();
m_textBox = ref new TextBox;
m_textBox->Text = m_strText;
m_textBox->Name = "cocos2d_editbox_textbox";
m_textBox->MinWidth = 200;
m_textBox->PlaceholderText = m_strPlaceholder;
m_textBox->Select(m_textBox->Text->Length(), 0);
m_textBox->MaxLength = m_maxLength < 0 ? 0 : m_maxLength;
SetInputScope(m_textBox, m_inputMode);
auto g = findXamlElement(m_flyout->Content, "cocos2d_editbox_grid");
auto grid = dynamic_cast<Grid^>(g);
grid->Children->InsertAt(0, m_textBox);
}
void EditBoxWinRT::SetupPasswordBox()
{
RemoveTextBox();
m_passwordBox = ref new PasswordBox();
m_passwordBox->Password = m_strText;
m_passwordBox->MinWidth = 200;
m_passwordBox->Name = "cocos2d_editbox_textbox";
m_passwordBox->SelectAll();
m_passwordBox->PlaceholderText = m_strPlaceholder;
m_passwordBox->MaxLength = m_maxLength < 0 ? 0 : m_maxLength;
auto g = findXamlElement(m_flyout->Content, "cocos2d_editbox_grid");
auto grid = dynamic_cast<Grid^>(g);
grid->Children->InsertAt(0, m_passwordBox);
}
void EditBoxWinRT::SetInputScope(TextBox^ box, EditBox::InputMode inputMode)
{
// TextBox.SetInputScope
InputScope^ inputScope = ref new InputScope();
InputScopeName^ name = ref new InputScopeName();
switch (inputMode)
{
case EditBox::InputMode::ANY:
name->NameValue = InputScopeNameValue::Default;
break;
case EditBox::InputMode::EMAIL_ADDRESS:
name->NameValue = InputScopeNameValue::EmailSmtpAddress;
break;
case EditBox::InputMode::NUMERIC:
name->NameValue = InputScopeNameValue::Number;
break;
case EditBox::InputMode::PHONE_NUMBER:
name->NameValue = InputScopeNameValue::TelephoneNumber;
break;
case EditBox::InputMode::URL:
name->NameValue = InputScopeNameValue::Url;
break;
case EditBox::InputMode::DECIMAL:
name->NameValue = InputScopeNameValue::Number;
break;
case EditBox::InputMode::SINGLE_LINE:
name->NameValue = InputScopeNameValue::Default;
break;
default:
name->NameValue = InputScopeNameValue::Default;
break;
}
box->InputScope = nullptr;
inputScope->Names->Append(name);
box->InputScope = inputScope;
}
void EditBoxWinRT::QueueText()
{
critical_section::scoped_lock lock(m_criticalSection);
if ((m_passwordBox == nullptr) && (m_textBox == nullptr))
{
return;
}
m_strText = m_inputFlag == EditBox::InputFlag::PASSWORD ? m_passwordBox->Password : m_textBox->Text;
std::shared_ptr<cocos2d::InputEvent> e(new UIEditBoxEvent(this, m_strText, m_receiveHandler));
cocos2d::GLViewImpl::sharedOpenGLView()->QueueEvent(e);
}
EditBoxImpl* __createSystemEditBox(EditBox* pEditBox)
{
return new UIEditBoxImplWinrt(pEditBox);
}
UIEditBoxImplWinrt::UIEditBoxImplWinrt( EditBox* pEditText )
: EditBoxImpl(pEditText)
, m_pLabel(NULL)
, m_pLabelPlaceHolder(NULL)
, m_eEditBoxInputMode(EditBox::InputMode::SINGLE_LINE)
, m_eEditBoxInputFlag(EditBox::InputFlag::INTIAL_CAPS_ALL_CHARACTERS)
, m_eKeyboardReturnType(EditBox::KeyboardReturnType::DEFAULT)
, m_colText(Color3B::WHITE)
, m_colPlaceHolder(Color3B::GRAY)
, m_nMaxLength(-1)
{
}
UIEditBoxImplWinrt::~UIEditBoxImplWinrt()
{
}
void UIEditBoxImplWinrt::openKeyboard()
{
if (_delegate != NULL)
{
_delegate->editBoxEditingDidBegin(_editBox);
}
EditBox* pEditBox = this->getEditBox();
if (NULL != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
{
CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
}
std::string placeHolder = m_pLabelPlaceHolder->getString();
if (placeHolder.length() == 0)
placeHolder = "Enter value";
char pText[100]= {0};
std::string text = getText();
if (text.length())
strncpy(pText, text.c_str(), 100);
if (!m_editBoxWinrt)
{
Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler = ref new Windows::Foundation::EventHandler<Platform::String^>(
[this](Platform::Object^ sender, Platform::String^ arg)
{
setText(PlatformStringTostring(arg).c_str());
if (_delegate != NULL) {
_delegate->editBoxTextChanged(_editBox, getText());
_delegate->editBoxEditingDidEnd(_editBox);
_delegate->editBoxReturn(_editBox);
}
});
m_editBoxWinrt = ref new EditBoxWinRT(stringToPlatformString(placeHolder), stringToPlatformString(getText()), m_nMaxLength, m_eEditBoxInputMode, m_eEditBoxInputFlag, receiveHandler);
}
m_editBoxWinrt->OpenXamlEditBox(stringToPlatformString(getText()));
}
bool UIEditBoxImplWinrt::initWithSize( const Size& size )
{
//! int fontSize = getFontSizeAccordingHeightJni(size.height-12);
m_pLabel = Label::createWithSystemFont("", "", size.height-12);
// align the text vertically center
m_pLabel->setAnchorPoint(Vec2(0.0f, 0.5f));
m_pLabel->setPosition(Vec2(5.0, size.height / 2.0f));
m_pLabel->setColor(m_colText);
_editBox->addChild(m_pLabel);
m_pLabelPlaceHolder = Label::createWithSystemFont("", "", size.height-12);
// align the text vertically center
m_pLabelPlaceHolder->setAnchorPoint(Vec2(0.0f, 0.5f));
m_pLabelPlaceHolder->setPosition(Vec2(5.0f, size.height / 2.0f));
m_pLabelPlaceHolder->setVisible(false);
m_pLabelPlaceHolder->setColor(m_colPlaceHolder);
_editBox->addChild(m_pLabelPlaceHolder);
m_EditSize = size;
return true;
}
void UIEditBoxImplWinrt::setFont( const char* pFontName, int fontSize )
{
if(m_pLabel != NULL) {
m_pLabel->setSystemFontName(pFontName);
m_pLabel->setSystemFontSize(fontSize);
}
if(m_pLabelPlaceHolder != NULL) {
m_pLabelPlaceHolder->setSystemFontName(pFontName);
m_pLabelPlaceHolder->setSystemFontSize(fontSize);
}
}
void UIEditBoxImplWinrt::setFontColor( const Color3B& color )
{
m_colText = color;
m_pLabel->setColor(color);
}
void UIEditBoxImplWinrt::setPlaceholderFont( const char* pFontName, int fontSize )
{
if(m_pLabelPlaceHolder != NULL) {
m_pLabelPlaceHolder->setSystemFontName(pFontName);
m_pLabelPlaceHolder->setSystemFontSize(fontSize);
}
}
void UIEditBoxImplWinrt::setPlaceholderFontColor( const Color3B& color )
{
m_colPlaceHolder = color;
m_pLabelPlaceHolder->setColor(color);
}
void UIEditBoxImplWinrt::setInputMode( EditBox::InputMode inputMode )
{
m_eEditBoxInputMode = inputMode;
}
void UIEditBoxImplWinrt::setInputFlag(EditBox::InputFlag inputFlag )
{
m_eEditBoxInputFlag = inputFlag;
}
void UIEditBoxImplWinrt::setMaxLength( int maxLength )
{
m_nMaxLength = maxLength;
}
int UIEditBoxImplWinrt::getMaxLength()
{
return m_nMaxLength;
}
void UIEditBoxImplWinrt::setReturnType( EditBox::KeyboardReturnType returnType )
{
m_eKeyboardReturnType = returnType;
}
bool UIEditBoxImplWinrt::isEditing()
{
return false;
}
void UIEditBoxImplWinrt::setText( const char* pText )
{
if (pText != NULL)
{
m_strText = pText;
if (m_strText.length() > 0)
{
m_pLabelPlaceHolder->setVisible(false);
std::string strToShow;
if (EditBox::InputFlag::PASSWORD == m_eEditBoxInputFlag)
{
long length = cc_utf8_strlen(m_strText.c_str(), -1);
for (long i = 0; i < length; i++)
{
strToShow.append("*");
}
}
else
{
strToShow = m_strText;
}
//! std::string strWithEllipsis = getStringWithEllipsisJni(strToShow.c_str(), m_EditSize.width, m_EditSize.height-12);
//! m_pLabel->setString(strWithEllipsis.c_str());
m_pLabel->setString(strToShow.c_str());
}
else
{
m_pLabelPlaceHolder->setVisible(true);
m_pLabel->setString("");
}
}
}
const char* UIEditBoxImplWinrt::getText( void )
{
return m_strText.c_str();
}
void UIEditBoxImplWinrt::setPlaceHolder( const char* pText )
{
if (pText != NULL)
{
m_strPlaceHolder = pText;
if (m_strPlaceHolder.length() > 0 && m_strText.length() == 0)
{
m_pLabelPlaceHolder->setVisible(true);
}
m_pLabelPlaceHolder->setString(m_strPlaceHolder.c_str());
}
}
void UIEditBoxImplWinrt::setPosition( const Vec2& pos )
{
}
void UIEditBoxImplWinrt::setVisible( bool visible )
{
}
void UIEditBoxImplWinrt::setContentSize( const Size& size )
{
}
void UIEditBoxImplWinrt::setAnchorPoint( const Vec2& anchorPoint )
{
}
void UIEditBoxImplWinrt::visit( void )
{
}
void UIEditBoxImplWinrt::doAnimationWhenKeyboardMove( float duration, float distance )
{
}
void UIEditBoxImplWinrt::closeKeyboard()
{
}
void UIEditBoxImplWinrt::onEnter( void )
{
}
Platform::String^ UIEditBoxImplWinrt::stringToPlatformString( std::string strSrc )
{
// to wide char
int nStrLen = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0);
wchar_t* pWStr = new wchar_t[nStrLen + 1];
memset(pWStr, 0, nStrLen + 1);
MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, pWStr, nStrLen);
Platform::String^ strDst = ref new Platform::String(pWStr);
delete[] pWStr;
return strDst;
}
std::string UIEditBoxImplWinrt::PlatformStringTostring( Platform::String^ strSrc )
{
const wchar_t* pWStr = strSrc->Data();
int nStrLen = WideCharToMultiByte(CP_UTF8, 0, pWStr, -1, NULL, 0, NULL, NULL);
char* pStr = new char[nStrLen + 1];
memset(pStr, 0, nStrLen + 1);
WideCharToMultiByte(CP_UTF8, 0, pWStr, -1, pStr, nStrLen, NULL, NULL); ;
std::string strDst = std::string(pStr);
delete[] pStr;
return strDst;
}
}
NS_CC_END
#endif // WP8

View File

@ -0,0 +1,146 @@
/****************************************************************************
Copyright (c) 2014 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __UIEditBoxIMPLWINRT_H__
#define __UIEditBoxIMPLWINRT_H__
#include "platform/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#include "UIEditBoxImpl.h"
NS_CC_BEGIN
namespace ui {
class EditBox;
ref class EditBoxWinRT sealed
{
public:
EditBoxWinRT();
virtual ~EditBoxWinRT();
internal:
EditBoxWinRT(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, EditBox::InputMode inputMode, EditBox::InputFlag inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
void OpenXamlEditBox(Platform::String^ strText);
private:
Windows::UI::Xaml::Controls::Control^ CreateTextBox(int maxLength);
Windows::UI::Xaml::Controls::Control^ CreatePasswordBox(int maxLength);
void SetInputScope(Windows::UI::Xaml::Controls::TextBox^ box, EditBox::InputMode inputMode);
void EditBoxWinRT::SetupTextBox();
void EditBoxWinRT::SetupPasswordBox();
void EditBoxWinRT::RemoveTextBox();
void RemoveControls();
void QueueText();
void Done(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void Cancel(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void Closed(Platform::Object^ sender, Platform::Object^ e);
void HideKeyboard(Windows::UI::ViewManagement::InputPane^ inputPane, Windows::UI::ViewManagement::InputPaneVisibilityEventArgs^ args);
void HideFlyout();
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
Windows::Foundation::EventHandler<Platform::String^>^ m_receiveHandler;
Windows::UI::Xaml::Controls::TextBox^ m_textBox;
Windows::UI::Xaml::Controls::PasswordBox^ m_passwordBox;
Windows::UI::Xaml::Controls::Flyout^ m_flyout;
Windows::UI::Xaml::Controls::Button^ m_doneButton;
Windows::UI::Xaml::Controls::Button^ m_cancelButton;
Windows::Foundation::EventRegistrationToken m_doneToken;
Windows::Foundation::EventRegistrationToken m_cancelToken;
Windows::Foundation::EventRegistrationToken m_closedToken;
Windows::Foundation::EventRegistrationToken m_hideKeyboardToken;
Concurrency::critical_section m_criticalSection;
Platform::String^ m_strText;
Platform::String^ m_strPlaceholder;
EditBox::InputMode m_inputMode;
EditBox::InputFlag m_inputFlag;
int m_maxLength;
};
class CC_GUI_DLL UIEditBoxImplWinrt : public EditBoxImpl
{
public:
UIEditBoxImplWinrt(EditBox* pEditText);
virtual ~UIEditBoxImplWinrt();
virtual bool initWithSize(const Size& size);
virtual void setFont(const char* pFontName, int fontSize);
virtual void setFontColor(const Color3B& color);
virtual void setPlaceholderFont(const char* pFontName, int fontSize);
virtual void setPlaceholderFontColor(const Color3B& color);
virtual void setInputMode(EditBox::InputMode inputMode);
virtual void setInputFlag(EditBox::InputFlag inputFlag);
virtual void setMaxLength(int maxLength);
virtual int getMaxLength();
virtual void setReturnType(EditBox::KeyboardReturnType returnType);
virtual bool isEditing();
virtual void setText(const char* pText);
virtual const char* getText(void);
virtual void setPlaceHolder(const char* pText);
virtual void setPosition(const Vec2& pos);
virtual void setVisible(bool visible);
virtual void setContentSize(const Size& size);
virtual void setAnchorPoint(const Vec2& anchorPoint);
virtual void visit(void);
virtual void doAnimationWhenKeyboardMove(float duration, float distance);
virtual void openKeyboard();
virtual void closeKeyboard();
virtual void onEnter(void);
private:
Platform::String^ stringToPlatformString(std::string strSrc);
std::string PlatformStringTostring(Platform::String^ strSrc);
private:
EditBoxWinRT^ m_editBoxWinrt;
Label* m_pLabel;
Label* m_pLabelPlaceHolder;
EditBox::InputMode m_eEditBoxInputMode;
EditBox::InputFlag m_eEditBoxInputFlag;
(EditBox::KeyboardReturnType m_eKeyboardReturnType;
std::string m_strText;
std::string m_strPlaceHolder;
Color3B m_colText;
Color3B m_colPlaceHolder;
int m_nMaxLength;
Size m_EditSize;
};
}
NS_CC_END
#endif //CC_PLATFORM_WINRT
#endif

View File

@ -7,6 +7,7 @@
"README.md",
"build/android-build.py",
"build/cocos2d-win32.vc2012.sln",
"build/cocos2d-win8.1-universal.sln",
"build/cocos2d-wp8.sln",
"build/cocos2d_libs.xcodeproj/project.pbxproj",
"build/cocos2d_tests.xcodeproj/project.pbxproj",
@ -31,6 +32,10 @@
"build/wp8/Cocos2dShaderCompiler/App.xaml",
"build/wp8/Cocos2dShaderCompiler/App.xaml.cpp",
"build/wp8/Cocos2dShaderCompiler/App.xaml.h",
"build/wp8/Cocos2dShaderCompiler/Assets/logo.png",
"build/wp8/Cocos2dShaderCompiler/Assets/smalllogo.png",
"build/wp8/Cocos2dShaderCompiler/Assets/splashscreen.png",
"build/wp8/Cocos2dShaderCompiler/Assets/storelogo.png",
"build/wp8/Cocos2dShaderCompiler/Cocos2dShaderCompiler.sln",
"build/wp8/Cocos2dShaderCompiler/Cocos2dShaderCompiler.vcxproj",
"build/wp8/Cocos2dShaderCompiler/Cocos2dShaderCompiler.vcxproj.filters",
@ -911,6 +916,15 @@
"cocos/platform/win32/CCStdC-win32.cpp",
"cocos/platform/win32/CCStdC-win32.h",
"cocos/platform/win32/compat/stdint.h",
"cocos/platform/win8.1-universal/Cocos2dRenderer.cpp",
"cocos/platform/win8.1-universal/Cocos2dRenderer.h",
"cocos/platform/win8.1-universal/OpenGLES.cpp",
"cocos/platform/win8.1-universal/OpenGLES.h",
"cocos/platform/win8.1-universal/OpenGLESPage.xaml",
"cocos/platform/win8.1-universal/OpenGLESPage.xaml.cpp",
"cocos/platform/win8.1-universal/OpenGLESPage.xaml.h",
"cocos/platform/win8.1-universal/pch.cpp",
"cocos/platform/win8.1-universal/pch.h",
"cocos/platform/winrt/CCApplication.cpp",
"cocos/platform/winrt/CCApplication.h",
"cocos/platform/winrt/CCCommon.cpp",
@ -941,6 +955,8 @@
"cocos/platform/winrt/InputEvent.cpp",
"cocos/platform/winrt/InputEvent.h",
"cocos/platform/winrt/InputEventTypes.h",
"cocos/platform/winrt/Keyboard-winrt.cpp",
"cocos/platform/winrt/Keyboard-winrt.h",
"cocos/platform/winrt/inet_ntop_winrt.cpp",
"cocos/platform/winrt/inet_ntop_winrt.h",
"cocos/platform/winrt/pch.cpp",
@ -1044,6 +1060,7 @@
"cocos/renderer/ccShader_PositionTextureColor_noMVP.vert",
"cocos/renderer/ccShader_PositionTexture_uColor.frag",
"cocos/renderer/ccShader_PositionTexture_uColor.vert",
"cocos/renderer/ccShader_Position_uColor-no-gl_PointSize.vert",
"cocos/renderer/ccShader_Position_uColor.frag",
"cocos/renderer/ccShader_Position_uColor.vert",
"cocos/renderer/ccShaders.cpp",
@ -1076,6 +1093,8 @@
"cocos/ui/UIEditBox/UIEditBoxImpl-stub.cpp",
"cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp",
"cocos/ui/UIEditBox/UIEditBoxImpl-win32.h",
"cocos/ui/UIEditBox/UIEditBoxImpl-winrt.cpp",
"cocos/ui/UIEditBox/UIEditBoxImpl-winrt.h",
"cocos/ui/UIEditBox/UIEditBoxImpl-wp8.cpp",
"cocos/ui/UIEditBox/UIEditBoxImpl-wp8.h",
"cocos/ui/UIEditBox/UIEditBoxImpl.h",

View File

@ -15,10 +15,10 @@
<ClCompile Include="main.cpp">
<Filter>win32</Filter>
</ClCompile>
<ClCompile Include="..\src\AppDelegate.cpp">
<ClCompile Include="..\Classes\AppDelegate.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\HelloWorldScene.cpp">
<ClCompile Include="..\Classes\HelloWorldScene.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
@ -26,10 +26,10 @@
<ClInclude Include="main.h">
<Filter>win32</Filter>
</ClInclude>
<ClInclude Include="..\src\AppDelegate.h">
<ClInclude Include="..\Classes\AppDelegate.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="..\src\HelloWorldScene.h">
<ClInclude Include="..\Classes\HelloWorldScene.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>

View File

@ -0,0 +1,13 @@
<Application
x:Class="cocos2d.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:cocos2d"
xmlns:localData="using:Shared">
<Application.Resources>
<x:String x:Key="AppName">cpp_tests</x:String>
</Application.Resources>
</Application>

View File

@ -0,0 +1,21 @@
#include "App.xaml.h"
#include "OpenGLESPage.xaml.h"
using namespace cocos2d;
App::App()
{
InitializeComponent();
}
void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
{
if (mPage == nullptr)
{
mPage = ref new OpenGLESPage(&mOpenGLES);
}
// Place the page in the current window and ensure that it is active.
Windows::UI::Xaml::Window::Current->Content = mPage;
Windows::UI::Xaml::Window::Current->Activate();
}

View File

@ -0,0 +1,19 @@
#pragma once
#include "app.g.h"
#include "OpenGLES.h"
#include "openglespage.xaml.h"
namespace cocos2d
{
ref class App sealed
{
public:
App();
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
private:
OpenGLESPage^ mPage;
OpenGLES mOpenGLES;
};
}

View File

@ -0,0 +1,85 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "Cocos2dRenderer.h"
#include "AppDelegate.h"
#include "CCGLViewImpl-winrt.h"
#include "CCApplication.h"
#include "cocos2d.h"
// These are used by the shader compilation methods.
#include <vector>
#include <iostream>
#include <fstream>
using namespace Platform;
using namespace Windows::UI::Core;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Graphics::Display;
USING_NS_CC;
Cocos2dRenderer::Cocos2dRenderer(const int width, const int height, CoreDispatcher^ dispatcher, Panel^ panel)
: mApp(nullptr)
, mWidth(width)
, mHeight(height)
, m_dispatcher(dispatcher)
, m_panel(panel)
{
mApp = new AppDelegate();
auto director = cocos2d::Director::getInstance();
GLViewImpl* glview = GLViewImpl::create("Test Cpp");
glview->setDispatcher(dispatcher);
glview->setPanel(panel);
glview->Create(static_cast<float>(width), static_cast<float>(height), DisplayOrientations::Landscape);
director->setOpenGLView(glview);
CCApplication::getInstance()->run();
}
Cocos2dRenderer::~Cocos2dRenderer()
{
delete mApp;
}
// Draws a basic triangle
void Cocos2dRenderer::Draw(GLsizei width, GLsizei height)
{
if (width != mWidth || height != mHeight)
{
mWidth = width;
mHeight = height;
GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(static_cast<float>(width), static_cast<float>(height));
}
GLViewImpl::sharedOpenGLView()->ProcessEvents();
GLViewImpl::sharedOpenGLView()->Render();
}
void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args)
{
GLViewImpl::sharedOpenGLView()->QueuePointerEvent(type, args);
}
void Cocos2dRenderer::QueueKeyBoardEvent(cocos2d::Cocos2dKeyEvent type, Windows::UI::Core::KeyEventArgs^ e)
{
//GLViewImpl::sharedOpenGLView()->QueuePointerEvent(type, e);
}

View File

@ -0,0 +1,47 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
#include <agile.h>
#include "cocos2d.h"
class AppDelegate;
namespace cocos2d
{
class Cocos2dRenderer
{
public:
Cocos2dRenderer(const int width, const int height, Windows::UI::Core::CoreDispatcher^ dispathcer, Windows::UI::Xaml::Controls::Panel^ panel);
~Cocos2dRenderer();
void Draw(GLsizei width, GLsizei height);
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
void QueueKeyBoardEvent(Cocos2dKeyEvent type, Windows::UI::Core::KeyEventArgs^ e);
private:
int mWidth;
int mHeight;
// The AppDelegate for the Cocos2D app
AppDelegate* mApp;
Platform::Agile<Windows::UI::Core::CoreDispatcher> m_dispatcher;
Platform::Agile<Windows::UI::Xaml::Controls::Panel> m_panel;
};
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>e956c24b-f04e-47bf-bf00-746681ae1301</SharedGUID>
<ItemsProjectGuid>{a3ad93e4-0b2f-4c58-9181-69bed2e42e3e}</ItemsProjectGuid>
<ItemsRootNamespace>HelloCpp</ItemsRootNamespace>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\HelloWorldScene.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)App.xaml.cpp">
<DependentUpon>$(MSBuildThisFileDirectory)App.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)OpenGLES.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)OpenGLESPage.xaml.cpp">
<DependentUpon>$(MSBuildThisFileDirectory)OpenGLESPage.xaml</DependentUpon>
</ClCompile>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppMacros.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\HelloWorldScene.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)App.xaml.h">
<DependentUpon>$(MSBuildThisFileDirectory)App.xaml</DependentUpon>
</ClInclude>
<ClCompile Include="$(MSBuildThisFileDirectory)pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClInclude Include="$(MSBuildThisFileDirectory)OpenGLES.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)OpenGLESPage.xaml.h">
<DependentUpon>$(MSBuildThisFileDirectory)OpenGLESPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
</ItemGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<_CustomResource Include="$(MSBuildThisFileDirectory)..\..\Resources\**\*">
<Link>Assets\Resources\%(RecursiveDir)%(FileName)%(Extension)</Link>
<DeploymentContent>true</DeploymentContent>
</_CustomResource>
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)OpenGLESPage.xaml" />
</ItemGroup>
<Target Name="_CollectCustomResources" BeforeTargets="AssignTargetPaths">
<Message Text="Adding resource: %(_CustomResource.Identity) -&gt; %(_CustomResource.Link)" />
<ItemGroup>
<None Include="@(_CustomResource)" />
</ItemGroup>
</Target>
</Project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CLCompile Include="$(MSBuildThisFileDirectory)App.xaml.cpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)App.xaml.h" />
<CLCompile Include="$(MSBuildThisFileDirectory)pch.cpp" />
<ClInclude Include="$(MSBuildThisFileDirectory)pch.h" />
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\Classes\HelloWorldScene.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Cocos2dRenderer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)OpenGLES.cpp" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="$(MSBuildThisFileDirectory)App.xaml" />
</ItemGroup>
<ItemGroup>
<Filter Include="Classes">
<UniqueIdentifier>{38ad799c-8c3c-44a2-8e41-516c8f62f556}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppDelegate.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\AppMacros.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\Classes\HelloWorldScene.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\..\..\..\cocos\platform\win8.1-universal\OpenGLESPage.xaml.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)OpenGLES.h" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)OpenGLESPage.xaml" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,175 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "OpenGLES.h"
using namespace Platform;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
OpenGLES::OpenGLES() :
mEglConfig(nullptr),
mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT)
{
Initialize();
}
OpenGLES::~OpenGLES()
{
Cleanup();
}
void OpenGLES::Initialize()
{
const EGLint configAttributes[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 8,
EGL_STENCIL_SIZE, 8,
EGL_NONE
};
const EGLint displayAttributes[] =
{
// This can be used to configure D3D11. For example, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE could be used.
// This would ask the graphics card to use D3D11 Feature Level 9_3 instead of Feature Level 11_0+.
// On Windows Phone, this would allow the Phone Emulator to act more like the GPUs that are available on real Phone devices.
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_FL9_3_ANGLE,
EGL_NONE,
#else
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_NONE,
#endif
};
const EGLint contextAttributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
// eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in 'displayAttributes' to configure D3D11.
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
if (!eglGetPlatformDisplayEXT)
{
throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT");
}
mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, displayAttributes);
if (mEglDisplay == EGL_NO_DISPLAY)
{
throw Exception::CreateException(E_FAIL, L"Failed to get default EGL display");
}
if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL");
}
EGLint numConfigs = 0;
if (eglGetConfigs(mEglDisplay, NULL, 0, &numConfigs) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to get EGLConfig count");
}
if (eglChooseConfig(mEglDisplay, configAttributes, &mEglConfig, 1, &numConfigs) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig");
}
mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, contextAttributes);
if (mEglContext == EGL_NO_CONTEXT)
{
throw Exception::CreateException(E_FAIL, L"Failed to create EGL context");
}
}
void OpenGLES::Cleanup()
{
if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT)
{
eglDestroyContext(mEglDisplay, mEglContext);
mEglContext = EGL_NO_CONTEXT;
}
if (mEglDisplay != EGL_NO_DISPLAY)
{
eglTerminate(mEglDisplay);
mEglDisplay = EGL_NO_DISPLAY;
}
}
void OpenGLES::Reset()
{
Cleanup();
Initialize();
}
EGLSurface OpenGLES::CreateSurface(SwapChainPanel^ panel, const Size* renderSurfaceSize)
{
if (!panel)
{
throw Exception::CreateException(E_INVALIDARG, L"SwapChainPanel parameter is invalid");
}
EGLSurface surface = EGL_NO_SURFACE;
// Create a PropertySet and initialize with the EGLNativeWindowType.
PropertySet^ surfaceCreationProperties = ref new PropertySet();
surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), panel);
// If a render surface size is specified, add it to the surface creation properties
if (renderSurfaceSize != nullptr)
{
surfaceCreationProperties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(*renderSurfaceSize));
}
surface = eglCreateWindowSurface(mEglDisplay, mEglConfig, reinterpret_cast<IInspectable*>(surfaceCreationProperties), NULL);
if (surface == EGL_NO_SURFACE)
{
throw Exception::CreateException(E_FAIL, L"Failed to create EGL surface");
}
return surface;
}
void OpenGLES::DestroySurface(const EGLSurface surface)
{
if (mEglDisplay != EGL_NO_DISPLAY && surface != EGL_NO_SURFACE)
{
eglDestroySurface(mEglDisplay, surface);
}
}
void OpenGLES::MakeCurrent(const EGLSurface surface)
{
if (eglMakeCurrent(mEglDisplay, surface, surface, mEglContext) == EGL_FALSE)
{
throw Exception::CreateException(E_FAIL, L"Failed to make EGLSurface current");
}
}
EGLBoolean OpenGLES::SwapBuffers(const EGLSurface surface)
{
return (eglSwapBuffers(mEglDisplay, surface));
}

View File

@ -0,0 +1,52 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
// OpenGL ES includes
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
// EGL includes
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglplatform.h>
#include <angle_windowsstore.h>
class OpenGLES
{
public:
OpenGLES();
~OpenGLES();
EGLSurface CreateSurface(Windows::UI::Xaml::Controls::SwapChainPanel^ panel, const Windows::Foundation::Size* renderSurfaceSize);
void DestroySurface(const EGLSurface surface);
void MakeCurrent(const EGLSurface surface);
EGLBoolean SwapBuffers(const EGLSurface surface);
void Reset();
private:
void Initialize();
void Cleanup();
private:
EGLDisplay mEglDisplay;
EGLContext mEglContext;
EGLConfig mEglConfig;
};

View File

@ -0,0 +1,28 @@
<Page
x:Class="cocos2d.OpenGLESPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:cocos2d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<SwapChainPanel x:Name="swapChainPanel">
<Button x:Name="cocos2d_editbox" Visibility="Collapsed" Height="1">
<Button.Flyout>
<Flyout x:Name="cocos2d_editbox_flyout">
<Grid VerticalAlignment="Top" x:Name="cocos2d_editbox_grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="120" />
<ColumnDefinition Width="120" />
</Grid.ColumnDefinitions>
<Button x:Name="cocos2d_editbox_done" Grid.Column="1" VerticalAlignment="Center">Done</Button>
<Button x:Name="cocos2d_editbox_cancel" Grid.Column="2" VerticalAlignment="Center">Cancel</Button>
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</SwapChainPanel>
</Page>

View File

@ -1,10 +1,40 @@
#include "pch.h"
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#include "App.xaml.h"
#include "OpenGLESPage.xaml.h"
using namespace cpp_tests;
using namespace cocos2d;
using namespace Platform;
using namespace Concurrency;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::Graphics::Display;
using namespace Windows::System::Threading;
using namespace Windows::UI::Core;
using namespace Windows::UI::Input;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
OpenGLESPage::OpenGLESPage() :
OpenGLESPage(nullptr)
@ -16,7 +46,8 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
mOpenGLES(openGLES),
mRenderSurface(EGL_NO_SURFACE),
mCustomRenderSurfaceSize(0,0),
mUseCustomRenderSurfaceSize(false)
mUseCustomRenderSurfaceSize(false),
m_coreInput(nullptr)
{
InitializeComponent();
@ -31,7 +62,11 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
this->Loaded +=
ref new Windows::UI::Xaml::RoutedEventHandler(this, &OpenGLESPage::OnPageLoaded);
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
mSwapChainPanelSize = { swapChainPanel->RenderSize.Width, swapChainPanel->RenderSize.Height };
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
Windows::UI::ViewManagement::StatusBar::GetForCurrentView()->HideAsync();
#else
// Disable all pointer visual feedback for better performance when touching.
// This is not supported on Windows Phone applications.
auto pointerVisualizationSettings = Windows::UI::Input::PointerVisualizationSettings::GetForCurrentView();
@ -39,7 +74,28 @@ OpenGLESPage::OpenGLESPage(OpenGLES* openGLES) :
pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;
#endif
mSwapChainPanelSize = { swapChainPanel->RenderSize.Width, swapChainPanel->RenderSize.Height };
// Register our SwapChainPanel to get independent input pointer events
auto workItemHandler = ref new WorkItemHandler([this](IAsyncAction ^)
{
// The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
m_coreInput = swapChainPanel->CreateCoreIndependentInputSource(
Windows::UI::Core::CoreInputDeviceTypes::Mouse |
Windows::UI::Core::CoreInputDeviceTypes::Touch |
Windows::UI::Core::CoreInputDeviceTypes::Pen
);
// Register for pointer events, which will be raised on the background thread.
m_coreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerPressed);
m_coreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerMoved);
m_coreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &OpenGLESPage::OnPointerReleased);
// Begin processing input messages as they're delivered.
m_coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
});
// Run task on a dedicated high priority background thread.
m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);
}
OpenGLESPage::~OpenGLESPage()
@ -55,6 +111,32 @@ void OpenGLESPage::OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::Rou
StartRenderLoop();
}
void OpenGLESPage::OnPointerPressed(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerPressed, e);
}
}
void OpenGLESPage::OnPointerMoved(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerMoved, e);
}
}
void OpenGLESPage::OnPointerReleased(Object^ sender, PointerEventArgs^ e)
{
if (m_renderer)
{
m_renderer->QueuePointerEvent(PointerEventType::PointerReleased, e);
}
}
void OpenGLESPage::OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args)
{
if (args->Visible && mRenderSurface != EGL_NO_SURFACE)
@ -101,7 +183,7 @@ void OpenGLESPage::CreateRenderSurface()
// The render surface will be automatically scaled to fit the entire window. Using a
// smaller sized render surface can result in a performance gain.
//
//mCustomRenderSurfaceSize = Size(340, 400);
//mCustomRenderSurfaceSize = Size(800, 600);
//mUseCustomRenderSurfaceSize = true;
mRenderSurface = mOpenGLES->CreateSurface(swapChainPanel, mUseCustomRenderSurfaceSize ? &mCustomRenderSurfaceSize : nullptr);
@ -143,21 +225,29 @@ void OpenGLESPage::StartRenderLoop()
return;
}
auto dispatcher = Windows::UI::Xaml::Window::Current->CoreWindow->Dispatcher;
// Create a task for rendering that will be run on a background thread.
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this](Windows::Foundation::IAsyncAction ^ action)
auto workItemHandler = ref new Windows::System::Threading::WorkItemHandler([this, dispatcher](Windows::Foundation::IAsyncAction ^ action)
{
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
mOpenGLES->MakeCurrent(mRenderSurface);
HelloTriangleRenderer renderer;
GLsizei panelWidth = 0;
GLsizei panelHeight = 0;
GetSwapChainPanelSize(&panelWidth, &panelHeight);
if (m_renderer.get() == nullptr)
{
m_renderer = std::make_shared<Cocos2dRenderer>(panelWidth, panelHeight, dispatcher, swapChainPanel);
}
while (action->Status == Windows::Foundation::AsyncStatus::Started)
{
GLsizei panelWidth = 0;
GLsizei panelHeight = 0;
GetSwapChainPanelSize(&panelWidth, &panelHeight);
renderer.Draw(panelWidth, panelHeight);
m_renderer.get()->Draw(panelWidth, panelHeight);
// The call to eglSwapBuffers might not be successful (i.e. due to Device Lost)
// If the call fails, then we must reinitialize EGL and the GL resources.
@ -165,6 +255,7 @@ void OpenGLESPage::StartRenderLoop()
{
// XAML objects like the SwapChainPanel must only be manipulated on the UI thread.
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
//swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::High, ref new Windows::UI::Core::DispatchedHandler([=]()
{
RecoverFromLostDevice();
}, CallbackContext::Any));

View File

@ -0,0 +1,71 @@
/*
* cocos2d-x http://www.cocos2d-x.org
*
* Copyright (c) 2010-2014 - cocos2d-x community
*
* Portions Copyright (c) Microsoft Open Technologies, Inc.
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
#pragma once
#include "OpenGLES.h"
#include "OpenGLESPage.g.h"
#include <memory>
#include "Cocos2dRenderer.h"
namespace cocos2d
{
public ref class OpenGLESPage sealed
{
public:
OpenGLESPage();
virtual ~OpenGLESPage();
internal:
OpenGLESPage(OpenGLES* openGLES);
private:
void OnPageLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
void OnSwapChainPanelSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
void GetSwapChainPanelSize(GLsizei* width, GLsizei* height);
void CreateRenderSurface();
void DestroyRenderSurface();
void RecoverFromLostDevice();
void StartRenderLoop();
void StopRenderLoop();
OpenGLES* mOpenGLES;
std::shared_ptr<cocos2d::Cocos2dRenderer> m_renderer;
Windows::Foundation::Size mSwapChainPanelSize;
Concurrency::critical_section mSwapChainPanelSizeCriticalSection;
Windows::Foundation::Size mCustomRenderSurfaceSize;
bool mUseCustomRenderSurfaceSize;
EGLSurface mRenderSurface; // This surface is associated with a swapChainPanel on the page
Concurrency::critical_section mRenderSurfaceCriticalSection;
Windows::Foundation::IAsyncAction^ mRenderLoopWorker;
// Track user input on a background worker thread.
Windows::Foundation::IAsyncAction^ m_inputLoopWorker;
Windows::UI::Core::CoreIndependentInputSource^ m_coreInput;
// Independent input handling functions.
void OnPointerPressed(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
void OnPointerMoved(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
void OnPointerReleased(Platform::Object^ sender, Windows::UI::Core::PointerEventArgs^ e);
};
}

View File

@ -0,0 +1 @@
#include "pch.h"

View File

@ -0,0 +1,14 @@
//
// pch.h
// Header for standard system include files.
//
#pragma once
#include <collection.h>
#include <ppltasks.h>
#include "cocos2d.h"
#include "cocos-ext.h"

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

View File

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{79a8fcda-4b12-4dd1-b676-ff148d651638}</ProjectGuid>
<RootNamespace>cocos2d</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>8.1</ApplicationTypeRevision>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="..\HelloCpp.Shared\HelloCpp.Shared.vcxitems" Label="Shared" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_platform.props" />
<Import Project="..\..\..\..\cocos\2d\winrt_8.1_props\cocos2d_winrt_8.1_app.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<PackageCertificateKeyFile>HelloCpp.Windows_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundlePlatforms>x86</AppxBundlePlatforms>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalOptions>/bigobj /Zm200 %(AdditionalOptions)</AdditionalOptions>
<DisableSpecificWarnings>4453;28204;4756;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>../../Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="HelloCpp.Windows_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Logo.scale-100.png" />
<Image Include="Assets\SmallLogo.scale-100.png" />
<Image Include="Assets\StoreLogo.scale-100.png" />
<Image Include="Assets\SplashScreen.scale-100.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\cocos\2d\libcocos2d_8_1\libcocos2d_8_1\libcocos2d_8_1.Windows\libcocos2d_8_1.Windows.vcxproj">
<Project>{9335005f-678e-4e8e-9b84-50037216aec8}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\cocos\editor-support\spine\proj.win8.1-universal\libSpine.Windows\libSpine.Windows.vcxproj">
<Project>{f3550fe0-c795-44f6-8feb-093eb68143ae}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\external\Box2D\proj.win8.1-universal\libbox2d.Windows\libbox2d.Windows.vcxproj">
<Project>{3b26a12d-3a44-47ea-82d2-282660fc844d}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More