Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: very high fps with just a few lines

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2001
    Location
    Oss,n-brabant, holland
    Posts
    17

    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. #2
    Member Newbie
    Join Date
    May 2001
    Posts
    39

    Re: very high fps with just a few lines

    Try put that code in a display list

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    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).]
    Deiussum
    Software Engineer and OpenGL enthusiast

  4. #4
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    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. #5
    Junior Member Newbie
    Join Date
    Jun 2001
    Location
    Paris, Ile-de-France, France
    Posts
    10

    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. #6
    Member Contributor bsperlin's Avatar
    Join Date
    Feb 2001
    Location
    VA
    Posts
    67

    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. #7
    Junior Member Newbie
    Join Date
    Jun 2001
    Location
    Oss,n-brabant, holland
    Posts
    17

    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. #8
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    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.
    Deiussum
    Software Engineer and OpenGL enthusiast

  9. #9
    Junior Member Newbie
    Join Date
    Jun 2001
    Location
    Oss,n-brabant, holland
    Posts
    17

    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. #10
    Member Contributor
    Join Date
    Aug 2000
    Posts
    68

    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 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 06-15-2015, 03:48 AM
  2. high precision
    By howaidi in forum OpenCL
    Replies: 2
    Last Post: 11-21-2011, 03:59 PM
  3. CPU usage: How high is too high?
    By bucky in forum OpenGL: Windows
    Replies: 11
    Last Post: 01-13-2008, 09:27 AM
  4. high FPS
    By therealremi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-14-2006, 04:10 PM
  5. What's the use of high-level API's?
    By gtada in forum OpenGL: General
    Replies: 0
    Last Post: 02-17-2003, 07:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean