How to use BufferStrategy with JApplet?

View: New views
8 Messages — Rating Filter:   Alert me  

How to use BufferStrategy with JApplet?

by java2d :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Clearly BufferStrategy only works with Window and Canvas and as JApplet can use neither of these, how do I get a buffer strategy to work in a JApplet?

I have tried using Canvas and JApplet but I don't believe the combination of AWT and Swing components is recommended and also there is a problem where the back buffer seems to be cleared or even recreated on a resize.  Further to my other thread about BufferStrategy, the flickering I refer to there can be resolved in a JFrame/JPanel based application but I cannot get rid of the flickering when using JApplet and Canvas.

So I guess there are 2 questions: how do I use BufferStrategy properly with a JApplet OR is there a way to stop the back buffer being recreated or cleared when the applet is resized?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@...
[Replace the "SixFour" with numbers to email me]
[Message sent by forum member 'qu0ll' (qu0ll)]

http://forums.java.net/jive/thread.jspa?messageID=289238

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by java2d :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why would you want to use your own BufferStrategy with a JApplet? Why not use Applet?

Dmitri
[Message sent by forum member 'trembovetski' (trembovetski)]

http://forums.java.net/jive/thread.jspa?messageID=289240

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by java2d :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Dmitri,

Well I have been quite happy to use an Applet but I found that it's very problematic to avoid flickering on resizing when there are more than one rendering threads.  I have one thread which is responsible for rendering the basic layout of the screen and another which renders an animation.  I am struggling a bit with resizing seemingly causing the back buffer to be cleared but only when both threads have a different Graphics object for the draw graphics.

Anyway, this isn't happening in my JFrame implementation of the same program so I figured that perhaps if I change over to using JApplet and JPanel instead of Applet and Canvas then maybe the problem would go away.

I have now managed to minimize the flickering by doing a full re-render when a resize is detected and the second thread is active.  There is still a small degree of flickering but it is probably acceptable and as good as it is going to get :-)

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@...
[Replace the "SixFour" with numbers to email me]
[Message sent by forum member 'qu0ll' (qu0ll)]

http://forums.java.net/jive/thread.jspa?messageID=289297

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by Dmitri Trembovetski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Hi,

   I don't think using JApplet won't help you much.
   The only reason I think it may make a difference is that
   JApplets in 6u10 disable the clearing of the background on
   resize.

   I would suggest not to do multi-threaded rendering, it's
   generally a bad idea. You don't get any advantage from
   doing so, but the rendering code will be too complicated.

   One thing you should do when using BS is disable
   repaints (setIgnoreRepaint()) - it may help.

   Thanks,
     Dmitri


java2d@... wrote:
> Hi Dmitri,
>
> Well I have been quite happy to use an Applet but I found that it's very problematic to avoid flickering on resizing when there are more than one rendering threads.  I have one thread which is responsible for rendering the basic layout of the screen and another which renders an animation.  I am struggling a bit with resizing seemingly causing the back buffer to be cleared but only when both threads have a different Graphics object for the draw graphics.
>
> Anyway, this isn't happening in my JFrame implementation of the same program so I figured that perhaps if I change over to using JApplet and JPanel instead of Applet and Canvas then maybe the problem would go away.
>
> I have now managed to minimize the flickering by doing a full re-render when a resize is detected and the second thread is active.  There is still a small degree of flickering but it is probably acceptable and as good as it is going to get :-)
>

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by Dmitri Trembovetski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dmitri Trembovetski wrote:
>
>   Hi,
>
>   I don't think using JApplet won't help you much.

   Ok, that should have been:
     "I don't think using JApplet will help you much."

   Dmitri


>   The only reason I think it may make a difference is that
>   JApplets in 6u10 disable the clearing of the background on
>   resize.
>
>   I would suggest not to do multi-threaded rendering, it's
>   generally a bad idea. You don't get any advantage from
>   doing so, but the rendering code will be too complicated.
>
>   One thing you should do when using BS is disable
>   repaints (setIgnoreRepaint()) - it may help.
>
>   Thanks,
>     Dmitri
>
>
> java2d@... wrote:
>> Hi Dmitri,
>>
>> Well I have been quite happy to use an Applet but I found that it's
>> very problematic to avoid flickering on resizing when there are more
>> than one rendering threads.  I have one thread which is responsible
>> for rendering the basic layout of the screen and another which renders
>> an animation.  I am struggling a bit with resizing seemingly causing
>> the back buffer to be cleared but only when both threads have a
>> different Graphics object for the draw graphics.
>>
>> Anyway, this isn't happening in my JFrame implementation of the same
>> program so I figured that perhaps if I change over to using JApplet
>> and JPanel instead of Applet and Canvas then maybe the problem would
>> go away.
>>
>> I have now managed to minimize the flickering by doing a full
>> re-render when a resize is detected and the second thread is active.  
>> There is still a small degree of flickering but it is probably
>> acceptable and as good as it is going to get :-)
>>

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by java2d :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK thanks Dmitri.

Unfortunately using setIgnoreRepaint() doesn't help.

My multithreaded rendering is working very nicely and in some ways is less complex than putting it all in one thread.  I think I will just live with the small amount of flickering on resize that I have now.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@...
[Replace the "SixFour" with numbers to email me]
[Message sent by forum member 'qu0ll' (qu0ll)]

http://forums.java.net/jive/thread.jspa?messageID=289436

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by Dmitri Trembovetski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   May be you could suspend some of your rendering when
   resizing? Add a component event listener to the
   Japplet, and pause your rendering thread - may be
   it'll help.

   Dmitri


java2d@... wrote:
> OK thanks Dmitri.
>
> Unfortunately using setIgnoreRepaint() doesn't help.
>
> My multithreaded rendering is working very nicely and in some ways is less complex than putting it all in one thread.  I think I will just live with the small amount of flickering on resize that I have now.
>

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".

Re: How to use BufferStrategy with JApplet?

by java2d :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Gosh Dmitri - it was that simple!  Why didn't I think of that?

Thanks very much indeed :-) :-)

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@...
[Replace the "SixFour" with numbers to email me]
[Message sent by forum member 'qu0ll' (qu0ll)]

http://forums.java.net/jive/thread.jspa?messageID=289445

===========================================================================
To unsubscribe, send email to listserv@... and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
listserv@... and include in the body of the message "help".
LightInTheBox - Buy quality products at wholesale price