Qualcomm_Snapdragon_VR_SDK SvrEye脚本简介(4)

除了枚举类型eSide代表的是SvrEye中的左右眼类型属性外,SvrEye中还存在另外一个枚举类型保存的是当前左右眼图像传输到底层sdk的传输类型eType:

 public enum eType
    {
        RenderTexture = 0,
        StandardTexture = 1,
        EglTexture = 2,
    };

之后,SvrEye中通过变量imgeType保存了当前SvrEye中的传输类型:

[Tooltip("Image type: 0/Camera render target, 1/Texture 2d, 2/External egl")]
    public eType imageType = eType.RenderTexture;

该枚举类型中包括三中传输类型,

其中RenderTexture为imageType的默认类型,是指将左右眼的Camera图像通过RenderTexture的方式传输到底层SDK中。

而StandardTexture表示将预制的Texture2D图像传输到底层SDK中。

EglTexture表示将底层gl的图像传输到sdk中。


具体传输实现的逻辑如下:

  void InitializeBuffers()
    {
        for (int i = 0; i < bufferCount; ++i)
        {
            if (eyeTextures[i] != null)
                eyeTextures[i].Release();
            switch(imageType)
            {
                case eType.RenderTexture:
                    eyeTextures[i] = new RenderTexture((int)(resolution.x * resolutionScaleFactor), (int)(resolution.y * resolutionScaleFactor), depth, format);
                    eyeTextures[i].antiAliasing = antiAliasing;
                    eyeTextures[i].Create();
                    eyeTextureIds[i] = eyeTextures[i].GetNativeTexturePtr().ToInt32();
                    Debug.Log("Create Render Texture with ID: " + eyeTextureIds[i] + " Width: " + eyeTextures[i].width + " Height: " + eyeTextures[i].height + " AA: " + eyeTextures[i].antiAliasing);
                    break;

                case eType.StandardTexture:
                    if (imageTexture) eyeTextureIds[i] = imageTexture.GetNativeTexturePtr().ToInt32();
                    break;

                case eType.EglTexture:
                    eyeTextureIds[i] = 0;
                    break;
            }
        }
        dirty = false;
    }

当imageType为默认的RenderTexture类型时,程序中会创建一个RenderTexture变量,并且获取到RenderTexture的指针传入到sdk中,而StandardTexture则会把imageTexture的指针传入sdk中。

同eSide类似,SvrEye定义了一个ImageType的属性,供外部获取当前SvrEye中的type类型:


    public eType ImageType
    {
        get { return imageType; }
        set { imageType = value; }
    }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值