本文整理汇总了C++中ofFloatPixels::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFloatPixels::getData方法的具体用法?C++ ofFloatPixels::getData怎么用?C++ ofFloatPixels::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFloatPixels
的用法示例。
在下文中一共展示了ofFloatPixels::getData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadData
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix, int glFormat){
if(!isAllocated()){
allocate(pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix), ofGetUsingArbTex(), glFormat, ofGetGlType(pix));
}
ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
loadData(pix.getData(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}
示例2: 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
}
示例3: readToPixels
//----------------------------------------------------------
void ofFbo::readToPixels(ofFloatPixels & pixels, int attachmentPoint) const{
if(!bIsAllocated) return;
#ifndef TARGET_OPENGLES
getTexture(attachmentPoint).readToPixels(pixels);
#else
pixels.allocate(settings.width,settings.height,ofGetImageTypeFromGLType(settings.internalformat));
bind();
int format = ofGetGLFormatFromInternal(settings.internalformat);
glReadPixels(0,0,settings.width, settings.height, format, GL_FLOAT, pixels.getData());
unbind();
#endif
}
示例4: update
void update() {
#ifdef USE_AUDIO
//Speaker sampling code
speakerFbo.begin();
renderScene(shader, speakerXyzMap, speakerConfidenceMap);
speakerFbo.end();
//Read back the fbo, and average it on the CPU
speakerFbo.readToPixels(speakerPixels);
speakerPixels.setImageType(OF_IMAGE_GRAYSCALE);
ofxOscMessage brightnessMsg;
brightnessMsg.setAddress("/audio/brightness");
float* pix = speakerPixels.getData();
for(int i = 0; i < n_speakers; i++){
float avg = 0;
for(int j = 0; j < n_samples; j++){
avg += *pix++;
}
avg /= n_samples;
brightnessMsg.addFloatArg(avg);
}
oscSender.sendMessage(brightnessMsg);
float elapsedTime = ofGetElapsedTimef();
// copied from shader --- 8< ---
float t = elapsedTime / 30.; // duration of each stage
float stage = floor(t); // index of current stage
float i = t - stage; // progress in current stage
// copied from shader --- 8< ---
if(stage != previousStage) {
ofxOscMessage msg;
msg.setAddress("/audio/scene_change_event");
msg.addIntArg(stage == 0 ? 0 : 2);
oscSender.sendMessage(msg);
}
previousStage = stage;
if(stage == 0) {
float lighthouseAngle = ofGetElapsedTimef() / TWO_PI;
lighthouseAngle += 0; // set offset here
ofxOscMessage msg;
msg.setAddress("/audio/lighthouse_angle");
msg.addFloatArg(fmodf(lighthouseAngle, 1));
oscSender.sendMessage(msg);
}
#endif
}
示例5: 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);
}
示例6: loadData
void ofxTexture3d::loadData(ofFloatPixels & pix, int d, int xOffset, int yOffset, int zOffset)
{
loadData(pix.getData(), pix.getWidth(), pix.getHeight(), d, xOffset, yOffset, zOffset, ofGetGlFormat(pix));
}
示例7: loadData
//----------------------------------------------------------
void ofTexture::loadData(const ofFloatPixels & pix, int glFormat){
ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
loadData(pix.getData(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}