Yuri Cacher
asked on
BufferStrategy questions
I'm trying to understand this code, tell me if my considerations are correct
The getDrawGraphics give me a buffer zone where write , the render method create the frame in that space.
If the frame is correctly create the dispose method releases system resources by the buffer zone.
The contentsRestored() is called due a lost and it implies that the frame have to be redrawn.
The contentsLost is not clear to me...
//bs is a BufferStrategy object
public void gameLoop()
{
do
{
do
{
Graphics g=null;
try
{
g=bs.getDrawGraphics();
g.clearRect(0,0,getWidth(),getHeight());
render(g);
}
finally
{
if(g!=null)
{
g.dispose();
}
}
}
while(bs.contentsRestored());
bs.show();
}
while(bs.contentsLost());
}
The getDrawGraphics give me a buffer zone where write , the render method create the frame in that space.
If the frame is correctly create the dispose method releases system resources by the buffer zone.
The contentsRestored() is called due a lost and it implies that the frame have to be redrawn.
The contentsLost is not clear to me...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Only contribution and seemed to be on point.