View Full Version : Delay in open GL
02-21-2012, 04:03 AM
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.
02-21-2012, 08:40 AM
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.
02-21-2012, 11:55 AM
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
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
02-21-2012, 12:18 PM
Are you swapping back and front buffers before the delay?
02-21-2012, 09:46 PM
No, i m not swapping front and back buffers before delay.If i have to,what is command for swapping buffers.
02-22-2012, 12:21 AM
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:
case NormalScale: DrawNormalScale(); break;
case Enlarged: DrawLargeScale(); break;
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.
02-22-2012, 04:17 AM
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..
02-22-2012, 04:31 AM
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).
02-22-2012, 07:07 AM
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
02-22-2012, 07:29 AM
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.
02-22-2012, 08:23 AM
It would probably be called eglSwapBuffers since GL ES systems use EGL.
BTW, you might want to ask GL ES questions at the proper forums over at khronos.org
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.