本文整理汇总了C++中ofTexture::isAllocated方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::isAllocated方法的具体用法?C++ ofTexture::isAllocated怎么用?C++ ofTexture::isAllocated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTexture
的用法示例。
在下文中一共展示了ofTexture::isAllocated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void imageMeltingPoint::render( const ofTexture& _tex){
if( !_tex.isAllocated() ) return;// false;
int radius = karmaSoundAnalyser::getInstance().getZeroCrossings()/400;
_tex.draw(position);
/*for(int x=position.x-radius; x<position.x+radius; x+=round(ofRandom(1,radius/10)) ){
if( x < 0 || x > _tex.getWidth() ) continue;
for(int y=position.y-radius; y<position.y+radius; y+=round(ofRandom(1,radius/10))){
if( y < 0 || y > _tex.getHeight() ) continue;
int offset = y*_tex.getWidth() + x;
offset /= _tex.getNumChannels()*2;
ofSetColor( (ofColor) _tex[offset] );
ofDrawCircle(x, y, 1);
}
}*/
}
示例2: receive
//----------
bool Receiver::receive(ofTexture & texture) {
try {
//check if we're initialised
if (!this->isInitialized()) {
throw("Not initialized");
}
//prepare the channel name, allow it to be changed if different channels are available
char mutableName[256];
unsigned int mutableWidth, mutableHeight;
strcpy_s(mutableName, this->channelName.size() + 1, this->channelName.c_str());
//check if the texture is allocated correctly, if not, allocate it
if (texture.getWidth() != this->width || texture.getHeight() != this->height) {
int format = texture.isAllocated() ? texture.getTextureData().glInternalFormat : this->defaultFormat;
texture.allocate(width, height, format);
}
//pull data into the texture (keep any existing fbo attachments)
GLint drawFboId = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
if (!this->spoutReceiver->ReceiveTexture(mutableName, mutableWidth, mutableHeight, texture.getTextureData().textureID, texture.getTextureData().textureTarget, false, drawFboId)) {
throw("Can't receive texture");
}
//update our local settings incase anything changed
this->channelName = mutableName;
this->width = mutableWidth;
this->height = mutableHeight;
return true;
}
catch (const char * e) {
ofLogError("ofxSpout::Receiver::receive") << e;
return false;
}
}
示例3: endFrame
bool fboRecorder::endFrame(bool _showBuffer){
if(!isRecording()) return false;
if(!useGrabScreen){
if(!bFrameStarted) return false;
fbo.end();
//fbo.getTexture().getTextureData().bFlipTexture = false;
bFrameStarted=false;
}
static ofTexture tmpTex;
int w = ofGetWidth();
int h = ofGetHeight();
if(!tmpTex.isAllocated()){
tmpTex.allocate( w, h, GL_RGBA );
}
switch(fboRecMode){
case VIDEOREC_MODE_FILE_H264 :
case VIDEOREC_MODE_FILE_PNG : {
ofPixels pix;
pix.allocate(fbo.getWidth(),fbo.getHeight(), ofGetImageTypeFromGLType(GL_RGB));
if(useGrabScreen){
tmpTex.loadScreenData(0, 0, w, h);
tmpTex.readToPixels(pix);
}
else {
fbo.readToPixels(pix);
}
ofxVideoRecorder::addFrame(pix);
break;
}
#ifdef KM_ENABLE_SYPHON
case VIDEOREC_MODE_SYPHON: {
//fbo.updateTexture( fbo.getTexture().texData.textureID );
if( useGrabScreen ){
//syphonServer.publishScreen();
tmpTex.loadScreenData(0, 0, ofGetWidth(), ofGetHeight());
//tmpTex = fbo.getTexture();
syphonServer.publishTexture( &tmpTex );
}
else {
//tmpTex = fbo.getTexture();
syphonServer.publishTexture( &fbo.getTexture() );
}
break;
}
#endif
default:
return false;
break;
}
// flush
tmpTex.clear();
if(_showBuffer){
if(!useGrabScreen){
#ifdef KM_ENABLE_SYPHON
if( fboRecMode==VIDEOREC_MODE_SYPHON ){
#else
if(false){
#endif
fbo.draw(0, 0, fbo.getWidth(), fbo.getHeight()); // show recorded image
}
else {
fbo.draw(0, fbo.getHeight(),fbo.getWidth(), -fbo.getHeight()); // show recorded image
}
}
}
return true;
}
// LISTENERS
void fboRecorder::beforeDraw( karmaControllerDrawEventArgs& _args ){
beginFrame();
}
void fboRecorder::afterDraw( karmaControllerDrawEventArgs& _args ){
endFrame(videoRecShowOutput);
}