gpt4 book ai didi

c++ - 绘图期间未处理的异常 (nvoglv32.dll)(裂缝)

转载 作者:行者123 更新时间:2023-11-28 06:56:20 32 4
gpt4 key购买 nike

我实际上正在使用 HMD oculus rift 制作 AR。我不是 openGL 专家,我确​​信这是我问题的根源。

我收到这个错误:

Unhandled exception at 0x064DBD07 (nvoglv32.dll) in THING.exe: 0xC0000005: Access violation reading location 0x00000000.

它发生在 quadGeometry_supcam->draw() 的绘图过程中;在 renderCamera(eye) 中; :

  glDrawElements(elementType, elements * verticesPerElement,
GL_UNSIGNED_INT, (void*) 0);// Stop at this line in the debuger

下面是绘图代码

  frameBuffer.activate();
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl::Stacks::with_push(pr, mv, [&]{
mv.preMultiply(eyeArgs.modelviewOffset);
pr.preMultiply(eyeArgs.projectionOffset);
//renderCamera(eye); //If I uncomment this part, it crash
renderScene(eye);
//renderCamera(eye); //If I uncomment this part, it works but It's not what I want
});
frameBuffer.deactivate();
glDisable(GL_DEPTH_TEST);

viewport(eye);
distortProgram->use();
glActiveTexture(GL_TEXTURE1);
eyeArgs.distortionTexture->bind();
glActiveTexture(GL_TEXTURE0);
frameBuffer.color->bind();
quadGeometry->bindVertexArray();
quadGeometry->draw();
gl::VertexArray::unbind();
gl::Program::clear();

///////////////////////////////////////////////////////////

void renderScene(StereoEye eye) {
GlUtils::renderSkybox(Resource::IMAGES_SKY_CITY_XNEG_PNG);
GlUtils::renderFloorGrid(player);
gl::MatrixStack & mv = gl::Stacks::modelview();
gl::Stacks::with_push(mv, [&]{
mv.translate(glm::vec3(0, eyeHeight, 0)).scale(ipd);
GlUtils::drawColorCube(true); // Before this call renderCamera crash after it works
});
}

void renderCamera(StereoEye eye) {
gl::ProgramPtr program;
program = GlUtils::getProgram(
Resource::SHADERS_TEXTURED_VS,
Resource::SHADERS_TEXTURED_FS);
program->use();
textures[eye]->bind();
quadGeometry_supcam->bindVertexArray();
quadGeometry_supcam->draw();
}

如果我在 GlUtils::drawColorCube(true) 之前调用 renderCamera;它崩溃但在它工作之后。但我需要在休息之前画出相机。我不打算精确 drawColorCube 因为它使用其他着色器。我想问题出在着色器程序缺少的东西上。所以这是片段和顶点着色器。

顶点:

uniform mat4 Projection = mat4(1);
uniform mat4 ModelView = mat4(1);

layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord0;

out vec2 vTexCoord;

void main() {
gl_Position = Projection * ModelView * Position;
vTexCoord = TexCoord0;
}

片段:

uniform sampler2D sampler;

in vec2 vTexCoord;
out vec4 vFragColor;

void main() {
vFragColor = texture(sampler, vTexCoord);
}

(我想在相机的图像上绘制场景)。有什么想法吗?

最佳答案

调用 quadGeometry_supcam->draw(); 后,您并未清理 GL 状态。尝试在调用之后添加这些行

gl::VertexArray::unbind();
gl::Program::clear();

关于c++ - 绘图期间未处理的异常 (nvoglv32.dll)(裂缝),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23130339/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com