PDA

View Full Version : Max number of polygon



deduu10
05-10-2013, 01:49 AM
Hi,

I want to draw an object that consists of many polygons for I need to construct it from many polygons. But, I was stuck due to limited number of polygon I can draw in my device.
I used vertex array, no texture, with a single light source. Is there any chance to increase the number of polygon I can draw for each single frame?


Thanks

ClayMontgomery
05-10-2013, 11:13 AM
Hi,

I want to draw an object that consists of many polygons for I need to construct it from many polygons. But, I was stuck due to limited number of polygon I can draw in my device.
I used vertex array, no texture, with a single light source. Is there any chance to increase the number of polygon I can draw for each single frame?


Thanks

Using a vertex buffer object (VBO) will help, if you are not already doing that. VBO typically performs better than ordinary vertex arrays or triangle strips, particularly when the number of polygons is large. If you can control the algorithm that generates the polygons, try to discard triangles that will be too small to be visible.

Regards, Clay

deduu10
05-11-2013, 07:17 AM
Using a vertex buffer object (VBO) will help, if you are not already doing that. VBO typically performs better than ordinary vertex arrays or triangle strips, particularly when the number of polygons is large. If you can control the algorithm that generates the polygons, try to discard triangles that will be too small to be visible.

Regards, Clay

Hi,

I've tried using VBO but I got OutOfMemoryError. it seems my graphics memory has lower capacity than my client memory because it works when I rendered without VBO but failed with VB0. Do you have any idea about this issue?

Thanks

ClayMontgomery
05-13-2013, 07:52 AM
Hi,

I've tried using VBO but I got OutOfMemoryError. it seems my graphics memory has lower capacity than my client memory because it works when I rendered without VBO but failed with VB0. Do you have any idea about this issue?

Thanks

VBO is a required feature of OpenGL ES 2.0, so it should work. What platform and GPU are you using? If you have a lot of textures or FBOs allocated, try disabling that to free up more memory for the VBO.

Regards, Clay

deduu10
05-16-2013, 10:58 PM
VBO is a required feature of OpenGL ES 2.0, so it should work. What platform and GPU are you using? If you have a lot of textures or FBOs allocated, try disabling that to free up more memory for the VBO.

Regards, Clay

Hi, can you help me to figure out what's wrong with my snippet code? I could not figure out, what cause my VBO got OutOfMemoryError.
Here is my snippet code. I use Android platform, and I used no texture.


GLuint buffer[3];

glGenBuffers(3, buffer);

glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNumVerts * 4, genData.vertex, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeColorVerts *4, genData.colors, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNormalVerts * 4, genData.normals, GL_DYNAMIC_DRAW);


if(genData.vertex == 0 || genData.normals == 0 || genData.colors == 0) LOG("Error: failed to allocate a memory");


glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glEnableVertexAttribArray(vertexHandle);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,0);

glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glEnableVertexAttribArray(normalHandle);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,0);

// glVertexAttrib4fv(mColorHandle, genData.colors);
glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glEnableVertexAttribArray(mColorHandle);
glVertexAttribPointer(mColorHandle, 4, GL_FLOAT, GL_FALSE, 0,0);

glDrawArrays(GL_TRIANGLES, 0, genData.cubeNumVerts);

glDeleteBuffers(3, buffer);

Please helps..
Thanks

ClayMontgomery
05-17-2013, 11:02 AM
Hi, can you help me to figure out what's wrong with my snippet code? I could not figure out, what cause my VBO got OutOfMemoryError.
Here is my snippet code. I use Android platform, and I used no texture.


GLuint buffer[3];

glGenBuffers(3, buffer);

glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNumVerts * 4, genData.vertex, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeColorVerts *4, genData.colors, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNormalVerts * 4, genData.normals, GL_DYNAMIC_DRAW);


if(genData.vertex == 0 || genData.normals == 0 || genData.colors == 0) LOG("Error: failed to allocate a memory");


glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glEnableVertexAttribArray(vertexHandle);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,0);

glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glEnableVertexAttribArray(normalHandle);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,0);

// glVertexAttrib4fv(mColorHandle, genData.colors);
glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glEnableVertexAttribArray(mColorHandle);
glVertexAttribPointer(mColorHandle, 4, GL_FLOAT, GL_FALSE, 0,0);

glDrawArrays(GL_TRIANGLES, 0, genData.cubeNumVerts);

glDeleteBuffers(3, buffer);

Please helps..
Thanks

I recommended you try GL_STATIC_DRAW instead of GL_DYNAMIC_DRAW to see if it eliminates the error. I would also try commenting out the VBOs for the normal and color arrays temporarily to see if that helps.
I suspect this may be an OpenGL ES driver problem, rather than a bug in your code. Which GPU are you using (Nvidia, PowerVR, Adreno)? Is this code running in a native library or with the OpenGL ES wrapper classes? You should try running your code in an AVD emulator, but you must use a recent version of Android to do that. This article will help you setup an AVD for OpenGL ES 2.0:

http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-2

Regards, Clay

deduu10
05-20-2013, 02:42 AM
Hi,

I've tried using GL_STATIC_DRAW and the error persists. It's weird that I could render the from the same data with VAO but failed with VBO.
I'm using Mali 400MP, Yes, this code is running in a native library. Since I'm dealing with Augmented Reality, I just could not run this code in an AVD emulator.

Thanks

ClayMontgomery
05-20-2013, 02:50 PM
Hi,

I've tried using GL_STATIC_DRAW and the error persists. It's weird that I could render the from the same data with VAO but failed with VBO.
I'm using Mali 400MP, Yes, this code is running in a native library. Since I'm dealing with Augmented Reality, I just could not run this code in an AVD emulator.

Thanks

I think the problem might be a bug in the Mali OpenGL ES driver. I recommend you try your code on an Android device with a different type of GPU, such as Nvidia Tegra or PowerVR.

Regards, Clay