# cannot load in skybox texture

**URL:** <https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749>\
**Category:** PowerVR Insider\
**Tags:** pvrtextool\
**Created:** [April 14, 2013, 11:44am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749 "2013-04-14T11:44:51Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 14, 2013, 11:44am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/1 "2013-04-14T11:44:51Z")

</div>

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);`

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 15, 2013, 7:52am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/2 "2013-04-15T07:52:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 15, 2013, 9:24am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/3 "2013-04-15T09:24:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 15, 2013, 10:18pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/4 "2013-04-15T22:18:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 17, 2013, 6:51am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/5 "2013-04-17T06:51:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 17, 2013, 7:00am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/6 "2013-04-17T07:00:10Z")

</div>

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;
}`

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 18, 2013, 9:24am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/7 "2013-04-18T09:24:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 18, 2013, 10:51am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/8 "2013-04-18T10:51:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 18, 2013, 11:06am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/9 "2013-04-18T11:06:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 18, 2013, 11:39am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/10 "2013-04-18T11:39:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 18, 2013, 12:22pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/11 "2013-04-18T12:22:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 18, 2013, 12:40pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/12 "2013-04-18T12:40:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobias](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tobias](https://forums.imgtec.com/u/tobias)\
**Post date:** [April 18, 2013, 12:41pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/13 "2013-04-18T12:41:48Z")

</div>

Ah excellent, so it’s all working now?  
  
  
  
Regards,  
  
Tobias

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 18, 2013, 12:49pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/14 "2013-04-18T12:49:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [April 18, 2013, 1:37pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/15 "2013-04-18T13:37:06Z")

</div>

Hello John ,  
  
  
  
are you able to run the demo skybox 2?  
  
and start from the working point ?  
  
  
  
regards  
  
david

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 18, 2013, 1:42pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/16 "2013-04-18T13:42:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dgu](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@dgu](https://forums.imgtec.com/u/dgu)\
**Post date:** [April 18, 2013, 4:05pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/17 "2013-04-18T16:05:26Z")

</div>

yes to avoid big bang integration 🙂

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 23, 2013, 5:34am UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/18 "2013-04-23T05:34:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-lam](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@john-lam](https://forums.imgtec.com/u/john-lam)\
**Post date:** [April 24, 2013, 6:42pm UTC](https://forums.imgtec.com/t/cannot-load-in-skybox-texture/1749/19 "2013-04-24T18:42:54Z")

</div>

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