You are not logged in.

#1 2009-04-05 15:27:33

flarup
Member

Rendering to screen, without clearing buffer

Hi


I recently started developing some homebrew for my Wii, and my first little project is a painting program, that will enable my kids to paint on the TV by swinging the Wii-mote.

After having looked at various other programs that uses GRRLIB it's my impression that GRRLIB automatically does double buffering for us, and as a part of this job clears the appropriate buffer after calling Render(). However, for my little painting program I would like the graphics (the stuff that already has been painted) to "stay" on the screen - like on a real canvas.

I was thinking about one of these two options, but I'm not sure how to do it using GRRLIB:

1) Set a switch somewhere, that will disable clearing of buffer after the call to Render().
2) Copy what has been drawn so far (just before I call Render()) into a buffer of my own, and then "draw" this buffer first thing after the call to Render().

I hope it makes sense, and that someone can help me. Anyways, thank you VERY much for a great library!


Kind regards,
Flarup

Offline

 

#2 2009-04-05 16:17:09

NoNameNo
Administrator

Re: Rendering to screen, without clearing buffer

have a look at the svn there is a screen2texture function wink

http://code.google.com/p/grrlib/source/list

Offline

 

#3 2009-04-05 17:06:02

flarup
Member

Re: Rendering to screen, without clearing buffer

Thanks a lot. It ALMOST works smile However, everything fades to black for some reason?!? Right after the call to Render() I copy the buffer back onto the screen using the following command:

GRRLIB_DrawImg(0, 0, myBuffer, 0, 1, 1, 0xFFFFFFFF);

Isn't this the right way to copy the buffer back?

Offline

 

#4 2009-04-05 17:09:35

Crayon
Bad Mother Fucker

Re: Rendering to screen, without clearing buffer

That's how I'm doing it, if you want to see my code it's available here: http://wiibrew.org/wiki/Wii-Tac-Toe

Offline

 

#5 2009-04-06 20:27:07

flarup
Member

Re: Rendering to screen, without clearing buffer

I still have problems getting the graphics to stay on the screen - it fades away after a few seconds sad I've made a tiny example, where I in the beginning draw a big white rectangle on the screen. In my main loop I then copy the screen to buffer, call Render, and finally copy buffer back to screen. I would expect the result to be, that the big white rectangle would just stay on the screen - however, it faces to black. Can anyone see what I'm doing wrong?

Source code here:

http://www.flarup.org/main.cpp

Thanks a lot in advance.

Offline

 

#6 2009-04-07 10:43:21

NoNameNo
Administrator

Re: Rendering to screen, without clearing buffer

dear flarup wink

the bug you have is already known by the grrlib dev, in fact the FB is in a strange format YbCbr or something like this. when you call screentotexture, GX convert the FB to a RGBA texture format (loosing a little precision), so looping this process will tend to fade to black, i coded a sample code (in the svn) to show ppl this effect, i hope a workaround or something quick.

perhaps a correction in the converted texture buffer will correct this... dunno more for now...

Offline

 

#7 2009-04-07 21:38:18

flarup
Member

Re: Rendering to screen, without clearing buffer

Thanks a lot for the explanation.

I'll go ahead and modify my code, such that my painting is done directly to the texImg buffer, and then I copy this buffer to the screen before the call to render. This also saves a bunch of memory copying.

Offline

 

#8 2009-04-08 09:13:38

NoNameNo
Administrator

Re: Rendering to screen, without clearing buffer

yes you can do it easily with GRRLIB_SetPixelTotexImg for now, we hope providing something better soon.

btw drawing to a buffer then render it to FB is how worked grrlib 1.X version wink

Offline

 

Board footer

Powered by FluxBB