当前位置: 首页>>代码示例>>C++>>正文


C++ OVR_FREE函数代码示例

本文整理汇总了C++中OVR_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ OVR_FREE函数的具体用法?C++ OVR_FREE怎么用?C++ OVR_FREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OVR_FREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssignError

//-----------------------------------------------------------------------------
// Loads and parses the given JSON file pathname and returns a JSON object tree.
// The returned object must be Released after use.
JSON* JSON::Load(const char* path, const char** perror)
{
    SysFile f;
    if (!f.Open(path, File::Open_Read, File::Mode_Read))
    {
        AssignError(perror, "Failed to open file");
        return NULL;
    }

    int    len   = f.GetLength();
    uint8_t* buff  = (uint8_t*)OVR_ALLOC(len + 1);
    int    bytes = f.Read(buff, len);
    f.Close();

    if (bytes == 0 || bytes != len)
    {
        OVR_FREE(buff);
        return NULL;
    }

	// Ensure the result is null-terminated since Parse() expects null-terminated input.
	buff[len] = '\0';

    JSON* json = JSON::Parse((char*)buff, perror);
    OVR_FREE(buff);
    return json;
}
开发者ID:ArthurTorrente,项目名称:4A_Anim_Numerique_Genetic_Algorithm,代码行数:30,代码来源:OVR_JSON.cpp

示例2: PrintValue

//-----------------------------------------------------------------------------
// Serializes the JSON object to a String
String JSON::Stringify(bool fmt)
{
    char* text = PrintValue(0, fmt);
    String copy(text);
    OVR_FREE(text);
    return copy;
}
开发者ID:Interaptix,项目名称:OvrvisionPro,代码行数:9,代码来源:OVR_JSON.cpp

示例3: LoadTextureTga

// This is a temporary function implementation, and it functionality needs to be implemented in a more generic way.
Texture* LoadTextureTga(RenderParams& rParams, int samplerMode, OVR::File* f, uint8_t alpha)
{
    OVR::CAPI::GL::Texture* pTexture = NULL;

    int width, height;
    const uint8_t* pRGBA = LoadTextureTgaData(f, alpha, width, height);

    if (pRGBA)
    {
        pTexture = new OVR::CAPI::GL::Texture(&rParams, width, height);

        // SetSampleMode forces the use of mipmaps through GL_LINEAR_MIPMAP_LINEAR.
        pTexture->SetSampleMode(samplerMode); // Calls glBindTexture internally.

        // We are intentionally not using mipmaps. We need to use this because Texture::SetSampleMode unilaterally uses GL_LINEAR_MIPMAP_LINEAR.
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
        OVR_ASSERT(glGetError() == 0);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pRGBA);
        OVR_ASSERT(glGetError() == 0);

        // With OpenGL 4.2+ we can use this instead of glTexImage2D:
        // glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height);
        // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pRGBA);

        OVR_FREE(const_cast<uint8_t*>(pRGBA));
    }

    return pTexture;
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:32,代码来源:CAPI_GL_HSWDisplay.cpp

示例4: OVR_FREE

