Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: triangles or polygons

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    2

    triangles or polygons

    First of all, hello to all (i'm new). I got a question. I read that a triangle takes a lot LESS CPU to draw than a any other polygon. How true is this? Is it worth it to make all my polygons out of triangles?
    Another question. I made a very small program where a cube moves through the screen and rotates, and i checked the CPU usage and it was at 100%. Is that normal?
    Sorry if they're dumb questions...=)

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: triangles or polygons

    Hi !

    OpenGL can only render triangles, when you try to render a polygon (convex only) OpenGL will break it down into triangles for you, this will take a little time but I don't know how much, concave polygons are a different thing, this has to be tesselated into triangles before they can be used by OpenGL, the best thing is to keep it all to triangles /and strips and fans) to make sure you get the best performance.

    If your application is using 100% CPU it has nothing to do with OpenGL, I would guess that you are using Windows.... the best guess here it that your messageloop is a bit ugly and snatches all the CPU power, if you make a game or something it may not matter at all, but it might be worth heving a look at, if you don't have a Sleep() or one of the Wait...() functions in there your app will eat 100% CPU power, it's as simple as that.

    Mikael

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    2

    Re: triangles or polygons

    You're right, I am using Windows. My message loop goes something like this:

    if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
    if(msg.message==WM_QUIT){
    done=true;
    }else{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }else{
    ...
    DrawScene();
    ...
    }

    I realize that unless there is a message, I am redrawing everything every time around the loop. What can I do to prevent that?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: triangles or polygons

    You don't want to prevent that. That's how graphics programs work - you draw every time through the main loop!

    Now, if you have a lot of objects in your scene that aren't visible (like things behind you or way off in the distance), there are techniques to prevent sending them through the graphics pipeline. Do a search on "frustum culling" to learn more about these techniques.

Posting Permissions

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