Imagination PowerVR SDK Blog

skybox not loading


#1

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

}

}


#2

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


#3

Hello John,


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

#4

about your skybox ,

are you sure that you Filewrap it ? does the naming matches ?



#5

Hi David,

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


#6

then it is the encoding of the image


#7

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