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


C++ VisualGraphics::makeTextureOfStringWin方法代码示例

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


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

示例1: initWithStyledString

bool VisualTextureContainer::initWithStyledString(VisualStyledString& styledString) {
	
	this->releaseTextureData();
	
    bool success = true;
	
	const VisualString* aVisualString = &(styledString);
	VisualStringStyle& stringStyle = styledString.getStyle();
	if (aVisualString->getNumberOfCharacters() == 0) {
		return false;
	}
	
	VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
	uint32 maxPixelWidth = theVisualGraphics->getCanvasPixelWidth();
	uint32 maxPixelHeight = theVisualGraphics->getCanvasPixelHeight();
	
	this->textureName = theVisualGraphics->getNextFreeTextureName();
	this->aTextureIsSet = true;
	VisualTextureContainer::textureRefCountMap[this->textureName] = 1;
	this->useRectExtension = theVisualGraphics->canUseTextureRectExtension();
	
#if TARGET_OS_MAC
	char alignmentStr[32];	
	switch (stringStyle.horizontalAlignment) {
		case (kLeftAligned):
			strcpy(alignmentStr, "left");
			break;
		case(kCenterAligned):
			strcpy(alignmentStr, "center");
			break;
		case(kRightAligned):
			strcpy(alignmentStr, "right");
			break;
		default:
			break;
	}
	
	success = getDimensionsOfCocoaStringBitmap((void*)aVisualString, (void*)&stringStyle, &(this->imageRect.width), &(this->imageRect.height), maxPixelWidth, maxPixelHeight, alignmentStr);
	if (!success) {
		return success;
	}
	
	if (this->useRectExtension == false) {
		this->textureRect.width = theVisualGraphics->power2Ceiling(this->imageRect.width);
		this->textureRect.height = theVisualGraphics->power2Ceiling(this->imageRect.height);
	} else {
		this->textureRect.width = this->imageRect.width;
		this->textureRect.height = this->imageRect.height;
	}
	
	PixelColor* pixelBuffer = (uint32*)calloc(this->textureRect.width * this->textureRect.height, sizeof(uint32));
	
	success = getCocoaStringBitmapData((void*)&styledString, this->textureRect.width, this->textureRect.height, alignmentStr, &(pixelBuffer));
	
	success = theVisualGraphics->copyARGBBitmapDataToTexture(this->textureName, this->textureRect.width, this->textureRect.height, this->useRectExtension, const_cast<const uint32**>(&(pixelBuffer)));
	
#endif
	
#if TARGET_OS_WIN
	
	wchar_t* stringValueRef = (wchar_t*)(styledString.getCharactersPointer());
	uint8 red = (uint8)(stringStyle.fontColor.r * 255.0f);
	uint8 green = (uint8)(stringStyle.fontColor.g * 255.0f);
	uint8 blue = (uint8)(stringStyle.fontColor.b * 255.0f);

	if (!stringValueRef) {
		success = false;
		return success;
	}
	
	success = theVisualGraphics->makeTextureOfStringWin(stringValueRef, styledString.getNumberOfCharacters(), this->textureName, this->textureRect.width, this->textureRect.height, this->imageRect.width, this->imageRect.height, stringStyle.fontNameStr, (uint16)stringStyle.fontSize, red, green, blue, stringStyle.horizontalAlignment, maxPixelWidth, maxPixelHeight);
	
#endif
	
	if (this->useRectExtension == false) {
		this->logicalSize.width = (double)this->imageRect.width / (double)this->textureRect.width;
		this->logicalSize.height = (double)this->imageRect.height / (double)this->textureRect.height;
	} else {
		this->logicalSize.width = (double)this->textureRect.width;
		this->logicalSize.height = (double)this->textureRect.height;
	}
	
	return success;
}
开发者ID:LupusDei,项目名称:8LU-DSP,代码行数:84,代码来源:VisualTextureContainer.cpp

示例2: initWithString

