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


C++ ofBuffer::getBinaryBuffer方法代码示例

本文整理汇总了C++中ofBuffer::getBinaryBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ ofBuffer::getBinaryBuffer方法的具体用法?C++ ofBuffer::getBinaryBuffer怎么用?C++ ofBuffer::getBinaryBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ofBuffer的用法示例。


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

示例1: loadModel

//-------------------------------------------
bool ofxAssimpModelLoader::loadModel(ofBuffer & buffer, bool optimize, const char * extension){
	normalizeFactor = ofGetWidth() / 2.0;

	// only ever give us triangles.
	aiSetImportPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT );
	aiSetImportPropertyInteger(AI_CONFIG_PP_PTV_NORMALIZE, true);

	// aiProcess_FlipUVs is for VAR code. Not needed otherwise. Not sure why.
	unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_Triangulate | aiProcess_FlipUVs;
	if(optimize) flags |=  aiProcess_ImproveCacheLocality | aiProcess_OptimizeGraph |
			aiProcess_OptimizeMeshes | aiProcess_JoinIdenticalVertices |
			aiProcess_RemoveRedundantMaterials;

	if(scene){
		clear();
	}
	scene = aiImportFileFromMemory(buffer.getBinaryBuffer(), buffer.size(), flags, extension);
	if(scene){
		calculateDimensions();
		loadGLResources();

		if(getAnimationCount())
			ofLog(OF_LOG_VERBOSE, "scene has animations");
		else {
			ofLog(OF_LOG_VERBOSE, "no animations");

		}
		return true;
	}else{
		ofLog(OF_LOG_ERROR,string("ofxAssimpModelLoader: ") + aiGetErrorString());
		return false;
	}

}
开发者ID:6301158,项目名称:openFrameworks_0.071_debian_package,代码行数:35,代码来源:ofxAssimpModelLoader.cpp

示例2: load

bool Scene::load(const ofBuffer& buffer, bool optimize, Handedness handness, const char* extension) {
	unload();

	unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality;

	if (optimize) {
		flags |= aiProcess_ImproveCacheLocality | 
				 aiProcess_JoinIdenticalVertices |
				 aiProcess_RemoveRedundantMaterials;
	}

	if (handness == LEFT_HANDED) {
		flags |= aiProcess_ConvertToLeftHanded;
	}

	scene = aiImportFileFromMemory(buffer.getBinaryBuffer(), buffer.size(),
								   flags, extension);
	string err_str = aiGetErrorString();
	if (!err_str.empty())
	{
		ofLogError("ofxAssimp::Scene::load") << err_str;
	}
	assert(scene);
	
	setupResources();
	setupNodes();
	setupAnimations();

	return true;
}
开发者ID:satoruhiga,项目名称:ofxAssimp,代码行数:30,代码来源:Scene.cpp

示例3: string

string ofxCrypto::base64_encode(ofBuffer &buffer) {
    long max = buffer.size();
    char *buf = buffer.getBinaryBuffer();

    string str = string(buf,max);

    return base64_encode(str);
}
开发者ID:alg-a,项目名称:GAmuza,代码行数:8,代码来源:ofxCrypto.cpp

示例4: ofLoadImage

