本文整理汇总了C++中ofFloatPixels::getNumChannels方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFloatPixels::getNumChannels方法的具体用法?C++ ofFloatPixels::getNumChannels怎么用?C++ ofFloatPixels::getNumChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFloatPixels
的用法示例。
在下文中一共展示了ofFloatPixels::getNumChannels方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ofGetGlInternalFormat
//---------------------------------
int ofGetGlInternalFormat(const ofFloatPixels& pix) {
#ifndef TARGET_OPENGLES
switch(pix.getNumChannels()) {
case 3: return GL_RGB32F;
case 4: return GL_RGBA32F;
case 2:
if(ofIsGLProgrammableRenderer()){
return GL_RG32F;
}else{
return GL_LUMINANCE_ALPHA32F_ARB;
}
default:
if(ofIsGLProgrammableRenderer()){
return GL_R32F;
}else{
return GL_LUMINANCE32F_ARB;
}
}
#else
ofLogWarning("ofGLUtils") << "ofGetGlInternalFormat(): float textures not supported in OpenGL ES";
switch(pix.getNumChannels()) {
case 3: return GL_RGB;
case 4: return GL_RGBA;
case 2:
return GL_LUMINANCE_ALPHA;
default:
return GL_LUMINANCE;
}
#endif
}
示例2: getFreeImageType
FREE_IMAGE_TYPE getFreeImageType(ofFloatPixels& pix) {
switch(pix.getNumChannels()) {
case 1: return FIT_FLOAT;
case 3: return FIT_RGBF;
case 4: return FIT_RGBAF;
default:
ofLogError() << "Unkown freeimage type for" << pix.getNumChannels() << "channels";
return FIT_UNKNOWN;
}
}
示例3: ofGetGlInternalFormat
//---------------------------------
int ofGetGlInternalFormat(const ofFloatPixels& pix) {
#ifndef TARGET_OPENGLES
switch(pix.getNumChannels()) {
case 3: return GL_RGB32F_ARB;
case 4: return GL_RGBA32F_ARB;
default: return GL_LUMINANCE32F_ARB;
}
#else
ofLogWarning()<< "float textures not supported in GLES";
switch(pix.getNumChannels()) {
case 3: return GL_RGB;
case 4: return GL_RGBA;
default: return GL_LUMINANCE;
}
#endif
}
示例4: getFreeImageType
FREE_IMAGE_TYPE getFreeImageType(const ofFloatPixels& pix) {
switch(pix.getNumChannels()) {
case 1: return FIT_FLOAT;
case 3: return FIT_RGBF;
case 4: return FIT_RGBAF;
default:
ofLogError("ofImage") << "getFreeImageType(): unknown FreeImage type for number of channels:" << pix.getNumChannels();
return FIT_UNKNOWN;
}
}
示例5: readToPixels
void ofTexture::readToPixels(ofFloatPixels & pixels) const {
#ifndef TARGET_OPENGLES
pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glInternalFormat));
ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,pixels.getWidth(),pixels.getBytesPerChannel(),pixels.getNumChannels());
glBindTexture(texData.textureTarget,texData.textureID);
glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_FLOAT,pixels.getData());
glBindTexture(texData.textureTarget,0);
#endif
}
示例6: loadData
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix){
ofSetPixelStorei(pix.getWidth(),pix.getBytesPerChannel(),pix.getNumChannels());
loadData(pix.getPixels(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
}
示例7: toPixels
// get float pixels from a fbo or texture
void ftUtil::toPixels(ofTexture& _tex, ofFloatPixels& _pixels) {
ofTextureData& texData = _tex.getTextureData();
int format = texData.glInternalFormat;
int readFormat, numChannels;
switch(format){
case GL_R32F: readFormat = GL_RED, numChannels = 1; break; // or is it GL_R
case GL_RG32F: readFormat = GL_RG, numChannels = 2; break;
case GL_RGB32F: readFormat = GL_RGB, numChannels = 3; break;
case GL_RGBA32F: readFormat = GL_RGBA, numChannels = 4; break;
default:
ofLogWarning("ftUtil") << "toPixels: " << "can only read float textures to ofFloatPixels";
return;
}
if (_pixels.getWidth() != texData.width || _pixels.getHeight() != texData.height || _pixels.getNumChannels() != numChannels) {
_pixels.allocate(texData.width, texData.height, numChannels);
}
ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT, texData.width, 4, numChannels);
glBindTexture(texData.textureTarget, texData.textureID);
glGetTexImage(texData.textureTarget, 0, readFormat, GL_FLOAT, _pixels.getData());
glBindTexture(texData.textureTarget, 0);
}