Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

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

Thread: Delay in open GL

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    7

    Delay in open GL

    Hi,

    I am new to the open GL.i am facing problem in implementing delay.I am using open GL ES 1.0. What i am trying to do is to scale up an image and wait for few seconds and bring it to back to original one.But it is waiting for some time and doing both scale up and down simultaneously.Please help me in solving this .I used two for loops for implementing delay.Is there any function for delay or sleep in open GL ES 1.0.

  2. #2
    Junior Member Regular Contributor tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    200

    Re: Delay in open GL

    What is the operating system? Look for OS*specific time / timer functions.

    Once you have a function that returns current time, you can do float size = std::sin(time()); or something / anything like that.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    7

    Re: Delay in open GL

    I guess it is not related operating system.Anyways i am using linux OS ,eclipse IDE and android SDK.code is like

    scale up i.e glscalef()

    sleep or wait

    scaledown

    so it has to display output with scaled image and then wait and then scaled down output...but actually what happening is it is waiting for some time and displays scaled up and scaled down outputs simulatenously with out any delay

  4. #4
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    Re: Delay in open GL

    Are you swapping back and front buffers before the delay?

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    7

    Re: Delay in open GL

    No, i m not swapping front and back buffers before delay.If i have to,what is command for swapping buffers.

  6. #6
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    Re: Delay in open GL

    Usually, you draw in the back buffer. It will not be shown untill you swap the back buffer with the front buffer. Otherwise, the user would have seen when the sreen is cleared, and when various drawing operations are completed.

    So if you draw in the back buffer, then delay, then draw some more, and then eventually swap the back buffer with the front buffer, then the user will not see any changes until the end.

    I would recommend that use an algorithm as follows:
    Code :
    while(1) {
        switch(CurrentState()) {
        case NormalScale: DrawNormalScale(); break;
        case Enlarged: DrawLargeScale(); break;
        }
        SwapBackBuffer();
    }
    You need to set the value of state from a time depending function. Of course, if you want to be fancy, you can have a gradual change of scale instead of two distinct modes.

  7. #7
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    7

    Re: Delay in open GL

    Thanks 4 ur suggestion.It looks fine.But can u illustrate on implementing swap buffer function.or is it a predefined function which is available in open gl library..

  8. #8
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    212

    Re: Delay in open GL

    Swapping buffers is not part of the OpenGL API. It depends on the environment you are in. For the glut library, there is glutSwapBuffers(). For the glfw library, there is glfwSwapBuffers(). For your environment, I don't know.

    It may depend on how your main loop is handled. If you use glut, for example, you don't really have control of the main loop (unless glfw, which I prefer).

  9. #9
    Junior Member Newbie
    Join Date
    Feb 2012
    Posts
    7

    Re: Delay in open GL

    I am not using glut or glfw.I am using open gl es 1.0

    Iss there any replacement for glutswapbuffers in open gl es 1.0

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    964

    Re: Delay in open GL

    No - swap buffers is not an OpenGL command, it is an operating system command. You need to read some documentation and work out what the command for swapping buffers on your operating system is.

Posting Permissions

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