Skip to main content
gamedev.net
🔒 Locked

Rendering a large grid

Started by Xgkkp 2 replies 200+ views
Original Post
Xgkkp
Xgkkp
I want to do some basic terrain stuff, (mainly looking at random generation). I have a large grid of points with height/type etc and i was wondering what the best way of rendering it was, be it a triangle strip, individual polygons etc.
greeneggs
greeneggs
You have a grid, so just use a triangle strip to start.

For example, using one big degenerated triangle strip,


glBegin(GL_TRIANGLE_STRIP); // use degenerated triangle strips
for(x = 0; x <= xmax; x += step) {
vertex(x, ymax); // degenerated
for(y = ymax; y >= 0; y -= step) {
vertex(x, y);
vertex(x + step, y);
}
vertex(x + step, y + step); // degenerated
}
glEnd();


where vertex(.,.) is a macro which sends the texture and vertex coordinates, normals, and colors for points in the grid.

Next, you''ll want to add some level-of-detail support and view-frustrum culling. For example,

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=05-14-2002&forum=iotd&id=-1

has one approach, although you''ll probably want to start with something simpler.
RipTorn
RipTorn
for speed, use vertex arrays (vertex buffers in DX). yes, triangle strips are good. But you can make them faster, new video cards have vertex caches on them, usually 16 verticies (I think)... so, order your rendering to make the strips go through 16 vertices, then move across 1 column... repeat till then edge, then go up 1 row...
this could, in theory, reduce your vertex transforms to 56%.... which makes a noticable difference (I got about 40% boost in fps when I went from 1 big mesh to lots of smaller mesh''s)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.