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

Thread: GLUT: Erratic frame rate despite limiting (Using Windows)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    5

    Question GLUT: Erratic frame rate despite limiting (Using Windows)

    Edit:
    (1) Just realized the attachment is too small to really be visible so I included the stdout at the bottom of the post, sorry about that.

    The Problem:
    As you can see in the attachment below the frame rates I am getting are very erratic despite my attempt to limit it. I'm assuming I am probably missing something pretty obvious. Does anyone have any insight why this might be happening?

    My System:
    Alienware M18x
    Windows 7 Home Premium
    Dual Radeon 6990m cards
    2nd Gen i7 2.4ghz-3.1ghz

    Compiler:
    MingW - gcc version 4.7.2

    Compiler Command:
    g++ -o Modeler -Wall *.cpp glut32.lib -lopengl32 -lglu32 -static -std=c++11


    Any insight at all would be very appreciated.

    Thank you for your time,
    Brandon Murphy


    My display function:

    Code :
    int multiplier = 1;
     
    /**
     * Callback function to display the scene
     */
    void Window::displayCallback()
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        static int theta = 1;
     
        // TODO: Pull this out into the model object
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
        glBindTexture(GL_TEXTURE_2D, texName);
     
        glPushMatrix();
            glTranslatef(0, 0, -4 * multiplier);
            glRotatef(theta, 0.1, 0.5, 1);
            for(int i=0; i<multiplier; i++)
            {
                for(int j=0; j<multiplier; j++)
                {
                    for(int k=0; k<multiplier; k++)
                    {
                            GLHelper::drawCube(i, j, k, 1, 1, 1);
                    }
                }
            }
        glPopMatrix();
     
     
        theta++;
     
        glutSwapBuffers();
     
     
        // TODO: this is a mess
        int dT = ChubbyEngine::getFrameTimeDifference();
        ChubbyEngine::frameRendered();
        dT = (dT <= 0) ? 1 : dT;
        int sleepTime = 1000/ChubbyEngine::getFrameRate() - dT; // getFrameRate() returns 60
        sleepTime = (sleepTime <= 0) ? 1 : sleepTime;
        Time::sleep(sleepTime);
        cout<<"FPS: "<<(int)(1000/dT)<<" \tCubeCount: "<< multiplier*multiplier*multiplier<<"    Render Time: "<<dT<<"ms"<<endl;
        glutPostRedisplay();
    }


    Time.cpp

    Code :
    #include "Time.h"
     
    int Time::getTime()
    {
        #ifdef WINDOWS
            SYSTEMTIME st;
            GetSystemTime(&st);
            return (((st.wHour)*60 + st.wMinute)*60 + st.wSecond)*1000 + st.wMilliseconds;
        #endif
     
        #ifdef LINUX
            return time(0);
        #endif
    }
     
    void Time::sleep(int milliseconds)
    {
        #ifdef WINDOWS
            Sleep(milliseconds);
        #endif
     
        #ifdef LINUX
            std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
        #endif
    }


    Standard Out (short selection):
    Code :
    FPS: 71 	CubeCount: 1    Render Time: 14ms
    FPS: 1000 	CubeCount: 1    Render Time: 1ms
    FPS: 500 	CubeCount: 1    Render Time: 2ms
    FPS: 66 	CubeCount: 1    Render Time: 15ms
    FPS: 71 	CubeCount: 1    Render Time: 14ms
    FPS: 1000 	CubeCount: 1    Render Time: 1ms
    FPS: 500 	CubeCount: 1    Render Time: 2ms
    FPS: 66 	CubeCount: 1    Render Time: 15ms
    FPS: 71 	CubeCount: 1    Render Time: 14ms
    FPS: 1000 	CubeCount: 1    Render Time: 1ms
    FPS: 500 	CubeCount: 1    Render Time: 2ms
    FPS: 66 	CubeCount: 1    Render Time: 15ms
    FPS: 71 	CubeCount: 1    Render Time: 14ms
    FPS: 1000 	CubeCount: 1    Render Time: 1ms

    Click image for larger version. 

Name:	ErraticFrameRate.jpg 
Views:	426 
Size:	20.5 KB 
ID:	1036
    Last edited by officialhopsof; 05-27-2013 at 11:12 AM.

Tags for this Thread

Posting Permissions

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