Need ability to specify size of the buffer index is not equal to the maximum for efficient rendering

Hi Аll.



I have not found such an opportunity and it looks like it really is not all the time rendered the entire index buffer.



LwjglRender.java

[java] glDrawRangeElements(convertElementMode(mesh.getMode()),

0,

vertCount,

indexBuf.getData().capacity(),

convertFormat(indexBuf.getFormat()),

0);[/java]



I tried to change it by changing indexBuf.getData().capacity () to indexBuf.getData().position () but found that the position () == 0 always!

Even if I put it earlier, it still dumped somewhere.



I solved the problem changing jme, but my solution is not elegant, since I’m not sufficiently versed in the device engine.

I dont understand you 100% but maybe you have to call mesh.getFloatBuffer(Type.Position).clear(); when you create custom meshes?

You can pass the offset/position as the last parameter to glDrawRangeElements, then you can compute the length by doing limit() - position() and pass it instead of capacity.

I dont understand you 100% but maybe you have to call mesh.getFloatBuffer(Type.Position).clear(); when you create custom meshes?

Sorry for my English is not my native language.

I only modify the index buffer, vertex not yet touched.

At the vertex buffer can not change the size, because it can not fill completely, and it has almost no effect on performance.

And for the buffer indices did not work mesh.getIndexBuffer (). GetBuffer (). Clear ();
All the same, rendered all the vertices have even irrelevant to the previous frame when the number of indices is less than in the previous frame.

I tested it also on the nightly builds 4.2.2011

Re-create an index buffer each frame of the performance drops sharply.

You can pass the offset/position as the last parameter to glDrawRangeElements, then you can compute the length by doing limit() – position() and pass it instead of capacity.


So I did.
But maybe someone will need a similar functionality, it is strange that the engine can not do it without modifications.


Incidentally at the same time would like to know how to make direct calls to OpenGL in jme using lwjgl?

I do so in SimpleApplication
[java]
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.*;

...

@Override
public void simpleRender(RenderManager rm) {

//TODO: add render code

//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);

gluPerspective( 45.0f, 1.777f, 0.1f, 1000.0f ); // I use lwjgl_util.jar


glTranslatef(-1.5f,0.0f,-6.0f);

glColor3f(1.0f,0.0f,0.0f); // red
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f); // up
glVertex3f(-1.0f,-1.0f, 0.0f); // left down
glVertex3f( 1.0f,-1.0f, 0.0f); // right down
glEnd();
}[/java]

And the triangle is not displayed.
Although if you uncomment glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
the whole geometry of the output engine clean, and that is glClear works, the rest is not (

You should not make direct GL calls in jME3, if you can explain better, maybe we can add an option to achieve what you want?