Lines 18-24
Link Here
|
18 |
import javax.media.opengl.GLDrawableFactory; |
18 |
import javax.media.opengl.GLDrawableFactory; |
19 |
import javax.media.opengl.GLException; |
19 |
import javax.media.opengl.GLException; |
20 |
import javax.media.opengl.GLProfile; |
20 |
import javax.media.opengl.GLProfile; |
21 |
import javax.media.opengl.glu.GLU; |
|
|
22 |
|
21 |
|
23 |
import com.ardor3d.annotation.MainThread; |
22 |
import com.ardor3d.annotation.MainThread; |
24 |
import com.ardor3d.framework.CanvasRenderer; |
23 |
import com.ardor3d.framework.CanvasRenderer; |
Lines 140-186
Link Here
|
140 |
} |
139 |
} |
141 |
|
140 |
|
142 |
_context.makeCurrent(); |
141 |
_context.makeCurrent(); |
143 |
|
142 |
try { |
144 |
// Look up a shared context, if a shared JoglCanvasRenderer is given. |
143 |
// Look up a shared context, if a shared JoglCanvasRenderer is given. |
145 |
RenderContext sharedContext = null; |
144 |
RenderContext sharedContext = null; |
146 |
if (settings.getShareContext() != null) { |
145 |
if (settings.getShareContext() != null) { |
147 |
sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext() |
146 |
sharedContext = ContextManager.getContextForKey(settings.getShareContext().getRenderContext() |
148 |
.getContextKey()); |
147 |
.getContextKey()); |
|
|
148 |
} |
149 |
|
150 |
final ContextCapabilities caps = createContextCapabilities(); |
151 |
_currentContext = new RenderContext(_context, caps, sharedContext); |
152 |
|
153 |
ContextManager.addContext(_context, _currentContext); |
154 |
ContextManager.switchContext(_context); |
155 |
|
156 |
_renderer = new JoglRenderer(); |
157 |
|
158 |
if (settings.getSamples() != 0 && caps.isMultisampleSupported()) { |
159 |
final GL gl = _context.getGL(); |
160 |
gl.glEnable(GL.GL_MULTISAMPLE); |
161 |
} |
162 |
|
163 |
_renderer.setBackgroundColor(ColorRGBA.BLACK); |
164 |
|
165 |
if (_camera == null) { |
166 |
/** Set up how our camera sees. */ |
167 |
_camera = new Camera(settings.getWidth(), settings.getHeight()); |
168 |
_camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, 1000); |
169 |
_camera.setProjectionMode(ProjectionMode.Perspective); |
170 |
|
171 |
final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f); |
172 |
final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f); |
173 |
final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f); |
174 |
final Vector3 dir = new Vector3(0.0f, 0f, -1.0f); |
175 |
/** Move our camera to a correct place and orientation. */ |
176 |
_camera.setFrame(loc, left, up, dir); |
177 |
} else { |
178 |
// use new width and height to set ratio. |
179 |
_camera.setFrustumPerspective(_camera.getFovY(), |
180 |
(float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), _camera |
181 |
.getFrustumFar()); |
182 |
} |
183 |
} finally { |
184 |
_context.release(); |
149 |
} |
185 |
} |
150 |
|
|
|
151 |
final ContextCapabilities caps = createContextCapabilities(); |
152 |
_currentContext = new RenderContext(_context, caps, sharedContext); |
153 |
|
154 |
ContextManager.addContext(_context, _currentContext); |
155 |
ContextManager.switchContext(_context); |
156 |
|
157 |
_renderer = new JoglRenderer(); |
158 |
|
159 |
if (settings.getSamples() != 0 && caps.isMultisampleSupported()) { |
160 |
final GL gl = GLU.getCurrentGL(); |
161 |
gl.glEnable(GL.GL_MULTISAMPLE); |
162 |
} |
163 |
|
164 |
_renderer.setBackgroundColor(ColorRGBA.BLACK); |
165 |
|
166 |
if (_camera == null) { |
167 |
/** Set up how our camera sees. */ |
168 |
_camera = new Camera(settings.getWidth(), settings.getHeight()); |
169 |
_camera.setFrustumPerspective(45.0f, (float) settings.getWidth() / (float) settings.getHeight(), 1, 1000); |
170 |
_camera.setProjectionMode(ProjectionMode.Perspective); |
171 |
|
172 |
final Vector3 loc = new Vector3(0.0f, 0.0f, 10.0f); |
173 |
final Vector3 left = new Vector3(-1.0f, 0.0f, 0.0f); |
174 |
final Vector3 up = new Vector3(0.0f, 1.0f, 0.0f); |
175 |
final Vector3 dir = new Vector3(0.0f, 0f, -1.0f); |
176 |
/** Move our camera to a correct place and orientation. */ |
177 |
_camera.setFrame(loc, left, up, dir); |
178 |
} else { |
179 |
// use new width and height to set ratio. |
180 |
_camera.setFrustumPerspective(_camera.getFovY(), |
181 |
(float) settings.getWidth() / (float) settings.getHeight(), _camera.getFrustumNear(), _camera |
182 |
.getFrustumFar()); |
183 |
} |
184 |
} |
186 |
} |
185 |
|
187 |
|
186 |
public GLContext getContext() { |
188 |
public GLContext getContext() { |