BinaryReader::~BinaryReader()
{
	if ( Allocated )
	{
		OVR_FREE( const_cast< UByte* >( Data ) );
	}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:7,代码来源:OVR_BinaryFile.cpp

示例5: OVR_ALLOC

Vector3f SensorFilter::Median() const
{
    int half_window = Count / 2;
    float* sortx = (float*) OVR_ALLOC(Count * sizeof(float));
    float* sorty = (float*) OVR_ALLOC(Count * sizeof(float));
    float* sortz = (float*) OVR_ALLOC(Count * sizeof(float));
    float resultx = 0.0f, resulty = 0.0f, resultz = 0.0f;

    for (int i = 0; i < Count; i++) 
    {
        sortx[i] = Elements[i].x;
        sorty[i] = Elements[i].y;
        sortz[i] = Elements[i].z;
    }
    for (int j = 0; j <= half_window; j++) 
    {
        int minx = j;
        int miny = j;
        int minz = j;
        for (int k = j + 1; k < Count; k++) 
        {
            if (sortx[k] < sortx[minx]) minx = k;
            if (sorty[k] < sorty[miny]) miny = k;
            if (sortz[k] < sortz[minz]) minz = k;
        }
        const float tempx = sortx[j];
        const float tempy = sorty[j];
        const float tempz = sortz[j];
        sortx[j] = sortx[minx];
        sortx[minx] = tempx;

        sorty[j] = sorty[miny];
        sorty[miny] = tempy;

        sortz[j] = sortz[minz];
        sortz[minz] = tempz;
    }
    resultx = sortx[half_window];
    resulty = sorty[half_window];
    resultz = sortz[half_window];

    OVR_FREE(sortx);
    OVR_FREE(sorty);
    OVR_FREE(sortz);

    return Vector3f(resultx, resulty, resultz);
}
开发者ID:edqu,项目名称:oculus-ane,代码行数:47,代码来源:OVR_SensorFilter.cpp

示例6: OVR_FREE

ShaderBase::~ShaderBase()
{
    if (UniformData)
    {
        OVR_FREE(UniformData);
        UniformData = NULL;
    }
}
开发者ID:OculusRiftInAction,项目名称:OculusSDK,代码行数:8,代码来源:RenderTiny_D3D11_Device.cpp

示例7: FlushBuffer

// Destructor
BufferedFile::~BufferedFile()
{
    // Flush in case there's data
    if (pFile)
        FlushBuffer();
    // Get rid of buffer
    if (pBuffer)
        OVR_FREE(pBuffer);
}
开发者ID:ArthurTorrente,项目名称:4A_Anim_Numerique_Genetic_Algorithm,代码行数:10,代码来源:OVR_File.cpp

示例8: OVR_FREE

void BitStream::WrapBuffer(unsigned char* _data, const unsigned int lengthInBytes)
{
    if (copyData && numberOfBitsAllocated > (BITSTREAM_STACK_ALLOCATION_SIZE << 3))
        OVR_FREE(data);  // Use realloc and free so we are more efficient than delete and new for resizing

    numberOfBitsUsed = lengthInBytes << 3;
    readOffset = 0;
    copyData = false;
    numberOfBitsAllocated = lengthInBytes << 3;
    data = (unsigned char*)_data;
}
开发者ID:ChristophHaag,项目名称:OculusSDK,代码行数:11,代码来源:OVR_BitStream.cpp

示例9: OVR_FREE

bool FILEFile::Close()
{
#ifdef OVR_FILE_VERIFY_SEEK_ERRORS
    if (pFileTestBuffer)
    {
        OVR_FREE(pFileTestBuffer);
        pFileTestBuffer = 0;
        FileTestLength  = 0;
    }
#endif

    bool closeRet = !fclose(fs);

    if (!closeRet)
    {
        ErrorCode = SFerror();
        return 0;
    }
    else
    {
        Opened    = 0;
        fs        = 0;
        ErrorCode = 0;
    }

    // Handle safe truncate
    /*
    if ((OpenFlags & OVR_FO_SAFETRUNC) == OVR_FO_SAFETRUNC)
    {
        // Delete original file (if it existed)
        DWORD oldAttributes = FileUtilWin32::GetFileAttributes(FileName);
        if (oldAttributes!=0xFFFFFFFF)
            if (!FileUtilWin32::DeleteFile(FileName))
            {
                // Try to remove the readonly attribute
                FileUtilWin32::SetFileAttributes(FileName, oldAttributes & (~FILE_ATTRIBUTE_READONLY) );
                // And delete the file again
                if (!FileUtilWin32::DeleteFile(FileName))
                    return 0;
            }

        // Rename temp file to real filename
        if (!FileUtilWin32::MoveFile(TempName, FileName))
        {
            //ErrorCode = errno;
            return 0;
        }
    }
    */
    return 1;
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:ofxOculusRift,代码行数:51,代码来源:OVR_FileFILE.cpp

示例10: LoadTextureDDS

Texture* LoadTextureDDS(RenderDevice* ren, File* f)
{
    OVR_DDS_HEADER header;
    unsigned char filecode[4];

    f->Read(filecode, 4);
    if (strncmp((const char*)filecode, "DDS ", 4) != 0)
    {
        return NULL;
    }

    f->Read((unsigned char*)(&header), sizeof(header));

    int width = header.Width;
    int height = header.Height;

    int format = 0;

    UInt32 mipCount = header.MipMapCount;
    if(mipCount <= 0)
    {
        mipCount = 1;
    }
    if(header.PixelFormat.Flags & OVR_DDS_PF_FOURCC)
    {
        if(header.PixelFormat.FourCC == OVR_DTX1_MAGIC_NUMBER)
        {
            format = Texture_DXT1;
        }
        else if(header.PixelFormat.FourCC == OVR_DTX5_MAGIC_NUMBER)
        {
            format = Texture_DXT5;
        }
        else
        {
            return NULL;
        }
    }

    int            byteLen = f->BytesAvailable();
    unsigned char* bytes   = new unsigned char[byteLen];
    f->Read(bytes, byteLen);
    Texture* out = ren->CreateTexture(format, (int)width, (int)height, bytes, mipCount);
    if(strstr(f->GetFilePath(), "_c."))
    {
        out->SetSampleMode(Sample_Clamp);
    }
    OVR_FREE(bytes);
    return out;
}
开发者ID:lye,项目名称:ovrsdk,代码行数:50,代码来源:Render_LoadTextureDDS.cpp

示例11: IOHIDManagerCopyDevices

bool HIDDeviceManager::Enumerate(HIDEnumerateVisitor* enumVisitor)
{
    if (!initializeManager())
    {
        return false;
    }
    

	CFSetRef deviceSet = IOHIDManagerCopyDevices(HIDManager);
	CFIndex deviceCount = CFSetGetCount(deviceSet);
    
    // Allocate a block of memory and read the set into it.
    IOHIDDeviceRef* devices = (IOHIDDeviceRef*) OVR_ALLOC(sizeof(IOHIDDeviceRef) * deviceCount);
    CFSetGetValues(deviceSet, (const void **) devices);
    

    // Iterate over devices.
    for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
    {
        IOHIDDeviceRef hidDev = devices[deviceIndex];
        
        if (!hidDev)
        {
            continue;
        }
        
        HIDDeviceDesc devDesc;
                
        if (getPath(hidDev, &(devDesc.Path)) &&
            initVendorProductVersion(hidDev, &devDesc) &&
            enumVisitor->MatchVendorProduct(devDesc.VendorId, devDesc.ProductId) &&
            initUsage(hidDev, &devDesc))
        {
            initStrings(hidDev, &devDesc);
            initSerialNumber(hidDev, &devDesc);

            // Construct minimal device that the visitor callback can get feature reports from.
            OSX::HIDDevice device(this, hidDev);
            
            enumVisitor->Visit(device, devDesc);
        }
    }
    
    OVR_FREE(devices);
    CFRelease(deviceSet);
    
    return true;
}
开发者ID:ReallyRad,项目名称:ofxOculusRift,代码行数:48,代码来源:OVR_OSX_HIDDevice.cpp

示例12: ConfigureRendering

HMDState::~HMDState()
{
    if (pClient)
    {
		pClient->Hmd_Release(NetId);
		pClient = 0;
    }

    ConfigureRendering(0,0,0,0);

    if (pHmdDesc)
    {
        OVR_FREE(pHmdDesc);
        pHmdDesc = NULL;
    }
}
开发者ID:ArthurTorrente,项目名称:4A_Anim_Numerique_Genetic_Algorithm,代码行数:16,代码来源:CAPI_HMDState.cpp

示例13: va_start

void StringBuffer::AppendFormat(const char* format, ...)
{       
    va_list argList;

    va_start(argList, format);
    UPInt size = OVR_vscprintf(format, argList);
    va_end(argList);

    char* buffer = (char*) OVR_ALLOC(sizeof(char) * (size+1));

    va_start(argList, format);
    UPInt result = OVR_vsprintf(buffer, size+1, format, argList);
    OVR_UNUSED1(result);
    va_end(argList);
    OVR_ASSERT_LOG(result == size, ("Error in OVR_vsprintf"));

    AppendString(buffer);

    OVR_FREE(buffer);
}
开发者ID:1107979819,项目名称:OculusVRStudy,代码行数:20,代码来源:OVR_String_FormatUtil.cpp

示例14: OVR_FREE

void ShaderBase::InitUniforms(const Uniform* refl, size_t reflSize)
{
    if(!refl)
    {
        UniformRefl = NULL;
        UniformReflSize = 0;

        UniformsSize = 0;
        if (UniformData)
        {
            OVR_FREE(UniformData);
            UniformData = 0;
        }
        return; // no reflection data
    }

    UniformRefl = refl;
    UniformReflSize = reflSize;
    
    UniformsSize = UniformRefl[UniformReflSize-1].Offset + UniformRefl[UniformReflSize-1].Size;
    UniformData = (unsigned char*)OVR_ALLOC(UniformsSize);
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:22,代码来源:CAPI_GL_Util.cpp

示例15: PrintValue

//-----------------------------------------------------------------------------
// Serializes the JSON object and writes to the give file path
bool JSON::Save(const char* path)
{
    SysFile f;
    if (!f.Open(path, File::Open_Write | File::Open_Create | File::Open_Truncate, File::Mode_Write))
        return false;

    char* text = PrintValue(0, true);
    if (text)
    {
        intptr_t len   = OVR_strlen(text);
        OVR_ASSERT(len <= (intptr_t)(int)len);

        int   bytes = f.Write((uint8_t*)text, (int)len);
        f.Close();
        OVR_FREE(text);
        return (bytes == len);
    }
    else
    {
        return false;
    }
}
开发者ID:ArthurTorrente,项目名称:4A_Anim_Numerique_Genetic_Algorithm,代码行数:24,代码来源:OVR_JSON.cpp


注:本文中的OVR_FREE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。