2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
;
9 import javax
.media
.opengl
.*;
13 * @version $Id: BasicFrameController.java 1941 2007-06-02 08:52:28Z tgaskins $
15 public class BasicFrameController
implements FrameController
17 public void initializeFrame(DrawContext dc
)
21 String msg
= WorldWind
.retrieveErrMsg("nullValue.DrawContextIsNull");
22 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
23 throw new IllegalArgumentException(msg
);
26 javax
.media
.opengl
.GL gl
= dc
.getGL();
28 gl
.glPushAttrib(GL
.GL_VIEWPORT_BIT
| GL
.GL_ENABLE_BIT
| GL
.GL_TRANSFORM_BIT
);
30 gl
.glMatrixMode(GL
.GL_MODELVIEW
);
34 gl
.glMatrixMode(GL
.GL_PROJECTION
);
38 gl
.glEnable(GL
.GL_DEPTH_TEST
);
41 public void finalizeFrame(DrawContext dc
)
45 String msg
= WorldWind
.retrieveErrMsg("nullValue.DrawContextIsNull");
46 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
47 throw new IllegalArgumentException(msg
);
52 gl
.glMatrixMode(GL
.GL_MODELVIEW
);
55 gl
.glMatrixMode(GL
.GL_PROJECTION
);
66 * Called to check for openGL errors. This method includes a "round-trip" between the application and renderer,
67 * which is slow. Therefore, this method is excluded from the "normal" render pass. It is here as a matter of
68 * convenience to developers, and is not part of the API.
70 * @param dc the relevant <code>DrawContext</code>
72 @SuppressWarnings({"UNUSED_SYMBOL", "UnusedDeclaration"})
73 private void checkGLErrors(DrawContext dc
)
76 int err
= gl
.glGetError();
77 if (err
!= GL
.GL_NO_ERROR
)
79 String msg
= dc
.getGLU().gluErrorString(err
);
81 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
85 public void clearFrame(DrawContext dc
)
87 java
.awt
.Color cc
= dc
.getClearColor();
88 dc
.getGL().glClearColor(cc
.getRed(), cc
.getGreen(), cc
.getBlue(), cc
.getAlpha());
89 dc
.getGL().glClear(GL
.GL_COLOR_BUFFER_BIT
| GL
.GL_DEPTH_BUFFER_BIT
);