本文整理汇总了C++中MBGL_CHECK_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ MBGL_CHECK_ERROR函数的具体用法?C++ MBGL_CHECK_ERROR怎么用?C++ MBGL_CHECK_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MBGL_CHECK_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showDebugImage
void showDebugImage(std::string name, const char *data, size_t width, size_t height) {
glfwInit();
static GLFWwindow *debugWindow = nullptr;
if (!debugWindow) {
debugWindow = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
if (!debugWindow) {
glfwTerminate();
fprintf(stderr, "Failed to initialize window\n");
exit(1);
}
}
GLFWwindow *currentWindow = glfwGetCurrentContext();
glfwSetWindowSize(debugWindow, width, height);
glfwMakeContextCurrent(debugWindow);
int fbWidth, fbHeight;
glfwGetFramebufferSize(debugWindow, &fbWidth, &fbHeight);
float scale = static_cast<float>(fbWidth) / static_cast<float>(width);
{
gl::PreservePixelZoom pixelZoom;
gl::PreserveRasterPos rasterPos;
MBGL_CHECK_ERROR(glPixelZoom(scale, -scale));
MBGL_CHECK_ERROR(glRasterPos2f(-1.0f, 1.0f));
MBGL_CHECK_ERROR(glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data));
}
glfwSwapBuffers(debugWindow);
glfwMakeContextCurrent(currentWindow);
}
示例2: Get
inline static Type Get() {
GLint sfail, dpfail, dppass;
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_FAIL, &sfail));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &dpfail));
MBGL_CHECK_ERROR(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &dppass));
return { static_cast<GLenum>(sfail), static_cast<GLenum>(dpfail), static_cast<GLuint>(dppass) };
}
示例3: MBGL_CHECK_ERROR
void LinepatternShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset + 0));
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_UNSIGNED_BYTE, false, 8, offset + 4));
}
示例4: MBGL_CHECK_ERROR
void Painter::renderClipMasks() {
config.stencilTest = GL_FALSE;
config.depthTest = GL_FALSE;
config.program = 0;
config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
#ifndef GL_ES_VERSION_2_0
config.pixelZoom = { 1, 1 };
config.rasterPos = {{ -1, -1, 0, 0 }};
// Read the stencil buffer
const auto& fbSize = frame.framebufferSize;
auto pixels = std::make_unique<uint8_t[]>(fbSize[0] * fbSize[1]);
MBGL_CHECK_ERROR(glReadPixels(
0, // GLint x
0, // GLint y
fbSize[0], // GLsizei width
fbSize[1], // GLsizei height
GL_STENCIL_INDEX, // GLenum format
GL_UNSIGNED_BYTE, // GLenum type
pixels.get() // GLvoid * data
));
// Scale the Stencil buffer to cover the entire color space.
auto it = pixels.get();
auto end = it + fbSize[0] * fbSize[1];
const auto factor = 255.0f / *std::max_element(it, end);
for (; it != end; ++it) {
*it *= factor;
}
MBGL_CHECK_ERROR(glWindowPos2i(0, 0));
MBGL_CHECK_ERROR(glDrawPixels(fbSize[0], fbSize[1], GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels.get()));
#endif // GL_ES_VERSION_2_0
}
示例5: MBGL_CHECK_ERROR
void ObjectStore::performCleanup() {
for (GLuint id : abandonedPrograms) {
MBGL_CHECK_ERROR(glDeleteProgram(id));
}
abandonedPrograms.clear();
for (GLuint id : abandonedShaders) {
MBGL_CHECK_ERROR(glDeleteShader(id));
}
abandonedShaders.clear();
if (!abandonedBuffers.empty()) {
MBGL_CHECK_ERROR(glDeleteBuffers(int(abandonedBuffers.size()), abandonedBuffers.data()));
abandonedBuffers.clear();
}
if (!abandonedTextures.empty()) {
MBGL_CHECK_ERROR(glDeleteTextures(int(abandonedTextures.size()), abandonedTextures.data()));
abandonedTextures.clear();
}
if (!abandonedVAOs.empty()) {
MBGL_CHECK_ERROR(gl::DeleteVertexArrays(int(abandonedVAOs.size()), abandonedVAOs.data()));
abandonedVAOs.clear();
}
}
示例6: glPixelTransferf
void Painter::renderDepthBuffer() {
context.stencilTest = GL_FALSE;
context.depthTest = GL_FALSE;
context.program = 0;
context.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
#ifndef GL_ES_VERSION_2_0
context.pixelZoom = { 1, 1 };
context.rasterPos = {{ -1, -1, 0, 0 }};
// Read the stencil buffer
const auto& fbSize = frame.framebufferSize;
auto pixels = std::make_unique<GLubyte[]>(fbSize[0] * fbSize[1]);
const double base = 1.0 / (1.0 - depthRangeSize);
glPixelTransferf(GL_DEPTH_SCALE, base);
glPixelTransferf(GL_DEPTH_BIAS, 1.0 - base);
MBGL_CHECK_ERROR(glReadPixels(
0, // GLint x
0, // GLint y
fbSize[0], // GLsizei width
fbSize[1], // GLsizei height
GL_DEPTH_COMPONENT, // GLenum format
GL_UNSIGNED_BYTE, // GLenum type
pixels.get() // GLvoid * data
));
MBGL_CHECK_ERROR(glWindowPos2i(0, 0));
MBGL_CHECK_ERROR(glDrawPixels(fbSize[0], fbSize[1], GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels.get()));
#endif // GL_ES_VERSION_2_0
}
示例7: end_group
inline void end_group() {
if (gl::PopDebugGroup != nullptr) {
MBGL_CHECK_ERROR(gl::PopDebugGroup());
} else if (gl::PopGroupMarkerEXT != nullptr) {
MBGL_CHECK_ERROR(gl::PopGroupMarkerEXT());
}
// indent--;
}
示例8: MBGL_CHECK_ERROR
void Raster::updateFilter() {
MBGL_CHECK_ERROR(glTexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
filter == Scaling::Linear
? (mipmap == MipMap::Yes ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR)
: (mipmap == MipMap::Yes ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST)));
MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
filter == Scaling::Linear ? GL_LINEAR : GL_NEAREST));
}
示例9: start_group
// static int indent = 0;
inline void start_group(const std::string &str) {
if (gl::PushDebugGroup != nullptr) {
MBGL_CHECK_ERROR(gl::PushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(str.size()), str.c_str()));
} else if (gl::PushGroupMarkerEXT != nullptr) {
MBGL_CHECK_ERROR(gl::PushGroupMarkerEXT(GLsizei(str.size() + 1), str.c_str()));
}
// fprintf(stderr, "%s%s\n", std::string(indent * 4, ' ').c_str(), str.c_str());
// indent++;
}
示例10: enable
void enable() {
if (!DebugMessageControl || !DebugMessageCallback) {
return;
}
// This will enable all messages including performance hints
//MBGL_CHECK_ERROR(DebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE));
// This will only enable high and medium severity messages
MBGL_CHECK_ERROR(DebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, GL_TRUE));
MBGL_CHECK_ERROR(DebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, GL_TRUE));
MBGL_CHECK_ERROR(DebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE));
MBGL_CHECK_ERROR(DebugMessageCallback(debugCallback, nullptr));
}
示例11: MBGL_CHECK_ERROR
void VertexArrayObject::bindVertexArrayObject() {
if (!GenVertexArrays || !BindVertexArray) {
static bool reported = false;
if (!reported) {
Log::Warning(Event::OpenGL, "Not using Vertex Array Objects");
reported = true;
}
return;
}
if (!vao) {
MBGL_CHECK_ERROR(GenVertexArrays(1, &vao));
}
MBGL_CHECK_ERROR(BindVertexArray(vao));
}
示例12: MBGL_DEBUG_GROUP
void Painter::drawClippingMasks(PaintParameters& parameters, const std::map<UnwrappedTileID, ClipID>& stencils) {
MBGL_DEBUG_GROUP("clipping masks");
auto& plainShader = parameters.shaders.plain;
auto& arrayCoveringPlain = parameters.shaders.coveringPlainArray;
mat4 matrix;
const GLuint mask = 0b11111111;
config.program = plainShader.getID();
config.stencilOp.reset();
config.stencilTest = GL_TRUE;
config.depthTest = GL_FALSE;
config.depthMask = GL_FALSE;
config.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
config.stencilMask = mask;
arrayCoveringPlain.bind(plainShader, tileStencilBuffer, BUFFER_OFFSET_0, store);
for (const auto& stencil : stencils) {
const auto& id = stencil.first;
const auto& clip = stencil.second;
MBGL_DEBUG_GROUP(std::string{ "mask: " } + util::toString(id));
state.matrixFor(matrix, id);
matrix::multiply(matrix, projMatrix, matrix);
plainShader.u_matrix = matrix;
const GLint ref = (GLint)(clip.reference.to_ulong());
config.stencilFunc = { GL_ALWAYS, ref, mask };
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
}
}
示例13: MBGL_CHECK_ERROR
void AttributeBinding<T, N>::bind(Context& context, AttributeLocation location, std::size_t vertexOffset) const {
// FillProgram will attempt to bind at location -1 because it includes
// a fill-outline-color paint property but does not use it or have an
// a_outline_color shader attribute - in this case, we have nothing to bind.
if (location == -1) return;
context.vertexBuffer = vertexBuffer;
MBGL_CHECK_ERROR(glEnableVertexAttribArray(location));
MBGL_CHECK_ERROR(glVertexAttribPointer(
location,
static_cast<GLint>(attributeSize),
static_cast<GLenum>(DataTypeOf<T>),
static_cast<GLboolean>(false),
static_cast<GLsizei>(vertexSize),
reinterpret_cast<GLvoid*>(attributeOffset + (vertexSize * vertexOffset))));
}
示例14: bind
// Transfers this buffer to the GPU and binds the buffer to the GL context.
void bind() {
if (buffer) {
MBGL_CHECK_ERROR(glBindBuffer(bufferType, buffer));
} else {
MBGL_CHECK_ERROR(glGenBuffers(1, &buffer));
MBGL_CHECK_ERROR(glBindBuffer(bufferType, buffer));
if (array == nullptr) {
Log::Debug(Event::OpenGL, "Buffer doesn't contain elements");
pos = 0;
}
MBGL_CHECK_ERROR(glBufferData(bufferType, pos, array, GL_STATIC_DRAW));
if (!retainAfterUpload) {
cleanup();
}
}
}
示例15: bind
// Transfers this buffer to the GPU and binds the buffer to the GL context.
void bind(gl::ObjectStore& store) {
if (buffer) {
MBGL_CHECK_ERROR(glBindBuffer(bufferType, *buffer));
} else {
buffer = store.createBuffer();
MBGL_CHECK_ERROR(glBindBuffer(bufferType, *buffer));
if (array == nullptr) {
Log::Debug(Event::OpenGL, "Buffer doesn't contain elements");
pos = 0;
}
MBGL_CHECK_ERROR(glBufferData(bufferType, pos, array, GL_STATIC_DRAW));
if (!retainAfterUpload) {
cleanup();
}
}
}