display context doubt

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

display context doubt

Post by everlasting »

I have been working on the Text sample from the sdk, and i've take a look to other GU samples. One of the things i do not understand is that it seems to be two display contexts. By doing swapbuffers you print the screen and go back to the previous context which might be different from the last one.
This means that you have to print the same thing at least twice in order to have the same info in both contexts. At least this is what i have understood, but i can't see the usefulness of this.

I would like to get deeper into GU module, therefore if anyone could supply any info or links i'd be grateful.Thanks
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

You write to only one buffer at once.You can't write to the currently displayed buffer.You draw on the second one,and then you swap them.Then,the display buffer becomes the second one(non-visible),and vice-versa.But that's true that you should draw everything again after every buffer swap.
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

i knew you only write in only one buffer each time (i´m spanish so may be i didn't explain myself very well), but i didn`t know that is not possible to write to the displayed buffer. So you have to worry about 'copying' every modification you do in the non-visible buffer to the visible one after swapping haven't you?.
Thanks a lot your explanation was very usefull.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Read here for info on doublebuffering: http://en.wikipedia.org/wiki/Double_buffering

Also, you CAN draw to the displaybuffer. However, normally you should avoid that, because when the drawing is slow (or you are drawing a lot), the single drawing steps can be seen. That's why double buffering is used.
Also, a swapbuffer call doesn't change the context. It merely swaps draw and display buffer (page flipping).

If you don't understand why you have to repeatedly draw things on the screen, then you should start researching how basic drawing loops work, since this is common approach around all computer graphic applications.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

thanks raphael, good info.
Post Reply