# Thread: very high fps with just a few lines

1. ## very high fps with just a few lines

Does anyone know how i can get a very high fps when i'm using a loop:

glbegin(gl_lines);
for x := 0 to 99 do
for y := 0 to 99 do
begin
glvertex3f(x,y,0);
glvertex3f(x+1,y,0);

glvertex3f(x+1,y,0);
glvertex3f(x+1,y+1,0);

glvertex3f(x+1,y+1,0);
glvertex3f(x,y+1,0);

glvertex3f(x,y+1,0);
glvertex3f(x,y,0);

end;
glend;

when i'm using this i'll get a fps around 15 to 20. but i think i can get a much higher performance.

can somebody help.

please know i'm just 14 years old and want to become a real programmer in 3D

2. ## Re: very high fps with just a few lines

Try put that code in a display list

3. ## Re: very high fps with just a few lines

Display lists might help, but you are drawing a lot more lines than you really need to get the same display. If you change your loops a bit you can do the whole thing in 1 for loop with a lot fewer lines and that would probably speed you up more than anything else.

For instance you could get the same result with this...

glbegin(gl_lines);
for x:=0 to 100 do
begin

glvertex3f(x,0,0);
glvertex3f(x,100,0);

glvertex3f(0,x,0);
glvertex3f(100,x,0);
end
glend;

[This message has been edited by Deiussum (edited 06-11-2001).]

4. ## Re: very high fps with just a few lines

it looks like your lines are joined up if so
it'll be better using GL_LINE_STRIP or GL_LINE_LOOP

5. ## Re: very high fps with just a few lines

Why don't you try to use a vertex array ?
I don't know this technique very well, so I couldn't help you more, but I think it is the good direction to look in.

6. ## Re: very high fps with just a few lines

A quick look at Deiussem rewrite of the nested loops: I don't think that it's the same as the original. For example, at some point of the original x=20 and y=20 simultaneously, but the rewrite doesn't have this situation.
Barry

7. ## Re: very high fps with just a few lines

well, I do know how to use it and I do. But my fps is still round the same numbers.

And i want to get some kind of a mountain in my scene so i use more like this code:
glnewlist(MY_FIELD, gl_compile);
glbegin(gl_lines);
for x := 0 to 99 do
for y := 0 to 99 do
begin
glvertex3f(@terrain[x,y]);
glvertex3f(@terrain[x+1,y]);

glvertex3f(@terrain[x+1,y]);
glvertex3f(@terrain[x+1,y+1]);

glvertex3f(@terrain[x+1,y+1]);
glvertex3f(@terrain[x,y+1]);

glvertex3f(@terrain[x,y+1]);
glvertex3f(@terrain[x,y]);
glend;
glendlist;

8. ## Re: very high fps with just a few lines

Originally posted by bsperlin:
A quick look at Deiussem rewrite of the nested loops: I don't think that it's the same as the original. For example, at some point of the original x=20 and y=20 simultaneously, but the rewrite doesn't have this situation.
Barry
I don't quite understand what you mean. Walk though a few loops of his code and you see he is just drawing a grid of squares left to right, bottom to top. He's going to have a LOT of lines that are redundant. You can get the same effect by just drawing a bunch of horizontal and vertical lines, which my code does.

Take your example for instance. When x=20, y=20 my solution covers that because when x=20 it drew a line from (20,0) to (20,100) which goes through the same line on the left that he would have written. The bottom would have been taken care of by drawing the line (0,20)-(100,20). When my x=21 it would draw the line to the left side and top of his box when x=20, y=20.

Now if he wants to do a heightmap, as it appears from is later post, then my rework wouldn't work because he couldn't assign individual heights. His original code had all heights of 0, so my rework is perfectly valid.

9. ## Re: very high fps with just a few lines

you're right.

But when i said i wanted to make a field with a mountain.
I mean that in your 21 * 21 grid a mountain is.
this mountain is at point 5,5 and to make it a mountain the y isn't 0 but 1.

Thanks anyway.

10. ## Re: very high fps with just a few lines

When I tried this a while ago I drew the terrain with a series of triangle strips and then I used a technique that I read in the red book online that described how to render none see-through faces in a wireframe mode.

Unfortunatly on most machines lines will always be slow.

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•