OpenGL
-
Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan
-
Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan
Does your scene change every 100 msecs? Tomasz Sowinski -- http://www.shooltz.com.pl
-
Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan
Hi, Having the advantage of using MFC, you could do any of the followings: 1/ The best is to create a separate thread to do that particular job for you while the application is idle. 2/ The other option is to have the message pump method. 3/ Last but not least, is to put your anmation code in the OnIdle method of the application class. Override the OnIdle and try your code lines there. Hope these helped. Cheers! :)
-
Does your scene change every 100 msecs? Tomasz Sowinski -- http://www.shooltz.com.pl
Well, not whole of the scene, but some disjoint parts of the scene change. Currently, I redraw the whole picture. Is there any way to restrict drawing of only those parts which change and leaving the unchanged part intact? Thanks, Krishnan
-
Well, not whole of the scene, but some disjoint parts of the scene change. Currently, I redraw the whole picture. Is there any way to restrict drawing of only those parts which change and leaving the unchanged part intact? Thanks, Krishnan
> Is there any way to restrict drawing of only those parts > which change and leaving the unchanged part intact? Honestly, I don't know. But I think you need to move your rendering code to separate thread to make app UI responsive. I'd render to a bitmap and then blt results to the screen. Of course, you'll have to use some synchronization stuff (critical sections). Tomasz Sowinski -- http://www.shooltz.com.pl
-
> Is there any way to restrict drawing of only those parts > which change and leaving the unchanged part intact? Honestly, I don't know. But I think you need to move your rendering code to separate thread to make app UI responsive. I'd render to a bitmap and then blt results to the screen. Of course, you'll have to use some synchronization stuff (critical sections). Tomasz Sowinski -- http://www.shooltz.com.pl
I have done some performance tests on my app. They show that the time to actually issue OpenGL commands is more than the time to swap the buffers. as far as multithreading is concerned, I don't think that the CPU load would decrease by that.
-
I have done some performance tests on my app. They show that the time to actually issue OpenGL commands is more than the time to swap the buffers. as far as multithreading is concerned, I don't think that the CPU load would decrease by that.
: as far as multithreading is concerned, I don't think that : the CPU load would decrease by that. Multithreading is not going to reduce CPU load. Moving the rendering code to second thread will make your application *more responsive* - users will be able to more easily select options from the menu, resize the window or exit the program. Tomasz Sowinski -- http://www.shooltz.com.pl
-
Hi, I am developing an OpenGL application using MFC. I have a requirement that I need to redraw the whole scene every 100 millisecs. when I do this using windows timers and invalidating the client area each time, the CPU usage is 100%. The result is that the app cannot process any other messages like, keyboard, mouse etc. Can anyone help me in making this efficient. Thanks, Krishnan
Heres a mulit threaded OpenGL View class for you to use. It handles all of the threading issues for you. You just put your drawing code in the correct overloaded method and away you go... http://mkennedy.101main.com/software/OpenGLandCPP.asp Pete
-
Heres a mulit threaded OpenGL View class for you to use. It handles all of the threading issues for you. You just put your drawing code in the correct overloaded method and away you go... http://mkennedy.101main.com/software/OpenGLandCPP.asp Pete
Haha! "Mulit threadded" pete