Search Unity

Newbie Help! Errors with basic ios export

Discussion in 'iOS and tvOS' started by FlashX, Sep 24, 2014.

  1. FlashX

    FlashX

    Joined:
    Nov 16, 2013
    Posts:
    51
    Hi guys,

    Ive set up a basic scene in unity (a cube) and exported it out to xcode (iOS) however I'm receiving this error message when i go to view it on my ipad:

    Semantic Issue
    Use of undeclared identifier
    'GL_BGRA_EXT'

    When i click on that error it shows this:

    Code (csharp):
    1.  
    2.  
    3.  
    4. #include "CMVideoSampling.h"
    5.  
    6.  
    7.  
    8. #include "CVTextureCache.h"
    9.  
    10. #include "GLESHelper.h"
    11.  
    12.  
    13.  
    14. #include <OpenGLES/ES2/gl.h>
    15.  
    16. #include <AVFoundation/AVFoundation.h>
    17.  
    18.  
    19.  
    20. void CMVideoSampling_Initialize(CMVideoSampling* sampling)
    21.  
    22. {
    23.  
    24.     ::memset(sampling, 0x00, sizeof(CMVideoSampling));
    25.  
    26.     if(CanUseCVTextureCache())
    27.  
    28.         sampling->cvTextureCache = CreateCVTextureCache();
    29.  
    30.     else
    31.  
    32.         GLES_CHK(glGenTextures(2, (GLuint*)sampling->glTex));
    33.  
    34. }
    35.  
    36.  
    37.  
    38. void CMVideoSampling_Uninitialize(CMVideoSampling* sampling)
    39.  
    40. {
    41.  
    42.     if(sampling->cvTextureCacheTexture)
    43.  
    44.     {
    45.  
    46.         CFRelease(sampling->cvTextureCacheTexture);
    47.  
    48.         sampling->cvTextureCacheTexture = 0;
    49.  
    50.     }
    51.  
    52.     if(sampling->cvTextureCache)
    53.  
    54.     {
    55.  
    56.         CFRelease(sampling->cvTextureCache);
    57.  
    58.         sampling->cvTextureCache = 0;
    59.  
    60.     }
    61.  
    62.     if(sampling->glTex[0])
    63.  
    64.     {
    65.  
    66.         GLES_CHK(glDeleteTextures(2, (GLuint*)sampling->glTex));
    67.  
    68.         sampling->glTex[0] = sampling->glTex[1] = 0;
    69.  
    70.     }
    71.  
    72. }
    73.  
    74.  
    75.  
    76. int CMVideoSampling_SampleBuffer(CMVideoSampling* sampling, void* buffer, int w, int h)
    77.  
    78. {
    79.  
    80.     int retTex = 0;
    81.  
    82.  
    83.  
    84.     CVImageBufferRef cvImageBuffer = CMSampleBufferGetImageBuffer((CMSampleBufferRef)buffer);
    85.  
    86.     if(CanUseCVTextureCache())
    87.  
    88.     {
    89.  
    90.         if(sampling->cvTextureCacheTexture)
    91.  
    92.         {
    93.  
    94.             CFRelease(sampling->cvTextureCacheTexture);
    95.  
    96.             FlushCVTextureCache(sampling->cvTextureCache);
    97.  
    98.         }
    99.  
    100.         sampling->cvTextureCacheTexture = CreateTextureFromCVTextureCache(sampling->cvTextureCache, cvImageBuffer, w, h, GL_BGRA_EXT, GL_RGBA, GL_UNSIGNED_BYTE);
    101.  
    102.         if(sampling->cvTextureCacheTexture)
    103.  
    104.             retTex = GetGLTextureFromCVTextureCache(sampling->cvTextureCacheTexture);
    105.  
    106.     }
    107.  
    108.     else
    109.  
    110.     {
    111.  
    112.         retTex = sampling->glTex[1];
    113.  
    114.  
    115.  
    116.         CVPixelBufferLockBaseAddress(cvImageBuffer,0);
    117.  
    118.         void* texData = CVPixelBufferGetBaseAddress(cvImageBuffer);
    119.  
    120.  
    121.  
    122.         // TODO: provide unity interface?
    123.  
    124.         GLES_CHK(glBindTexture(GL_TEXTURE_2D, retTex));
    125.  
    126.         GLES_CHK(glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, texData));
    127.  
    128.  
    129.  
    130.         CVPixelBufferUnlockBaseAddress(cvImageBuffer,0);
    131.  
    132.  
    133.  
    134.         // swap read and draw textures
    135.  
    136.         {
    137.  
    138.             int __temp = sampling->glTex[0];
    139.  
    140.             sampling->glTex[0] = sampling->glTex[1];
    141.  
    142.             sampling->glTex[1] = __temp;
    143.  
    144.         }
    145.  
    146.     }
    147.  
    148.  
    149.  
    150.     GLES_CHK(glBindTexture(GL_TEXTURE_2D, retTex));
    151.  
    152.     GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
    153.  
    154.     GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
    155.  
    156.     GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
    157.  
    158.     GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
    159.  
    160.     GLES_CHK(glBindTexture(GL_TEXTURE_2D, 0));
    161.  
    162.  
    163.  
    164.     return retTex;
    165.  
    166. }
    167.  
    168.  
    169.  
    170. int  CMVideoSampling_LastSampledTexture(CMVideoSampling* sampling)
    171.  
    172. {
    173.  
    174.     return sampling->cvTextureCacheTexture ? GetGLTextureFromCVTextureCache(sampling->cvTextureCacheTexture) : sampling->glTex[0];
    175.  
    176. }
    177.  
    178.  

    Ive signed up for a developer account etc and followed everything to the best of my ability through here: http://mobilegbl.wordpress.com/2013/05/21/from-unity-to-an-ios-device/


    I really need help, I'm such a noob when it comes to this :/
     
  2. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    745
    Which Unity Version and XCode do you use? Maybe you need to specify the egl3 header too.

    Code (CSharp):
    1. #include <OpenGLES/ES3/gl.h>
     
  3. FlashX

    FlashX

    Joined:
    Nov 16, 2013
    Posts:
    51
    Hi David,

    I'm running unity 4.5.4 (a fresh install) and xcode version 6.0.1 (6A317)

    Forgive me for being a noob, but where would i put the above #include?


    Cheers
     
  4. FlashX

    FlashX

    Joined:
    Nov 16, 2013
    Posts:
    51
    oh my gosh! I think ive got it working! I think my machine just needed a good reboot! Thanks for your help anyways David ;)
     
    David-Berger likes this.
  5. David-Berger

    David-Berger

    Unity Technologies

    Joined:
    Jul 16, 2014
    Posts:
    745
    Oh, that's good to hear! However, Unity 4.5.4p1 is the latest patch with includes some good fixes. The include would be added to the other include in your code. But if it works now, there is no need to try it anyway! Glad it works now.
     
  6. auggd

    auggd

    Joined:
    Feb 11, 2014
    Posts:
    1
    That fixed include is not working for me when I build with an old version of Unity 4.3 against XCode 6.

    Anyone got a fix for older Unity builds? We can't upgrade Unity for this project.
     
  7. beuzel

    beuzel

    Joined:
    Jul 22, 2012
    Posts:
    16
    Same problem like "Explore Engage" with Unity 4.3.4 and xcode 6.0.1. here. Also it is problematic to upgrade Unity in this project.
     
  8. Quirkstreet

    Quirkstreet

    Joined:
    Aug 25, 2013
    Posts:
    1
    Same problem here, too. Just need to run an original test build once on the simulator to document it ... Project was built on Unity 4.3.4 and I'm using Xcode 6.0.1. Wishing I hadn't upgraded Xcode. Any workarounds gratefully received.

    The above solution didn't work for me either.
     
  9. VIPINSIRWANI

    VIPINSIRWANI

    Joined:
    Apr 3, 2013
    Posts:
    2
  10. pallav_panda

    pallav_panda

    Joined:
    Jan 26, 2013
    Posts:
    4
    EbenK likes this.
  11. raimon.massanet

    raimon.massanet

    Joined:
    Feb 26, 2013
    Posts:
    4
  12. Amanna

    Amanna

    Joined:
    Dec 16, 2014
    Posts:
    2
    Thanks " VIPINSIRWANI " . It's working for 4.3.4 and xcode 6.1.1 ..
     
  13. taxvi

    taxvi

    Joined:
    Feb 18, 2013
    Posts:
    30