glMapBufferRange访问冲突 [英] glMapBufferRange Access Violation

查看:948
本文介绍了glMapBufferRange访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在shader-storage-buffer中存储一些粒子。我使用glMapBufferRange()函数设置粒子值,但是每当调用这个函数时,我总是得到一个Access Violation错误。

I want to store some particles in a shader-storage-buffer. I use the glMapBufferRange() function to set the particles values but I always get an Access Violation error whenever this function is called.

glGenBuffers(1, &bufferID);
glBindBuffer(GL_SHADER_STORAGE_BUFFER, bufferID);
glBufferData(GL_SHADER_STORAGE_BUFFER, numParticles*sizeof(Particle), NULL ,GL_STATIC_DRAW);


struct Particle* particles = (struct Particle*) glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, numParticles*sizeof(Particle), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);

for(int i = 0; i < numParticles; ++i){
    //.. Do something with particles..//
}

glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);

当我使用glMapBuffer()代替,一切正常。我已经确定我已经创建了一个与glfw和初始化glew正确的OpenGL上下文。

When I use glMapBuffer() instead, everything works fine. I already made sure that I have created an OpenGL context with glfw and initialized glew properly.

推荐答案

。当我设计我的GLFW-Window类时,我使用GLFW_OPENGL_FORWARD_COMPAT提示来创建一个向前兼容的OpenGL上下文。我不知道为什么我这样做,但是当我不使用这个提示一切工作正常。 :)

Ok, I finally found the problem. When I designed my GLFW-Window class I used the GLFW_OPENGL_FORWARD_COMPAT hint to create a forward-compatible OpenGL context. I don't know why I did this, but when I don't use this hint everything works fine. :)

这篇关于glMapBufferRange访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