//---------------------------------------------------------- void ofTexture::allocateAsBufferTexture(const ofBufferObject & buffer, int glInternalFormat){ texData.glInternalFormat = glInternalFormat; texData.textureTarget = GL_TEXTURE_BUFFER; texData.bufferId = buffer.getId(); allocate(texData,0,0); buffer.bind(GL_TEXTURE_BUFFER); }
void ofBufferObject::copyTo(ofBufferObject & dstBuffer, int readOffset, int writeOffset, size_t size) const{ bind(GL_COPY_READ_BUFFER); dstBuffer.bind(GL_COPY_WRITE_BUFFER); glCopyBufferSubData(GL_COPY_READ_BUFFER,GL_COPY_WRITE_BUFFER,readOffset,writeOffset,size); unbind(GL_COPY_READ_BUFFER); dstBuffer.unbind(GL_COPY_WRITE_BUFFER); }
void ofBufferObject::copyTo(ofBufferObject & dstBuffer) const{ bind(GL_COPY_READ_BUFFER); dstBuffer.bind(GL_COPY_WRITE_BUFFER); glCopyBufferSubData(GL_COPY_READ_BUFFER,GL_COPY_WRITE_BUFFER,0,0,size()); unbind(GL_COPY_READ_BUFFER); dstBuffer.unbind(GL_COPY_WRITE_BUFFER); }
//---------------------------------------------------------- void ofFbo::copyTo(ofBufferObject & buffer) const{ if(!bIsAllocated) return; bind(); buffer.bind(GL_PIXEL_PACK_BUFFER); glReadPixels(0, 0, settings.width, settings.height, ofGetGLFormatFromInternal(settings.internalformat), ofGetGlTypeFromInternal(settings.internalformat), NULL); buffer.unbind(GL_PIXEL_PACK_BUFFER); unbind(); }
//---------------------------------------------------------- void ofTexture::copyTo(ofBufferObject & buffer) const{ ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,getWidth(),ofGetBytesPerChannelFromGLType(ofGetGlTypeFromInternal(texData.glInternalFormat)),ofGetNumChannelsFromGLFormat(ofGetGLFormatFromInternal(texData.glInternalFormat))); buffer.bind(GL_PIXEL_PACK_BUFFER); glBindTexture(texData.textureTarget,texData.textureID); glGetTexImage(texData.textureTarget,0,ofGetGLFormatFromInternal(texData.glInternalFormat),ofGetGlTypeFromInternal(texData.glInternalFormat),0); glBindTexture(texData.textureTarget,0); buffer.unbind(GL_PIXEL_PACK_BUFFER); }
void ofBufferObject::copyTo(ofBufferObject & dstBuffer, int readOffset, int writeOffset, size_t size) const{ #ifdef GLEW_VERSION_4_5 if (GLEW_EXT_direct_state_access) { glCopyNamedBufferSubData(data->id,dstBuffer.getId(),readOffset,writeOffset,size); return; } #endif bind(GL_COPY_READ_BUFFER); dstBuffer.bind(GL_COPY_WRITE_BUFFER); glCopyBufferSubData(GL_COPY_READ_BUFFER,GL_COPY_WRITE_BUFFER,readOffset,writeOffset,size); unbind(GL_COPY_READ_BUFFER); dstBuffer.unbind(GL_COPY_WRITE_BUFFER); }
//---------------------------------------------------------- void ofTexture::loadData(const ofBufferObject & buffer, int glFormat, int glType){ buffer.bind(GL_PIXEL_UNPACK_BUFFER); loadData(0,texData.width,texData.height,glFormat,glType); buffer.unbind(GL_PIXEL_UNPACK_BUFFER); }