OSStatus VisualTextureContainer::initWithString(const VisualString& stringValue, VisualStringStyle& stringStyle) {
	
	this->releaseTextureData();
	if (this->pixelBuffer != NULL) {
		free(this->pixelBuffer);
		this->pixelBuffer = NULL;
	}

    OSStatus status = noErr;

	VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
	UInt16 maxPixelWidth = theVisualGraphics->getCanvasPixelWidth();
	UInt16 maxPixelHeight = theVisualGraphics->getCanvasPixelHeight();
	
	this->textureName = theVisualGraphics->getNextFreeTextureName();
	this->textureIsSet = true;
	VisualTextureContainer::textureRefCountMap[this->textureName] = 1;
	this->useRectExtension = theVisualGraphics->canUseTextureRectExtension();

#if TARGET_OS_MAC
	char alignmentStr[32];	
	switch (stringStyle.horizontalAlignment) {
		case (kLeftAligned):
			strcpy(alignmentStr, "left");
			break;
		case(kCenterAligned):
			strcpy(alignmentStr, "center");
			break;
		case(kRightAligned):
			strcpy(alignmentStr, "right");
			break;
		default:
			break;
	}
	
	status = getDimensionsOfCocoaStringBitmap((void*)&stringValue, &(this->imageWidth), &(this->imageHeight), const_cast<char*>(stringStyle.fontNameStr), &(stringStyle.fontSize), stringStyle.fontColor.r, stringStyle.fontColor.g, stringStyle.fontColor.b, maxPixelWidth, maxPixelHeight, alignmentStr);
	
	if (this->useRectExtension == false) {
		this->textureWidth = theVisualGraphics->power2Ceiling(this->imageWidth);
		this->textureHeight = theVisualGraphics->power2Ceiling(this->imageHeight);
	} else {
		this->textureWidth = this->imageWidth;
		this->textureHeight = this->imageHeight;
	}
	
	this->pixelBuffer = (UInt32*)calloc(this->textureWidth * this->textureHeight, sizeof(UInt32));

	status = getCocoaStringBitmapData((void*)&stringValue, this->textureWidth, this->textureHeight, const_cast<char*>(stringStyle.fontNameStr), stringStyle.fontSize, stringStyle.fontColor.r, stringStyle.fontColor.g, stringStyle.fontColor.b, alignmentStr, &(this->pixelBuffer));
	
	theVisualGraphics->copyARGBBitmapDataToTexture(this->textureName, this->textureWidth, this->textureHeight, this->useRectExtension, this->pixelFormat, this->dataType, const_cast<const UInt32**>(&(this->pixelBuffer)));

#endif

#if TARGET_OS_WIN

	wchar_t* stringValueRef = (wchar_t*)stringValue.getCharactersPointer();
	UInt8 red = (UInt8)(stringStyle.fontColor.r * 255.0f);
	UInt8 green = (UInt8)(stringStyle.fontColor.g * 255.0f);
	UInt8 blue = (UInt8)(stringStyle.fontColor.b * 255.0f);
	
	status = theVisualGraphics->makeTextureOfStringWin(stringValueRef, stringValue.getNumberOfCharacters(), this->textureName, this->textureWidth, this->textureHeight, this->imageWidth, this->imageHeight, stringStyle.fontNameStr, (UInt16)stringStyle.fontSize, red, green, blue, stringStyle.horizontalAlignment, maxPixelWidth, maxPixelHeight);

#endif

	if (this->useRectExtension == false) {
		this->textureLogicalWidth = (double)this->imageWidth / (double)this->textureWidth;
		this->textureLogicalHeight = (double)this->imageHeight / (double)this->textureHeight;
	} else {
		this->textureLogicalWidth = (double)this->textureWidth;
		this->textureLogicalHeight = (double)this->textureHeight;
	}

	return status;
}
开发者ID:alexpaulzor,项目名称:projectm,代码行数:74,代码来源:VisualTextureContainer.cpp


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