本文整理汇总了C++中OVR_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ OVR_FREE函数的具体用法?C++ OVR_FREE怎么用?C++ OVR_FREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OVR_FREE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: defined
// Helper function: obtain file information time.
bool SysFile::GetFileStat(FileStat* pfileStat, const String& path)
{
#if defined(OVR_OS_WIN32)
// 64-bit implementation on Windows.
struct __stat64 fileStat;
// Stat returns 0 for success.
wchar_t *pwpath = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(path.ToCStr())+1)*sizeof(wchar_t));
UTF8Util::DecodeString(pwpath, path.ToCStr());
int ret = _wstat64(pwpath, &fileStat);
OVR_FREE(pwpath);
if (ret) return false;
#else
struct stat fileStat;
// Stat returns 0 for success.
if (stat(path, &fileStat) != 0)
return false;
#endif
pfileStat->AccessTime = fileStat.st_atime;
pfileStat->ModifyTime = fileStat.st_mtime;
pfileStat->FileSize = fileStat.st_size;
return true;
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:ofxOculusRift,代码行数:24,代码来源:OVR_FileFILE.cpp
示例17: D3DReflect
void ShaderBase::InitUniforms(void* s, size_t size)
{
ID3D11ShaderReflection* ref = NULL;
D3DReflect(s, size, IID_ID3D11ShaderReflection, (void**) &ref);
ID3D11ShaderReflectionConstantBuffer* buf = ref->GetConstantBufferByIndex(0);
D3D11_SHADER_BUFFER_DESC bufd;
if (FAILED(buf->GetDesc(&bufd)))
{
UniformsSize = 0;
if (UniformData)
{
OVR_FREE(UniformData);
UniformData = 0;
}
return;
}
for(unsigned i = 0; i < bufd.Variables; i++)
{
ID3D11ShaderReflectionVariable* var = buf->GetVariableByIndex(i);
if (var)
{
D3D11_SHADER_VARIABLE_DESC vd;
if (SUCCEEDED(var->GetDesc(&vd)))
{
Uniform u;
u.Name = vd.Name;
u.Offset = vd.StartOffset;
u.Size = vd.Size;
UniformInfo.PushBack(u);
}
}
}
UniformsSize = bufd.Size;
UniformData = (unsigned char*)OVR_ALLOC(bufd.Size);
}
开发者ID:msakuta,项目名称:OculusCrystal,代码行数:37,代码来源:RenderTiny_D3D11_Device.cpp
示例18: va_copy
void StringBuffer::AppendFormatV(const char* format, va_list argList)
{
char buffer[512];
char* bufferUsed = buffer;
char* bufferAllocated = NULL;
va_list argListSaved;
va_copy(argListSaved, argList);
int requiredStrlen = vsnprintf(bufferUsed, OVR_ARRAY_COUNT(buffer), format, argListSaved); // The large majority of the time this will succeed.
if(requiredStrlen >= (int)sizeof(buffer)) // If the initial capacity wasn't enough...
{
bufferAllocated = (char*)OVR_ALLOC(sizeof(char) * (requiredStrlen + 1));
bufferUsed = bufferAllocated;
if(bufferAllocated)
{
va_end(argListSaved);
va_copy(argListSaved, argList);
requiredStrlen = vsnprintf(bufferAllocated, (requiredStrlen + 1), format, argListSaved);
}
}
if(requiredStrlen < 0) // If there was a printf format error...
{
bufferUsed = NULL;
}
va_end(argListSaved);
if(bufferUsed)
AppendString(bufferUsed);
if(bufferAllocated)
OVR_FREE(bufferAllocated);
}
开发者ID:PLUSToolkit,项目名称:OvrvisionPro,代码行数:36,代码来源:OVR_String_FormatUtil.cpp
示例19: if
void FILEFile::init()
{
// Open mode for file's open
const char *omode = "rb";
if (OpenFlags & Open_Truncate)
{
if (OpenFlags & Open_Read)
omode = "w+b";
else
omode = "wb";
}
else if (OpenFlags & Open_Create)
{
if (OpenFlags & Open_Read)
omode = "a+b";
else
omode = "ab";
}
else if (OpenFlags & Open_Write)
omode = "r+b";
#ifdef OVR_OS_WIN32
SysErrorModeDisabler disabler(FileName.ToCStr());
#endif
#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400)
wchar_t womode[16];
wchar_t *pwFileName = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(FileName.ToCStr())+1) * sizeof(wchar_t));
UTF8Util::DecodeString(pwFileName, FileName.ToCStr());
OVR_ASSERT(strlen(omode) < sizeof(womode)/sizeof(womode[0]));
UTF8Util::DecodeString(womode, omode);
_wfopen_s(&fs, pwFileName, womode);
OVR_FREE(pwFileName);
#else
fs = fopen(FileName.ToCStr(), omode);
#endif
if (fs)
rewind (fs);
Opened = (fs != NULL);
// Set error code
if (!Opened)
ErrorCode = SFerror();
else
{
// If we are testing file seek correctness, pre-load the entire file so
// that we can do comparison tests later.
#ifdef OVR_FILE_VERIFY_SEEK_ERRORS
TestPos = 0;
fseek(fs, 0, SEEK_END);
FileTestLength = ftell(fs);
fseek(fs, 0, SEEK_SET);
pFileTestBuffer = (UByte*)OVR_ALLOC(FileTestLength);
if (pFileTestBuffer)
{
OVR_ASSERT(FileTestLength == (unsigned)Read(pFileTestBuffer, FileTestLength));
Seek(0, Seek_Set);
}
#endif
ErrorCode = 0;
}
LastOp = 0;
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:ofxOculusRift,代码行数:64,代码来源:OVR_FileFILE.cpp
示例20: IOHIDManagerCopyDevices
bool HIDDevice::openDevice()
{
// Have to iterate through devices again to generate paths.
CFSetRef deviceSet = IOHIDManagerCopyDevices(HIDManager->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.
IOHIDDeviceRef device = NULL;
for (CFIndex deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
{
IOHIDDeviceRef tmpDevice = devices[deviceIndex];
if (!tmpDevice)
{
continue;
}
String path;
if (!HIDManager->getPath(tmpDevice, &path))
{
continue;
}
if (path == DevDesc.Path)
{
device = tmpDevice;
break;
}
}
OVR_FREE(devices);
if (!device)
{
CFRelease(deviceSet);
return false;
}
// Attempt to open device.
if (IOHIDDeviceOpen(device, kIOHIDOptionsTypeSeizeDevice)
!= kIOReturnSuccess)
{
CFRelease(deviceSet);
return false;
}
// Retain the device before we release the set.
CFRetain(device);
CFRelease(deviceSet);
Device = device;
if (!initInfo())
{
IOHIDDeviceClose(Device, kIOHIDOptionsTypeSeizeDevice);
CFRelease(Device);
Device = NULL;
return false;
}
// Setup the Run Loop and callbacks.
IOHIDDeviceScheduleWithRunLoop(Device,
HIDManager->getRunLoop(),
kCFRunLoopDefaultMode);
IOHIDDeviceRegisterInputReportCallback(Device,
ReadBuffer,
ReadBufferSize,
staticHIDReportCallback,
this);
IOHIDDeviceRegisterRemovalCallback(Device,
staticDeviceRemovedCallback,
this);
return true;
}
开发者ID:123woodman,项目名称:minko,代码行数:88,代码来源:OVR_OSX_HIDDevice.cpp
注:本文中的OVR_FREE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论