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 6 of 6

Thread: Not rendering very fast....

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Colorado
    Posts
    11

    Not rendering very fast....

    I have a 2D program that I made to practice with file programing. Everthing works fine, but it renders at less than 1 frame per second. I wanted to see where it was slowing down, so I wrote my own profiler. Its not the most accurate thing, but I am sure it is the actuall drawing code slowing it down. I have 2 triangels that make up a square in a call list. I use the call list to draw a 10*10 grid with different textures. So, the call list is called a total of 100 times per frame, which takes over a second. Any ideas why its drawing so slow?? I'm programming on a 300Mhz AMD, so I wasn't expecting much but with 2d graphics it should be at least 30 frames a second I would think. I'm using borland if that makes a difference. thx

  2. #2
    Intern Contributor
    Join Date
    Nov 2002
    Location
    Oirsbeek,Holland
    Posts
    69

    Re: Not rendering very fast....

    Try to use double buffering,
    example :

    ...
    PFD_DRAW_TO_WINDOW|
    PFD_SUPPORT_OPENGL|
    PFD_DOUBLEBUFFER|
    PFD_TYPE_RGBA,
    ...

  3. #3
    Intern Newbie
    Join Date
    Nov 2002
    Location
    Germany
    Posts
    48

    Re: Not rendering very fast....

    Had that problem as well. I found out, that it's the texture switching. Load all textures into the video buffer first and refer to them by names, instead of sending a new texture to the video buffer and dropping the old for every polygon.

    GLuint textures[100];

    glGenTextures(100,textures);
    for (int i = 0;i < 100;i++) {
    glBindTexture(GL_TEXTURE_2D,textures[i]);
    glTexImage2D( /* define texture image here */ );
    /* specify parameters and other texture properties here */
    }

    Then just switch the texture by glBindTexture() when rendering the scene.

    [This message has been edited by mm_freak (edited 11-10-2002).]
    Knowledge is Power

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Colorado
    Posts
    11

    Re: Not rendering very fast....

    Thank you both, but neither one was the problem. I already have double buffering on. I was loading all my textures at startup and just rebinding it when I was changing textures. If no one else has any ideas, I'll just chalk it up to a really slow onboard video card. On my 1.4Ghz with a G-force 3, the whole thing was rendering like several hundred times a second. Part of the problem might be my profiler too. I think it is measuring CPU time not actual time. Does anyone know how to access system time down to the millisecond?

  5. #5
    Intern Newbie
    Join Date
    Nov 2002
    Location
    Germany
    Posts
    48

    Re: Not rendering very fast....

    To test the speed of a certain routine, I would get the number of milliseconds elapsed since the system was started (GetTickCount() under Win32: DWORD GetTickCount(void)). After the routine, get the milliseconds again and from that subtract the older value and you'll have the time elapsed. Note that even this way could be inaccurate (system-dependent), but the result accuracy should be something around 20 to 40 ms.

    DWORD etm;

    etm = GetTickCount();
    /* draw here */
    etm = GetTickCount() - etm;
    printf("Time elapsed: %lu ms\n",etm);
    Knowledge is Power

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Colorado
    Posts
    11

    Re: Not rendering very fast....

    I rewrote my profiler using a different method than you sugested. I used QueryPreformanceCounter(). It seems to be very accurate. I found out that the SwapBuffers(ghDC) is taking .4 seconds and

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(-1,-1,0);
    for(int i=0; i<10;i++)
    {
    for(int j=0; j<10; j++)
    {
    glPushMatrix();
    glBindTexture(GL_TEXTURE_2D, texture[screenb[(10*i)+j]]);
    glTranslatef(.2*j,.2*i,0);
    glCallList(boxlist);
    glPopMatrix();
    }
    }

    is taking .6 seconds. Anyone know why this is taking so long? Especially the SwapBuffers, which is completely taken care of by opengl. Thx

Posting Permissions

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