SlideShare a Scribd company logo
1 of 30
@splhack
cocos2d +
Loading
Loading.......
@yuroyuro: 31 May 2011




            http://twitter.com/#!/yuroyoro/status/75399664496680960
cocos2d
          RunLoop




cocos2d             CADisplayLink
CADisplayLink




RunLoop
VSYNC
VSYNC
VSYNC


Vertical Synchronizing signal
VRAM
VSYNC
CADisplayLink

RunLoop VSYNC
CADisplayLink


iOS      1/60

      60FPS

16.666
1/60

             VSYNC

1/60 → 2/60(1/30) → 3/60(1/20)
      → 4/60(1/15) → ...
RunLoop
          (Blocking)
RunLoop
          (Blocking)
RunLoop
cocos2d



 CCTextureCache
 - (void)addImageAsync:target:selector:
addImageAsync


•
•                       GL API


    (EAGLContext sharegroup)
addImageAsync


•
•OpenGL ES
•glTexImage2D
 (        GL          )
addImageAsync



•
“


RunLoop        Main Queue
Global Queue                Serial Queue   ”

       iOS 4
Grand Central Dispatch


   GCD

          iOS 4
Grand Central Dispatch

         Global Queue
         Serial Queue

addImageAsync
Grand Central Dispatch
cocos2d + 非同期

More Related Content

Similar to cocos2d + 非同期

みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
techtalkdwango
 
Iphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2DIphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2D
creagamers
 
Identifying Hotspots in Software Build Processes
Identifying Hotspots in Software Build ProcessesIdentifying Hotspots in Software Build Processes
Identifying Hotspots in Software Build Processes
Shane McIntosh
 

Similar to cocos2d + 非同期 (20)

Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
 
みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
みゆっき☆Think#4 「こんどはiPhoneに触ってみるよ!」
 
Iphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2DIphone and Ipad development Game with Cocos2D
Iphone and Ipad development Game with Cocos2D
 
Accelerometer and Open GL
Accelerometer and Open GLAccelerometer and Open GL
Accelerometer and Open GL
 
Accelerometer and OpenGL
Accelerometer and OpenGLAccelerometer and OpenGL
Accelerometer and OpenGL
 
Cansecwest_16_Dont_Trust_Your_Eye_Apple_Graphics_Is_Compromised
Cansecwest_16_Dont_Trust_Your_Eye_Apple_Graphics_Is_CompromisedCansecwest_16_Dont_Trust_Your_Eye_Apple_Graphics_Is_Compromised
Cansecwest_16_Dont_Trust_Your_Eye_Apple_Graphics_Is_Compromised
 
How to Use OpenMP on Native Activity
How to Use OpenMP on Native ActivityHow to Use OpenMP on Native Activity
How to Use OpenMP on Native Activity
 
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
 
Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)Embedded Graphics Drivers in Mesa (ELCE 2019)
Embedded Graphics Drivers in Mesa (ELCE 2019)
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
The journey of asyncio adoption in instagram
The journey of asyncio adoption in instagramThe journey of asyncio adoption in instagram
The journey of asyncio adoption in instagram
 
about "AIR for Android" (at FxUG No135 in Toyama.)
about "AIR for Android"  (at FxUG No135 in Toyama.)about "AIR for Android"  (at FxUG No135 in Toyama.)
about "AIR for Android" (at FxUG No135 in Toyama.)
 
I pv6 mrtg_20111025
I pv6 mrtg_20111025I pv6 mrtg_20111025
I pv6 mrtg_20111025
 
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
Build 2016 - B880 - Top 6 Reasons to Move Your C++ Code to Visual Studio 2015
 
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & CouchbaseBulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
 
IL2CPP: Debugging and Profiling
IL2CPP: Debugging and ProfilingIL2CPP: Debugging and Profiling
IL2CPP: Debugging and Profiling
 
Computer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptxComputer Graphics with OpenGL presentation Slides.pptx
Computer Graphics with OpenGL presentation Slides.pptx
 
Sergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with StarlingSergey Gonchar - Fast rendering with Starling
Sergey Gonchar - Fast rendering with Starling
 
Identifying Hotspots in Software Build Processes
Identifying Hotspots in Software Build ProcessesIdentifying Hotspots in Software Build Processes
Identifying Hotspots in Software Build Processes
 
Pc54
Pc54Pc54
Pc54
 

Recently uploaded

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

cocos2d + 非同期

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. 非同期話の前に、メインループの話。cocos2dでもRunLoopベース。\n\n
  8. \n
  9. \n
  10. オブジェクトを動かしているシーンで、VSYNC無視して画面更新すると、\nオブジェクトがぶったぎれて見える\n\n
  11. \n
  12. 垂直同期信号って何? ブラウン管テレビの時代までさかのぼります\nビームが左上から右下にかけて徐々に動いて、VRAMをブラウン管に反映していく\n一番下まで行って、一番下から一番上にもどるとこを垂直帰線区間。この間、絵は更新されない\n
  13. ビームが戻る垂直帰線区間内に画面を更新させるためにVSYNCは存在する\n垂直帰線区間外にVRAMを更新すると残念なことになる。\niPhoneでも基本同じ。ブラウン管じゃなくて液晶ディスプレイ。\n
  14. CADisplayLinkを使うと、RunLoopがVSYNCに同期してループする\n
  15. 1回のループの時間が1/60秒\n
  16. 1/60 ぬめぬめ動く\n
  17. データをロードしてRunLoopをブロック\nフレームレート低下どころの話ではない\n画面止まっちゃう\n
  18. \n
  19. まずやっかいなのがテクスチャを非同期で読み込む方法。でもcocos2dだと簡単です。\n
  20. addImageAsyncを実際にどう使うか、この本を読んでいただくか、ぐぐってもらうとして\n
  21. どういう実装になっているか\n
  22. 通常メインスレッド以外でOpenGL ES APIを呼び出せば例外発生\n
  23. \n
  24. \n
  25. \n
  26. ただし、コールバックは呼び出し元ではなく、メインスレッドで呼び出される\n
  27. iOS 4プログラミングブックの第5章をぜひ読んでくださいませ\n
  28. \n