37
37
import com .jme3 .renderer .ViewPort ;
38
38
import com .jme3 .renderer .queue .RenderQueue ;
39
39
import com .jme3 .texture .FrameBuffer ;
40
- import com .jme3 .texture .Image .Format ;
41
40
import com .jme3 .util .BufferUtils ;
42
41
import com .jme3 .util .Screenshots ;
43
42
import java .awt .*;
57
56
58
57
public class AwtPanel extends Canvas implements SceneProcessor {
59
58
59
+ private static final Logger logger = Logger .getLogger (AwtPanel .class .getName ());
60
+
60
61
private boolean attachAsMain = false ;
61
62
62
63
private BufferedImage img ;
@@ -66,19 +67,19 @@ public class AwtPanel extends Canvas implements SceneProcessor {
66
67
private IntBuffer intBuf ;
67
68
private RenderManager rm ;
68
69
private PaintMode paintMode ;
69
- private ArrayList <ViewPort > viewPorts = new ArrayList <>();
70
+ private final java . util . List <ViewPort > viewPorts = new ArrayList <>();
70
71
71
72
// Visibility/drawing vars
72
73
private BufferStrategy strategy ;
73
74
private AffineTransformOp transformOp ;
74
- private AtomicBoolean hasNativePeer = new AtomicBoolean (false );
75
- private AtomicBoolean showing = new AtomicBoolean (false );
76
- private AtomicBoolean repaintRequest = new AtomicBoolean (false );
75
+ private final AtomicBoolean hasNativePeer = new AtomicBoolean (false );
76
+ private final AtomicBoolean showing = new AtomicBoolean (false );
77
+ private final AtomicBoolean repaintRequest = new AtomicBoolean (false );
77
78
78
79
// Reshape vars
79
80
private int newWidth = 1 ;
80
81
private int newHeight = 1 ;
81
- private AtomicBoolean reshapeNeeded = new AtomicBoolean (false );
82
+ private final AtomicBoolean reshapeNeeded = new AtomicBoolean (false );
82
83
private final Object lock = new Object ();
83
84
84
85
public AwtPanel (PaintMode paintMode ) {
@@ -180,7 +181,7 @@ public void drawFrameInThread() {
180
181
BufferCapabilities .FlipContents .UNDEFINED )
181
182
);
182
183
} catch (AWTException ex ) {
183
- ex . printStackTrace ( );
184
+ logger . log ( Level . WARNING , "Failed to create buffer strategy!" , ex );
184
185
}
185
186
strategy = getBufferStrategy ();
186
187
}
@@ -190,7 +191,7 @@ public void drawFrameInThread() {
190
191
do {
191
192
Graphics2D g2d = (Graphics2D ) strategy .getDrawGraphics ();
192
193
if (g2d == null ) {
193
- Logger . getLogger ( AwtPanel . class . getName ()) .log (Level .WARNING , "OGL: DrawGraphics was null." );
194
+ logger .log (Level .WARNING , "OGL: DrawGraphics was null." );
194
195
return ;
195
196
}
196
197
@@ -210,7 +211,7 @@ public boolean isActiveDrawing() {
210
211
}
211
212
212
213
public void attachTo (boolean overrideMainFramebuffer , ViewPort ... vps ) {
213
- if (viewPorts .size () > 0 ) {
214
+ if (! viewPorts .isEmpty () ) {
214
215
for (ViewPort vp : viewPorts ) {
215
216
vp .setOutputFrameBuffer (null );
216
217
}
@@ -242,8 +243,8 @@ private void reshapeInThread(int width, int height) {
242
243
}
243
244
244
245
fb = new FrameBuffer (width , height , 1 );
245
- fb .setDepthBuffer ( Format .Depth );
246
- fb .setColorBuffer ( Format .RGB8 );
246
+ fb .setDepthTarget ( FrameBuffer . FrameBufferTarget . newTarget ( com . jme3 . texture . Image . Format .Depth ) );
247
+ fb .addColorTarget ( FrameBuffer . FrameBufferTarget . newTarget ( com . jme3 . texture . Image . Format .RGB8 ) );
247
248
fb .setSrgb (srgb );
248
249
249
250
if (attachAsMain ) {
0 commit comments