Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenGL glBindTexture()崩溃_C++_Opengl - Fatal编程技术网

C++ OpenGL glBindTexture()崩溃

C++ OpenGL glBindTexture()崩溃,c++,opengl,C++,Opengl,当我调用glBindTexture(GL_TEXTURE_2D,_ID)时,程序冻结;在“Renderer”类的draw(Sprite)方法中。(实际代码是sprite.getTexture()->bind(),但我在glBindTexture()调用前后在该函数中添加了一个std::cout,它只打印一次) 我正在努力理解为什么程序冻结——当我调用glBindTexture时,程序没有响应并崩溃。这里是指向github的链接,而不是用一长串代码来填充这个页面,相关的文件主要是src/graph

当我调用glBindTexture(GL_TEXTURE_2D,_ID)时,程序冻结;在“Renderer”类的draw(Sprite)方法中。(实际代码是sprite.getTexture()->bind(),但我在glBindTexture()调用前后在该函数中添加了一个std::cout,它只打印一次)

我正在努力理解为什么程序冻结——当我调用glBindTexture时,程序没有响应并崩溃。这里是指向github的链接,而不是用一长串代码来填充这个页面,相关的文件主要是src/graphics/renderer.cpp和src/graphics/texture.cpp


如果有人有时间通读代码并尝试为我指出正确的方向,我将不胜感激,因为我已经思考了好几个小时。

是不是有问题?如有的话—

SplashState::SplashState(Game* game)
{
    _game = game;
    Texture2D backgroundTexture("res/darkguy.png", 96, 128);
    Sprite _background;
    _background.setTexture(backgroundTexture);
}

您正在将纹理指定给局部范围的
精灵
,而不是
SplashState
——因此,当您尝试在渲染函数中绘制纹理时,类级别的
精灵
没有纹理

是的,删除“Sprite\u background”行解决了问题。我不知道为什么我声明twiceIt会发生(特别是在喝咖啡之前)!你能标记为已解决吗?