Speeding up glEvalMesh2?

Started by Timetodothis, November 08, 2011, 18:24:24

Previous topic - Next topic

Timetodothis

To build my landscape I use Beizer surfaces, rendering them with glEvalMesh2.

All it well, however when I use an exceeding number of control points (50+) my frame rate is terribly effected.

I've used display lists only to find the fps remains the same?
import static org.lwjgl.opengl.GL11.*;
......

public void compileLists() {
........
        glMap2f(GL_MAP2_VERTEX_3, 0.0f, 1.0f, 3, getSurface().getLength(), 0.0f, 1.0f, getSurface().getStride(), getSurface().getLength(), getSurface().getLandscape());
        glMapGrid2f(detail, 0f, 1f, detail, 0f, 1f);
        glEnable(GL_MAP2_VERTEX_3);

        glNewList(landscape, GL_COMPILE); 
        ........
        [*]glEvalMesh2(Game.getGame().getHub().isGridView() ? GL_LINE : GL_FILL, 0, detail, 0, detail);
        ........
        glEndList();
.......
}


Then on rendering all I call is
glCallList(landscape);


It works well, except with 25+ control points the fps declines.

I geuss my questions are:
   
  • Why is the glList the same speed as just rendering without the lists (Same decline at 50 points+)
       
  • Is there another way I can render this to improve frame rate

    I've pondered vbo's however I don't believe Ill get the same Beizer surface effect.

    Here's a video of my program:

    http://www.youtube.com/watch?v=6ZHvdR48HGA

Timetodothis

It's clear by lowering my detail I get a much higher frame rate, but I hope you guys know of a way to maintain details, high control points, and high fps.

If not, is there another solution to a highly detailed Bezier surface?

Fool Running

I'm pretty sure display lists do not compile a mesh into a static mesh. What they do is compile a list of commands to execute so you can just make one call to OpenGL and have all the commands run. Since glEvalMesh2 generates a mesh at run-time, you don't notice any speed up.

The proper way to do what you are trying to do is to generate the mesh yourself, turning it into polygons, and send the polygons to OpenGL (probably using VBOs). OpenGL can then optimize the drawing using on-GPU memory and other optimizations that speed it up.

Sorry, but OpenGL is not normally used for drawing Bezier surfaces and is not optimized for them at all. OpenGL (and DirectX) work best with straight polygons.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

kappa

I'd say the fastest way is to draw the Bezier's is generate them directly on the GPU using GLSL instead of doing it clientside first and sending it to the GPU. A search on the topic should show plenty of articles on this subject. example.

Timetodothis

Quote from: Fool Running on November 09, 2011, 13:29:15
I'm pretty sure display lists do not compile a mesh into a static mesh. What they do is compile a list of commands to execute so you can just make one call to OpenGL and have all the commands run. Since glEvalMesh2 generates a mesh at run-time, you don't notice any speed up.

The proper way to do what you are trying to do is to generate the mesh yourself, turning it into polygons, and send the polygons to OpenGL (probably using VBOs). OpenGL can then optimize the drawing using on-GPU memory and other optimizations that speed it up.

Sorry, but OpenGL is not normally used for drawing Bezier surfaces and is not optimized for them at all. OpenGL (and DirectX) work best with straight polygons.

Thanks a lot for the tip. Can you inform me of some literature which discusses writing directly onto the processing unit's memory? (That's the job of a vbo?)

Quote from: kappa on November 09, 2011, 13:43:51
I'd say the fastest way is to draw the Bezier's is generate them directly on the GPU using GLSL instead of doing it clientside first and sending it to the GPU. A search on the topic should show plenty of articles on this subject. example.

Thanks for the know-how, so know matter what I'm going to need to make a method to generate the vertexes myself? (Whether or not I use GLSL or an VBO approach)

Fool Running

Quote from: kappa on November 09, 2011, 13:43:51
I'd say the fastest way is to draw the Bezier's is generate them directly on the GPU using GLSL instead of doing it clientside first and sending it to the GPU. A search on the topic should show plenty of articles on this subject. example.
I guess I was thinking (since he is using it for terrain generation) that he might want to compute it and then store it as a static mesh for faster rendering when the control points are not changing.

Quote from: Timetodothis on November 09, 2011, 21:00:27
Thanks a lot for the tip. Can you inform me of some literature which discusses writing directly onto the processing unit's memory? (That's the job of a vbo?)
Just Google "OpenGL VBO example" or "OpenGL VBO tutorial" should get you started.

Quote from: Timetodothis on November 09, 2011, 21:00:27
Thanks for the know-how, so know matter what I'm going to need to make a method to generate the vertexes myself? (Whether or not I use GLSL or an VBO approach)
Yes, I'm afraid so. It should be possible to find some code somewhere that you can just "use", which would make it easier.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D