//----------------------------------------------------
bool ofLoadImage(ofPixels & pix, const ofBuffer & buffer) {

	int					width, height, bpp;
	bool bLoaded		= false;
	FIBITMAP * bmp		= NULL;
	FIMEMORY *hmem		= NULL;
	
	hmem = FreeImage_OpenMemory((unsigned char*)buffer.getBinaryBuffer(), buffer.size());
	if (hmem == NULL){
		ofLog(OF_LOG_ERROR, "couldn't create memory handle!");
		return false;
	}

	//get the file type!
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
	if( fif == -1 ){
		ofLog(OF_LOG_ERROR, "unable to guess format", fif);
		return false;
		FreeImage_CloseMemory(hmem);
	}


	//make the image!!
	bmp = FreeImage_LoadFromMemory(fif, hmem, 0);
	
	if( bmp != NULL ){
		bLoaded = true;
		ofLog(OF_LOG_VERBOSE, "FreeImage_LoadFromMemory worked!");
	}
	
	//-----------------------------

	if (bLoaded){
		putBmpIntoPixels(bmp,pix);
	} else {
		width = height = bpp = 0;
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
	
	if( hmem != NULL ){
		FreeImage_CloseMemory(hmem);
	}

	return bLoaded;
}
开发者ID:alfredoBorboa,项目名称:openFrameworks,代码行数:49,代码来源:ofImage.cpp

示例5: loadModel

bool ofxAssimpModelLoader::loadModel(ofBuffer & buffer, bool optimize, const char * extension){
    
    ofLogVerbose("ofxAssimpModelLoader") << "loadModel(): loading from memory buffer \"." << extension << "\"";
    
    if(scene != NULL){
        clear();
    }
    
    // sets various properties & flags to a default preference
    unsigned int flags = initImportProperties(optimize);
    
    // loads scene from memory buffer - note this will not work for multipart files (obj, md3, etc)
    scene = shared_ptr<const aiScene>(aiImportFileFromMemoryWithProperties(buffer.getBinaryBuffer(), buffer.size(), flags, extension, store.get()), aiReleaseImport);
    
    bool bOk = processScene();
    return bOk;
}
开发者ID:liquidzym,项目名称:openFrameworks,代码行数:17,代码来源:ofxAssimpModelLoader.cpp

示例6: loadImage

static bool loadImage(ofPixels_<PixelType> & pix, const ofBuffer & buffer){
	ofInitFreeImage();
	bool bLoaded = false;
	FIBITMAP* bmp = NULL;
	FIMEMORY* hmem = NULL;
	
	hmem = FreeImage_OpenMemory((unsigned char*) buffer.getBinaryBuffer(), buffer.size());
	if (hmem == NULL){
		ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, opening FreeImage memory failed";
		return false;
	}

	//get the file type!
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(hmem);
	if( fif == -1 ){
		ofLogError("ofImage") << "loadImage(): couldn't load image from ofBuffer, unable to guess image format from memory";
		return false;
		FreeImage_CloseMemory(hmem);
	}


	//make the image!!
	bmp = FreeImage_LoadFromMemory(fif, hmem, 0);
	
	if( bmp != NULL ){
		bLoaded = true;
	}
	
	//-----------------------------
	
	if (bLoaded){
		putBmpIntoPixels(bmp,pix);
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
	
	if( hmem != NULL ){
		FreeImage_CloseMemory(hmem);
	}

	return bLoaded;
}
开发者ID:jateeter,项目名称:openFrameworks,代码行数:44,代码来源:ofImage.cpp

示例7: loadModel

//-------------------------------------------
bool ofxAssimpModelLoader::loadModel(ofBuffer & buffer, bool optimize, const char * extension){
	normalizeFactor = ofGetWidth() / 2.0;
    
    if(scene != NULL){
        clear();
    }
    
	// only ever give us triangles.
	aiSetImportPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT );
	aiSetImportPropertyInteger(AI_CONFIG_PP_PTV_NORMALIZE, true);

	// aiProcess_FlipUVs is for VAR code. Not needed otherwise. Not sure why.
	unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality | aiProcess_Triangulate | aiProcess_FlipUVs;
	if(optimize) flags |=  aiProcess_ImproveCacheLocality | aiProcess_OptimizeGraph |
			aiProcess_OptimizeMeshes | aiProcess_JoinIdenticalVertices |
			aiProcess_RemoveRedundantMaterials;

	scene = aiImportFileFromMemory(buffer.getBinaryBuffer(), buffer.size(), flags, extension);
    
	if(scene){
		calculateDimensions();
		loadGLResources();
        update();

		if(getAnimationCount())
			ofLogVerbose("ofxAssimpModelLoader") << "loadModel(): scene has " << getAnimationCount() << "animations";
		else {
			ofLogVerbose("ofxAssimpModelLoader") << "loadMode(): no animations";
		}

		ofAddListener(ofEvents().exit,this,&ofxAssimpModelLoader::onAppExit);


		return true;
	}else{
		ofLogError("ofxAssimpModelLoader") << "loadModel(): " + (string) aiGetErrorString();
		clear();
		return false;
	}
}
开发者ID:Adorkable-forkable,项目名称:openFrameworks,代码行数:41,代码来源:ofxAssimpModelLoader.cpp

示例8: sendBinary

 //--------------------------------------------------------------
 void Server::sendBinary( ofBuffer buffer ){
     sendBinary(buffer.getBinaryBuffer(), buffer.size());
 }
开发者ID:armadillu,项目名称:ofxLibwebsockets,代码行数:4,代码来源:Server.cpp

示例9: send

bool ofxZmqSocket::send(const ofBuffer &data, bool nonblocking, bool more)
{
	return ofxZmqSocket::send((const void*)data.getBinaryBuffer(), data.size(), nonblocking, more);
}
开发者ID:armadillu,项目名称:ofxZmq,代码行数:4,代码来源:ofxZmqSocket.cpp

示例10: send

int ofxNanomsgPublisher::send(const string &topic, const ofBuffer &data, bool nonblocking)
{
    return ofxNanomsgSocket::send(topic + " " + data.getBinaryBuffer(), nonblocking);
}
开发者ID:hideyukisaito,项目名称:ofxNanomsg,代码行数:4,代码来源:ofxNanomsgPublisher.cpp


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