awt - Fully understanding the BufferStrategy code sample from Java docs -


the official java documentation gives example on how use bufferstrategy:

// render single frame  {      // following loop ensures contents of drawing buffer      // consistent in case underlying surface recreated      {          // new graphics context every time through loop          // make sure strategy validated          graphics graphics = strategy.getdrawgraphics();           // render graphics          // ...           // dispose graphics          graphics.dispose();           // repeat rendering if drawing buffer contents          // restored      } while (strategy.contentsrestored());       // display buffer      strategy.show();       // repeat rendering if drawing buffer lost  } while (strategy.contentslost()); 

however, not able grasp whats going on here documentation quiet sparse samples.

from code sample got following notion: while invoking several methods on graphics object, underlying video memory (vram) might lost , restored halfway through. whole rendering process has repeated. not get, why there check contents lost after show has been invoked on strategy instance?


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -