Exemple #1
0
        private void Create(OGLBufferDesc desc)
        {
            mFormat = desc.Format;
            mType   = desc.Type;
            mWidth  = desc.Width;
            mHeight = desc.Height;
            mDepth  = desc.Depth;

            if (desc.Format == Format.Unknown)
            {
                throw new OptixException("OGLBuffer Error: Unknown buffer types not supported");
            }

            if (desc.Format == Format.User && desc.ElemSize <= 0)
            {
                throw new OptixException("D3DBuffer Error: ElemSize must be non-zero for User formats.");
            }

            if (desc.Type == BufferType.InputOutputLocal)
            {
                throw new OptixException("OGLBuffer Error: BufferType::InputOutputLocal Unsupported!");
            }

            uint type = (uint)desc.Type;

            CheckError(GlInterop.rtBufferCreateFromGLBO(mContext.InternalPtr, type, desc.Resource, ref InternalPtr));

            CheckError(Api.rtBufferSetFormat(InternalPtr, (RTformat)desc.Format));

            if (desc.Format == Format.User)
            {
                CheckError(Api.rtBufferSetElementSize(InternalPtr, (uint)desc.ElemSize));
            }

            SetSize(desc.Width, desc.Height, desc.Depth);
        }
Exemple #2
0
 public OGLBuffer(Context c, OGLBufferDesc desc) : base(c)
 {
     Create(desc);
 }