I'm hacking the editor for the game I'm working on, and as part of this editor, I need to have textures, obviously. I created the std :: map variable so
std::map<std::string, unsigned int> textures;
In my image upload 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 trying to use the above code. An access violation error that during debugging points to the std :: map code itself, in particular, this part:
_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 only make one call to the image upload function just to check the system. I checked the variables and the file names and identifiers are correct. Any ideas on what could lead to a runtime failure?
Steve healy
source share