1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Merge pull request #277 from TomHarte/MappingFallback

Adds a fallback route for the array builder if it can't map a buffer.
This commit is contained in:
Thomas Harte 2017-11-13 19:27:48 -08:00 committed by GitHub
commit 1027f85683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -125,9 +125,13 @@ std::size_t ArrayBuilder::Buffer::submit(bool is_input) {
} else {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
uint8_t *destination = static_cast<uint8_t *>(glMapBufferRange(GL_ARRAY_BUFFER, 0, (GLsizeiptr)length, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_FLUSH_EXPLICIT_BIT));
std::memcpy(destination, data.data(), length);
glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, (GLsizeiptr)length);
glUnmapBuffer(GL_ARRAY_BUFFER);
if(false) {
std::memcpy(destination, data.data(), length);
glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, (GLsizeiptr)length);
glUnmapBuffer(GL_ARRAY_BUFFER);
} else {
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)length, data.data(), GL_STREAM_DRAW);
}
}
submitted_data = flushed_data;
return length;

View File

@ -8,12 +8,9 @@
#include "TextureTarget.hpp"
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace OpenGL;
TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit, GLint mag_filter) :
@ -33,7 +30,6 @@ TextureTarget::TextureTarget(GLsizei width, GLsizei height, GLenum texture_unit,
glBindTexture(GL_TEXTURE_2D, texture_);
std::vector<uint8_t> blank_buffer(static_cast<size_t>(expanded_width_ * expanded_height_ * 4), 0);
std::cout << blank_buffer.size() << std::endl;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(expanded_width_), static_cast<GLsizei>(expanded_height_), 0, GL_RGBA, GL_UNSIGNED_BYTE, blank_buffer.data());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);