Archived

This topic is now archived and is closed to further replies.

penetrator

VAR arrays

Recommended Posts

My terrain engine is currently based on a simple triangle strip. To speed up rendering, i''d like to use VAR arrays. Is there any good tutorial or perhaps some hints about it ? A sample of my terrain engine code is here: for(x=1; x<100; x--) { for(y=1; y<100; y++) { { glBegin(GL_TRIANGLE_STRIP); glVertex3f(y,x+1, h1); glVertex3f(y,x, h1); } } glEnd(); }

Share this post


Link to post
Share on other sites
This piece of code should generate errors. You''re calling glBegin 100 times before the first glEnd.

As for vertex array range, here''s some hints :
1- you should start with "standard" vertex arrays, it''s a first necessary step,
2- vertex array ranges are NVIDIA-only. If you want to optimize for all graphics cards, you should write different code path for different manufacturers (VAR for NVIDIA, VAO for ATI).
3- the vertex array range specification can be found at the extensions registry maintained by sgi : http://oss.sgi.com/projects/ogl-sample/registry/

Share this post


Link to post
Share on other sites
and never draw a block of terrain with only a single triangle strip. use strips of length of around 10 verts, then instead of drawing the next strip on from it, draw the strip next to it, so the maximum number of verticies are shared (5). this means of the 10 verts per strip, only 1 or 2 verts will ever need to be recalculated due to vertex caching (of 10). Which very neraly effectivly doubles your T&L performance (it is very noticable when you do toggled comparisons). Compared to using a single strip which would require each vertex (except edges) to be transformed twice.

Unless of course your terrain block is 5x5.

Share this post


Link to post
Share on other sites