cannot load in skybox texture

Hey I cannot seem to get my skybox texture to load it keeps on firing the error message, I am using your skybox from your Skybox2 demo



// PVR texture files

const char* c_szTextureFile[2] =

{ “n_Map1.pvr”,

“Skybox.pvr”};




if(PVRTTextureLoadFromPVR(c_szTextureFile[1], &m_uiTexture[1]))

{

*pErrorStr = CPVRTString(“ERROR: Cannot open skybox”);

return false;

}



glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Hi John,



Would you be able to step through the PVRTTextureLoadFromPVR function and find out where it’s failing? There should be no good reason for this to fail, but there are a few things which could cause it. If you can let me know where it’s failing I should be able to help debug the issue.



Thanks,

Tobias

Hi Tobias,



When I get to this stage of the code in the PVRShellOS it fires the “cannot open skybox” error message



while(init.Run());



delete[] pszCmdLine;



return EXIT_NOERR_CODE;




I’m not entirely sure how to step through the PVRTTextureLoadFromPVR function.

I also want to add that this has not only happened to the skybox but has happened to another texture I have tried to load in just now.

Hmm, it’s possible that there’s a gl error being thrown before you actually get to that function. This is a common problem we have (something I’m trying to address in the new tools code). Try putting a glGetError before your texture load function and see if you still get the error inside the function, or if the glGetError now picks it up.



As for stepping through the function, the source for this function is available in the tools folder, under the name of the API you’re running. So e.g. if you’re using OpenGL ES 2, look in the “OGLES2” folder. The file you want there is “PVRTTextureAPI.cpp”. All you need to do then is to build the tools in debug mode and set a breakpoint with whichever debug tools you’re using (gdb / visual studio / xcode).



Also, what platform are you developing/running on?



Thanks,

Tobias

I am running on windows 7, I have put my glGetError(); in the following position but still get nothing, it still fires the pErrorStr



bool OGLESIntroducingPVRTools::load_Tex(CPVRTString* const pErrorStr){

/*

Loads the texture using the tool function PVRTTextureLoadFromPVR.

The first parameter is the name of the file and the

second parameter returns the resulting texture handle.

The third parameter is a CPVRTString for error message output.

This function can also be used to conveniently set the filter modes. If

those parameters are not given, OpenGL ES defaults are used.

Setting a mipmap filter on a mipmap-less texture will result in an error.

*/

glGetError();



if(PVRTTextureLoadFromPVR(c_szTextureFile[0], &m_uiTexture[0]) != PVR_SUCCESS)

{

*pErrorStr = CPVRTString(“texture could not be loaded1”);

return false;

}

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);



glGetError();



if(PVRTTextureLoadFromPVR(c_szTextureFile[1], &m_uiTexture[1]) != PVR_SUCCESS)

{

*pErrorStr = CPVRTString(“texture could not be loaded2”);

return false;

}

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);



if(PVRTTextureLoadFromPVR(c_szTextureFile[2], &m_uiTexture[2]))

{

pErrorStr = CPVRTString(“ERROR: Cannot open skybox”);

return false;

}



glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);



return true;

}




and this part is within my initview method



bool OGLESIntroducingPVRTools::InitView()

{



// Sets the clear color

glClearColor(0.6f, 0.8f, 1.0f, 1.0f);



CPVRTString pErrorStr;

/

Load textures

*/

glGetError();



if(!load_Tex(&pErrorStr))

{

PVRShellSet(prefExitMessage, pErrorStr.c_str());

return false;

}

Hi John,



So there’s really only a couple of (normal) reasons why it would be failing, given that you’re using the shell.



The first one is fairly easy to verify - can you try calling “fopen()” on the file path, to verify that it’s looking in the correct place for the file?



Secondly, could you try reopening the files in PVRTexToolGUI just to verify that they haven’t become mangled somehow?



Thanks,

Tobias

Hi Tobias,



I have reopened the files in PVRTexToolGUI and they open just fine, as for the first option



I have made a method to do the fopen and it goes as follows



void OGLESIntroducingPVRTools::loadTex(char* file){

FILE TexFile;

TexFile = fopen(file, “r”);

if(!TexFile)

printf(“Error cannot open file”);

else

printf(“fopen() successful…”);

}




and then in the initview just above where I load the textures



/

Load textures

*/

glGetError();



loadTex(“C:\Users\john\Documents\OGLES2_PCX86_EMULATION\OGLES2_PVR\SDK_3.0\Examples\Beginner5_IntroducingPVRTools\OGLES2\DUDV_map”);



if(!load_Tex(&pErrorStr))

{

PVRShellSet(prefExitMessage, pErrorStr.c_str());

return false;

}




however nothing prints to the console, or should I say it doesnt run at all. I have put breakpoints in but it doesn’t seem to go into that method.



Thanks

John

That’s… weird :S



Oh - sometimes Visual Studio will have errors during compilation, but run your last compiled binary anyway. Maybe that’s the issue? It’s also worth using the method “OutputDebugString” instead for visual studio - it prints to the debug window in Visual Studio itself rather than the console.



Tobias

Hi Tobias,



I changed my method to use OutputDebugString as you said and it prints out “Error cannot open file”

Hi John,



Just looking at your code, is the texture file supposed to not have a file extension on it? If it’s a .pvr file - you’ll need to add the extension for it to open. If that’s not the reason, I’d suggest verifying the rest of the file path (a copy+paste into the file explorer should tell you if it’s valid).



Thanks,

Tobias

oh sorry I forgot to put the extension, it says that the file is successful in opening. Thanks for pointing it out



Thanks

John

Ah excellent, so it’s all working now?



Regards,

Tobias

sorry no, I meant the loadTex fopen method says its successful, however when I actually try to load it in with PVRTTextureLoadFromPVR it still fires the error message. Also I noticed in the debug it said that IniView failed, but I think this is due to the texture not loading? Although I could be wrong.

Hello John ,



are you able to run the demo skybox 2?

and start from the working point ?



regards

david

Hi David,

I am able to run skybox2 do you suggest I move my code on to that project and use that as a working point?

yes to avoid big bang integration :slight_smile:

Hi David,



I have already tried what you have suggested, this leads me to think there is something wrong with the textures themselves. However when I call fopen(); on them they seem to open fine…now my normal map won’t even load when I bring my code into the skybox2 demo



Thanks

John

http://forum.imgtec.com/discussion/2615/shader-doesnt-load#latest It was because I hadn’t included the filewrapped .cpp’s into the project -.-