I want to have my program load a texture that a text file specifys. I have everything working but there's 1 problem. I cant convert from a C++ string to a "const wchar_t *".
I looked on MSDN and found a nice page that told me everything, apart from using C++ strings. So i thought that if i convert from my C++ string to a char, then follow MSDN and convert it to a wchar_t it would work. It didnt.
Here is the function call to load a texture:
Success = Load2DOpenGLTexture(&TEXTURE_MenuBack, <FILENAME>, &ErrorStr);
I replace <FILENAME> with the filename as a "const whcar_t *"
Here is the definition if it is any help. (the function itself works perfectly)
bool Load2DOpenGLTexture(GLuint* PointerToOpenGLTextureID, const wchar_t* ImageFileName, string* ErrorString){ //This is a complicated function that loads an OpenGL texture and return's 3 values ILboolean Success; ILuint DevILTextureID; //GLuint TempOGLTextureID; ilGenImages(1, &DevILTextureID); ilBindImage(DevILTextureID); Success = ilLoadImage(ImageFileName); if(Success) { Success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); if(!Success) { //string TempString = "Could not convert image"; //ErrorString = &TempString; *ErrorString = "Could not convert image"; return false; } glGenTextures(1, PointerToOpenGLTextureID); glBindTexture(GL_TEXTURE_2D, *PointerToOpenGLTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData()); ilDeleteImages(1, &DevILTextureID); } else { //string TempString = "Could not load image"; //ErrorString = &TempString; *ErrorString = "Could not load image"; return false; } //PointerToOpenGLTextureID = &TempOGLTextureID; return true;}
I am using OpenGL and DevIL
So any idea on how i can convert from a C++ "string" to a "const whcar_t *" ?