MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CopyCpuToGpu

Method CopyCpuToGpu

GTE/Graphics/GL46/GL46Buffer.cpp:87–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87bool GL46Buffer::CopyCpuToGpu()
88{
89 if (!PreparedForCopy(GL_WRITE_ONLY))
90 {
91 return false;
92 }
93
94 Buffer* buffer = GetBuffer();
95 GLuint numActiveBytes = buffer->GetNumActiveBytes();
96 if (numActiveBytes > 0)
97 {
98 // Copy from CPU memory to GPU memory.
99 GLintptr offsetInBytes =
100 static_cast<GLintptr>(buffer->GetOffset()) *
101 static_cast<GLintptr>(buffer->GetElementSize());
102 char const* source = buffer->GetData() + offsetInBytes;
103 glBindBuffer(mType, mGLHandle);
104 glBufferSubData(mType, offsetInBytes, numActiveBytes, source);
105 glBindBuffer(mType, 0);
106 }
107 return true;
108}
109
110bool GL46Buffer::CopyGpuToCpu()
111{

Callers

nothing calls this directly

Calls 6

glBindBufferFunction · 0.85
glBufferSubDataFunction · 0.85
GetNumActiveBytesMethod · 0.80
GetElementSizeMethod · 0.80
GetOffsetMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected