MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetVideoBuffer

Method GetVideoBuffer

src/video/opengl.cpp:1148–1164  ·  view source on GitHub ↗

* Get a pointer to the memory for the video driver to draw to. * @return Pointer to draw on. */

Source from the content-addressed store, hash-verified

1146 * @return Pointer to draw on.
1147 */
1148void *OpenGLBackend::GetVideoBuffer()
1149{
1150#ifndef NO_GL_BUFFER_SYNC
1151 if (this->sync_vid_mapping != nullptr) _glClientWaitSync(this->sync_vid_mapping, GL_SYNC_FLUSH_COMMANDS_BIT, 100000000); // 100ms timeout.
1152#endif
1153
1154 if (!this->persistent_mapping_supported) {
1155 assert(this->vid_buffer == nullptr);
1156 _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo);
1157 this->vid_buffer = _glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
1158 } else if (this->vid_buffer == nullptr) {
1159 _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vid_pbo);
1160 this->vid_buffer = _glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, static_cast<GLsizeiptr>(_screen.pitch) * _screen.height * BlitterFactory::GetCurrentBlitter()->GetScreenDepth() / 8, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
1161 }
1162
1163 return this->vid_buffer;
1164}
1165
1166/**
1167 * Get a pointer to the memory for the separate animation buffer.

Callers 2

GetVideoPointerMethod · 0.80
GetVideoPointerMethod · 0.80

Calls 1

GetScreenDepthMethod · 0.45

Tested by

no test coverage detected