# skybox not loading

**URL:** <https://forums.imgtec.com/t/skybox-not-loading/1739>\
**Category:** PowerVR Insider\
**Created:** [April 7, 2013, 12:41pm UTC](https://forums.imgtec.com/t/skybox-not-loading/1739 "2013-04-07T12:41:09Z")\
**Posts on this page:** 7\
**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 7, 2013, 12:41pm UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/1 "2013-04-07T12:41:09Z")

</div>

hey guys I have tried to load in my skybox texture but it fires up the error that I have setup for it and don’t really understand why, I have added in the code as such(I am using the skybox in the skybox2 demo).  
  
  
  
`bool OGLESIntroducingPVRTools::load_Tex(CPVRTString* const pErrorStr){

for(int texNo = 0; texNo < 2; ++texNo){
if(PVRTTextureLoadFromPVR(c_szTextureFile[texNo], &m_uiTexture[texNo]) != PVR_SUCCESS)
{
pErrorStr = CPVRTString(“Error: This texture number could not be loaded number:”) + texNo;
return false;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
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;
}`  
  
  
  
I then call this method within InitView method like this as one of your examples showed.  
  
  
  
`if(!load_Tex(&Error_message)){
PVRShellSet(prefExitMessage, Error_message.c_str());
return false;
}`  
  
  
  
and at the top I have defined the file name in an array along with the other texture files  
  
  
  
`const char c_szTextureFile[n_TexFile]	=
{ “n_Map1.pvr”,
“n_Map2.pvr”,
“Skybox.pvr”};`  
  
  
  
and in you skybox2 demo you used effect files…I am still using the seperate vert and frag shaders and was wondering how I could change my code in order to do what your method was doing. I’m not quite sure how to actually set the sampler Currently my drawSkybox looks like this which I am not sure if it is right, I then call this in the renderscene method and enable cull face then disable it after:  
  
  
  
`void OGLESIntroducingPVRTools::DrawSkybox(){
//draw skybox
glBindBuffer(GL_ARRAY_BUFFER, m_skyBoxVBO);
glEnableVertexAttribArray(sky_VERTARRAY);
glUniform1i(glGetUniformLocation(skyShaderProgram.uiId, “SkyTex”), 3);
for(int face = 0; face < 6; ++face){
size_t offset = sizeof(float) * face4*3;
glVertexAttribPointer(sky_VERTARRAY, 3, GL_FLOAT, GL_FALSE, sizeof(float)3, (void) offset);
}
}`

---

<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 7, 2013, 5:17pm UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/2 "2013-04-07T17:17:03Z")

</div>

Also I was wondering how big the drawing surface actually is? or Viewport

---

<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 7, 2013, 6:02pm UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/3 "2013-04-07T18:02:20Z")

</div>

Hello John,

````auto
inline float GetVirtualWidth()<br />
{<br />
return (float)(IsRotated() ? PVRShellGet(prefHeight) : PVRShellGet(prefWidth));<br />
}<br />
<br />
inline float GetVirtualHeight()<br />
{<br />
return (float)(IsRotated() ? PVRShellGet(prefWidth) : PVRShellGet(prefHeight));<br />
}
```<br />
regards<br />
david
````

---

<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 8, 2013, 8:26am UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/4 "2013-04-08T08:26:03Z")

</div>

about your skybox ,  
  
are you sure that you Filewrap it ? does the naming matches ?

---

<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 8, 2013, 9:28am UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/5 "2013-04-08T09:28:17Z")

</div>

Hi David,  
  
I have filewrapped it and the naming does match but I am still getting that error message fired.

---

<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 8, 2013, 10:13am UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/6 "2013-04-08T10:13:36Z")

</div>

then it is the encoding of the image

---

<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 8, 2013, 10:28am UTC](https://forums.imgtec.com/t/skybox-not-loading/1739/7 "2013-04-08T10:28:08Z")

</div>

I took the original one from the skybox2 folder but still no luck
