本文整理汇总了C++中VisualGraphics::doesSupportGLConvolutionFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualGraphics::doesSupportGLConvolutionFilter方法的具体用法?C++ VisualGraphics::doesSupportGLConvolutionFilter怎么用?C++ VisualGraphics::doesSupportGLConvolutionFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualGraphics
的用法示例。
在下文中一共展示了VisualGraphics::doesSupportGLConvolutionFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyConvolutionFilter
void VisualTextureContainer::applyConvolutionFilter(const VisualConvolutionFilter& aConvolutionFilter) {
VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
uint16 dataType;
uint16 pixelFormat = kGL_BGRA;
// BGRA on intel machines and ARGB on ppc
#if TARGET_OS_WIN
dataType = kGL_UNSIGNED_BYTE;
#else
#if __BIG_ENDIAN__
dataType = kGL_UNSIGNED_INT_8_8_8_8_REV;
#else
dataType = kGL_UNSIGNED_INT_8_8_8_8;
#endif
#endif
if (theVisualGraphics->doesSupportGLConvolutionFilter()) {
int prevReadBuffer = theVisualGraphics->getCurrentColorBufferForPixelReadingOperations();
theVisualGraphics->setColorBufferForPixelReadingOperations(kGL_BACK_COLOR_BUFFER);
int prevDrawBuffer = theVisualGraphics->getCurrentColorBufferForPixelDrawingOperations();
theVisualGraphics->setColorBufferForPixelDrawingOperations(kGL_BACK_COLOR_BUFFER);
uint32* prevPixels = NULL;
char errStr[512];
uint8 numberOfBytesPerChannel = 0;
uint8 numberOfChannels = 0; // channel == color resp. alpha channel
uint8 numberOfBytesPerPixel = 0;
uint32 numberOfBytesPerRow = 0;
if ((pixelFormat == kGL_RGBA) || (pixelFormat == kGL_BGRA)) {
numberOfChannels = 4;
} else {
sprintf(errStr, "unknown format %d in file: %s (line: %d) [%s])", pixelFormat, __FILE__, __LINE__, __FUNCTION__);
writeLog(errStr);
return;
}
if ((dataType == kGL_UNSIGNED_INT_8_8_8_8_REV) || (dataType == kGL_UNSIGNED_INT_8_8_8_8) || (dataType == kGL_UNSIGNED_BYTE)) {
numberOfBytesPerChannel = 1; // // 1 byte (== 8 bits) per color/channel
} else {
sprintf(errStr, "unknown type %d in file: %s (line: %d) [%s])", dataType, __FILE__, __LINE__, __FUNCTION__);
writeLog(errStr);
return;
}
numberOfBytesPerPixel = numberOfBytesPerChannel * numberOfChannels;
numberOfBytesPerRow = numberOfBytesPerPixel * this->textureRect.width;
// read previous pixels
if ((pixelFormat == kGL_RGBA) || (pixelFormat == kGL_BGRA)) {
prevPixels = (uint32*)calloc((numberOfBytesPerRow / numberOfBytesPerPixel) * this->textureRect.height, numberOfBytesPerPixel);
}
VisualCamera aCamera;
aCamera.setOrthographicProjection();
theVisualGraphics->readPixels(aCamera.getMaxLeftCoord(), aCamera.getMaxBottomCoord(), this->textureRect.width, this->textureRect.height, &prevPixels, pixelFormat, dataType, aCamera);
PixelColor* pixels = NULL;
pixels = this->createARGBImagePixels();
if (pixels == NULL) {
sprintf(errStr, "pixels == NULL in file: %s (line: %d) [%s])", __FILE__, __LINE__, __FUNCTION__);
writeLog(errStr);
return;
}
theVisualGraphics->drawPixels(&pixels, aCamera.getMaxLeftCoord(), aCamera.getMaxBottomCoord(), this->imageRect.width, this->imageRect.height, pixelFormat, dataType, &aConvolutionFilter);
free(pixels);
pixels = NULL;
BottomLeftPositionedPixelRect clipRect;
clipRect.bottomLeftPixel.x = 0;
clipRect.bottomLeftPixel.y = 0;
clipRect.pixelRect.width = this->textureRect.width;
clipRect.pixelRect.height = this->textureRect.height;
theVisualGraphics->enableTexturing(this->useRectExtension);
theVisualGraphics->copyFramebufferToTexture(this->textureName, this->useRectExtension, clipRect, pixelFormat, dataType);
theVisualGraphics->disableTexturing(this->useRectExtension);
// restore previous pixels
theVisualGraphics->drawPixels(&prevPixels, aCamera.getMaxLeftCoord(), aCamera.getMaxBottomCoord(), this->textureRect.width, this->textureRect.height, pixelFormat, dataType);
free(prevPixels);
theVisualGraphics->setColorBufferForPixelDrawingOperations(prevDrawBuffer);
theVisualGraphics->setColorBufferForPixelReadingOperations(prevReadBuffer);
} else {
PixelColor* pixels = this->createARGBImagePixels();
PixelColor* filteredPixels = NULL;
aConvolutionFilter.applyToPixelData(pixels, this->imageRect.width, this->imageRect.height, pixelFormat, dataType, &filteredPixels);
free(pixels);
pixels = NULL;
bool success = false;
const PixelColor* constFilteredPixels = const_cast<const PixelColor*>(filteredPixels);
//.........这里部分代码省略.........