Keyboard is sooooo slow!!!! /long/ - Xwindows

This is a discussion on Keyboard is sooooo slow!!!! /long/ - Xwindows ; Hi I'm writing simple Opengl app on Xwindow. I have fglrx but i'm using software renderer in Mesa i'm measuring perf with this code if(frames == 0) { err = gettimeofday(&t1, NULL); poczatek = t1.tv_usec; } drawGLScene(); ++frames; if(frames { ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Keyboard is sooooo slow!!!! /long/

  1. Keyboard is sooooo slow!!!! /long/

    Hi


    I'm writing simple Opengl app on Xwindow.
    I have fglrx but i'm using software renderer in Mesa
    i'm measuring perf with this code

    if(frames == 0)
    {
    err = gettimeofday(&t1, NULL);
    poczatek = t1.tv_usec;
    }
    drawGLScene();
    ++frames;
    if(frames < 1000)
    {
    err = gettimeofday(&t2, NULL);
    koniec += t2.tv_usec;
    }
    if(frames == 1000)
    {
    koniec += t2.tv_usec;
    time = koniec / poczatek;
    fps = 1000 / (time / 1000);
    cout << "FPS: " << fps << endl;
    koniec = 0;
    poczatek = 0;
    frames = 0;
    }
    swapBuffers();
    I get avg about 1000 fps(its 1 triangle rotating) but IO is so TERRIBLY slow
    I got basecode from
    http://nehe.gamedev.net/counter.asp?...egl_glx.tar.gz
    Could anybody tell me why keyb interaction is so slow while opengl runs
    quite fast ?


    Here is function that handles keys:

    while(running)
    {
    while(XPending(GLWin.dpy) > 0)
    {
    XNextEvent(GLWin.dpy, &event);
    switch(event.type)
    {
    case Expose:
    if (event.xexpose.count != 0)
    break;
    break;
    case ConfigureNotify:
    if ((event.xconfigure.width != GLWin.width) ||
    (event.xconfigure.height != GLWin.height))
    {
    GLWin.width = event.xconfigure.width;
    GLWin.height = event.xconfigure.height;
    printf("Resize Event\n");
    resizeGLScene();
    }
    break;
    case KeyPress:
    switch(XLookupKeysym(&event.xkey,0))
    {
    case XK_k:
    updateGLScene();
    cout << "Wcisnieto K" << endl;
    break;
    case XK_Escape: /* Quit application */
    running = 0;
    break;
    case XK_F1:
    /* Switch between fullscreen and windowed mode */
    killGLWindow();
    GLWin.fs = !GLWin.fs;
    createGLWindow("Nehe's GLX Base Code", 640, 480, 24, GLWin.fs);
    break;
    }
    break;
    case KeyRelease:
    break;
    case ClientMessage:
    if (*XGetAtomName(GLWin.dpy, event.xclient.message_type) ==
    *"WM_PROTOCOLS")
    {
    running = 0;
    }
    break;
    default:
    break;
    }
    }


    --
    Don't Stop Dancing.....

  2. Re: Keyboard is sooooo slow!!!! /long/

    RumbaDancer wrote:

    > Hi
    >
    >
    > I'm writing simple Opengl app on Xwindow.
    > I have fglrx but i'm using software renderer in Mesa

    funny i switched to hardware fglrx rendering and keys are processed smoothly
    Only one thing still bothers me, why in software implementation this problem
    exist. fglrx runs the same amount FPS 400-1600....
    --
    Don't Stop Dancing.....

  3. Re: Keyboard is sooooo slow!!!! /long/

    On 2007-11-02, RumbaDancer wrote:

    > I'm writing simple Opengl app on Xwindow.
    > I have fglrx but i'm using software renderer in Mesa
    >
    > I get avg about 1000 fps(its 1 triangle rotating) but IO is so
    > TERRIBLY slow I got basecode from
    > http://nehe.gamedev.net/counter.asp?...egl_glx.tar.gz
    > Could anybody tell me why keyb interaction is so slow while
    > opengl runs quite fast ?


    Without looking at the code, I'm guessing your program gives the
    X server too much to do between polling for incoming events. You
    could try looking for incoming events more frequently (E.G.,
    every 10 frames or whatever takes less than 50 ms to process).

    --
    André Majorel
    (Counterfeit: rekemir@sextillion.com dypon@bolshevik.com)
    There is always someone somewhere who needs a good laugh.

  4. Re: Keyboard is sooooo slow!!!! /long/

    Andre Majorel wrote:

    > On 2007-11-02, RumbaDancer wrote:
    >
    >> I'm writing simple Opengl app on Xwindow.
    >> I have fglrx but i'm using software renderer in Mesa
    >>
    >> I get avg about 1000 fps(its 1 triangle rotating) but IO is so
    >> TERRIBLY slow I got basecode from
    >> http://nehe.gamedev.net/counter.asp?...egl_glx.tar.gz
    >> Could anybody tell me why keyb interaction is so slow while
    >> opengl runs quite fast ?

    >
    > Without looking at the code, I'm guessing your program gives the
    > X server too much to do between polling for incoming events. You
    > could try looking for incoming events more frequently (E.G.,
    > every 10 frames or whatever takes less than 50 ms to process).
    >


    it is checked every frame...
    --
    Don't Stop Dancing.....

+ Reply to Thread