void * ofBufferObject::map(GLenum access){ if(!this->data) return nullptr; #ifdef GLEW_ARB_direct_state_access if (GLEW_ARB_direct_state_access) { return glMapNamedBuffer(data->id,access); } #endif /// --------| invariant: direct state access is not available if(!data->isBound){ // if the buffer wasn't already bound and the operation // is one of unpack/pack buffer alternate between the 2 // since the tipical use is to pack to copy to the buffer // then unpack to copy from it. // for more advanced usages one can just bind the buffer // before mapping if(data->lastTarget==GL_PIXEL_PACK_BUFFER){ data->lastTarget = GL_PIXEL_UNPACK_BUFFER; }else if(data->lastTarget == GL_PIXEL_UNPACK_BUFFER){ data->lastTarget = GL_PIXEL_PACK_BUFFER; } glBindBuffer(data->lastTarget, data->id); } auto ret = glMapBuffer(data->lastTarget,access); if(!data->isBound){ unbind(data->lastTarget); } return ret; }
// void VertexBuffer::setSubData(GLfloat *data, GLintptr offset, GLsizeiptr count) // { // glNamedBufferSubData(m_BufferID, offset * m_ComponentCount, count * m_ComponentCount, data); // } // void* VertexBuffer::mapBuffer(GLenum access) { #ifdef TR_CURRENT return glMapNamedBuffer(m_BufferID, access); #else return glMapBuffer(GL_ARRAY_BUFFER, access); #endif }
void * ofBufferObject::map(GLenum access){ if(!this->data) return NULL; #ifdef GLEW_ARB_direct_state_access if (data->useDSA) { return glMapNamedBuffer(data->id,access); } #endif /// --------| invariant: direct state access is not available if(data->lastTarget==GL_PIXEL_PACK_BUFFER){ bind(GL_PIXEL_UNPACK_BUFFER); }else{ bind(data->lastTarget); } return glMapBuffer(data->lastTarget,access); }
void* glMapBuffer(GLenum target, GLenum access) { return glMapNamedBuffer((GLuint) boundBuffer, access); }
void * BufferImplementation_DirectStateAccessARB::map(const Buffer * buffer, GLenum access) const { return glMapNamedBuffer(buffer->id(), access); }