<small id='HIyno'></small><noframes id='HIyno'>

      <bdo id='HIyno'></bdo><ul id='HIyno'></ul>

    1. <tfoot id='HIyno'></tfoot>
      <legend id='HIyno'><style id='HIyno'><dir id='HIyno'><q id='HIyno'></q></dir></style></legend>
      <i id='HIyno'><tr id='HIyno'><dt id='HIyno'><q id='HIyno'><span id='HIyno'><b id='HIyno'><form id='HIyno'><ins id='HIyno'></ins><ul id='HIyno'></ul><sub id='HIyno'></sub></form><legend id='HIyno'></legend><bdo id='HIyno'><pre id='HIyno'><center id='HIyno'></center></pre></bdo></b><th id='HIyno'></th></span></q></dt></tr></i><div id='HIyno'><tfoot id='HIyno'></tfoot><dl id='HIyno'><fieldset id='HIyno'></fieldset></dl></div>
      1. 着色器程序在 Cocos2d 2.2 Obj.C iOS 12 中不起作用

        时间:2024-08-12
        • <i id='pAHSF'><tr id='pAHSF'><dt id='pAHSF'><q id='pAHSF'><span id='pAHSF'><b id='pAHSF'><form id='pAHSF'><ins id='pAHSF'></ins><ul id='pAHSF'></ul><sub id='pAHSF'></sub></form><legend id='pAHSF'></legend><bdo id='pAHSF'><pre id='pAHSF'><center id='pAHSF'></center></pre></bdo></b><th id='pAHSF'></th></span></q></dt></tr></i><div id='pAHSF'><tfoot id='pAHSF'></tfoot><dl id='pAHSF'><fieldset id='pAHSF'></fieldset></dl></div>
          <tfoot id='pAHSF'></tfoot>
            <tbody id='pAHSF'></tbody>

          <small id='pAHSF'></small><noframes id='pAHSF'>

                <legend id='pAHSF'><style id='pAHSF'><dir id='pAHSF'><q id='pAHSF'></q></dir></style></legend>
                  <bdo id='pAHSF'></bdo><ul id='pAHSF'></ul>
                • 本文介绍了着色器程序在 Cocos2d 2.2 Obj.C iOS 12 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  代码:

                    [lightRender beginWithClear:0 g:0 b:0 a:0];
                  
                      self.shaderProgram = [[CCShaderCache sharedShaderCache] programForKey:kCCShader_PositionColor];
                  
                      CC_NODE_DRAW_SETUP();
                  
                      CGPoint vertices[3];
                      ccColor4F colors[3];
                  
                      CGPoint mid = BODY_POSITION(cursor.body);
                  
                      float radius = LIGHT_RANGE * lightRadius;             // - (CCRANDOM_0_1() * LIGHT_RANGE * .015);
                  
                      float initialAlpha = .7f;
                  
                      for (int i = 0; i < LIGHT_PRECISION; i++)
                      {
                          int nVertices = 0;
                          float angle = 2*M_PI/LIGHT_PRECISION * i;
                          float nextAngle = 2*M_PI/LIGHT_PRECISION * (i+1);
                          int n = i + 1;
                          if (n == LIGHT_PRECISION)
                              n = 0;
                  
                          vertices[nVertices] = ccpAdd(mid, ccp(cosf(angle) * radius * lightLength[i], sinf(angle) * radius * lightLength[i]));
                          colors[nVertices++] = (ccColor4F){1, 1, .9, initialAlpha * (1 - lightLength[i])};
                          vertices[nVertices] = ccpAdd(mid, ccp(cosf(nextAngle) * radius * lightLength[n], sinf(nextAngle) * radius * lightLength[n]));
                          colors[nVertices++] = (ccColor4F){1, 1, .9, initialAlpha * (1 - lightLength[n])};
                          vertices[nVertices] = mid;
                          colors[nVertices++] = (ccColor4F){1, 1, .8, initialAlpha};
                  
                          ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position  | kCCVertexAttribFlag_Color);
                  
                          glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
                          glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, colors);
                          glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
                          glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)nVertices);
                      }
                  
                      [lightRender end];
                  

                  CC_NODE_DRAW_SETUP 代码:

                  CC_NODE_DRAW_SETUP Code:

                  #define CC_NODE_DRAW_SETUP()                                                                    
                  do {                                                                                            
                      ccGLEnable( _glServerState );                                                               
                      NSAssert1(_shaderProgram, @"No shader program set for node: %@", self);                     
                      [_shaderProgram use];                                                                       
                      [_shaderProgram setUniformsForBuiltins];                                    
                  } while(0)
                  

                  如何使用 Cocos2d 2.2 Obj.C 项目修复 iOS12 中的着色器代码?如果我在 iOS 7 模拟器中运行,它可以完美运行..相同的代码在 iOS 12 中不起作用

                  How to fix shader code in iOS12 with Cocos2d 2.2 Obj.C project ? If I run in iOS 7 simulator it works perfect..same code not working in iOS 12

                  推荐答案

                  修复 Cocos2d 中的 Shaders 问题.

                  Fixed Shaders Problem in Cocos2d.

                  在上面的代码中,主要问题是 CGFloat...将它转换为所有顶点的浮点数.

                  In Above code, main problem is CGFloat...converted it to float for all vertices.

                  我还从 Cocos2d-x 中获取了与着色器相关的文件,并将其转换为 Cocos2d 的 obj.C.

                  Also I took shaders related files from Cocos2d-x and converted it to obj.C for Cocos2d.

                  现在所有着色器都可以在 Cocos2d v2.2 Obj.C iOS 12、iPhoneX/XR/XSMax 中完美运行..

                  Now all shaders working Perfect in Cocos2d v2.2 Obj.C iOS 12, iPhoneX/XR/XSMax also..

                  编码愉快!干杯:)

                  这篇关于着色器程序在 Cocos2d 2.2 Obj.C iOS 12 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Objective C - XCode无法识别if语句之外的变量 下一篇:cocos2d中没有正确检测到CGPath

                  相关文章

                • <tfoot id='aMsi9'></tfoot>
                  <i id='aMsi9'><tr id='aMsi9'><dt id='aMsi9'><q id='aMsi9'><span id='aMsi9'><b id='aMsi9'><form id='aMsi9'><ins id='aMsi9'></ins><ul id='aMsi9'></ul><sub id='aMsi9'></sub></form><legend id='aMsi9'></legend><bdo id='aMsi9'><pre id='aMsi9'><center id='aMsi9'></center></pre></bdo></b><th id='aMsi9'></th></span></q></dt></tr></i><div id='aMsi9'><tfoot id='aMsi9'></tfoot><dl id='aMsi9'><fieldset id='aMsi9'></fieldset></dl></div>

                    <bdo id='aMsi9'></bdo><ul id='aMsi9'></ul>

                  <small id='aMsi9'></small><noframes id='aMsi9'>

                  <legend id='aMsi9'><style id='aMsi9'><dir id='aMsi9'><q id='aMsi9'></q></dir></style></legend>