Archived

This topic is now archived and is closed to further replies.

Fier

Question about updating object on openGL screen.

Recommended Posts

Fier    122
Hi all, this is first time I post on here and I am new to openGL. Please excuse me if I post something stupid. All the openGL source code and tutorial I''ve encountered so far put the main drawscreen function in a loop, which means the screen is constantly redrawing itself and swap the buffer when it is done. This is how the openGL shows the movement of the objects, similiar to movie. I am wondering if it is possible that just update one particular obejct, say sphere, on the screen instead of the whole openGL screen? So each update would not have to draw the whoel frame over and over again? Any constructive response would be deeply appreciated.

Share this post


Link to post
Share on other sites
Palidine    1315
i''m sure you could find a way to write directly to the screen, but there''s not point in that. the cost of swapping buffers is about zero. you''re not going to gain anything in your application by finding a way around it. every commercial game on the market re-draws the entire screen every frame.

-me

Share this post


Link to post
Share on other sites
JTippetts    12950
Especially with modern 3D graphics, where the pixels that compose a scene are so much more dependent upon the spatial relationships of geometry and rendering order than graphics were in 2D. In 2D, you could get away with using update rects to just re-draw the parts of the screen that have changed, erasing the old rectangle and drawing the new. In 3D, there is no convenient way of doing this, and combinations such as depth-buffering + translucent geometry like water surfaces can make the whole effort a god-awful mess. Handling situations like this, assuming you could even find a way, would absolutely destroy framerate.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites
Fier    122
Thank you for the feedback. Now I know swapBuffer() is very cheap. But I am wondering if the contantly redraw of the entire screen would be expansive when a lot objects are appear on the screen?
right now my program refreash its frame at 15 time per sec, i.e. 15hz, is that fast enough to not cause any flicker screen during object movement?

Share this post


Link to post
Share on other sites
Palidine    1315
quote:
Original post by Fier
15hz, is that fast enough to not cause any flicker screen during object movement?


that''s actually really slow. trying to optimize by removing the swapbuffer call, however, is not the way to go. what''s your app like at the moment?

are you using scene culling algorithms? have you run a profiler on your code to see where the bottlenecks are? are you using vertex arrays instead of glbegin/glend calls? there are literally hundreds of ways to optimize your game. getting rid of swap buffer, however, is not one of them.

-me

Share this post


Link to post
Share on other sites
Fier    122
"have you run a profiler on your code to see where the bottlenecks are? "

I don''t know how to do that. Can you give me more detail on that?
I am not coding a game. I am coding an openGL API that basically let other people call my function to draw object on the screen. I am drawing basic shapes like sphere and cuboids on the screen, each object would have texture map onto it. On top of that, I also draw two overlay texture that covers the screen. On top of the overlay, I have to draw twoD text and cursor. I am using glBegin() and glEnd() for all the quad and circle. But I am using gluNewQuadric() for sphere, bitmapFont for 2D text, outlineFont for 3D text.

Share this post


Link to post
Share on other sites
JTippetts    12950
Framerates that low are usually a result of the way you draw your scene, and would most certainly not be improved by trying to mess with update regions onscreen. First of all, I would look at culling as Palidine suggested. If an object would not be visible from the camera''s viewpoint, then no calls should be made to draw it. In scenes with large sets, drawing every object only to have it clipped off-screen is a good way to kill framerate.

Graphic card driver quality, and hardware capabilities are also a determining factor. It sounds to me that you are geometry-limited, not fill-rate limited, and that means that somewhere you are drawing excessive geometry, not culling, etc... I understand that quadrics can be slow, so you might look there for performance killers. If you have a fairly decent graphics card, fillrate is exceptional, so this low fps means either a lot of redundant filling, or extremely slow geometry processing that should be fixed.

Basically, you''re shooting for at least 60fps. Good animation can be achieved as low as 18fps or so, but ~60 gives you a good smooth update and allows for frame interpolation to smooth out animation jumps and lurches. The more fps the better, but at least 60 seems to work best for me. 15 definitely is not acceptable.


Golem
Blender--The Gimp--Python--Lua--SDL
Nethack--Crawl--ADOM--Angband--Dungeondweller

Share this post


Link to post
Share on other sites
Fier    122
Thank you all for the constructive replies. I think I should just tell my boss that it is not a good idea to update 1 object instead of whole screen. I shoudl stick to render entire screen and swap the buffer contantly.

I tried my program on other machines, it seems like with Getforce4 and 1.8 Ghz my program would run up to 100 frame per sec I guess the original computer''s dell build in video card was just too crappy.

Two last questions, what is culling ???
also, how do you guys determine your frame rate? The method I used was just use time function to minus end time with start time. THen use 1 sec divides by the time that need to render the entire screen.

Share this post


Link to post
Share on other sites