• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            厚積薄發(fā),滴水穿石

            搬家到主站了:http://www.cnblogs.com/cokecoffe/
            隨筆 - 45, 文章 - 8, 評(píng)論 - 12, 引用 - 0
            數(shù)據(jù)加載中……

            OpenGL ES multithreading and EAGLSharegroup

            http://developer.apple.com/library/ios/#qa/qa1612/_index.html
            Technical Q&A QA1612

            OpenGL ES multithreading and EAGLSharegroup

            Q:  In my multithreading OpenGL ES application, I load textures (or vertices) on a secondary thread then draw them onto screen on the main thread. Occasionally I see blank images or application freezes. What could be causing this?

            A: In my multithreading OpenGL ES application, I load textures (or vertices) on a secondary thread then draw them onto screen on the main thread. Occasionally I see blank images or application freezes. What could be causing this?

            It is very likely that the main and background threads are accessing the same OpenGL ES context simultaneously.

            OpenGL ES commands for a specific context are not reentrant. You should never have more than one thread accessing a single context at the same time. It is highly recommended that you use only one thread per context.

            Listing 1 demonstrates how to create and make current a context contextB using the sharegroup property (an EAGLSharegroup object) obtained from another already-allocated context contextA. Such contexts that belong to the same sharegroup can share resources, for example, textures, FBOs, etc. So you may use contextB on the secondary thread to create textures, and contextA on the main thread to draw the textures onto screen.


            Listing 1  Creating a context belonging to the same sharegroup

            contextB = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1      
                                         sharegroup:contextA.sharegroup]; 
            if (!contextB || ![EAGLContext setCurrentContext:contextB]) 
            {       
             // Handle errors here 
            }

             

            When you want to modify a resource on one context, you must first make sure it is not currently in use on another, even if you are accessing them from different threads. Once you modify it, its state is undefined until flushing and binding the object have been completed. You should never use an undefined object, whether you access it from a different context or not.

            Take a texture as an example. Listing 2 shows the correct way to deal with multiple contexts. Any other ordering will not ensure consistent and correct behavior. It may result in data corruption, leaks, or crashes otherwise.

            Listing 2  Modifying a texture on context B prior to using it on context A


            // 1. Ensure context A is not bound to the texture
             [EAGLContext setCurrentContext:contextA];
             glBindTexture(GL_TEXTURE_2D, 0);  

            // 2. Call flush on context A  
            glFlush();   

            // 3. Modify the texture on context B 
            [EAGLContext setCurrentContext:contextB]; 
            glBindTexture(GL_TEXTURE_2D, texId); 

             //
             Modify the texture data here
             //

            // 4. Call flush on context B 
            glFlush();  
             
            // 5. Rebind the texture on context A 
            [EAGLContext setCurrentContext:contextA];
             glBindTexture(GL_TEXTURE_2D, texId); 

            // 6. Use the texture as normal on context A

             

            For more information on the EAGLContext/-initWithAPI:sharegroup: API and the sharegroup property, see the EAGLContext Class Reference.

            posted on 2011-11-15 17:36 Wangkeke 閱讀(1811) 評(píng)論(0)  編輯 收藏 引用 所屬分類: IOS

            国产日韩欧美久久| 欧美久久久久久精选9999| 亚洲欧美日韩久久精品第一区| 欧美久久久久久| 亚洲色大成网站WWW久久九九| 国产一久久香蕉国产线看观看| 精品国产91久久久久久久a| 久久久久久久91精品免费观看| 狠狠色婷婷久久一区二区三区| 久久乐国产精品亚洲综合| 亚洲熟妇无码另类久久久| 女同久久| 91久久国产视频| 久久国产色AV免费观看| 午夜精品久久影院蜜桃| 观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 | 国产亚洲精品自在久久| 久久频这里精品99香蕉久| 成人精品一区二区久久久| 日产精品久久久久久久性色| 欧美精品一区二区久久| 久久黄色视频| 国产精品成人99久久久久 | 久久精品国产99久久久古代| 久久精品不卡| 国产毛片久久久久久国产毛片 | 久久久久久av无码免费看大片| 精品综合久久久久久888蜜芽| 亚洲天堂久久久| 精品久久久一二三区| 四虎影视久久久免费| 人妻无码久久精品| 亚洲国产精品成人AV无码久久综合影院| 国产一级做a爰片久久毛片| 精品免费久久久久久久| 国产亚洲精久久久久久无码| 久久国产精品一国产精品金尊| 亚洲精品国产字幕久久不卡| 人妻精品久久久久中文字幕一冢本| 久久大香萑太香蕉av| 午夜欧美精品久久久久久久|