Imagination PowerVR SDK Blog

3D object rendered partially


#1

I rendered a 3D box using PVRShell library. But when I changed the camera position, I came to know that the box was actually rendered two dimensionally i.e. only the top face is visible. Can anyone point out where did I go wrong ?



This is a part of my InitView() function :



afVertices and indices are declared as 2D arrays

GLfloat **afVertices;

GLushort **indices;



glGenBuffers(nummeshes, m_ui32Vbo);



for(i=0;i<nummeshes;i++)

{

// Bind the buffer objects

glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);



//Set the buffer’s data

glBufferData(GL_ARRAY_BUFFER, vertexcount * (3 * sizeof(GLfloat)) , afVertices, GL_STATIC_DRAW);



m_ui32Ibo = 0;

glGenBuffers(1, &m_ui32Ibo);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ui32Ibo);

glBufferData(GL_ELEMENT_ARRAY_BUFFER, facecount * (3 * sizeof(GL_UNSIGNED_SHORT)) , indices, GL_STATIC_DRAW);

}



This is a part of my RenderScene() function :



for(i=0;i<nummeshes;i++)

{

// Bind the buffer objects

glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);



glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ui32Ibo);



glEnableVertexAttribArray(VERTEX_ARRAY);



// Points to the data for this vertex attribute

glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);



if(m_ui32Ibo)

{

glDrawElements(GL_TRIANGLES, facecount * 3, GL_UNSIGNED_SHORT, NULL);

}

else

{

glDrawArrays(GL_TRIANGLES, 0, facecount * 3);

}



// Unbind the buffer objects

glBindBuffer(GL_ARRAY_BUFFER, 0);



glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

}


#2

Hi,



Your scene needs to be transformed by a matrix calculation based on your camera’s position. This can be done in OpenGL ES 2.0 by passing a matrix to a bound vertex shader.



I would recommend referring to our IntroducingPOD Example application. The source code & comments explain how to set up a camera and use it to transform the objects in your scene.



Regards,

Joe


#3

Oh, so does it mean the box is rendered in 3D, but I couldn’t see it from a transformed angle as I didn’t refresh the scene from that angle ?


#4

Hello



Joe mention that you should perhaps calculate your View Matrix model, like that you will be able to move your camera by any transformation possible, the sample that he mention is very good as well.

Also is like aloooooot of sample inside the SDK check it out you will have a lot of fun i think !!!

It s quite very progressive learning path.

regards

david


#5

OK. I have started going through the sample program. Can I be assured that the box is rendered in 3D for now ? :smiley:


#6

Based on the information you’ve provided, I suspect the box is in 3D but you’re only seeing one side of it.



Thanks,

Joe