• <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>

            厚積薄發,滴水穿石

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

            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 閱讀(1810) 評論(0)  編輯 收藏 引用 所屬分類: IOS

            久久久久亚洲精品无码网址| 日本福利片国产午夜久久| 久久亚洲国产中v天仙www| 久久精品a亚洲国产v高清不卡| 九九久久自然熟的香蕉图片| 久久国产乱子精品免费女| 久久国产成人亚洲精品影院| 中文精品久久久久人妻| 久久国产乱子伦免费精品| 66精品综合久久久久久久| 国产精品久久久天天影视香蕉 | 国产精品久久久久久久久久影院| 日韩美女18网站久久精品 | 狠狠88综合久久久久综合网 | 99热成人精品热久久669| 久久久国产精品福利免费| 美女久久久久久| 97久久久久人妻精品专区| 一级a性色生活片久久无少妇一级婬片免费放| 久久久久女教师免费一区| 久久婷婷五月综合国产尤物app| 国产精品免费久久久久电影网| 久久久久久精品免费免费自慰| 久久996热精品xxxx| 久久精品天天中文字幕人妻| 欧美久久综合九色综合| 伊人久久综在合线亚洲2019 | 88久久精品无码一区二区毛片| 国产精品亚洲综合久久| 精品无码久久久久久久动漫| 国产精品久久久久久福利69堂| 综合网日日天干夜夜久久| 久久久久久毛片免费看| 国产精品女同一区二区久久| 久久久久综合网久久| 久久久久久亚洲精品成人| 丁香色欲久久久久久综合网| 综合久久给合久久狠狠狠97色| 久久精品国产WWW456C0M| 久久国产免费| 亚洲国产成人精品91久久久|