异常的 std::map 运行时错误
我正在为我正在开发的游戏编写一个编辑器,作为该编辑器的一部分,显然我需要有纹理。 我已经创建了一个 std::map 变量,
std::map<std::string, unsigned int> textures;
在我的图像加载代码中,我有以下代码片段。
unsigned int id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
glBindTexture(GL_TEXTURE_2D, 0);
textures[filename] = id;
现在,由于某种原因,我在尝试使用上述代码后收到运行时错误。 一个访问冲突错误,在调试时,将我指向 std::map 代码本身,特别是这部分:
_Nodeptr _Lbound(const key_type& _Keyval) const
{ // find leftmost node not less than _Keyval
_Nodeptr _Pnode = _Root(); // ** this is the highlighted line **
_Nodeptr _Wherenode = _Myhead; // end() if search fails
while (!_Isnil(_Pnode))
if (_DEBUG_LT_PRED(this->comp, _Key(_Pnode), _Keyval))
_Pnode = _Right(_Pnode); // descend right subtree
else
{ // _Pnode not less than _Keyval, remember it
_Wherenode = _Pnode;
_Pnode = _Left(_Pnode); // descend left subtree
}
return (_Wherenode); // return best remembered candidate
}
我只对图像加载函数进行一次调用,只是为了测试系统。 我检查了变量,文件名和 id 变量都是正确的。 关于可能导致运行时崩溃的任何想法?
I'm hacking together an editor for a game I'm working on and as part of that editor, I need to have textures, obviously. I've created a std::map variable as so,
std::map<std::string, unsigned int> textures;
In my image loading code, I have the following snippet.
unsigned int id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
glBindTexture(GL_TEXTURE_2D, 0);
textures[filename] = id;
Now for some reason, I get a runtime error after attempting to use the above code. An access violation error, that, when debugged, points me to the std::map code itself, specifically, this portion:
_Nodeptr _Lbound(const key_type& _Keyval) const
{ // find leftmost node not less than _Keyval
_Nodeptr _Pnode = _Root(); // ** this is the highlighted line **
_Nodeptr _Wherenode = _Myhead; // end() if search fails
while (!_Isnil(_Pnode))
if (_DEBUG_LT_PRED(this->comp, _Key(_Pnode), _Keyval))
_Pnode = _Right(_Pnode); // descend right subtree
else
{ // _Pnode not less than _Keyval, remember it
_Wherenode = _Pnode;
_Pnode = _Left(_Pnode); // descend left subtree
}
return (_Wherenode); // return best remembered candidate
}
I'm only making one call to my image loading function just to test the system. I checked the variables and both the filename and id variables are correct. Any ideas as far as to what could be causing the runtime crash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论