//---------------------------------------------------------- void ofTexture::loadData(const ofShortPixels & 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)); }
//---------------------------------------------------------- void ofTexture::loadData(const ofShortPixels & pix){ if(!isAllocated()){ allocate(pix); }else{ ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getBytesStride()); loadData(pix.getData(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix)); } }
//---------------------------------------------------------- void ofTexture::readToPixels(ofShortPixels & 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_UNSIGNED_SHORT,pixels.getData()); glBindTexture(texData.textureTarget,0); #endif }
//---------------------------------------------------------- void ofFbo::readToPixels(ofShortPixels & 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_UNSIGNED_SHORT, pixels.getData()); unbind(); #endif }
void ofxTexture3d::loadData(ofShortPixels & pix, int d, int xOffset, int yOffset, int zOffset) { loadData(pix.getData(), pix.getWidth(), pix.getHeight(), d, xOffset, yOffset, zOffset, ofGetGlFormat(pix)); }
//---------------------------------------------------------- void ofTexture::loadData(const ofShortPixels & pix, int glFormat){ ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat)); loadData(pix.getData(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix)); }