Main repository of MikuMikuStudio
Revision | a889c6556262b4f9ed62adf4dfdb5e046ab8ee07 (tree) |
---|---|
Time | 2003-09-04 01:20:52 |
Author | mojomonkey <mojomonkey@75d0...> |
Commiter | mojomonkey |
Conversion to LWJGL 0.7
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@73 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -42,7 +42,7 @@ import org.lwjgl.Display; | ||
42 | 42 | import org.lwjgl.input.Keyboard; |
43 | 43 | import org.lwjgl.input.Mouse; |
44 | 44 | import org.lwjgl.opengl.GL; |
45 | -import org.lwjgl.opengl.GLU; | |
45 | +import org.lwjgl.opengl.Window; | |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * <code>AbstractGame</code> defines a common way to organize the flow of a |
@@ -56,18 +56,6 @@ import org.lwjgl.opengl.GLU; | ||
56 | 56 | |
57 | 57 | public abstract class AbstractGame { |
58 | 58 | |
59 | - /** | |
60 | - * gl is the object to communicate with the OpenGL base context. | |
61 | - * This object must be initialized during the initalization phase. | |
62 | - */ | |
63 | - protected GL gl = null; | |
64 | - | |
65 | - /** | |
66 | - * glu is the object to communication with the OpenGL utility context. | |
67 | - * This object must be initialized during the initalization phase. | |
68 | - */ | |
69 | - protected GLU glu = null; | |
70 | - | |
71 | 59 | //Flag for running the system. |
72 | 60 | private boolean finished; |
73 | 61 | //holds all splashscreens |
@@ -88,16 +76,15 @@ public abstract class AbstractGame { | ||
88 | 76 | initSystem(); |
89 | 77 | |
90 | 78 | //check if user initialized gl and glu; |
91 | - if (null == gl || null == glu) { | |
79 | + if (!Window.isCreated()) { | |
92 | 80 | throw new MonkeyRuntimeException( |
93 | - "The gl and glu contexts" | |
94 | - + "must be initialized in the init phase"); | |
81 | + "Window must be created during initialization."); | |
95 | 82 | } |
96 | 83 | showTitle(); |
97 | 84 | initGame(); |
98 | 85 | |
99 | 86 | //main loop |
100 | - while (!finished && !gl.isCloseRequested()) { | |
87 | + while (!finished && !Window.isCloseRequested()) { | |
101 | 88 | //update game state |
102 | 89 | update(); |
103 | 90 |
@@ -105,8 +92,8 @@ public abstract class AbstractGame { | ||
105 | 92 | render(); |
106 | 93 | |
107 | 94 | //swap buffers |
108 | - gl.paint(); | |
109 | - gl.tick(); | |
95 | + Window.paint(); | |
96 | + Window.update(); | |
110 | 97 | } |
111 | 98 | } catch (Throwable t) { |
112 | 99 | t.printStackTrace(); |
@@ -125,11 +112,11 @@ public abstract class AbstractGame { | ||
125 | 112 | public final void showTitle() { |
126 | 113 | |
127 | 114 | for(int i = 0; i < splashScreens.size(); i++) { |
128 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
129 | - gl.loadIdentity(); | |
115 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
116 | + GL.glLoadIdentity(); | |
130 | 117 | ((SplashScreen)splashScreens.get(i)).render(); |
131 | - gl.paint(); | |
132 | - gl.tick(); | |
118 | + Window.paint(); | |
119 | + Window.update(); | |
133 | 120 | ((SplashScreen)splashScreens.get(i)).holdDisplay(); |
134 | 121 | } |
135 | 122 | } |
@@ -360,8 +360,8 @@ public class BaseFPSController extends AbstractGameController { | ||
360 | 360 | Vector view = |
361 | 361 | entity.getView().subtract(entity.getPosition()); |
362 | 362 | |
363 | - float cosTheta = org.lwjgl.Math.cos(angle); | |
364 | - float sinTheta = org.lwjgl.Math.sin(angle); | |
363 | + float cosTheta = (float)Math.cos(angle); | |
364 | + float sinTheta = (float)Math.sin(angle); | |
365 | 365 | |
366 | 366 | newView.x = (cosTheta + (1 - cosTheta) * x * x) * view.x; |
367 | 367 | newView.x += ((1 - cosTheta) * x * y - z * sinTheta) * view.y; |
@@ -41,12 +41,12 @@ import jme.exception.MonkeyRuntimeException; | ||
41 | 41 | import jme.geometry.Geometry; |
42 | 42 | import jme.geometry.bounding.BoundingVolume; |
43 | 43 | import jme.math.Vector; |
44 | -import jme.physics.PhysicsModule; | |
45 | -import jme.system.DisplaySystem; | |
44 | +import jme.physics.PhysicsModule; | |
46 | 45 | import jme.entity.camera.Frustum; |
47 | 46 | import jme.utility.LoggingSystem; |
48 | 47 | |
49 | 48 | import org.lwjgl.opengl.GL; |
49 | +import org.lwjgl.opengl.Window; | |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * <code>Entity</code> defines a game entity that consists of a piece of |
@@ -65,7 +65,7 @@ import org.lwjgl.opengl.GL; | ||
65 | 65 | * <code>Entity</code> to represent something abstract. |
66 | 66 | * |
67 | 67 | * @author Mark Powell |
68 | - * @version 0.1.0 | |
68 | + * @version $Id: Entity.java,v 1.7 2003-09-03 16:20:52 mojomonkey Exp $ | |
69 | 69 | */ |
70 | 70 | public class Entity implements EntityInterface { |
71 | 71 | /** |
@@ -110,9 +110,6 @@ public class Entity implements EntityInterface { | ||
110 | 110 | //physics |
111 | 111 | private PhysicsModule physics; |
112 | 112 | |
113 | - //the gl object for translation and rotation of the entity. | |
114 | - protected GL gl; | |
115 | - | |
116 | 113 | /** |
117 | 114 | * Constructor initializes the entity. All attributes of the |
118 | 115 | * <code>Entity</code> are empty. |
@@ -127,11 +124,9 @@ public class Entity implements EntityInterface { | ||
127 | 124 | } |
128 | 125 | children = new ArrayList(); |
129 | 126 | position = new Vector(); |
130 | - | |
131 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
132 | 127 | |
133 | - if(null == gl) { | |
134 | - throw new MonkeyGLException("The OpenGL context must be set before " + "using Entity."); | |
128 | + if(!Window.isCreated()) { | |
129 | + throw new MonkeyGLException("Window must be created before Entity."); | |
135 | 130 | } |
136 | 131 | |
137 | 132 | LoggingSystem.getLoggingSystem().getLogger().log( |
@@ -154,8 +149,6 @@ public class Entity implements EntityInterface { | ||
154 | 149 | children = new ArrayList(); |
155 | 150 | position = new Vector(); |
156 | 151 | |
157 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
158 | - | |
159 | 152 | children.add(child); |
160 | 153 | |
161 | 154 | LoggingSystem.getLoggingSystem().getLogger().log( |
@@ -318,12 +311,12 @@ public class Entity implements EntityInterface { | ||
318 | 311 | * Each child is then rendered in turn. |
319 | 312 | */ |
320 | 313 | public void render() { |
321 | - gl.pushMatrix(); | |
322 | - gl.enable(GL.DEPTH_TEST); | |
323 | - gl.translatef(position.x, position.y, position.z); | |
324 | - gl.rotatef(roll, 0, 0, 1); | |
325 | - gl.rotatef(yaw, 0, 1, 0); | |
326 | - gl.rotatef(pitch, 1, 0, 1); | |
314 | + GL.glPushMatrix(); | |
315 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
316 | + GL.glTranslatef(position.x, position.y, position.z); | |
317 | + GL.glRotatef(roll, 0, 0, 1); | |
318 | + GL.glRotatef(yaw, 0, 1, 0); | |
319 | + GL.glRotatef(pitch, 1, 0, 1); | |
327 | 320 | |
328 | 321 | //no geometry, so don't render. |
329 | 322 | if (null != geometry) { |
@@ -334,8 +327,8 @@ public class Entity implements EntityInterface { | ||
334 | 327 | for (int i = 0; i < children.size(); i++) { |
335 | 328 | ((Entity)children.get(i)).render(); |
336 | 329 | } |
337 | - gl.disable(GL.DEPTH_TEST); | |
338 | - gl.popMatrix(); | |
330 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
331 | + GL.glPopMatrix(); | |
339 | 332 | } |
340 | 333 | |
341 | 334 | /** |
@@ -32,10 +32,12 @@ | ||
32 | 32 | |
33 | 33 | package jme.entity.camera; |
34 | 34 | |
35 | +import org.lwjgl.opengl.GL; | |
36 | +import org.lwjgl.opengl.GLU; | |
37 | + | |
35 | 38 | import jme.entity.Entity; |
36 | 39 | import jme.locale.external.feature.Sky; |
37 | 40 | import jme.math.Vector; |
38 | -import jme.system.DisplaySystem; | |
39 | 41 | |
40 | 42 | /** |
41 | 43 | * <code>Camera</code> defines a camera in three dimensional space. The camera |
@@ -288,20 +290,20 @@ public class Camera extends Entity{ | ||
288 | 290 | * camera to determine the view. |
289 | 291 | */ |
290 | 292 | public void render() { |
291 | - DisplaySystem.getDisplaySystem().getGLU().lookAt( | |
293 | + GLU.gluLookAt( | |
292 | 294 | getPosition().x, getPosition().y, getPosition().z, |
293 | 295 | getView().x, getView().y, getView().z, |
294 | 296 | getUp().x, getUp().y, getUp().z); |
295 | 297 | |
296 | 298 | if(null != sky) { |
297 | - gl.pushMatrix(); | |
299 | + GL.glPushMatrix(); | |
298 | 300 | float x = getPosition().x - sky.getSize() / 2; |
299 | 301 | float y = getPosition().y - sky.getSize() * 0.75f; |
300 | 302 | float z = getPosition().z - sky.getSize() / 2; |
301 | - gl.translatef(x, y, z); | |
303 | + GL.glTranslatef(x, y, z); | |
302 | 304 | |
303 | 305 | sky.render(); |
304 | - gl.popMatrix(); | |
306 | + GL.glPopMatrix(); | |
305 | 307 | } |
306 | 308 | |
307 | 309 | for(int i = 0; i < children.size(); i++) { |
@@ -37,10 +37,8 @@ import java.nio.ByteOrder; | ||
37 | 37 | import java.nio.FloatBuffer; |
38 | 38 | import java.util.logging.Level; |
39 | 39 | |
40 | -import jme.system.DisplaySystem; | |
41 | 40 | import jme.utility.LoggingSystem; |
42 | 41 | |
43 | -import org.lwjgl.Sys; | |
44 | 42 | import org.lwjgl.opengl.GL; |
45 | 43 | |
46 | 44 | /** |
@@ -71,7 +69,7 @@ public class Frustum { | ||
71 | 69 | * |
72 | 70 | */ |
73 | 71 | public Frustum() { |
74 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
72 | + //gl = DisplaySystem.getDisplaySystem().getGL(); | |
75 | 73 | proj = new float[16]; |
76 | 74 | modl = new float[16]; |
77 | 75 | clip = new float[16]; |
@@ -99,17 +97,14 @@ public class Frustum { | ||
99 | 97 | */ |
100 | 98 | public void update() { |
101 | 99 | float t; |
102 | - | |
103 | - int projPtr = Sys.getDirectBufferAddress(projBuf); | |
104 | - gl.getFloatv(GL.PROJECTION_MATRIX, projPtr); | |
105 | - projBuf.rewind(); | |
100 | + projBuf.clear(); | |
101 | + modlBuf.clear(); | |
102 | + GL.glGetFloat(GL.GL_PROJECTION_MATRIX, projBuf); | |
106 | 103 | projBuf.get(proj); |
107 | 104 | |
108 | - int modlPtr = Sys.getDirectBufferAddress(modlBuf); | |
109 | - gl.getFloatv(GL.MODELVIEW_MATRIX, modlPtr); | |
110 | - modlBuf.rewind(); | |
105 | + GL.glGetFloat(GL.GL_MODELVIEW_MATRIX, modlBuf); | |
111 | 106 | modlBuf.get(modl); |
112 | - | |
107 | + | |
113 | 108 | clip[0] = |
114 | 109 | modl[0] * proj[0] |
115 | 110 | + modl[1] * proj[4] |
@@ -202,7 +197,7 @@ public class Frustum { | ||
202 | 197 | |
203 | 198 | /* Normalize the result */ |
204 | 199 | t = |
205 | - org.lwjgl.Math.sqrt( | |
200 | + (float)Math.sqrt( | |
206 | 201 | frustum[0][0] * frustum[0][0] |
207 | 202 | + frustum[0][1] * frustum[0][1] |
208 | 203 | + frustum[0][2] * frustum[0][2]); |
@@ -219,7 +214,7 @@ public class Frustum { | ||
219 | 214 | |
220 | 215 | /* Normalize the result */ |
221 | 216 | t = |
222 | - org.lwjgl.Math.sqrt( | |
217 | + (float)Math.sqrt( | |
223 | 218 | frustum[1][0] * frustum[1][0] |
224 | 219 | + frustum[1][1] * frustum[1][1] |
225 | 220 | + frustum[1][2] * frustum[1][2]); |
@@ -236,7 +231,7 @@ public class Frustum { | ||
236 | 231 | |
237 | 232 | /* Normalize the result */ |
238 | 233 | t = |
239 | - org.lwjgl.Math.sqrt( | |
234 | + (float)Math.sqrt( | |
240 | 235 | frustum[2][0] * frustum[2][0] |
241 | 236 | + frustum[2][1] * frustum[2][1] |
242 | 237 | + frustum[2][2] * frustum[2][2]); |
@@ -253,7 +248,7 @@ public class Frustum { | ||
253 | 248 | |
254 | 249 | /* Normalize the result */ |
255 | 250 | t = |
256 | - org.lwjgl.Math.sqrt( | |
251 | + (float)Math.sqrt( | |
257 | 252 | frustum[3][0] * frustum[3][0] |
258 | 253 | + frustum[3][1] * frustum[3][1] |
259 | 254 | + frustum[3][2] * frustum[3][2]); |
@@ -270,7 +265,7 @@ public class Frustum { | ||
270 | 265 | |
271 | 266 | /* Normalize the result */ |
272 | 267 | t = |
273 | - org.lwjgl.Math.sqrt( | |
268 | + (float)Math.sqrt( | |
274 | 269 | frustum[4][0] * frustum[4][0] |
275 | 270 | + frustum[4][1] * frustum[4][1] |
276 | 271 | + frustum[4][2] * frustum[4][2]); |
@@ -287,7 +282,7 @@ public class Frustum { | ||
287 | 282 | |
288 | 283 | /* Normalize the result */ |
289 | 284 | t = |
290 | - org.lwjgl.Math.sqrt( | |
285 | + (float)Math.sqrt( | |
291 | 286 | frustum[5][0] * frustum[5][0] |
292 | 287 | + frustum[5][1] * frustum[5][1] |
293 | 288 | + frustum[5][2] * frustum[5][2]); |
@@ -36,11 +36,9 @@ import java.nio.ByteBuffer; | ||
36 | 36 | import java.nio.ByteOrder; |
37 | 37 | import java.nio.FloatBuffer; |
38 | 38 | |
39 | -import org.lwjgl.Sys; | |
40 | 39 | import org.lwjgl.opengl.GL; |
41 | 40 | import org.lwjgl.vector.Vector3f; |
42 | 41 | |
43 | -import jme.system.DisplaySystem; | |
44 | 42 | import jme.texture.TextureManager; |
45 | 43 | |
46 | 44 | /** |
@@ -64,8 +62,6 @@ import jme.texture.TextureManager; | ||
64 | 62 | * @version 1 |
65 | 63 | */ |
66 | 64 | public class ParticleEmitter { |
67 | - //gl object for rendering | |
68 | - private GL gl; | |
69 | 65 | |
70 | 66 | //handles the particle objects. |
71 | 67 | private int numParticles; |
@@ -110,7 +106,6 @@ public class ParticleEmitter { | ||
110 | 106 | * on screen at any one time. |
111 | 107 | */ |
112 | 108 | public ParticleEmitter(int numParticles) { |
113 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
114 | 109 | |
115 | 110 | this.numParticles = numParticles; |
116 | 111 | particles = new Particle[numParticles]; |
@@ -206,16 +201,15 @@ public class ParticleEmitter { | ||
206 | 201 | * effect using two dimensional objects. |
207 | 202 | */ |
208 | 203 | public void render() { |
209 | - gl.pushMatrix(); | |
204 | + GL.glPushMatrix(); | |
210 | 205 | //set gl state. |
211 | - gl.enable(GL.TEXTURE_2D); | |
212 | - gl.enable(GL.BLEND); | |
213 | - gl.blendFunc(GL.SRC_ALPHA, GL.ONE); | |
206 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
207 | + GL.glEnable(GL.GL_BLEND); | |
208 | + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); | |
214 | 209 | TextureManager.getTextureManager().bind(texId); |
215 | 210 | |
216 | 211 | //get the view matrix for billboarding. |
217 | - int bufPtr = Sys.getDirectBufferAddress(buf); | |
218 | - gl.getFloatv(GL.MODELVIEW_MATRIX, bufPtr); | |
212 | + GL.glGetFloat(GL.GL_MODELVIEW_MATRIX, buf); | |
219 | 213 | buf.rewind(); |
220 | 214 | buf.get(matrix); |
221 | 215 |
@@ -230,13 +224,13 @@ public class ParticleEmitter { | ||
230 | 224 | |
231 | 225 | //render each particle |
232 | 226 | for (int i = 0; i < numParticles; i++) { |
233 | - gl.color4f( | |
227 | + GL.glColor4f( | |
234 | 228 | particles[i].color.x, |
235 | 229 | particles[i].color.y, |
236 | 230 | particles[i].color.z, |
237 | 231 | particles[i].life); |
238 | - gl.begin(GL.TRIANGLE_STRIP); | |
239 | - gl.texCoord2d(1, 1); | |
232 | + GL.glBegin(GL.GL_TRIANGLE_STRIP); | |
233 | + GL.glTexCoord2f(1, 1); | |
240 | 234 | |
241 | 235 | //top right of quad |
242 | 236 | billboard.x = |
@@ -248,8 +242,8 @@ public class ParticleEmitter { | ||
248 | 242 | billboard.z = |
249 | 243 | (right.z + up.z) * particles[i].size.z |
250 | 244 | + particles[i].position.z; |
251 | - gl.vertex3f(billboard.x, billboard.y, billboard.z); | |
252 | - gl.texCoord2d(0, 1); | |
245 | + GL.glVertex3f(billboard.x, billboard.y, billboard.z); | |
246 | + GL.glTexCoord2f(0, 1); | |
253 | 247 | |
254 | 248 | //top left of quad |
255 | 249 | billboard.x = |
@@ -262,8 +256,8 @@ public class ParticleEmitter { | ||
262 | 256 | (up.z - right.z) * particles[i].size.z |
263 | 257 | + particles[i].position.z; |
264 | 258 | |
265 | - gl.vertex3f(billboard.x, billboard.y, billboard.z); | |
266 | - gl.texCoord2d(1, 0); | |
259 | + GL.glVertex3f(billboard.x, billboard.y, billboard.z); | |
260 | + GL.glTexCoord2f(1, 0); | |
267 | 261 | |
268 | 262 | //bottom right of quad |
269 | 263 | billboard.x = |
@@ -273,8 +267,8 @@ public class ParticleEmitter { | ||
273 | 267 | billboard.z = |
274 | 268 | (right.z - up.z) * particles[i].size.z + particles[i].position.z; |
275 | 269 | |
276 | - gl.vertex3f(billboard.x, billboard.y, billboard.z); | |
277 | - gl.texCoord2d(0, 0); | |
270 | + GL.glVertex3f(billboard.x, billboard.y, billboard.z); | |
271 | + GL.glTexCoord2f(0, 0); | |
278 | 272 | |
279 | 273 | //bottom left of quad |
280 | 274 | billboard.x = |
@@ -290,15 +284,15 @@ public class ParticleEmitter { | ||
290 | 284 | - particles[i].size.z |
291 | 285 | + particles[i].position.z; |
292 | 286 | |
293 | - gl.vertex3f(billboard.x, billboard.y, billboard.z); | |
294 | - gl.end(); | |
287 | + GL.glVertex3f(billboard.x, billboard.y, billboard.z); | |
288 | + GL.glEnd(); | |
295 | 289 | |
296 | 290 | } |
297 | 291 | |
298 | 292 | //revert open gl state |
299 | - gl.disable(GL.TEXTURE_2D); | |
300 | - gl.disable(GL.BLEND); | |
301 | - gl.popMatrix(); | |
293 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
294 | + GL.glDisable(GL.GL_BLEND); | |
295 | + GL.glPopMatrix(); | |
302 | 296 | } |
303 | 297 | |
304 | 298 | /** |
@@ -399,8 +393,8 @@ public class ParticleEmitter { | ||
399 | 393 | public void setTexture(String filename) { |
400 | 394 | texId = TextureManager.getTextureManager().loadTexture( |
401 | 395 | filename, |
402 | - GL.LINEAR_MIPMAP_LINEAR, | |
403 | - GL.LINEAR, | |
396 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
397 | + GL.GL_LINEAR, | |
404 | 398 | true); |
405 | 399 | } |
406 | 400 |
@@ -38,7 +38,6 @@ import org.lwjgl.opengl.GL; | ||
38 | 38 | import org.lwjgl.vector.Vector3f; |
39 | 39 | |
40 | 40 | import jme.entity.EntityInterface; |
41 | -import jme.system.DisplaySystem; | |
42 | 41 | import jme.entity.camera.Frustum; |
43 | 42 | import jme.geometry.bounding.BoundingVolume; |
44 | 43 |
@@ -47,17 +46,15 @@ import jme.geometry.bounding.BoundingVolume; | ||
47 | 46 | * particle emitters. |
48 | 47 | * |
49 | 48 | * @author Mark Powell |
50 | - * @version $Id: ParticleSystem.java,v 1.3 2003-08-31 19:49:49 mojomonkey Exp $ | |
49 | + * @version $Id: ParticleSystem.java,v 1.4 2003-09-03 16:20:52 mojomonkey Exp $ | |
51 | 50 | */ |
52 | 51 | public class ParticleSystem implements EntityInterface { |
53 | 52 | private ArrayList emitters; |
54 | 53 | private Vector3f position; |
55 | - private GL gl; | |
56 | 54 | private BoundingVolume boundingVolume; |
57 | 55 | |
58 | 56 | public ParticleSystem() { |
59 | 57 | emitters = new ArrayList(); |
60 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
61 | 58 | position = new Vector3f(); |
62 | 59 | } |
63 | 60 |
@@ -65,12 +62,12 @@ public class ParticleSystem implements EntityInterface { | ||
65 | 62 | * @see jme.entity.EntityInterface#render() |
66 | 63 | */ |
67 | 64 | public void render() { |
68 | - gl.pushMatrix(); | |
69 | - gl.translatef(position.x, position.y, position.z); | |
65 | + GL.glPushMatrix(); | |
66 | + GL.glTranslatef(position.x, position.y, position.z); | |
70 | 67 | for(int i = 0; i < emitters.size(); i++) { |
71 | 68 | ((ParticleEmitter)emitters.get(i)).render(); |
72 | 69 | } |
73 | - gl.popMatrix(); | |
70 | + GL.glPopMatrix(); | |
74 | 71 | } |
75 | 72 | |
76 | 73 | /** |
@@ -33,10 +33,10 @@ package jme.geometry.hud; | ||
33 | 33 | |
34 | 34 | import jme.exception.MonkeyGLException; |
35 | 35 | import jme.exception.MonkeyRuntimeException; |
36 | -import jme.system.DisplaySystem; | |
37 | 36 | import jme.texture.TextureManager; |
38 | 37 | |
39 | 38 | import org.lwjgl.opengl.GL; |
39 | +import org.lwjgl.opengl.Window; | |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * <code>SplashScreen</code> creates a screen encompassing splash screen to |
@@ -45,10 +45,9 @@ import org.lwjgl.opengl.GL; | ||
45 | 45 | * to be displayed for a set amount of time. |
46 | 46 | * |
47 | 47 | * @author Mark Powell |
48 | - * @version 0.1.0 | |
48 | + * @version $Id: SplashScreen.java,v 1.2 2003-09-03 16:20:51 mojomonkey Exp $ | |
49 | 49 | */ |
50 | 50 | public class SplashScreen { |
51 | - private GL gl; | |
52 | 51 | private int texId; |
53 | 52 | private float x, y; |
54 | 53 | private float width, height; |
@@ -62,17 +61,16 @@ public class SplashScreen { | ||
62 | 61 | * the OpenGL context. |
63 | 62 | */ |
64 | 63 | public SplashScreen() { |
65 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
66 | - if(null == gl) { | |
67 | - throw new MonkeyGLException("GL is null. Insure Display has been " + "created."); | |
64 | + if(!Window.isCreated()) { | |
65 | + throw new MonkeyGLException("Window must be created first."); | |
68 | 66 | } |
69 | 67 | red = 1.0f; |
70 | 68 | blue = 1.0f; |
71 | 69 | green = 1.0f; |
72 | 70 | alpha = 1.0f; |
73 | 71 | |
74 | - width = gl.getWidth(); | |
75 | - height = gl.getHeight(); | |
72 | + width = Window.getWidth(); | |
73 | + height = Window.getHeight(); | |
76 | 74 | |
77 | 75 | isBlended = true; |
78 | 76 | } |
@@ -84,8 +82,8 @@ public class SplashScreen { | ||
84 | 82 | public void setTexture(String filename) { |
85 | 83 | texId = TextureManager.getTextureManager().loadTexture( |
86 | 84 | filename, |
87 | - GL.LINEAR, | |
88 | - GL.LINEAR, | |
85 | + GL.GL_LINEAR, | |
86 | + GL.GL_LINEAR, | |
89 | 87 | true); |
90 | 88 | } |
91 | 89 |
@@ -169,46 +167,46 @@ public class SplashScreen { | ||
169 | 167 | |
170 | 168 | //set the GL states to how we want them. |
171 | 169 | if(isBlended) { |
172 | - gl.enable(GL.BLEND); | |
170 | + GL.glEnable(GL.GL_BLEND); | |
173 | 171 | } |
174 | - gl.disable(GL.DEPTH_TEST); | |
175 | - gl.enable(GL.TEXTURE_2D); | |
176 | - gl.matrixMode(GL.PROJECTION); | |
177 | - gl.pushMatrix(); | |
178 | - gl.loadIdentity(); | |
179 | - gl.ortho(0, gl.getWidth(), 0, gl.getHeight(), -1, 1); | |
180 | - gl.matrixMode(GL.MODELVIEW); | |
181 | - gl.pushMatrix(); | |
182 | - gl.loadIdentity(); | |
183 | - gl.translatef(x,y,0); | |
184 | - gl.color4f(red,green,blue,alpha); | |
172 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
173 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
174 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
175 | + GL.glPushMatrix(); | |
176 | + GL.glLoadIdentity(); | |
177 | + GL.glOrtho(0, Window.getWidth(), 0, Window.getHeight(), -1, 1); | |
178 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
179 | + GL.glPushMatrix(); | |
180 | + GL.glLoadIdentity(); | |
181 | + GL.glTranslatef(x,y,0); | |
182 | + GL.glColor4f(red,green,blue,alpha); | |
185 | 183 | TextureManager.getTextureManager().bind(texId); |
186 | 184 | |
187 | - gl.begin(GL.QUADS); | |
185 | + GL.glBegin(GL.GL_QUADS); | |
188 | 186 | |
189 | - gl.texCoord2i(0,1); | |
190 | - gl.vertex3f(0.0f, height, 0.0f); | |
187 | + GL.glTexCoord2f(0,1); | |
188 | + GL.glVertex3f(0.0f, height, 0.0f); | |
191 | 189 | |
192 | - gl.texCoord2i(0,0); | |
193 | - gl.vertex3f(0.0f, 0.0f, 0.0f); | |
190 | + GL.glTexCoord2f(0,0); | |
191 | + GL.glVertex3f(0.0f, 0.0f, 0.0f); | |
194 | 192 | |
195 | - gl.texCoord2i(1,0); | |
196 | - gl.vertex3f(width, 0.0f, 0.0f); | |
193 | + GL.glTexCoord2f(1,0); | |
194 | + GL.glVertex3f(width, 0.0f, 0.0f); | |
197 | 195 | |
198 | - gl.texCoord2i(1,1); | |
199 | - gl.vertex3f(width, height, 0.0f); | |
196 | + GL.glTexCoord2f(1,1); | |
197 | + GL.glVertex3f(width, height, 0.0f); | |
200 | 198 | |
201 | - gl.end(); | |
199 | + GL.glEnd(); | |
202 | 200 | |
203 | 201 | if(isBlended) { |
204 | - gl.disable(GL.BLEND); | |
202 | + GL.glDisable(GL.GL_BLEND); | |
205 | 203 | } |
206 | - gl.matrixMode(GL.PROJECTION); | |
207 | - gl.popMatrix(); | |
208 | - gl.matrixMode(GL.MODELVIEW); | |
209 | - gl.popMatrix(); | |
210 | - gl.enable(GL.DEPTH_TEST); | |
211 | - gl.disable(GL.TEXTURE_2D); | |
204 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
205 | + GL.glPopMatrix(); | |
206 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
207 | + GL.glPopMatrix(); | |
208 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
209 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
212 | 210 | } |
213 | 211 | |
214 | 212 |
@@ -35,11 +35,10 @@ package jme.geometry.hud.text; | ||
35 | 35 | import java.nio.ByteBuffer; |
36 | 36 | import java.util.logging.Level; |
37 | 37 | |
38 | -import org.lwjgl.Sys; | |
39 | 38 | import org.lwjgl.opengl.GL; |
39 | +import org.lwjgl.opengl.Window; | |
40 | 40 | |
41 | 41 | import jme.exception.MonkeyRuntimeException; |
42 | -import jme.system.DisplaySystem; | |
43 | 42 | |
44 | 43 | import jme.texture.TextureManager; |
45 | 44 | import jme.utility.LoggingSystem; |
@@ -60,21 +59,19 @@ import jme.utility.LoggingSystem; | ||
60 | 59 | * |
61 | 60 | * |
62 | 61 | * @author Mark Powell |
63 | - * @version 1 | |
62 | + * @version $Id: Font2D.java,v 1.3 2003-09-03 16:20:52 mojomonkey Exp $ | |
64 | 63 | */ |
65 | 64 | public class Font2D { |
66 | 65 | public static final int NORMAL = 0; |
67 | 66 | public static final int ITALICS = 1; |
68 | 67 | |
69 | - private GL gl = null; | |
70 | - | |
71 | 68 | //texture name and |
72 | 69 | private int texId; |
73 | 70 | private int base; |
74 | - | |
71 | + | |
75 | 72 | //Color to render the font. |
76 | 73 | private float red, green, blue, alpha; |
77 | - | |
74 | + | |
78 | 75 | private boolean isBlended = true; |
79 | 76 | |
80 | 77 | /** |
@@ -85,27 +82,24 @@ public class Font2D { | ||
85 | 82 | * @see jme.texture.TextureManager |
86 | 83 | * |
87 | 84 | * @param texture the path to the image that defines the fonts. |
88 | - */ | |
85 | + */ | |
89 | 86 | public Font2D(String texture) { |
90 | 87 | red = 1.0f; |
91 | 88 | green = 1.0f; |
92 | 89 | blue = 1.0f; |
93 | 90 | alpha = 1.0f; |
94 | - | |
95 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
96 | - | |
97 | - if(null == gl) { | |
98 | - throw new MonkeyRuntimeException("GL must be created before a call " + | |
99 | - "to Font2D is allowed."); | |
91 | + | |
92 | + if (!Window.isCreated()) { | |
93 | + throw new MonkeyRuntimeException("Window must be created before Font2D."); | |
100 | 94 | } |
101 | - | |
95 | + | |
102 | 96 | setFontTexture(texture); |
103 | 97 | |
104 | 98 | buildDisplayList(); |
105 | - | |
106 | - | |
107 | - LoggingSystem.getLoggingSystem().getLogger().log(Level.INFO, | |
108 | - "Successfully created Font2D using " + texture); | |
99 | + | |
100 | + LoggingSystem.getLoggingSystem().getLogger().log( | |
101 | + Level.INFO, | |
102 | + "Successfully created Font2D using " + texture); | |
109 | 103 | } |
110 | 104 | |
111 | 105 | /** |
@@ -115,11 +109,12 @@ public class Font2D { | ||
115 | 109 | * @param texture the new texture to use. |
116 | 110 | */ |
117 | 111 | public void setFontTexture(String texture) { |
118 | - texId = TextureManager.getTextureManager().loadTexture( | |
119 | - texture, | |
120 | - GL.LINEAR, | |
121 | - GL.LINEAR, | |
122 | - false); | |
112 | + texId = | |
113 | + TextureManager.getTextureManager().loadTexture( | |
114 | + texture, | |
115 | + GL.GL_LINEAR, | |
116 | + GL.GL_LINEAR, | |
117 | + false); | |
123 | 118 | } |
124 | 119 | |
125 | 120 | /** |
@@ -137,14 +132,14 @@ public class Font2D { | ||
137 | 132 | blue = b; |
138 | 133 | alpha = a; |
139 | 134 | } |
140 | - | |
135 | + | |
141 | 136 | /** |
142 | 137 | * <code>deleteFont</code> deletes the current display list of font objects. |
143 | 138 | * The font will be useless until a call to <code>buildDisplayLists</code> |
144 | 139 | * is made. |
145 | 140 | */ |
146 | 141 | public void deleteFont() { |
147 | - gl.deleteLists(base, 256); | |
142 | + GL.glDeleteLists(base, 256); | |
148 | 143 | } |
149 | 144 | |
150 | 145 | /** |
@@ -165,43 +160,42 @@ public class Font2D { | ||
165 | 160 | } |
166 | 161 | |
167 | 162 | TextureManager.getTextureManager().bind(texId); |
168 | - | |
163 | + | |
169 | 164 | //set the GL states to how we want them. |
170 | - if(isBlended) { | |
171 | - gl.enable(GL.BLEND); | |
165 | + if (isBlended) { | |
166 | + GL.glEnable(GL.GL_BLEND); | |
172 | 167 | } |
173 | - gl.disable(GL.DEPTH_TEST); | |
174 | - gl.enable(GL.TEXTURE_2D); | |
175 | - gl.matrixMode(GL.PROJECTION); | |
176 | - gl.pushMatrix(); | |
177 | - gl.loadIdentity(); | |
178 | - gl.ortho(0, gl.getWidth(), 0, gl.getHeight(), -1, 1); | |
179 | - gl.matrixMode(GL.MODELVIEW); | |
180 | - gl.pushMatrix(); | |
181 | - gl.loadIdentity(); | |
182 | - gl.translated(x, y, 0); | |
183 | - gl.listBase(base - 32 + (128 * set)); | |
168 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
169 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
170 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
171 | + GL.glPushMatrix(); | |
172 | + GL.glLoadIdentity(); | |
173 | + GL.glOrtho(0, Window.getWidth(), 0, Window.getHeight(), -1, 1); | |
174 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
175 | + GL.glPushMatrix(); | |
176 | + GL.glLoadIdentity(); | |
177 | + GL.glTranslatef(x, y, 0); | |
178 | + GL.glListBase(base - 32 + (128 * set)); | |
184 | 179 | |
185 | 180 | //Put the string into a "pointer" |
186 | - ByteBuffer scratch = ByteBuffer.allocateDirect(text.getBytes().length); | |
181 | + ByteBuffer scratch = | |
182 | + ByteBuffer.allocateDirect(text.getBytes().length); | |
187 | 183 | scratch.put(text.getBytes()); |
188 | - gl.color4f(red,green,blue,alpha); | |
184 | + scratch.flip(); | |
185 | + GL.glColor4f(red, green, blue, alpha); | |
189 | 186 | //call the list for each letter in the string. |
190 | - gl.callLists( | |
191 | - text.length(), | |
192 | - GL.BYTE, | |
193 | - Sys.getDirectBufferAddress(scratch)); | |
194 | - | |
187 | + GL.glCallLists(scratch); | |
188 | + | |
195 | 189 | //reset the GL states. |
196 | - if(isBlended) { | |
197 | - gl.disable(GL.BLEND); | |
190 | + if (isBlended) { | |
191 | + GL.glDisable(GL.GL_BLEND); | |
198 | 192 | } |
199 | - gl.matrixMode(GL.PROJECTION); | |
200 | - gl.popMatrix(); | |
201 | - gl.matrixMode(GL.MODELVIEW); | |
202 | - gl.popMatrix(); | |
203 | - gl.enable(GL.DEPTH_TEST); | |
204 | - gl.disable(GL.TEXTURE_2D); | |
193 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
194 | + GL.glPopMatrix(); | |
195 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
196 | + GL.glPopMatrix(); | |
197 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
198 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
205 | 199 | } |
206 | 200 | |
207 | 201 | /** |
@@ -213,29 +207,29 @@ public class Font2D { | ||
213 | 207 | float cx; |
214 | 208 | float cy; |
215 | 209 | |
216 | - base = gl.genLists(256); | |
210 | + base = GL.glGenLists(256); | |
217 | 211 | TextureManager.getTextureManager().bind(texId); |
218 | 212 | |
219 | 213 | for (int loop = 0; loop < 256; loop++) { |
220 | 214 | cx = (loop % 16) / 16.0f; |
221 | 215 | cy = (loop / 16) / 16.0f; |
222 | 216 | |
223 | - gl.newList(base + loop, GL.COMPILE); | |
224 | - gl.begin(GL.QUADS); | |
225 | - gl.texCoord2f(cx, 1 - cy - 0.0625f); | |
226 | - gl.vertex2i(0, 0); | |
227 | - gl.texCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); | |
228 | - gl.vertex2i(16, 0); | |
229 | - gl.texCoord2f(cx + 0.0625f, 1 - cy); | |
230 | - gl.vertex2i(16, 16); | |
231 | - gl.texCoord2f(cx, 1 - cy); | |
232 | - gl.vertex2i(0, 16); | |
233 | - gl.end(); | |
234 | - gl.translated(10, 0, 0); | |
235 | - gl.endList(); | |
217 | + GL.glNewList(base + loop, GL.GL_COMPILE); | |
218 | + GL.glBegin(GL.GL_QUADS); | |
219 | + GL.glTexCoord2f(cx, 1 - cy - 0.0625f); | |
220 | + GL.glVertex2i(0, 0); | |
221 | + GL.glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f); | |
222 | + GL.glVertex2i(16, 0); | |
223 | + GL.glTexCoord2f(cx + 0.0625f, 1 - cy); | |
224 | + GL.glVertex2i(16, 16); | |
225 | + GL.glTexCoord2f(cx, 1 - cy); | |
226 | + GL.glVertex2i(0, 16); | |
227 | + GL.glEnd(); | |
228 | + GL.glTranslatef(10, 0, 0); | |
229 | + GL.glEndList(); | |
236 | 230 | } |
237 | 231 | } |
238 | - | |
232 | + | |
239 | 233 | /** |
240 | 234 | * <code>toString</code> returns the string representation of this |
241 | 235 | * font object in the Format:<br><br> |
@@ -249,9 +243,9 @@ public class Font2D { | ||
249 | 243 | public String toString() { |
250 | 244 | String string = super.toString(); |
251 | 245 | string += "\nColor: " + red + " " + green + " " + blue + " " + alpha; |
252 | - string += "\nBlended: " + isBlended; | |
246 | + string += "\nBlended: " + isBlended; | |
253 | 247 | string += "\nTexture: " + texId; |
254 | - | |
248 | + | |
255 | 249 | return string; |
256 | 250 | } |
257 | 251 | } |
@@ -59,8 +59,8 @@ import jme.geometry.bounding.BoundingBox; | ||
59 | 59 | import jme.geometry.bounding.BoundingSphere; |
60 | 60 | import jme.geometry.model.Triangle; |
61 | 61 | |
62 | -import org.lwjgl.Sys; | |
63 | 62 | import org.lwjgl.opengl.GL; |
63 | +import org.lwjgl.opengl.Window; | |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * <code>Md3Model</code> handles loading and rendering a Quake 3 MD3 format |
@@ -99,6 +99,7 @@ import org.lwjgl.opengl.GL; | ||
99 | 99 | * |
100 | 100 | * |
101 | 101 | * @author Mark Powell |
102 | + * @version $Id: Md3Model.java,v 1.7 2003-09-03 16:20:52 mojomonkey Exp $ | |
102 | 103 | */ |
103 | 104 | public class Md3Model implements Geometry { |
104 | 105 | /** |
@@ -153,9 +154,6 @@ public class Md3Model implements Geometry { | ||
153 | 154 | private BoundingSphere boundingSphere; |
154 | 155 | private BoundingBox boundingBox; |
155 | 156 | |
156 | - //OpenGL context. | |
157 | - private GL gl; | |
158 | - | |
159 | 157 | //Model constants |
160 | 158 | private static final int START_TORSO_ANIMATION = 6; |
161 | 159 | private static final int START_LEGS_ANIMATION = 13; |
@@ -174,9 +172,8 @@ public class Md3Model implements Geometry { | ||
174 | 172 | if (null == path || null == model) { |
175 | 173 | throw new MonkeyRuntimeException("Path and model cannot be null."); |
176 | 174 | } |
177 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
178 | - if (null == gl) { | |
179 | - throw new MonkeyGLException("OpenGL context must be created first."); | |
175 | + if (!Window.isCreated()) { | |
176 | + throw new MonkeyGLException("Window must be created first."); | |
180 | 177 | } |
181 | 178 | |
182 | 179 | buf = |
@@ -270,16 +267,16 @@ public class Md3Model implements Geometry { | ||
270 | 267 | * front. |
271 | 268 | */ |
272 | 269 | public void render() { |
273 | - DisplaySystem.getDisplaySystem().cullMode(GL.FRONT, true); | |
270 | + DisplaySystem.getDisplaySystem().cullMode(GL.GL_FRONT, true); | |
274 | 271 | |
275 | 272 | //MD3 has Z up, so remedy this. |
276 | - gl.rotatef(-90,0,1,0); | |
277 | - gl.rotatef(-90, 1, 0, 0); | |
273 | + GL.glRotatef(-90,0,1,0); | |
274 | + GL.glRotatef(-90, 1, 0, 0); | |
278 | 275 | |
279 | 276 | //scale by a desired factor |
280 | - gl.scalef(scale.x, scale.y, scale.z); | |
277 | + GL.glScalef(scale.x, scale.y, scale.z); | |
281 | 278 | //set the desired color |
282 | - gl.color4f(r, g, b, a); | |
279 | + GL.glColor4f(r, g, b, a); | |
283 | 280 | |
284 | 281 | //Update the leg and torso animations |
285 | 282 | updateModel(lower); |
@@ -287,8 +284,8 @@ public class Md3Model implements Geometry { | ||
287 | 284 | |
288 | 285 | //start rendering with the legs first. |
289 | 286 | drawLink(lower); |
290 | - //set culling back to GL.BACK | |
291 | - DisplaySystem.getDisplaySystem().cullMode(GL.BACK, true); | |
287 | + //set culling back to GL.GL_BACK | |
288 | + DisplaySystem.getDisplaySystem().cullMode(GL.GL_BACK, true); | |
292 | 289 | } |
293 | 290 | |
294 | 291 | /** |
@@ -1047,8 +1044,8 @@ public class Md3Model implements Geometry { | ||
1047 | 1044 | ((MaterialInfo)model.materials.get(i)).texureId = |
1048 | 1045 | TextureManager.getTextureManager().loadTexture( |
1049 | 1046 | fullPath, |
1050 | - GL.LINEAR_MIPMAP_LINEAR, | |
1051 | - GL.LINEAR, | |
1047 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
1048 | + GL.GL_LINEAR, | |
1052 | 1049 | true); |
1053 | 1050 | } |
1054 | 1051 | } |
@@ -1246,16 +1243,16 @@ public class Md3Model implements Geometry { | ||
1246 | 1243 | finalMatrix[14] = position.z; |
1247 | 1244 | |
1248 | 1245 | //render the model |
1249 | - gl.pushMatrix(); | |
1246 | + GL.glPushMatrix(); | |
1250 | 1247 | |
1251 | 1248 | buf.clear(); |
1252 | 1249 | buf.put(finalMatrix); |
1253 | - int ptr = Sys.getDirectBufferAddress(buf); | |
1254 | - gl.multMatrixf(ptr); | |
1250 | + buf.flip(); | |
1251 | + GL.glMultMatrixf(buf); | |
1255 | 1252 | //render the children |
1256 | 1253 | drawLink(model.links[i]); |
1257 | 1254 | |
1258 | - gl.popMatrix(); | |
1255 | + GL.glPopMatrix(); | |
1259 | 1256 | } |
1260 | 1257 | } |
1261 | 1258 |
@@ -1308,18 +1305,18 @@ public class Md3Model implements Geometry { | ||
1308 | 1305 | |
1309 | 1306 | //if there is a texture assigned to the model, use it. |
1310 | 1307 | if (object3d.hasTexture) { |
1311 | - gl.enable(GL.TEXTURE_2D); | |
1308 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
1312 | 1309 | |
1313 | 1310 | int textureID = ((MaterialInfo)model.materials.get( |
1314 | 1311 | object3d.materialID)).texureId; |
1315 | 1312 | |
1316 | 1313 | TextureManager.getTextureManager().bind(textureID); |
1317 | 1314 | } else { |
1318 | - gl.disable(GL.TEXTURE_2D); | |
1315 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
1319 | 1316 | } |
1320 | 1317 | |
1321 | 1318 | //render the model as triangles |
1322 | - gl.begin(GL.TRIANGLES); | |
1319 | + GL.glBegin(GL.GL_TRIANGLES); | |
1323 | 1320 | |
1324 | 1321 | for (int j = 0; j < object3d.numOfFaces; j++) { |
1325 | 1322 | for (int whichVertex = 0; whichVertex < 3; whichVertex++) { |
@@ -1327,7 +1324,7 @@ public class Md3Model implements Geometry { | ||
1327 | 1324 | |
1328 | 1325 | if (object3d.texVerts != null) { |
1329 | 1326 | // Assign the texture coordinate to this vertex |
1330 | - gl.texCoord2f( | |
1327 | + GL.glTexCoord2f( | |
1331 | 1328 | object3d.texVerts[index].x, |
1332 | 1329 | object3d.texVerts[index].y); |
1333 | 1330 | } |
@@ -1336,14 +1333,14 @@ public class Md3Model implements Geometry { | ||
1336 | 1333 | Vector point2 = object3d.verts[nextIndex + index]; |
1337 | 1334 | |
1338 | 1335 | //interpolate |
1339 | - gl.vertex3f( | |
1336 | + GL.glVertex3f( | |
1340 | 1337 | point1.x + model.t * (point2.x - point1.x), |
1341 | 1338 | point1.y + model.t * (point2.y - point1.y), |
1342 | 1339 | point1.z + model.t * (point2.z - point1.z)); |
1343 | 1340 | |
1344 | 1341 | } |
1345 | 1342 | } |
1346 | - gl.end(); | |
1343 | + GL.glEnd(); | |
1347 | 1344 | } |
1348 | 1345 | } |
1349 | 1346 |
@@ -37,11 +37,11 @@ import java.io.FileNotFoundException; | ||
37 | 37 | import java.io.IOException; |
38 | 38 | import java.nio.ByteBuffer; |
39 | 39 | import java.nio.ByteOrder; |
40 | +import java.nio.FloatBuffer; | |
40 | 41 | import java.util.logging.Level; |
41 | 42 | |
42 | -import org.lwjgl.Sys; | |
43 | 43 | import org.lwjgl.opengl.GL; |
44 | -import org.lwjgl.vector.Vector3f; | |
44 | +import org.lwjgl.opengl.Window; | |
45 | 45 | |
46 | 46 | import jme.exception.MonkeyGLException; |
47 | 47 | import jme.geometry.*; |
@@ -55,7 +55,6 @@ import jme.geometry.model.Triangle; | ||
55 | 55 | import jme.geometry.model.Vertex; |
56 | 56 | import jme.math.Matrix; |
57 | 57 | import jme.math.Vector; |
58 | -import jme.system.DisplaySystem; | |
59 | 58 | import jme.texture.TextureManager; |
60 | 59 | import jme.utility.Conversion; |
61 | 60 | import jme.utility.LoggingSystem; |
@@ -67,6 +66,7 @@ import jme.utility.LoggingSystem; | ||
67 | 66 | * to version 3. Animation is not currently supported, but planned. |
68 | 67 | * |
69 | 68 | * @author Mark Powell |
69 | + * @version $Id: MilkshapeModel.java,v 1.5 2003-09-03 16:20:52 mojomonkey Exp $ | |
70 | 70 | */ |
71 | 71 | public class MilkshapeModel implements Geometry { |
72 | 72 | //defines the bounding volumes of the model. |
@@ -77,17 +77,14 @@ public class MilkshapeModel implements Geometry { | ||
77 | 77 | private float animationFPS; |
78 | 78 | private float currentTime; |
79 | 79 | private int totalFrames; |
80 | - | |
80 | + | |
81 | 81 | //model data information |
82 | 82 | private String modelFile; |
83 | 83 | private ByteBuffer buffer; |
84 | 84 | private String id; |
85 | 85 | private String path; |
86 | 86 | private int version; |
87 | - /** | |
88 | - * the OpenGL context object. | |
89 | - */ | |
90 | - private GL gl; | |
87 | + | |
91 | 88 | /** |
92 | 89 | * the color of the model. This color will be applied as a whole to the |
93 | 90 | * model and may be trumped by the material level. |
@@ -96,7 +93,7 @@ public class MilkshapeModel implements Geometry { | ||
96 | 93 | /** |
97 | 94 | * the scale of the model, where 1.0 is the standard size of the model. |
98 | 95 | */ |
99 | - private Vector3f scale; | |
96 | + private Vector scale; | |
100 | 97 | /** |
101 | 98 | * the number of meshes that makes up the model. |
102 | 99 | */ |
@@ -148,8 +145,7 @@ public class MilkshapeModel implements Geometry { | ||
148 | 145 | * @throws MonkeyGLException if the OpenGL context has not been created. |
149 | 146 | */ |
150 | 147 | public MilkshapeModel(String modelFile) { |
151 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
152 | - if (null == gl) { | |
148 | + if (!Window.isCreated()) { | |
153 | 149 | throw new MonkeyGLException( |
154 | 150 | "OpenGL context must be " + "created before MilkshapeModel."); |
155 | 151 | } |
@@ -160,7 +156,7 @@ public class MilkshapeModel implements Geometry { | ||
160 | 156 | blue = 1.0f; |
161 | 157 | green = 1.0f; |
162 | 158 | alpha = 1.0f; |
163 | - scale = new Vector3f(1.0f, 1.0f, 1.0f); | |
159 | + scale = new Vector(1.0f, 1.0f, 1.0f); | |
164 | 160 | |
165 | 161 | initialize(); |
166 | 162 | setBoundingVolumes(); |
@@ -178,7 +174,7 @@ public class MilkshapeModel implements Geometry { | ||
178 | 174 | file.getAbsolutePath().substring( |
179 | 175 | 0, |
180 | 176 | file.getAbsolutePath().length() - file.getName().length()); |
181 | - int length = (int)file.length(); | |
177 | + int length = (int) file.length(); | |
182 | 178 | data = new byte[length]; |
183 | 179 | FileInputStream fis; |
184 | 180 | try { |
@@ -428,58 +424,56 @@ public class MilkshapeModel implements Geometry { | ||
428 | 424 | Triangle currentTri; |
429 | 425 | int triangleIndex; |
430 | 426 | int index; |
431 | - ByteBuffer temp = ByteBuffer.allocateDirect(16); | |
432 | - temp.order(ByteOrder.nativeOrder()); | |
433 | - gl.color4f(red, green, blue, alpha); | |
434 | - gl.pushMatrix(); | |
435 | - gl.scalef(scale.x, scale.y, scale.z); | |
427 | + FloatBuffer temp = | |
428 | + ByteBuffer | |
429 | + .allocateDirect(16) | |
430 | + .order(ByteOrder.nativeOrder()) | |
431 | + .asFloatBuffer(); | |
432 | + GL.glColor4f(red, green, blue, alpha); | |
433 | + GL.glPushMatrix(); | |
434 | + GL.glScalef(scale.x, scale.y, scale.z); | |
436 | 435 | |
437 | 436 | //go through each mesh and render them. |
438 | 437 | for (int i = 0; i < numMeshes; i++) { |
439 | 438 | int materialIndex = meshes[i].materialIndex; |
440 | 439 | //if the material is set, use it to set the texture and lighting. |
441 | 440 | if (materialIndex >= 0) { |
442 | - | |
443 | - gl.materialfv( | |
444 | - GL.FRONT, | |
445 | - GL.AMBIENT, | |
446 | - Sys.getDirectBufferAddress( | |
447 | - temp.asFloatBuffer().put( | |
448 | - materials[materialIndex].ambient))); | |
449 | - gl.materialfv( | |
450 | - GL.FRONT, | |
451 | - GL.DIFFUSE, | |
452 | - Sys.getDirectBufferAddress( | |
453 | - temp.asFloatBuffer().put( | |
454 | - materials[materialIndex].diffuse))); | |
455 | - gl.materialfv( | |
456 | - GL.FRONT, | |
457 | - GL.SPECULAR, | |
458 | - Sys.getDirectBufferAddress( | |
459 | - temp.asFloatBuffer().put( | |
460 | - materials[materialIndex].specular))); | |
461 | - gl.materialfv( | |
462 | - GL.FRONT, | |
463 | - GL.EMISSION, | |
464 | - Sys.getDirectBufferAddress( | |
465 | - temp.asFloatBuffer().put( | |
466 | - materials[materialIndex].emissive))); | |
467 | - gl.materialf( | |
468 | - GL.FRONT, | |
469 | - GL.SHININESS, | |
441 | + temp.clear(); | |
442 | + temp.put(materials[materialIndex].ambient); | |
443 | + temp.flip(); | |
444 | + GL.glMaterial(GL.GL_FRONT, GL.GL_AMBIENT, temp); | |
445 | + | |
446 | + temp.clear(); | |
447 | + temp.put(materials[materialIndex].diffuse); | |
448 | + temp.flip(); | |
449 | + GL.glMaterial(GL.GL_FRONT, GL.GL_DIFFUSE, temp); | |
450 | + | |
451 | + temp.clear(); | |
452 | + temp.put(materials[materialIndex].specular); | |
453 | + temp.flip(); | |
454 | + GL.glMaterial(GL.GL_FRONT, GL.GL_SPECULAR, temp); | |
455 | + | |
456 | + temp.clear(); | |
457 | + temp.put(materials[materialIndex].emissive); | |
458 | + temp.flip(); | |
459 | + GL.glMaterial(GL.GL_FRONT, GL.GL_EMISSION, temp); | |
460 | + | |
461 | + GL.glMaterialf( | |
462 | + GL.GL_FRONT, | |
463 | + GL.GL_SHININESS, | |
470 | 464 | materials[materialIndex].shininess); |
471 | 465 | |
472 | 466 | if (materials[materialIndex].texture > 0) { |
473 | 467 | TextureManager.getTextureManager().bind( |
474 | 468 | materials[materialIndex].texture); |
475 | - gl.enable(GL.TEXTURE_2D); | |
469 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
476 | 470 | } else |
477 | - gl.disable(GL.TEXTURE_2D); | |
471 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
478 | 472 | } else { |
479 | - gl.disable(GL.TEXTURE_2D); | |
473 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
480 | 474 | } |
481 | 475 | |
482 | - gl.begin(GL.TRIANGLES); | |
476 | + GL.glBegin(GL.GL_TRIANGLES); | |
483 | 477 | int m = meshes[i].numTriangles; |
484 | 478 | |
485 | 479 | //render all triangles defined for the current mesh. |
@@ -490,21 +484,21 @@ public class MilkshapeModel implements Geometry { | ||
490 | 484 | for (int k = 0; k < 3; k++) { |
491 | 485 | index = currentTri.vertexIndices[k]; |
492 | 486 | |
493 | - gl.normal3f( | |
487 | + GL.glNormal3f( | |
494 | 488 | currentTri.vertexNormals[k][0], |
495 | 489 | currentTri.vertexNormals[k][1], |
496 | 490 | currentTri.vertexNormals[k][2]); |
497 | - gl.texCoord2f(currentTri.s[k], currentTri.t[k]); | |
498 | - gl.vertex3f( | |
491 | + GL.glTexCoord2f(currentTri.s[k], currentTri.t[k]); | |
492 | + GL.glVertex3f( | |
499 | 493 | vertices[index].point[0], |
500 | 494 | vertices[index].point[1], |
501 | 495 | vertices[index].point[2]); |
502 | 496 | } |
503 | 497 | } |
504 | - gl.end(); | |
498 | + GL.glEnd(); | |
505 | 499 | } |
506 | - gl.popMatrix(); | |
507 | - gl.disable(GL.TEXTURE_2D); | |
500 | + GL.glPopMatrix(); | |
501 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
508 | 502 | } |
509 | 503 | |
510 | 504 | /** |
@@ -538,7 +532,7 @@ public class MilkshapeModel implements Geometry { | ||
538 | 532 | * normal size of the model. |
539 | 533 | * @param scale the multiplier of the model's size. |
540 | 534 | */ |
541 | - public void setScale(Vector3f scale) { | |
535 | + public void setScale(Vector scale) { | |
542 | 536 | this.scale = scale; |
543 | 537 | } |
544 | 538 |
@@ -578,11 +572,13 @@ public class MilkshapeModel implements Geometry { | ||
578 | 572 | } |
579 | 573 | } |
580 | 574 | distanceSqr *= scale.x; |
581 | - float distance = (float)Math.sqrt(distanceSqr); | |
575 | + float distance = (float) Math.sqrt(distanceSqr); | |
582 | 576 | boundingSphere = new BoundingSphere(distance, null); |
583 | - boundingBox = new BoundingBox(new Vector(), | |
584 | - new Vector(-distance, -distance, -distance), | |
585 | - new Vector(distance, distance, distance)); | |
577 | + boundingBox = | |
578 | + new BoundingBox( | |
579 | + new Vector(), | |
580 | + new Vector(-distance, -distance, -distance), | |
581 | + new Vector(distance, distance, distance)); | |
586 | 582 | } |
587 | 583 | |
588 | 584 | /** |
@@ -653,8 +649,8 @@ public class MilkshapeModel implements Geometry { | ||
653 | 649 | materials[i].texture = |
654 | 650 | TextureManager.getTextureManager().loadTexture( |
655 | 651 | fullFilename, |
656 | - GL.LINEAR_MIPMAP_LINEAR, | |
657 | - GL.LINEAR, | |
652 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
653 | + GL.GL_LINEAR, | |
658 | 654 | true); |
659 | 655 | } else |
660 | 656 | materials[i].texture = 0; |
@@ -37,7 +37,6 @@ import jme.exception.MonkeyRuntimeException; | ||
37 | 37 | import jme.geometry.bounding.BoundingBox; |
38 | 38 | import jme.geometry.bounding.BoundingSphere; |
39 | 39 | import jme.math.Vector; |
40 | -import jme.system.DisplaySystem; | |
41 | 40 | import jme.texture.TextureManager; |
42 | 41 | import jme.utility.LoggingSystem; |
43 | 42 |
@@ -60,7 +59,7 @@ import org.lwjgl.opengl.GL; | ||
60 | 59 | * 7 - Back face, bottom right<br> |
61 | 60 | * |
62 | 61 | * @author Mark Powell |
63 | - * @version $Id: Box.java,v 1.3 2003-08-08 18:59:01 mojomonkey Exp $ | |
62 | + * @version $Id: Box.java,v 1.4 2003-09-03 16:20:51 mojomonkey Exp $ | |
64 | 63 | */ |
65 | 64 | public class Box extends Primitive { |
66 | 65 | private GL gl; |
@@ -71,7 +70,6 @@ public class Box extends Primitive { | ||
71 | 70 | * of the box defined as (0,0,0). |
72 | 71 | */ |
73 | 72 | public Box() { |
74 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
75 | 73 | corners = new Vector[8]; |
76 | 74 | for(int i = 0; i < 8; i++) { |
77 | 75 | corners[i] = new Vector(); |
@@ -92,7 +90,6 @@ public class Box extends Primitive { | ||
92 | 90 | throw new MonkeyRuntimeException("Corners cannot be null."); |
93 | 91 | } |
94 | 92 | this.corners = corners; |
95 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
96 | 93 | initialize(); |
97 | 94 | LoggingSystem.getLoggingSystem().getLogger().log(Level.INFO, |
98 | 95 | "Box created."); |
@@ -105,7 +102,6 @@ public class Box extends Primitive { | ||
105 | 102 | * @param size the length of a side of the cube. |
106 | 103 | */ |
107 | 104 | public Box(float size) { |
108 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
109 | 105 | corners = new Vector[8]; |
110 | 106 | |
111 | 107 | corners[0] = new Vector(-size/2, size/2, -size/2); |
@@ -129,76 +125,76 @@ public class Box extends Primitive { | ||
129 | 125 | public void render() { |
130 | 126 | if(getTextureId() > 0) { |
131 | 127 | TextureManager.getTextureManager().bind(getTextureId()); |
132 | - gl.enable(GL.TEXTURE_2D); | |
128 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
133 | 129 | } |
134 | 130 | |
135 | - gl.begin(GL.QUADS); | |
131 | + GL.glBegin(GL.GL_QUADS); | |
136 | 132 | |
137 | 133 | //front |
138 | - gl.color4f(red, blue, green, alpha); | |
139 | - gl.texCoord2i(1,1); | |
140 | - gl.vertex3f(corners[0].x, corners[0].y, corners[0].z); | |
141 | - gl.texCoord2i(0,1); | |
142 | - gl.vertex3f(corners[1].x, corners[1].y, corners[1].z); | |
143 | - gl.texCoord2i(0,0); | |
144 | - gl.vertex3f(corners[3].x, corners[3].y, corners[3].z); | |
145 | - gl.texCoord2i(1,0); | |
146 | - gl.vertex3f(corners[2].x, corners[2].y, corners[2].z); | |
134 | + GL.glColor4f(red, blue, green, alpha); | |
135 | + GL.glTexCoord2f(1,1); | |
136 | + GL.glVertex3f(corners[0].x, corners[0].y, corners[0].z); | |
137 | + GL.glTexCoord2f(0,1); | |
138 | + GL.glVertex3f(corners[1].x, corners[1].y, corners[1].z); | |
139 | + GL.glTexCoord2f(0,0); | |
140 | + GL.glVertex3f(corners[3].x, corners[3].y, corners[3].z); | |
141 | + GL.glTexCoord2f(1,0); | |
142 | + GL.glVertex3f(corners[2].x, corners[2].y, corners[2].z); | |
147 | 143 | |
148 | 144 | //back |
149 | - gl.texCoord2i(1,1); | |
150 | - gl.vertex3f(corners[5].x, corners[5].y, corners[5].z); | |
151 | - gl.texCoord2i(0,1); | |
152 | - gl.vertex3f(corners[4].x, corners[4].y, corners[4].z); | |
153 | - gl.texCoord2i(0,0); | |
154 | - gl.vertex3f(corners[6].x, corners[6].y, corners[6].z); | |
155 | - gl.texCoord2i(1,0); | |
156 | - gl.vertex3f(corners[7].x, corners[7].y, corners[7].z); | |
145 | + GL.glTexCoord2f(1,1); | |
146 | + GL.glVertex3f(corners[5].x, corners[5].y, corners[5].z); | |
147 | + GL.glTexCoord2f(0,1); | |
148 | + GL.glVertex3f(corners[4].x, corners[4].y, corners[4].z); | |
149 | + GL.glTexCoord2f(0,0); | |
150 | + GL.glVertex3f(corners[6].x, corners[6].y, corners[6].z); | |
151 | + GL.glTexCoord2f(1,0); | |
152 | + GL.glVertex3f(corners[7].x, corners[7].y, corners[7].z); | |
157 | 153 | |
158 | 154 | //Top |
159 | - gl.texCoord2i(1,1); | |
160 | - gl.vertex3f(corners[4].x, corners[4].y, corners[4].z); | |
161 | - gl.texCoord2i(0,1); | |
162 | - gl.vertex3f(corners[5].x, corners[5].y, corners[5].z); | |
163 | - gl.texCoord2i(0,0); | |
164 | - gl.vertex3f(corners[1].x, corners[1].y, corners[1].z); | |
165 | - gl.texCoord2i(1,0); | |
166 | - gl.vertex3f(corners[0].x, corners[0].y, corners[0].z); | |
155 | + GL.glTexCoord2f(1,1); | |
156 | + GL.glVertex3f(corners[4].x, corners[4].y, corners[4].z); | |
157 | + GL.glTexCoord2f(0,1); | |
158 | + GL.glVertex3f(corners[5].x, corners[5].y, corners[5].z); | |
159 | + GL.glTexCoord2f(0,0); | |
160 | + GL.glVertex3f(corners[1].x, corners[1].y, corners[1].z); | |
161 | + GL.glTexCoord2f(1,0); | |
162 | + GL.glVertex3f(corners[0].x, corners[0].y, corners[0].z); | |
167 | 163 | |
168 | 164 | //Bottom |
169 | - gl.texCoord2i(1,1); | |
170 | - gl.vertex3f(corners[6].x, corners[6].y, corners[6].z); | |
171 | - gl.texCoord2i(0,1); | |
172 | - gl.vertex3f(corners[2].x, corners[2].y, corners[2].z); | |
173 | - gl.texCoord2i(0,0); | |
174 | - gl.vertex3f(corners[3].x, corners[3].y, corners[3].z); | |
175 | - gl.texCoord2i(1,0); | |
176 | - gl.vertex3f(corners[7].x, corners[7].y, corners[7].z); | |
165 | + GL.glTexCoord2f(1,1); | |
166 | + GL.glVertex3f(corners[6].x, corners[6].y, corners[6].z); | |
167 | + GL.glTexCoord2f(0,1); | |
168 | + GL.glVertex3f(corners[2].x, corners[2].y, corners[2].z); | |
169 | + GL.glTexCoord2f(0,0); | |
170 | + GL.glVertex3f(corners[3].x, corners[3].y, corners[3].z); | |
171 | + GL.glTexCoord2f(1,0); | |
172 | + GL.glVertex3f(corners[7].x, corners[7].y, corners[7].z); | |
177 | 173 | |
178 | 174 | //left |
179 | - gl.texCoord2i(1,1); | |
180 | - gl.vertex3f(corners[4].x, corners[4].y, corners[4].z); | |
181 | - gl.texCoord2i(0,1); | |
182 | - gl.vertex3f(corners[0].x, corners[0].y, corners[0].z); | |
183 | - gl.texCoord2i(0,0); | |
184 | - gl.vertex3f(corners[2].x, corners[2].y, corners[2].z); | |
185 | - gl.texCoord2i(1,0); | |
186 | - gl.vertex3f(corners[6].x, corners[6].y, corners[6].z); | |
175 | + GL.glTexCoord2f(1,1); | |
176 | + GL.glVertex3f(corners[4].x, corners[4].y, corners[4].z); | |
177 | + GL.glTexCoord2f(0,1); | |
178 | + GL.glVertex3f(corners[0].x, corners[0].y, corners[0].z); | |
179 | + GL.glTexCoord2f(0,0); | |
180 | + GL.glVertex3f(corners[2].x, corners[2].y, corners[2].z); | |
181 | + GL.glTexCoord2f(1,0); | |
182 | + GL.glVertex3f(corners[6].x, corners[6].y, corners[6].z); | |
187 | 183 | |
188 | 184 | //right |
189 | - gl.texCoord2i(1,1); | |
190 | - gl.vertex3f(corners[1].x, corners[1].y, corners[1].z); | |
191 | - gl.texCoord2i(0,1); | |
192 | - gl.vertex3f(corners[5].x, corners[5].y, corners[5].z); | |
193 | - gl.texCoord2i(0,0); | |
194 | - gl.vertex3f(corners[7].x, corners[7].y, corners[7].z); | |
195 | - gl.texCoord2i(1,0); | |
196 | - gl.vertex3f(corners[3].x, corners[3].y, corners[3].z); | |
185 | + GL.glTexCoord2f(1,1); | |
186 | + GL.glVertex3f(corners[1].x, corners[1].y, corners[1].z); | |
187 | + GL.glTexCoord2f(0,1); | |
188 | + GL.glVertex3f(corners[5].x, corners[5].y, corners[5].z); | |
189 | + GL.glTexCoord2f(0,0); | |
190 | + GL.glVertex3f(corners[7].x, corners[7].y, corners[7].z); | |
191 | + GL.glTexCoord2f(1,0); | |
192 | + GL.glVertex3f(corners[3].x, corners[3].y, corners[3].z); | |
197 | 193 | |
198 | - gl.end(); | |
194 | + GL.glEnd(); | |
199 | 195 | |
200 | 196 | if(getTextureId() > 0) { |
201 | - gl.disable(GL.TEXTURE_2D); | |
197 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
202 | 198 | } |
203 | 199 | |
204 | 200 | } |
@@ -38,7 +38,6 @@ import jme.exception.MonkeyRuntimeException; | ||
38 | 38 | import jme.geometry.bounding.BoundingBox; |
39 | 39 | import jme.geometry.bounding.BoundingSphere; |
40 | 40 | import jme.math.Vector; |
41 | -import jme.system.DisplaySystem; | |
42 | 41 | import jme.utility.LoggingSystem; |
43 | 42 | |
44 | 43 | import org.lwjgl.opengl.GLU; |
@@ -53,7 +52,7 @@ import org.lwjgl.opengl.GLU; | ||
53 | 52 | * image, but framerate will suffer. |
54 | 53 | * |
55 | 54 | * @author Mark Powell |
56 | - * @version $Id: Cylinder.java,v 1.2 2003-08-07 21:24:37 mojomonkey Exp $ | |
55 | + * @version $Id: Cylinder.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
57 | 56 | */ |
58 | 57 | public class Cylinder extends Quadric { |
59 | 58 |
@@ -100,7 +99,6 @@ public class Cylinder extends Quadric { | ||
100 | 99 | boundingBox = new BoundingBox(new Vector(), new Vector(-(float)height,-(float)height,-(float)height), |
101 | 100 | new Vector((float)height,(float)height,(float)height)); |
102 | 101 | |
103 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
104 | 102 | |
105 | 103 | super.initialize(); |
106 | 104 |
@@ -113,8 +111,8 @@ public class Cylinder extends Quadric { | ||
113 | 111 | */ |
114 | 112 | public void render() { |
115 | 113 | super.preRender(); |
116 | - glu.cylinder(quadricPointer, baseRadius, topRadius, height, slices, | |
117 | - stacks); | |
114 | +// GLU.gluCylinder(quadricPointer, baseRadius, topRadius, height, slices, | |
115 | +// stacks); | |
118 | 116 | super.clean(); |
119 | 117 | } |
120 | 118 |
@@ -38,10 +38,8 @@ import jme.exception.MonkeyRuntimeException; | ||
38 | 38 | import jme.geometry.bounding.BoundingBox; |
39 | 39 | import jme.geometry.bounding.BoundingSphere; |
40 | 40 | import jme.math.Vector; |
41 | -import jme.system.DisplaySystem; | |
42 | 41 | import jme.utility.LoggingSystem; |
43 | 42 | |
44 | -import org.lwjgl.opengl.GLU; | |
45 | 43 | |
46 | 44 | /** |
47 | 45 | * <code>Disk</code> defines a disk geometry. The disk is defined by two radii. |
@@ -52,7 +50,7 @@ import org.lwjgl.opengl.GLU; | ||
52 | 50 | * determine the number of concentric rings around the center. |
53 | 51 | * |
54 | 52 | * @author Mark Powell |
55 | - * @version $Id: Disk.java,v 1.2 2003-08-07 21:24:37 mojomonkey Exp $ | |
53 | + * @version $Id: Disk.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
56 | 54 | */ |
57 | 55 | public class Disk extends Quadric { |
58 | 56 |
@@ -62,8 +60,6 @@ public class Disk extends Quadric { | ||
62 | 60 | protected int slices; |
63 | 61 | protected int loops; |
64 | 62 | |
65 | - //reference to the GLU object | |
66 | - protected GLU glu; | |
67 | 63 | |
68 | 64 | /** |
69 | 65 | * Constructor creates a new Disk geometry object. The disk is defined by |
@@ -100,8 +96,6 @@ public class Disk extends Quadric { | ||
100 | 96 | new Vector((float)outerRadius,(float)outerRadius,(float)outerRadius)); |
101 | 97 | boundingSphere = new BoundingSphere((float)outerRadius, null); |
102 | 98 | |
103 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
104 | - | |
105 | 99 | super.initialize(); |
106 | 100 | |
107 | 101 | LoggingSystem.getLoggingSystem().getLogger().log(Level.INFO, |
@@ -113,7 +107,7 @@ public class Disk extends Quadric { | ||
113 | 107 | */ |
114 | 108 | public void render() { |
115 | 109 | super.preRender(); |
116 | - glu.disk(quadricPointer, innerRadius, outerRadius, slices, loops); | |
110 | + //glu.disk(quadricPointer, innerRadius, outerRadius, slices, loops); | |
117 | 111 | super.clean(); |
118 | 112 | } |
119 | 113 |
@@ -50,7 +50,7 @@ import jme.math.Vector; | ||
50 | 50 | * the negative x-axis |
51 | 51 | * |
52 | 52 | * @author Mark Powell |
53 | - * @version $Id: PartialDisk.java,v 1.2 2003-08-07 21:24:37 mojomonkey Exp $ | |
53 | + * @version $Id: PartialDisk.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
54 | 54 | */ |
55 | 55 | public class PartialDisk extends Disk { |
56 | 56 |
@@ -91,8 +91,8 @@ public class PartialDisk extends Disk { | ||
91 | 91 | public void render() { |
92 | 92 | super.preRender(); |
93 | 93 | |
94 | - glu.partialDisk(quadricPointer, innerRadius, outerRadius, slices, | |
95 | - loops, startAngle, endAngle); | |
94 | +// glu.partialDisk(quadricPointer, innerRadius, outerRadius, slices, | |
95 | +// loops, startAngle, endAngle); | |
96 | 96 | |
97 | 97 | super.clean(); |
98 | 98 | } |
@@ -37,7 +37,6 @@ import org.lwjgl.opengl.GL; | ||
37 | 37 | import jme.geometry.Geometry; |
38 | 38 | import jme.geometry.bounding.BoundingBox; |
39 | 39 | import jme.geometry.bounding.BoundingSphere; |
40 | -import jme.system.DisplaySystem; | |
41 | 40 | import jme.texture.TextureManager; |
42 | 41 | |
43 | 42 | /** |
@@ -91,8 +90,8 @@ public abstract class Primitive implements Geometry { | ||
91 | 90 | public void setTexture(String filename) { |
92 | 91 | texID = TextureManager.getTextureManager().loadTexture( |
93 | 92 | filename, |
94 | - GL.LINEAR_MIPMAP_LINEAR, | |
95 | - GL.LINEAR, | |
93 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
94 | + GL.GL_LINEAR, | |
96 | 95 | true); |
97 | 96 | } |
98 | 97 | /** |
@@ -131,7 +130,7 @@ public abstract class Primitive implements Geometry { | ||
131 | 130 | */ |
132 | 131 | public void clean() { |
133 | 132 | if (-1 != texID) { |
134 | - DisplaySystem.getDisplaySystem().getGL().disable(GL.TEXTURE_2D); | |
133 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
135 | 134 | } |
136 | 135 | } |
137 | 136 |
@@ -38,11 +38,11 @@ import jme.exception.MonkeyRuntimeException; | ||
38 | 38 | import jme.geometry.bounding.BoundingBox; |
39 | 39 | import jme.geometry.bounding.BoundingSphere; |
40 | 40 | import jme.math.Vector; |
41 | -import jme.system.DisplaySystem; | |
42 | 41 | import jme.texture.TextureManager; |
43 | 42 | import jme.utility.LoggingSystem; |
44 | 43 | |
45 | 44 | import org.lwjgl.opengl.GL; |
45 | +import org.lwjgl.opengl.Window; | |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * <code>Pyramid</code> defines a primitive object of a pyramid shape. The |
@@ -50,7 +50,7 @@ import org.lwjgl.opengl.GL; | ||
50 | 50 | * base and the height. |
51 | 51 | * |
52 | 52 | * @author Mark Powell |
53 | - * @version $Id: Pyramid.java,v 1.2 2003-08-07 21:24:37 mojomonkey Exp $ | |
53 | + * @version $Id: Pyramid.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
54 | 54 | */ |
55 | 55 | public class Pyramid extends Primitive { |
56 | 56 | private boolean usingDisplay; |
@@ -73,11 +73,10 @@ public class Pyramid extends Primitive { | ||
73 | 73 | throw new MonkeyRuntimeException( |
74 | 74 | "Neither base nor height can be " + "negative."); |
75 | 75 | } |
76 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
77 | 76 | |
78 | - if (null == gl) { | |
77 | + if (!Window.isCreated()) { | |
79 | 78 | throw new MonkeyGLException( |
80 | - "OpenGL context must be created " + "before Pyramid."); | |
79 | + "Window must be created before Pyramid."); | |
81 | 80 | } |
82 | 81 | this.base = base; |
83 | 82 | this.height = height; |
@@ -119,10 +118,11 @@ public class Pyramid extends Primitive { | ||
119 | 118 | */ |
120 | 119 | public void useDisplayList(boolean value) { |
121 | 120 | if (value) { |
122 | - listId = gl.genLists(1); | |
123 | - gl.newList(listId, GL.COMPILE); | |
121 | + listId = GL.glGenLists(1); | |
122 | + GL.glNewList(listId, GL.GL_COMPILE); | |
124 | 123 | renderPyramid(); |
125 | - gl.endList(); | |
124 | + GL.glEndList(); | |
125 | + usingDisplay = true; | |
126 | 126 | } else { |
127 | 127 | usingDisplay = false; |
128 | 128 | } |
@@ -133,7 +133,7 @@ public class Pyramid extends Primitive { | ||
133 | 133 | */ |
134 | 134 | public void render() { |
135 | 135 | if (usingDisplay) { |
136 | - gl.callList(listId); | |
136 | + GL.glCallList(listId); | |
137 | 137 | } else { |
138 | 138 | renderPyramid(); |
139 | 139 | } |
@@ -171,62 +171,62 @@ public class Pyramid extends Primitive { | ||
171 | 171 | private void renderPyramid() { |
172 | 172 | if (getTextureId() > 0) { |
173 | 173 | TextureManager.getTextureManager().bind(getTextureId()); |
174 | - gl.enable(GL.TEXTURE_2D); | |
174 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
175 | 175 | } |
176 | 176 | |
177 | - gl.color4f(red, green, blue, alpha); | |
178 | - gl.begin(GL.TRIANGLES); | |
177 | + GL.glColor4f(red, green, blue, alpha); | |
178 | + GL.glBegin(GL.GL_TRIANGLES); | |
179 | 179 | |
180 | 180 | //front |
181 | - gl.texCoord2f(1, 0); | |
182 | - gl.vertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
183 | - gl.texCoord2f(0.5f, 1); | |
184 | - gl.vertex3f(0, height / 2, 0); //top | |
185 | - gl.texCoord2f(0.75f, 0); | |
186 | - gl.vertex3f(base / 2, -height / 2, -base / 2); //f2 | |
181 | + GL.glTexCoord2f(1, 0); | |
182 | + GL.glVertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
183 | + GL.glTexCoord2f(0.5f, 1); | |
184 | + GL.glVertex3f(0, height / 2, 0); //top | |
185 | + GL.glTexCoord2f(0.75f, 0); | |
186 | + GL.glVertex3f(base / 2, -height / 2, -base / 2); //f2 | |
187 | 187 | |
188 | 188 | //right |
189 | - gl.texCoord2f(0.75f, 0); | |
190 | - gl.vertex3f(base / 2, -height / 2, -base / 2); //f2 | |
191 | - gl.texCoord2f(0.5f, 1); | |
192 | - gl.vertex3f(0, height / 2, 0); //top | |
193 | - gl.texCoord2f(0.5f, 0); | |
194 | - gl.vertex3f(base / 2, -height / 2, base / 2); //b2 | |
189 | + GL.glTexCoord2f(0.75f, 0); | |
190 | + GL.glVertex3f(base / 2, -height / 2, -base / 2); //f2 | |
191 | + GL.glTexCoord2f(0.5f, 1); | |
192 | + GL.glVertex3f(0, height / 2, 0); //top | |
193 | + GL.glTexCoord2f(0.5f, 0); | |
194 | + GL.glVertex3f(base / 2, -height / 2, base / 2); //b2 | |
195 | 195 | |
196 | 196 | //back |
197 | - gl.texCoord2f(0.5f, 0); | |
198 | - gl.vertex3f(base / 2, -height / 2, base / 2); //b2 | |
199 | - gl.texCoord2f(0.5f, 1); | |
200 | - gl.vertex3f(0, height / 2, 0); //top | |
201 | - gl.texCoord2f(0.25f, 0); | |
202 | - gl.vertex3f(-base / 2, -height / 2, base / 2); //b1 | |
197 | + GL.glTexCoord2f(0.5f, 0); | |
198 | + GL.glVertex3f(base / 2, -height / 2, base / 2); //b2 | |
199 | + GL.glTexCoord2f(0.5f, 1); | |
200 | + GL.glVertex3f(0, height / 2, 0); //top | |
201 | + GL.glTexCoord2f(0.25f, 0); | |
202 | + GL.glVertex3f(-base / 2, -height / 2, base / 2); //b1 | |
203 | 203 | |
204 | 204 | //left |
205 | - gl.texCoord2f(0.25f, 0); | |
206 | - gl.vertex3f(-base / 2, -height / 2, base / 2); //b1 | |
207 | - gl.texCoord2f(0.5f, 1); | |
208 | - gl.vertex3f(0, height / 2, 0); //top | |
209 | - gl.texCoord2f(0, 0); | |
210 | - gl.vertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
205 | + GL.glTexCoord2f(0.25f, 0); | |
206 | + GL.glVertex3f(-base / 2, -height / 2, base / 2); //b1 | |
207 | + GL.glTexCoord2f(0.5f, 1); | |
208 | + GL.glVertex3f(0, height / 2, 0); //top | |
209 | + GL.glTexCoord2f(0, 0); | |
210 | + GL.glVertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
211 | 211 | |
212 | 212 | //bottom |
213 | - gl.texCoord2f(0, 0); | |
214 | - gl.vertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
215 | - gl.texCoord2f(1, 1); | |
216 | - gl.vertex3f(base / 2, -height / 2, base / 2); //b2 | |
217 | - gl.texCoord2f(0, 1); | |
218 | - gl.vertex3f(-base / 2, -height / 2, base / 2); //b1 | |
219 | - gl.texCoord2f(0, 0); | |
220 | - gl.vertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
221 | - gl.texCoord2f(1, 0); | |
222 | - gl.vertex3f(base / 2, -height / 2, -base / 2); //f2 | |
223 | - gl.texCoord2f(1, 1); | |
224 | - gl.vertex3f(base / 2, -height / 2, base / 2); //b2 | |
225 | - | |
226 | - gl.end(); | |
213 | + GL.glTexCoord2f(0, 0); | |
214 | + GL.glVertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
215 | + GL.glTexCoord2f(1, 1); | |
216 | + GL.glVertex3f(base / 2, -height / 2, base / 2); //b2 | |
217 | + GL.glTexCoord2f(0, 1); | |
218 | + GL.glVertex3f(-base / 2, -height / 2, base / 2); //b1 | |
219 | + GL.glTexCoord2f(0, 0); | |
220 | + GL.glVertex3f(-base / 2, -height / 2, -base / 2); //f1 | |
221 | + GL.glTexCoord2f(1, 0); | |
222 | + GL.glVertex3f(base / 2, -height / 2, -base / 2); //f2 | |
223 | + GL.glTexCoord2f(1, 1); | |
224 | + GL.glVertex3f(base / 2, -height / 2, base / 2); //b2 | |
225 | + | |
226 | + GL.glEnd(); | |
227 | 227 | |
228 | 228 | if (getTextureId() > 0) { |
229 | - gl.disable(GL.TEXTURE_2D); | |
229 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
230 | 230 | } |
231 | 231 | } |
232 | 232 |
@@ -36,7 +36,6 @@ import jme.exception.MonkeyRuntimeException; | ||
36 | 36 | import jme.geometry.bounding.BoundingBox; |
37 | 37 | import jme.geometry.bounding.BoundingSphere; |
38 | 38 | import jme.math.Vector; |
39 | -import jme.system.DisplaySystem; | |
40 | 39 | import jme.texture.TextureManager; |
41 | 40 | |
42 | 41 | import org.lwjgl.opengl.GL; |
@@ -54,7 +53,7 @@ import org.lwjgl.opengl.GL; | ||
54 | 53 | * 3 - BottomLeft<br> |
55 | 54 | * |
56 | 55 | * @author Mark Powell |
57 | - * @version $Id: Quad.java,v 1.4 2003-08-19 02:10:14 mojomonkey Exp $ | |
56 | + * @version $Id: Quad.java,v 1.5 2003-09-03 16:20:51 mojomonkey Exp $ | |
58 | 57 | */ |
59 | 58 | public class Quad extends Primitive { |
60 | 59 | private GL gl; |
@@ -70,7 +69,6 @@ public class Quad extends Primitive { | ||
70 | 69 | if(null == points) { |
71 | 70 | throw new MonkeyRuntimeException("Points cannot be null."); |
72 | 71 | } |
73 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
74 | 72 | this.points = points; |
75 | 73 | initialize(); |
76 | 74 | } |
@@ -111,27 +109,27 @@ public class Quad extends Primitive { | ||
111 | 109 | */ |
112 | 110 | public void render() { |
113 | 111 | if(getTextureId() > 0) { |
114 | - gl.enable(GL.TEXTURE_2D); | |
112 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
115 | 113 | TextureManager.getTextureManager().bind(getTextureId()); |
116 | 114 | } |
117 | 115 | |
118 | - gl.begin(GL.QUADS); | |
116 | + GL.glBegin(GL.GL_QUADS); | |
119 | 117 | |
120 | - gl.color4f(red,green,blue,alpha); | |
118 | + GL.glColor4f(red,green,blue,alpha); | |
121 | 119 | |
122 | - gl.texCoord2i(1,1); | |
123 | - gl.vertex3f(points[0].x,points[0].y,points[0].z); | |
124 | - gl.texCoord2i(0,1); | |
125 | - gl.vertex3f(points[1].x,points[1].y,points[1].z); | |
126 | - gl.texCoord2i(0,0); | |
127 | - gl.vertex3f(points[2].x,points[2].y,points[2].z); | |
128 | - gl.texCoord2i(1,0); | |
129 | - gl.vertex3f(points[3].x,points[3].y,points[3].z); | |
120 | + GL.glTexCoord2f(1,1); | |
121 | + GL.glVertex3f(points[0].x,points[0].y,points[0].z); | |
122 | + GL.glTexCoord2f(0,1); | |
123 | + GL.glVertex3f(points[1].x,points[1].y,points[1].z); | |
124 | + GL.glTexCoord2f(0,0); | |
125 | + GL.glVertex3f(points[2].x,points[2].y,points[2].z); | |
126 | + GL.glTexCoord2f(1,0); | |
127 | + GL.glVertex3f(points[3].x,points[3].y,points[3].z); | |
130 | 128 | |
131 | - gl.end(); | |
129 | + GL.glEnd(); | |
132 | 130 | |
133 | 131 | if(getTextureId() > 0) { |
134 | - gl.disable(GL.TEXTURE_2D); | |
132 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
135 | 133 | } |
136 | 134 | |
137 | 135 | } |
@@ -34,7 +34,6 @@ package jme.geometry.primitive; | ||
34 | 34 | |
35 | 35 | import org.lwjgl.opengl.GL; |
36 | 36 | |
37 | -import jme.system.DisplaySystem; | |
38 | 37 | import jme.texture.TextureManager; |
39 | 38 | |
40 | 39 | /** |
@@ -63,7 +62,7 @@ public abstract class Quadric extends Primitive { | ||
63 | 62 | * subclass geometry. This creates a new quadric object. |
64 | 63 | */ |
65 | 64 | public void initialize() { |
66 | - quadricPointer = DisplaySystem.getDisplaySystem().getGLU().newQuadric(); | |
65 | + //quadricPointer = DisplaySystem.getDisplaySystem().getGLU().newQuadric(); | |
67 | 66 | } |
68 | 67 | |
69 | 68 | /** |
@@ -72,13 +71,13 @@ public abstract class Quadric extends Primitive { | ||
72 | 71 | */ |
73 | 72 | public void preRender() { |
74 | 73 | if (getTextureId() > 0) { |
75 | - DisplaySystem.getDisplaySystem().getGL().enable(GL.TEXTURE_2D); | |
74 | + //DisplaySystem.getDisplaySystem().getGL().enable(GL.TEXTURE_2D); | |
76 | 75 | TextureManager.getTextureManager().bind(getTextureId()); |
77 | - DisplaySystem.getDisplaySystem().getGLU().quadricTexture( | |
78 | - quadricPointer, | |
79 | - true); | |
76 | +// DisplaySystem.getDisplaySystem().getGLU().quadricTexture( | |
77 | +// quadricPointer, | |
78 | +// true); | |
80 | 79 | } |
81 | - DisplaySystem.getDisplaySystem().getGL().color4f( | |
80 | + GL.glColor4f( | |
82 | 81 | red, |
83 | 82 | green, |
84 | 83 | blue, |
@@ -40,7 +40,6 @@ import jme.exception.MonkeyRuntimeException; | ||
40 | 40 | import jme.geometry.bounding.BoundingBox; |
41 | 41 | import jme.geometry.bounding.BoundingSphere; |
42 | 42 | import jme.math.Vector; |
43 | -import jme.system.DisplaySystem; | |
44 | 43 | import jme.utility.LoggingSystem; |
45 | 44 | |
46 | 45 | /** |
@@ -52,7 +51,7 @@ import jme.utility.LoggingSystem; | ||
52 | 51 | * However, frame rate will drop accordingly. |
53 | 52 | * |
54 | 53 | * @author Mark Powell |
55 | - * @version $Id: Sphere.java,v 1.2 2003-08-07 21:24:37 mojomonkey Exp $ | |
54 | + * @version $Id: Sphere.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
56 | 55 | */ |
57 | 56 | public class Sphere extends Quadric { |
58 | 57 |
@@ -91,8 +90,6 @@ public class Sphere extends Quadric { | ||
91 | 90 | this.slices = slices; |
92 | 91 | this.stacks = stacks; |
93 | 92 | |
94 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
95 | - | |
96 | 93 | super.initialize(); |
97 | 94 | |
98 | 95 | //build bounding volumes |
@@ -110,7 +107,7 @@ public class Sphere extends Quadric { | ||
110 | 107 | public void render() { |
111 | 108 | super.preRender(); |
112 | 109 | |
113 | - glu.sphere(quadricPointer, radius, slices, stacks); | |
110 | + //glu.sphere(quadricPointer, radius, slices, stacks); | |
114 | 111 | |
115 | 112 | super.clean(); |
116 | 113 | } |
@@ -35,7 +35,6 @@ package jme.geometry.primitive; | ||
35 | 35 | import jme.exception.MonkeyRuntimeException; |
36 | 36 | import jme.geometry.bounding.BoundingBox; |
37 | 37 | import jme.geometry.bounding.BoundingSphere; |
38 | -import jme.system.DisplaySystem; | |
39 | 38 | import jme.texture.TextureManager; |
40 | 39 | import jme.math.Vector; |
41 | 40 |
@@ -53,7 +52,7 @@ import org.lwjgl.opengl.GL; | ||
53 | 52 | * 2 - BottomRight<br> |
54 | 53 | * |
55 | 54 | * @author Samuel Wasson |
56 | - * @version $Id: Triangle.java,v 1.2 2003-08-19 02:10:14 mojomonkey Exp $ | |
55 | + * @version $Id: Triangle.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
57 | 56 | */ |
58 | 57 | |
59 | 58 | public class Triangle extends Primitive { |
@@ -70,7 +69,6 @@ public class Triangle extends Primitive { | ||
70 | 69 | if(null == points) { |
71 | 70 | throw new MonkeyRuntimeException("Points cannot be null."); |
72 | 71 | } |
73 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
74 | 72 | this.points = points; |
75 | 73 | initialize(); |
76 | 74 | } |
@@ -110,24 +108,24 @@ public class Triangle extends Primitive { | ||
110 | 108 | */ |
111 | 109 | public void render() { |
112 | 110 | if(getTextureId() > 0) { |
113 | - gl.enable(GL.TEXTURE_2D); | |
111 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
114 | 112 | TextureManager.getTextureManager().bind(getTextureId()); |
115 | 113 | } |
116 | 114 | |
117 | - gl.begin(GL.TRIANGLES); | |
118 | - gl.color4f(red, green, blue, alpha); | |
115 | + GL.glBegin(GL.GL_TRIANGLES); | |
116 | + GL.glColor4f(red, green, blue, alpha); | |
119 | 117 | |
120 | - gl.texCoord2i(1,1); | |
121 | - gl.vertex3f(points[0].x, points[0].y, points[0].z); | |
122 | - gl.texCoord2i(0,0); | |
123 | - gl.vertex3f(points[1].x, points[1].y, points[1].z); | |
124 | - gl.texCoord2i(1,0); | |
125 | - gl.vertex3f(points[2].x, points[2].y, points[2].z); | |
118 | + GL.glTexCoord2f(1,1); | |
119 | + GL.glVertex3f(points[0].x, points[0].y, points[0].z); | |
120 | + GL.glTexCoord2f(0,0); | |
121 | + GL.glVertex3f(points[1].x, points[1].y, points[1].z); | |
122 | + GL.glTexCoord2f(1,0); | |
123 | + GL.glVertex3f(points[2].x, points[2].y, points[2].z); | |
126 | 124 | |
127 | - gl.end(); | |
125 | + GL.glEnd(); | |
128 | 126 | |
129 | 127 | if(getTextureId() > 0) { |
130 | - gl.disable(GL.TEXTURE_2D); | |
128 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
131 | 129 | } |
132 | 130 | } |
133 | 131 |
@@ -35,7 +35,6 @@ package jme.locale; | ||
35 | 35 | import java.util.logging.Level; |
36 | 36 | |
37 | 37 | import jme.exception.MonkeyRuntimeException; |
38 | -import jme.system.DisplaySystem; | |
39 | 38 | import jme.texture.TextureManager; |
40 | 39 | import jme.utility.LoggingSystem; |
41 | 40 |
@@ -67,7 +66,7 @@ public class SimpleLocale implements Locale { | ||
67 | 66 | private float alpha = 1.0f; |
68 | 67 | |
69 | 68 | //gl object. |
70 | - private GL gl; | |
69 | + //private GL gl; | |
71 | 70 | |
72 | 71 | /** |
73 | 72 | * Constructor builds a new <code>SimpleLocale</code> with the defined, |
@@ -88,8 +87,7 @@ public class SimpleLocale implements Locale { | ||
88 | 87 | |
89 | 88 | this.center = center; |
90 | 89 | this.halfLength = length / 2; |
91 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
92 | - | |
90 | + | |
93 | 91 | LoggingSystem.getLoggingSystem().getLogger().log( |
94 | 92 | Level.INFO, |
95 | 93 | "SimpleLocale created."); |
@@ -112,29 +110,29 @@ public class SimpleLocale implements Locale { | ||
112 | 110 | |
113 | 111 | //bind texture only if one has been set. |
114 | 112 | if (textureID > 0) { |
115 | - gl.enable(GL.TEXTURE_2D); | |
113 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
116 | 114 | TextureManager.getTextureManager().bind(textureID); |
117 | 115 | } |
118 | 116 | |
119 | - gl.color4f(red, green, blue, alpha); | |
120 | - gl.begin(GL.QUADS); | |
117 | + GL.glColor4f(red, green, blue, alpha); | |
118 | + GL.glBegin(GL.GL_QUADS); | |
121 | 119 | |
122 | - gl.texCoord2f(0f, 1f); | |
123 | - gl.vertex3f(center.x - halfLength, center.y, center.z + halfLength); | |
120 | + GL.glTexCoord2f(0f, 1f); | |
121 | + GL.glVertex3f(center.x - halfLength, center.y, center.z + halfLength); | |
124 | 122 | |
125 | - gl.texCoord2f(1f, 1f); | |
126 | - gl.vertex3f(center.x + halfLength, center.y, center.z + halfLength); | |
123 | + GL.glTexCoord2f(1f, 1f); | |
124 | + GL.glVertex3f(center.x + halfLength, center.y, center.z + halfLength); | |
127 | 125 | |
128 | - gl.texCoord2f(1f, 0f); | |
129 | - gl.vertex3f(center.x + halfLength, center.y, center.z - halfLength); | |
126 | + GL.glTexCoord2f(1f, 0f); | |
127 | + GL.glVertex3f(center.x + halfLength, center.y, center.z - halfLength); | |
130 | 128 | |
131 | - gl.texCoord2f(0f, 0f); | |
132 | - gl.vertex3f(center.x - halfLength, center.y, center.z - halfLength); | |
129 | + GL.glTexCoord2f(0f, 0f); | |
130 | + GL.glVertex3f(center.x - halfLength, center.y, center.z - halfLength); | |
133 | 131 | |
134 | - gl.end(); | |
132 | + GL.glEnd(); | |
135 | 133 | |
136 | 134 | if (textureID > 0) { |
137 | - gl.disable(GL.TEXTURE_2D); | |
135 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
138 | 136 | } |
139 | 137 | } |
140 | 138 |
@@ -145,8 +143,8 @@ public class SimpleLocale implements Locale { | ||
145 | 143 | public void setTexture(String filename) { |
146 | 144 | textureID = TextureManager.getTextureManager().loadTexture( |
147 | 145 | filename, |
148 | - GL.LINEAR_MIPMAP_LINEAR, | |
149 | - GL.LINEAR, | |
146 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
147 | + GL.GL_LINEAR, | |
150 | 148 | true); |
151 | 149 | } |
152 | 150 |
@@ -36,7 +36,6 @@ import org.lwjgl.opengl.GL; | ||
36 | 36 | |
37 | 37 | import jme.exception.MonkeyRuntimeException; |
38 | 38 | import jme.locale.external.data.AbstractHeightMap; |
39 | -import jme.system.DisplaySystem; | |
40 | 39 | import jme.texture.TextureManager; |
41 | 40 | |
42 | 41 | /** |
@@ -46,7 +45,7 @@ import jme.texture.TextureManager; | ||
46 | 45 | * distance, etc. |
47 | 46 | * |
48 | 47 | * @author Mark Powell |
49 | - * @version 1 | |
48 | + * @version $Id: BruteForce.java,v 1.2 2003-09-03 16:20:51 mojomonkey Exp $ | |
50 | 49 | */ |
51 | 50 | public class BruteForce extends Terrain { |
52 | 51 |
@@ -66,7 +65,6 @@ public class BruteForce extends Terrain { | ||
66 | 65 | |
67 | 66 | this.heightData = heightData; |
68 | 67 | this.terrainSize = heightData.getSize(); |
69 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
70 | 68 | } |
71 | 69 | |
72 | 70 |
@@ -97,16 +95,16 @@ public class BruteForce extends Terrain { | ||
97 | 95 | |
98 | 96 | //set up the appropriate textures. |
99 | 97 | if (isDetailed && isTextured) { |
100 | - gl.activeTextureARB(GL.TEXTURE0_ARB); | |
101 | - gl.enable(GL.TEXTURE_2D); | |
98 | + GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB); | |
99 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
102 | 100 | TextureManager.getTextureManager().bind(terrainTexture); |
103 | - gl.activeTextureARB(GL.TEXTURE1_ARB); | |
104 | - gl.enable(GL.TEXTURE_2D); | |
101 | + GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB); | |
102 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
105 | 103 | TextureManager.getTextureManager().bind(detailId); |
106 | - gl.texEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.COMBINE_ARB); | |
107 | - gl.texEnvi(GL.TEXTURE_ENV, GL.RGB_SCALE_ARB, 2); | |
104 | + GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE_ARB); | |
105 | + GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_RGB_SCALE_ARB, 2); | |
108 | 106 | } else if (isTextured) { |
109 | - gl.enable(GL.TEXTURE_2D); | |
107 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
110 | 108 | TextureManager.getTextureManager().bind(terrainTexture); |
111 | 109 | } |
112 | 110 |
@@ -117,7 +115,7 @@ public class BruteForce extends Terrain { | ||
117 | 115 | //be swapped. This will need to be resolved in the loaders, before |
118 | 116 | //the terrain can be rendered in a normal fashion. |
119 | 117 | for (int z = 0; z < terrainSize - 1; z++) { |
120 | - gl.begin(GL.TRIANGLE_STRIP); | |
118 | + GL.glBegin(GL.GL_TRIANGLE_STRIP); | |
121 | 119 | |
122 | 120 | if (isTextured) { |
123 | 121 | texDown = (float) z / terrainSize; |
@@ -138,21 +136,21 @@ public class BruteForce extends Terrain { | ||
138 | 136 | green = 1.0f; |
139 | 137 | blue = 1.0f; |
140 | 138 | } |
141 | - gl.color3f(red, green, blue); | |
139 | + GL.glColor3f(red, green, blue); | |
142 | 140 | |
143 | 141 | if (isTextured && isDetailed) { |
144 | 142 | texLeft = (float) x / terrainSize; |
145 | - gl.multiTexCoord2fARB(GL.TEXTURE0_ARB, texDown, texLeft); | |
146 | - gl.multiTexCoord2fARB( | |
147 | - GL.TEXTURE1_ARB, | |
143 | + GL.glMultiTexCoord2fARB(GL.GL_TEXTURE0_ARB, texDown, texLeft); | |
144 | + GL.glMultiTexCoord2fARB( | |
145 | + GL.GL_TEXTURE1_ARB, | |
148 | 146 | texLeft * repeatDetailMap, |
149 | 147 | texDown * repeatDetailMap); |
150 | 148 | } else if (isTextured) { |
151 | 149 | texLeft = (float) x / terrainSize; |
152 | - gl.texCoord2f(texLeft, texDown); | |
150 | + GL.glTexCoord2f(texLeft, texDown); | |
153 | 151 | } |
154 | 152 | |
155 | - gl.vertex3f(x, heightData.getScaledHeightAtPoint(z, x), z); | |
153 | + GL.glVertex3f(x, heightData.getScaledHeightAtPoint(z, x), z); | |
156 | 154 | |
157 | 155 | if (isLit) { |
158 | 156 | shade = lightMap.getShade(z+1,x); |
@@ -164,38 +162,38 @@ public class BruteForce extends Terrain { | ||
164 | 162 | green = 1.0f; |
165 | 163 | blue = 1.0f; |
166 | 164 | } |
167 | - gl.color3f(red, green, blue); | |
165 | + GL.glColor3f(red, green, blue); | |
168 | 166 | |
169 | 167 | if (isTextured && isDetailed) { |
170 | - gl.multiTexCoord2fARB(GL.TEXTURE0_ARB, texUp, texLeft); | |
171 | - gl.multiTexCoord2fARB( | |
172 | - GL.TEXTURE1_ARB, | |
168 | + GL.glMultiTexCoord2fARB(GL.GL_TEXTURE0_ARB, texUp, texLeft); | |
169 | + GL.glMultiTexCoord2fARB( | |
170 | + GL.GL_TEXTURE1_ARB, | |
173 | 171 | texLeft * repeatDetailMap, |
174 | 172 | texUp * repeatDetailMap); |
175 | 173 | } else if (isTextured) { |
176 | - gl.texCoord2f(texLeft, texUp); | |
174 | + GL.glTexCoord2f(texLeft, texUp); | |
177 | 175 | } |
178 | 176 | |
179 | - gl.vertex3f( | |
177 | + GL.glVertex3f( | |
180 | 178 | x, |
181 | 179 | heightData.getScaledHeightAtPoint(z+1, x), |
182 | 180 | z + 1); |
183 | 181 | } |
184 | 182 | |
185 | - gl.end(); | |
183 | + GL.glEnd(); | |
186 | 184 | } |
187 | 185 | |
188 | 186 | |
189 | 187 | |
190 | 188 | if (isDetailed) { |
191 | - gl.activeTextureARB(GL.TEXTURE1_ARB); | |
192 | - gl.bindTexture(GL.TEXTURE_2D, 0); | |
193 | - gl.activeTextureARB(GL.TEXTURE0_ARB); | |
194 | - gl.bindTexture(GL.TEXTURE_2D, 0); | |
189 | + GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB); | |
190 | + GL.glBindTexture(GL.GL_TEXTURE_2D, 0); | |
191 | + GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB); | |
192 | + GL.glBindTexture(GL.GL_TEXTURE_2D, 0); | |
195 | 193 | } |
196 | 194 | |
197 | 195 | if (isTextured) { |
198 | - gl.disable(GL.TEXTURE_2D); | |
196 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
199 | 197 | } |
200 | 198 | |
201 | 199 | } |
@@ -36,7 +36,6 @@ import java.util.logging.Level; | ||
36 | 36 | |
37 | 37 | import jme.exception.MonkeyRuntimeException; |
38 | 38 | import jme.locale.external.data.AbstractHeightMap; |
39 | -import jme.system.DisplaySystem; | |
40 | 39 | import jme.entity.camera.Camera; |
41 | 40 | import jme.texture.TextureManager; |
42 | 41 | import jme.utility.LoggingSystem; |
@@ -70,7 +69,7 @@ import org.lwjgl.opengl.GL; | ||
70 | 69 | * <code>MidPointHeightMap</code> would not work for this. |
71 | 70 | * |
72 | 71 | * @author Mark Powell |
73 | - * @version 0.1.0 | |
72 | + * @version $Id: Geomipmap.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
74 | 73 | */ |
75 | 74 | public class Geomipmap extends Terrain { |
76 | 75 | private Camera camera; |
@@ -96,7 +95,6 @@ public class Geomipmap extends Terrain { | ||
96 | 95 | if (patchSize <= 0) { |
97 | 96 | throw new MonkeyRuntimeException("patchSize must be greater than 0."); |
98 | 97 | } |
99 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
100 | 98 | |
101 | 99 | this.heightData = heightMap; |
102 | 100 | this.terrainSize = heightData.getSize(); |
@@ -190,7 +188,7 @@ public class Geomipmap extends Terrain { | ||
190 | 188 | |
191 | 189 | if (patches[patch].isVisible || camera.hasMoved()) { |
192 | 190 | patches[patch].distance = |
193 | - org.lwjgl.Math.sqrt( | |
191 | + (float)Math.sqrt( | |
194 | 192 | (patchX - camera.getPosition().x) |
195 | 193 | * (patchX - camera.getPosition().x) |
196 | 194 | + (patchY - camera.getPosition().y) |
@@ -210,20 +208,20 @@ public class Geomipmap extends Terrain { | ||
210 | 208 | */ |
211 | 209 | public void render() { |
212 | 210 | |
213 | - gl.activeTextureARB(GL.TEXTURE0_ARB); | |
214 | - gl.enable(GL.TEXTURE_2D); | |
215 | - gl.enable(GL.DEPTH_TEST); | |
211 | + GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB); | |
212 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
213 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
216 | 214 | if(useDistanceFog || useVolumeFog) { |
217 | - gl.enable(GL.FOG); | |
215 | + GL.glEnable(GL.GL_FOG); | |
218 | 216 | } |
219 | 217 | TextureManager.getTextureManager().bind(terrainTexture); |
220 | 218 | |
221 | 219 | if (isDetailed) { |
222 | - gl.activeTextureARB(GL.TEXTURE1_ARB); | |
223 | - gl.enable(GL.TEXTURE_2D); | |
220 | + GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB); | |
221 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
224 | 222 | TextureManager.getTextureManager().bind(detailId); |
225 | - gl.texEnvi(GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.COMBINE_ARB); | |
226 | - gl.texEnvi(GL.TEXTURE_ENV, GL.RGB_SCALE_ARB, 2); | |
223 | + GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_COMBINE_ARB); | |
224 | + GL.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_RGB_SCALE_ARB, 2); | |
227 | 225 | } |
228 | 226 | |
229 | 227 | patchesRendered = 0; |
@@ -236,16 +234,16 @@ public class Geomipmap extends Terrain { | ||
236 | 234 | } |
237 | 235 | } |
238 | 236 | |
239 | - gl.activeTextureARB(GL.TEXTURE1_ARB); | |
240 | - gl.disable(GL.TEXTURE_2D); | |
241 | - gl.bindTexture(GL.TEXTURE_2D, 0); | |
237 | + GL.glActiveTextureARB(GL.GL_TEXTURE1_ARB); | |
238 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
239 | + GL.glBindTexture(GL.GL_TEXTURE_2D, 0); | |
242 | 240 | |
243 | - gl.activeTextureARB(GL.TEXTURE0_ARB); | |
244 | - gl.disable(GL.TEXTURE_2D); | |
245 | - gl.bindTexture(GL.TEXTURE_2D, 0); | |
246 | - gl.disable(GL.DEPTH_TEST); | |
241 | + GL.glActiveTextureARB(GL.GL_TEXTURE0_ARB); | |
242 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
243 | + GL.glBindTexture(GL.GL_TEXTURE_2D, 0); | |
244 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
247 | 245 | if(useDistanceFog || useVolumeFog) { |
248 | - gl.disable(GL.FOG); | |
246 | + GL.glDisable(GL.GL_FOG); | |
249 | 247 | } |
250 | 248 | } |
251 | 249 |
@@ -285,13 +283,13 @@ public class Geomipmap extends Terrain { | ||
285 | 283 | green = 1.0f; |
286 | 284 | blue = 1.0f; |
287 | 285 | } |
288 | - gl.color3f(red, green, blue); | |
286 | + GL.glColor3f(red, green, blue); | |
289 | 287 | |
290 | 288 | //set up the texture coordinates. |
291 | - gl.multiTexCoord2fARB(GL.TEXTURE0_ARB, u, v); | |
289 | + GL.glMultiTexCoord2fARB(GL.GL_TEXTURE0_ARB, u, v); | |
292 | 290 | if (isDetailed) { |
293 | - gl.multiTexCoord2fARB( | |
294 | - GL.TEXTURE1_ARB, | |
291 | + GL.glMultiTexCoord2fARB( | |
292 | + GL.GL_TEXTURE1_ARB, | |
295 | 293 | u * repeatDetailMap, |
296 | 294 | v * repeatDetailMap); |
297 | 295 | } |
@@ -301,7 +299,7 @@ public class Geomipmap extends Terrain { | ||
301 | 299 | heightData.getScaledHeightAtPoint((int) x, (int) z)); |
302 | 300 | } |
303 | 301 | //render the point. |
304 | - gl.vertex3f( | |
302 | + GL.glVertex3f( | |
305 | 303 | x * xScale, |
306 | 304 | heightData.getScaledHeightAtPoint((int) x, (int) z), |
307 | 305 | z * zScale); |
@@ -335,7 +333,7 @@ public class Geomipmap extends Terrain { | ||
335 | 333 | midX = ((texLeft + texRight) / 2); |
336 | 334 | midZ = ((texBottom + texTop) / 2); |
337 | 335 | |
338 | - gl.begin(GL.TRIANGLE_FAN); | |
336 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
339 | 337 | |
340 | 338 | //a fan is rendered by drawing a line from the center to the |
341 | 339 | //four corners. If a neighbor side is true, we also draw a |
@@ -371,7 +369,7 @@ public class Geomipmap extends Terrain { | ||
371 | 369 | |
372 | 370 | renderVertex(x - halfSize, z - halfSize, texLeft, texBottom); |
373 | 371 | |
374 | - gl.end(); | |
372 | + GL.glEnd(); | |
375 | 373 | } |
376 | 374 | |
377 | 375 | /** |
@@ -34,12 +34,13 @@ package jme.locale.external; | ||
34 | 34 | |
35 | 35 | import java.nio.ByteBuffer; |
36 | 36 | import java.nio.ByteOrder; |
37 | +import java.nio.FloatBuffer; | |
37 | 38 | import java.util.logging.Level; |
38 | 39 | |
39 | 40 | import javax.swing.ImageIcon; |
40 | 41 | |
41 | -import org.lwjgl.Sys; | |
42 | 42 | import org.lwjgl.opengl.GL; |
43 | +import org.lwjgl.opengl.GLCaps; | |
43 | 44 | |
44 | 45 | import jme.exception.MonkeyRuntimeException; |
45 | 46 | import jme.lighting.AbstractLightMap; |
@@ -153,16 +154,13 @@ public abstract class Terrain implements Locale { | ||
153 | 154 | */ |
154 | 155 | public void setFogAttributes(int mode, float[] color, |
155 | 156 | float density, float start, float end) { |
156 | - ByteBuffer temp = ByteBuffer.allocateDirect(16); | |
157 | - temp.order(ByteOrder.nativeOrder()); | |
158 | - | |
159 | - gl.fogi(GL.FOG_MODE, mode); | |
160 | - gl.fogfv(GL.FOG_COLOR, | |
161 | - Sys.getDirectBufferAddress( | |
162 | - temp.asFloatBuffer().put(color))); | |
163 | - gl.fogf(GL.FOG_DENSITY, density); | |
164 | - gl.fogf(GL.FOG_START, start); | |
165 | - gl.fogf(GL.FOG_END, end); | |
157 | + FloatBuffer buf = ByteBuffer.allocateDirect(16).order(ByteOrder.nativeOrder()).asFloatBuffer(); | |
158 | + | |
159 | + GL.glFogi(GL.GL_FOG_MODE, mode); | |
160 | + GL.glFog(GL.GL_FOG_COLOR, buf); | |
161 | + GL.glFogf(GL.GL_FOG_DENSITY, density); | |
162 | + GL.glFogf(GL.GL_FOG_START, start); | |
163 | + GL.glFogf(GL.GL_FOG_END, end); | |
166 | 164 | } |
167 | 165 | |
168 | 166 | /** |
@@ -192,9 +190,9 @@ public abstract class Terrain implements Locale { | ||
192 | 190 | public void setDistanceFog(boolean value) { |
193 | 191 | useDistanceFog = value; |
194 | 192 | if(value) { |
195 | - gl.enable(GL.FOG); | |
193 | + GL.glEnable(GL.GL_FOG); | |
196 | 194 | } else { |
197 | - gl.disable(GL.FOG); | |
195 | + GL.glDisable(GL.GL_FOG); | |
198 | 196 | } |
199 | 197 | } |
200 | 198 |
@@ -217,10 +215,10 @@ public abstract class Terrain implements Locale { | ||
217 | 215 | useVolumeFog = value; |
218 | 216 | |
219 | 217 | if(value) { |
220 | - gl.fogi( GL.FOG_COORDINATE_SOURCE_EXT, GL.FOG_COORDINATE_EXT ); | |
221 | - gl.enable(GL.FOG); | |
218 | + GL.glFogi( GL.GL_FOG_COORDINATE_SOURCE_EXT, GL.GL_FOG_COORDINATE_EXT ); | |
219 | + GL.glEnable(GL.GL_FOG); | |
222 | 220 | } else { |
223 | - gl.disable(GL.FOG); | |
221 | + GL.glDisable(GL.GL_FOG); | |
224 | 222 | } |
225 | 223 | } |
226 | 224 |
@@ -231,9 +229,9 @@ public abstract class Terrain implements Locale { | ||
231 | 229 | */ |
232 | 230 | protected void setVolumetricFogCoord(float height) { |
233 | 231 | if(height > fogDepth) { |
234 | - gl.fogCoordfEXT(-(height-fogDepth)); | |
232 | + GL.glFogCoordfEXT(-(height-fogDepth)); | |
235 | 233 | } else { |
236 | - gl.fogCoordfEXT(0); | |
234 | + GL.glFogCoordfEXT(0); | |
237 | 235 | } |
238 | 236 | } |
239 | 237 |
@@ -247,7 +245,7 @@ public abstract class Terrain implements Locale { | ||
247 | 245 | public void setDetailTexture(String detailTexture, int repeat) { |
248 | 246 | |
249 | 247 | this.repeatDetailMap = repeat; |
250 | - boolean canMulti = gl.ARB_multitexture; | |
248 | + boolean canMulti = GLCaps.GL_ARB_multitexture; | |
251 | 249 | |
252 | 250 | if (!canMulti) { |
253 | 251 | LoggingSystem.getLoggingSystem().getLogger().log( |
@@ -258,8 +256,8 @@ public abstract class Terrain implements Locale { | ||
258 | 256 | if(null != detailTexture && canMulti) { |
259 | 257 | detailId = TextureManager.getTextureManager().loadTexture( |
260 | 258 | detailTexture, |
261 | - GL.LINEAR_MIPMAP_LINEAR, | |
262 | - GL.LINEAR, | |
259 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
260 | + GL.GL_LINEAR, | |
263 | 261 | true); |
264 | 262 | isDetailed = true; |
265 | 263 | } else { |
@@ -277,8 +275,8 @@ public abstract class Terrain implements Locale { | ||
277 | 275 | if (texture != null) { |
278 | 276 | if((terrainTexture = TextureManager.getTextureManager().loadTexture( |
279 | 277 | texture, |
280 | - GL.LINEAR_MIPMAP_LINEAR, | |
281 | - GL.LINEAR, | |
278 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
279 | + GL.GL_LINEAR, | |
282 | 280 | true)) != -1) { |
283 | 281 | isTextured = true; |
284 | 282 | } |
@@ -297,8 +295,8 @@ public abstract class Terrain implements Locale { | ||
297 | 295 | if (texture != null) { |
298 | 296 | if((terrainTexture = TextureManager.getTextureManager().loadTexture( |
299 | 297 | texture, |
300 | - GL.LINEAR_MIPMAP_LINEAR, | |
301 | - GL.LINEAR, | |
298 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
299 | + GL.GL_LINEAR, | |
302 | 300 | true)) != -1) { |
303 | 301 | isTextured = true; |
304 | 302 | } |
@@ -35,12 +35,11 @@ package jme.locale.external.feature; | ||
35 | 35 | import java.util.logging.Level; |
36 | 36 | |
37 | 37 | import jme.exception.MonkeyRuntimeException; |
38 | -import jme.system.DisplaySystem; | |
38 | +import jme.math.Vector; | |
39 | 39 | import jme.texture.TextureManager; |
40 | 40 | import jme.utility.LoggingSystem; |
41 | 41 | |
42 | 42 | import org.lwjgl.opengl.GL; |
43 | -import org.lwjgl.vector.Vector3f; | |
44 | 43 | |
45 | 44 | /** |
46 | 45 | * <code>SkyBox</code> defines a implementation of the sky interface |
@@ -49,7 +48,7 @@ import org.lwjgl.vector.Vector3f; | ||
49 | 48 | * depth buffer for the skybox is turn off so it will always appear behind |
50 | 49 | * any object/locale rendered. The skybox moves with the connected entity. |
51 | 50 | * @author Mark Powell |
52 | - * @version 0.1.0 | |
51 | + * @version $Id: SkyBox.java,v 1.2 2003-09-03 16:20:51 mojomonkey Exp $ | |
53 | 52 | */ |
54 | 53 | public class SkyBox implements Sky { |
55 | 54 | /** |
@@ -78,15 +77,12 @@ public class SkyBox implements Sky { | ||
78 | 77 | public static final int BACK = 5; |
79 | 78 | |
80 | 79 | //area of the box |
81 | - private Vector3f center; | |
80 | + private Vector center; | |
82 | 81 | private float size; |
83 | 82 | |
84 | 83 | //appearance of box |
85 | 84 | private int[] textures; |
86 | - private Vector3f color; | |
87 | - | |
88 | - //gl object for rendering. | |
89 | - private GL gl; | |
85 | + private Vector color; | |
90 | 86 | |
91 | 87 | /** |
92 | 88 | * Constructor creates a new <code>SkyBox</code> object. The size of |
@@ -95,12 +91,11 @@ public class SkyBox implements Sky { | ||
95 | 91 | * @param size the size of each side of the box. |
96 | 92 | */ |
97 | 93 | public SkyBox(float size) { |
98 | - center = new Vector3f(); | |
94 | + center = new Vector(); | |
99 | 95 | textures = new int[6]; |
100 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
101 | 96 | this.size = size / 2; |
102 | - this.center = new Vector3f(this.size, 32, this.size); | |
103 | - color = new Vector3f(1.0f, 1.0f, 1.0f); | |
97 | + this.center = new Vector(this.size, 32, this.size); | |
98 | + color = new Vector(1.0f, 1.0f, 1.0f); | |
104 | 99 | |
105 | 100 | LoggingSystem.getLoggingSystem().getLogger().log( |
106 | 101 | Level.INFO, |
@@ -122,8 +117,8 @@ public class SkyBox implements Sky { | ||
122 | 117 | |
123 | 118 | textures[side] = TextureManager.getTextureManager().loadTexture( |
124 | 119 | filename, |
125 | - GL.LINEAR_MIPMAP_LINEAR, | |
126 | - GL.LINEAR, | |
120 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
121 | + GL.GL_LINEAR, | |
127 | 122 | true); |
128 | 123 | } |
129 | 124 |
@@ -145,8 +140,8 @@ public class SkyBox implements Sky { | ||
145 | 140 | for (int i = 0; i < 6; i++) { |
146 | 141 | this.textures[i] = TextureManager.getTextureManager().loadTexture( |
147 | 142 | textures[i], |
148 | - GL.LINEAR_MIPMAP_LINEAR, | |
149 | - GL.LINEAR, | |
143 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
144 | + GL.GL_LINEAR, | |
150 | 145 | true); |
151 | 146 | } |
152 | 147 | } |
@@ -163,7 +158,7 @@ public class SkyBox implements Sky { | ||
163 | 158 | * <code>setColor</code> sets the color tint of the skybox. |
164 | 159 | * @param color the tint of the box. |
165 | 160 | */ |
166 | - public void setColor(Vector3f color) { | |
161 | + public void setColor(Vector color) { | |
167 | 162 | if (null == color) { |
168 | 163 | throw new MonkeyRuntimeException("Color cannot be null."); |
169 | 164 | } |
@@ -184,93 +179,93 @@ public class SkyBox implements Sky { | ||
184 | 179 | */ |
185 | 180 | public void render() { |
186 | 181 | |
187 | - gl.color4f(color.x, color.y, color.z, 1.0f); | |
188 | - gl.enable(GL.TEXTURE_2D); | |
189 | - gl.disable(GL.DEPTH_TEST); | |
182 | + GL.glColor4f(color.x, color.y, color.z, 1.0f); | |
183 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
184 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
190 | 185 | |
191 | - gl.pushMatrix(); | |
192 | - gl.translatef(center.x, center.y, center.z); | |
186 | + GL.glPushMatrix(); | |
187 | + GL.glTranslatef(center.x, center.y, center.z); | |
193 | 188 | |
194 | 189 | //front face |
195 | 190 | TextureManager.getTextureManager().bind(textures[FRONT]); |
196 | - gl.begin(GL.TRIANGLE_FAN); | |
197 | - gl.texCoord2f(1.0f, 1.0f); | |
198 | - gl.vertex3f(size, size, size); | |
199 | - gl.texCoord2f(1.0f, 0.0f); | |
200 | - gl.vertex3f(size, -size, size); | |
201 | - gl.texCoord2f(0.0f, 0.0f); | |
202 | - gl.vertex3f(-size, -size, size); | |
203 | - gl.texCoord2f(0.0f, 1.0f); | |
204 | - gl.vertex3f(-size, size, size); | |
205 | - gl.end(); | |
191 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
192 | + GL.glTexCoord2f(1.0f, 1.0f); | |
193 | + GL.glVertex3f(size, size, size); | |
194 | + GL.glTexCoord2f(1.0f, 0.0f); | |
195 | + GL.glVertex3f(size, -size, size); | |
196 | + GL.glTexCoord2f(0.0f, 0.0f); | |
197 | + GL.glVertex3f(-size, -size, size); | |
198 | + GL.glTexCoord2f(0.0f, 1.0f); | |
199 | + GL.glVertex3f(-size, size, size); | |
200 | + GL.glEnd(); | |
206 | 201 | |
207 | 202 | //back face |
208 | 203 | TextureManager.getTextureManager().bind(textures[BACK]); |
209 | - gl.begin(GL.TRIANGLE_FAN); | |
210 | - gl.texCoord2f(1.0f, 1.0f); | |
211 | - gl.vertex3f(-size, size, -size); | |
212 | - gl.texCoord2f(1.0f, 0.0f); | |
213 | - gl.vertex3f(-size, -size, -size); | |
214 | - gl.texCoord2f(0.0f, 0.0f); | |
215 | - gl.vertex3f(size, -size, -size); | |
216 | - gl.texCoord2f(0.0f, 1.0f); | |
217 | - gl.vertex3f(size, size, -size); | |
218 | - gl.end(); | |
204 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
205 | + GL.glTexCoord2f(1.0f, 1.0f); | |
206 | + GL.glVertex3f(-size, size, -size); | |
207 | + GL.glTexCoord2f(1.0f, 0.0f); | |
208 | + GL.glVertex3f(-size, -size, -size); | |
209 | + GL.glTexCoord2f(0.0f, 0.0f); | |
210 | + GL.glVertex3f(size, -size, -size); | |
211 | + GL.glTexCoord2f(0.0f, 1.0f); | |
212 | + GL.glVertex3f(size, size, -size); | |
213 | + GL.glEnd(); | |
219 | 214 | |
220 | 215 | //right face |
221 | 216 | TextureManager.getTextureManager().bind(textures[RIGHT]); |
222 | - gl.begin(GL.TRIANGLE_FAN); | |
223 | - gl.texCoord2f(1.0f, 1.0f); | |
224 | - gl.vertex3f(size, size, -size); | |
225 | - gl.texCoord2f(1.0f, 0.0f); | |
226 | - gl.vertex3f(size, -size, -size); | |
227 | - gl.texCoord2f(0.0f, 0.0f); | |
228 | - gl.vertex3f(size, -size, size); | |
229 | - gl.texCoord2f(0.0f, 1.0f); | |
230 | - gl.vertex3f(size, size, size); | |
231 | - gl.end(); | |
217 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
218 | + GL.glTexCoord2f(1.0f, 1.0f); | |
219 | + GL.glVertex3f(size, size, -size); | |
220 | + GL.glTexCoord2f(1.0f, 0.0f); | |
221 | + GL.glVertex3f(size, -size, -size); | |
222 | + GL.glTexCoord2f(0.0f, 0.0f); | |
223 | + GL.glVertex3f(size, -size, size); | |
224 | + GL.glTexCoord2f(0.0f, 1.0f); | |
225 | + GL.glVertex3f(size, size, size); | |
226 | + GL.glEnd(); | |
232 | 227 | |
233 | 228 | //left face |
234 | 229 | TextureManager.getTextureManager().bind(textures[LEFT]); |
235 | - gl.begin(GL.TRIANGLE_FAN); | |
236 | - gl.texCoord2f(1.0f, 1.0f); | |
237 | - gl.vertex3f(-size, size, size); | |
238 | - gl.texCoord2f(1.0f, 0.0f); | |
239 | - gl.vertex3f(-size, -size, size); | |
240 | - gl.texCoord2f(0.0f, 0.0f); | |
241 | - gl.vertex3f(-size, -size, -size); | |
242 | - gl.texCoord2f(0.0f, 1.0f); | |
243 | - gl.vertex3f(-size, size, -size); | |
244 | - gl.end(); | |
230 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
231 | + GL.glTexCoord2f(1.0f, 1.0f); | |
232 | + GL.glVertex3f(-size, size, size); | |
233 | + GL.glTexCoord2f(1.0f, 0.0f); | |
234 | + GL.glVertex3f(-size, -size, size); | |
235 | + GL.glTexCoord2f(0.0f, 0.0f); | |
236 | + GL.glVertex3f(-size, -size, -size); | |
237 | + GL.glTexCoord2f(0.0f, 1.0f); | |
238 | + GL.glVertex3f(-size, size, -size); | |
239 | + GL.glEnd(); | |
245 | 240 | |
246 | 241 | //top face |
247 | 242 | TextureManager.getTextureManager().bind(textures[TOP]); |
248 | - gl.begin(GL.TRIANGLE_FAN); | |
249 | - gl.texCoord2f(0.0f, 0.0f); | |
250 | - gl.vertex3f(-size, size, size); | |
251 | - gl.texCoord2f(0.0f, 1.0f); | |
252 | - gl.vertex3f(-size, size, -size); | |
253 | - gl.texCoord2f(1.0f, 1.0f); | |
254 | - gl.vertex3f(size, size, -size); | |
255 | - gl.texCoord2f(1.0f, 0.0f); | |
256 | - gl.vertex3f(size, size, size); | |
257 | - gl.end(); | |
243 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
244 | + GL.glTexCoord2f(0.0f, 0.0f); | |
245 | + GL.glVertex3f(-size, size, size); | |
246 | + GL.glTexCoord2f(0.0f, 1.0f); | |
247 | + GL.glVertex3f(-size, size, -size); | |
248 | + GL.glTexCoord2f(1.0f, 1.0f); | |
249 | + GL.glVertex3f(size, size, -size); | |
250 | + GL.glTexCoord2f(1.0f, 0.0f); | |
251 | + GL.glVertex3f(size, size, size); | |
252 | + GL.glEnd(); | |
258 | 253 | |
259 | 254 | //bottom face |
260 | 255 | TextureManager.getTextureManager().bind(textures[BOTTOM]); |
261 | - gl.begin(GL.TRIANGLE_FAN); | |
262 | - gl.texCoord2f(0.0f, 0.0f); | |
263 | - gl.vertex3f(-size, -size, -size); | |
264 | - gl.texCoord2f(0.0f, 1.0f); | |
265 | - gl.vertex3f(-size, -size, size); | |
266 | - gl.texCoord2f(1.0f, 1.0f); | |
267 | - gl.vertex3f(size, -size, size); | |
268 | - gl.texCoord2f(1.0f, 0.0f); | |
269 | - gl.vertex3f(size, -size, -size); | |
270 | - gl.end(); | |
271 | - gl.popMatrix(); | |
256 | + GL.glBegin(GL.GL_TRIANGLE_FAN); | |
257 | + GL.glTexCoord2f(0.0f, 0.0f); | |
258 | + GL.glVertex3f(-size, -size, -size); | |
259 | + GL.glTexCoord2f(0.0f, 1.0f); | |
260 | + GL.glVertex3f(-size, -size, size); | |
261 | + GL.glTexCoord2f(1.0f, 1.0f); | |
262 | + GL.glVertex3f(size, -size, size); | |
263 | + GL.glTexCoord2f(1.0f, 0.0f); | |
264 | + GL.glVertex3f(size, -size, -size); | |
265 | + GL.glEnd(); | |
266 | + GL.glPopMatrix(); | |
272 | 267 | |
273 | - gl.enable(GL.DEPTH_TEST); | |
268 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
274 | 269 | } |
275 | 270 | |
276 | 271 | } |
@@ -35,11 +35,11 @@ import java.util.logging.Level; | ||
35 | 35 | |
36 | 36 | import jme.exception.MonkeyGLException; |
37 | 37 | import jme.geometry.model.Vertex; |
38 | -import jme.system.DisplaySystem; | |
39 | 38 | import jme.texture.TextureManager; |
40 | 39 | import jme.utility.LoggingSystem; |
41 | 40 | |
42 | 41 | import org.lwjgl.opengl.GL; |
42 | +import org.lwjgl.opengl.Window; | |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * <code>SkyDome</code> defines an implementation of the sky interface where |
@@ -52,11 +52,11 @@ import org.lwjgl.opengl.GL; | ||
52 | 52 | * <a href="http://www.spheregames.com/files/SkyDomesPDF.zip">this</a> |
53 | 53 | * PDF file. |
54 | 54 | * @author Mark Powell |
55 | + * @version $Id: SkyDome.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
55 | 56 | */ |
56 | 57 | public class SkyDome implements Sky { |
57 | 58 | |
58 | 59 | private int texId; |
59 | - private GL gl; | |
60 | 60 | |
61 | 61 | //attributes of the dome |
62 | 62 | private float radius; |
@@ -97,11 +97,9 @@ public class SkyDome implements Sky { | ||
97 | 97 | float hTile, |
98 | 98 | float vTile) { |
99 | 99 | |
100 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
101 | - | |
102 | - if (null == gl) { | |
100 | + if (!Window.isCreated()) { | |
103 | 101 | throw new MonkeyGLException( |
104 | - "GL must be initialized before " + "calling SkyDome."); | |
102 | + "Window must be created before SkyDome."); | |
105 | 103 | } |
106 | 104 | |
107 | 105 | this.radius = radius; |
@@ -126,8 +124,8 @@ public class SkyDome implements Sky { | ||
126 | 124 | texId = |
127 | 125 | TextureManager.getTextureManager().loadTexture( |
128 | 126 | filename, |
129 | - GL.LINEAR_MIPMAP_LINEAR, | |
130 | - GL.LINEAR, | |
127 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
128 | + GL.GL_LINEAR, | |
131 | 129 | true); |
132 | 130 | } |
133 | 131 |
@@ -188,31 +186,31 @@ public class SkyDome implements Sky { | ||
188 | 186 | * texture. |
189 | 187 | */ |
190 | 188 | public void render() { |
191 | - gl.enable(GL.TEXTURE_2D); | |
192 | - gl.disable(GL.DEPTH_TEST); | |
193 | - gl.cullFace(GL.FRONT); | |
194 | - gl.bindTexture(GL.TEXTURE_2D, texId); | |
189 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
190 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
191 | + GL.glCullFace(GL.GL_FRONT); | |
192 | + GL.glBindTexture(GL.GL_TEXTURE_2D, texId); | |
195 | 193 | |
196 | - gl.pushMatrix(); | |
197 | - gl.rotatef(270, 1.0f, 0.0f, 0.0f); | |
198 | - gl.rotatef(rotation, 0.0f, 0.0f, 1.0f); | |
199 | - gl.begin(GL.TRIANGLE_STRIP); | |
194 | + GL.glPushMatrix(); | |
195 | + GL.glRotatef(270, 1.0f, 0.0f, 0.0f); | |
196 | + GL.glRotatef(rotation, 0.0f, 0.0f, 1.0f); | |
197 | + GL.glBegin(GL.GL_TRIANGLE_STRIP); | |
200 | 198 | |
201 | 199 | for (int i = 0; i < numVertices; i++) { |
202 | - gl.color3f(1.0f, 1.0f, 1.0f); | |
200 | + GL.glColor3f(1.0f, 1.0f, 1.0f); | |
203 | 201 | |
204 | - gl.texCoord2f( | |
202 | + GL.glTexCoord2f( | |
205 | 203 | vertices[i].u + xTexAnimation, |
206 | 204 | vertices[i].v + yTexAnimation); |
207 | - gl.vertex3f(vertices[i].x, vertices[i].y, vertices[i].z); | |
205 | + GL.glVertex3f(vertices[i].x, vertices[i].y, vertices[i].z); | |
208 | 206 | } |
209 | 207 | |
210 | - gl.end(); | |
208 | + GL.glEnd(); | |
211 | 209 | |
212 | - gl.popMatrix(); | |
213 | - gl.disable(GL.TEXTURE_2D); | |
214 | - gl.enable(GL.DEPTH_TEST); | |
215 | - gl.cullFace(GL.BACK); | |
210 | + GL.glPopMatrix(); | |
211 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
212 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
213 | + GL.glCullFace(GL.GL_BACK); | |
216 | 214 | } |
217 | 215 | |
218 | 216 | /** |
@@ -33,9 +33,7 @@ package jme.locale.external.feature; | ||
33 | 33 | |
34 | 34 | import java.util.logging.Level; |
35 | 35 | |
36 | -import jme.exception.MonkeyGLException; | |
37 | 36 | import jme.exception.MonkeyRuntimeException; |
38 | -import jme.system.DisplaySystem; | |
39 | 37 | import jme.texture.TextureManager; |
40 | 38 | import jme.utility.LoggingSystem; |
41 | 39 |
@@ -45,10 +43,10 @@ import org.lwjgl.opengl.GL; | ||
45 | 43 | * <code>WaterMesh</code> creates a mesh that represents water height values. |
46 | 44 | * This mesh contains a wave origin that causes ripples to flow outward. |
47 | 45 | * @author Mark Powell |
46 | + * @version $Id: WaterMesh.java,v 1.2 2003-09-03 16:20:51 mojomonkey Exp $ | |
48 | 47 | */ |
49 | 48 | public class WaterMesh implements Water { |
50 | 49 | private int texId; |
51 | - private GL gl; | |
52 | 50 | private float height; |
53 | 51 | private int size; |
54 | 52 | private int spacing; |
@@ -74,13 +72,7 @@ public class WaterMesh implements Water { | ||
74 | 72 | * @throws MonkeyRuntimeException if size is negative. |
75 | 73 | */ |
76 | 74 | public WaterMesh(int size, int spacing, float amplitude) { |
77 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
78 | - | |
79 | - if (null == gl) { | |
80 | - throw new MonkeyGLException( | |
81 | - "OpenGL Context must be created before WaterMesh."); | |
82 | - } | |
83 | - | |
75 | + | |
84 | 76 | water = new float[size][size]; |
85 | 77 | wt = new float[size][size]; |
86 | 78 | v = -4; |
@@ -111,8 +103,8 @@ public class WaterMesh implements Water { | ||
111 | 103 | texId = |
112 | 104 | TextureManager.getTextureManager().loadTexture( |
113 | 105 | filename, |
114 | - GL.LINEAR_MIPMAP_LINEAR, | |
115 | - GL.LINEAR, | |
106 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
107 | + GL.GL_LINEAR, | |
116 | 108 | true); |
117 | 109 | } |
118 | 110 |
@@ -169,17 +161,17 @@ public class WaterMesh implements Water { | ||
169 | 161 | * <code>render</code> displays the water mesh to the view port. |
170 | 162 | */ |
171 | 163 | public void render() { |
172 | - gl.enable(GL.BLEND); | |
173 | - gl.enable(GL.TEXTURE_2D); | |
174 | - gl.enable(GL.DEPTH_TEST); | |
175 | - gl.disable(GL.CULL_FACE); | |
164 | + GL.glEnable(GL.GL_BLEND); | |
165 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
166 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
167 | + GL.glDisable(GL.GL_CULL_FACE); | |
176 | 168 | TextureManager.getTextureManager().bind(texId); |
177 | 169 | float tx, ty; |
178 | 170 | |
179 | 171 | /* Draw water */ |
180 | - gl.color4f(1f, 1f, 1f, 0.6f); | |
172 | + GL.glColor4f(1f, 1f, 1f, 0.6f); | |
181 | 173 | |
182 | - gl.begin(GL.TRIANGLES); | |
174 | + GL.glBegin(GL.GL_TRIANGLES); | |
183 | 175 | float td = (float)1 / size; |
184 | 176 | |
185 | 177 | for (int i = 0; i < size - 1; i++) { |
@@ -188,38 +180,38 @@ public class WaterMesh implements Water { | ||
188 | 180 | for (int j = 0; j < size - 1; j++) { |
189 | 181 | ty = (float)j / size; |
190 | 182 | |
191 | - gl.texCoord2f(tx, ty); | |
192 | - gl.vertex3f(spacing * i, water[i][j] + height, spacing * j); | |
193 | - gl.texCoord2f(tx + td, ty); | |
194 | - gl.vertex3f( | |
183 | + GL.glTexCoord2f(tx, ty); | |
184 | + GL.glVertex3f(spacing * i, water[i][j] + height, spacing * j); | |
185 | + GL.glTexCoord2f(tx + td, ty); | |
186 | + GL.glVertex3f( | |
195 | 187 | spacing * (i + 1), |
196 | 188 | water[i + 1][j] + height, |
197 | 189 | spacing * j); |
198 | - gl.texCoord2f(tx + td, ty + td); | |
199 | - gl.vertex3f( | |
190 | + GL.glTexCoord2f(tx + td, ty + td); | |
191 | + GL.glVertex3f( | |
200 | 192 | spacing * (i + 1), |
201 | 193 | water[i + 1][j + 1] + height, |
202 | 194 | spacing * (j + 1)); |
203 | 195 | |
204 | - gl.texCoord2f(tx, ty + td); | |
205 | - gl.vertex3f( | |
196 | + GL.glTexCoord2f(tx, ty + td); | |
197 | + GL.glVertex3f( | |
206 | 198 | spacing * i, |
207 | 199 | water[i][j + 1] + height, |
208 | 200 | spacing * (j + 1)); |
209 | - gl.texCoord2f(tx, ty); | |
210 | - gl.vertex3f(spacing * i, water[i][j] + height, spacing * j); | |
211 | - gl.texCoord2f(tx + td, ty + td); | |
212 | - gl.vertex3f( | |
201 | + GL.glTexCoord2f(tx, ty); | |
202 | + GL.glVertex3f(spacing * i, water[i][j] + height, spacing * j); | |
203 | + GL.glTexCoord2f(tx + td, ty + td); | |
204 | + GL.glVertex3f( | |
213 | 205 | spacing * (i + 1), |
214 | 206 | water[i + 1][j + 1] + height, |
215 | 207 | spacing * (j + 1)); |
216 | 208 | } |
217 | 209 | } |
218 | - gl.end(); | |
210 | + GL.glEnd(); | |
219 | 211 | |
220 | - gl.disable(GL.BLEND); | |
221 | - gl.disable(GL.TEXTURE_2D); | |
222 | - gl.disable(GL.DEPTH_TEST); | |
223 | - gl.enable(GL.CULL_FACE); | |
212 | + GL.glDisable(GL.GL_BLEND); | |
213 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
214 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
215 | + GL.glEnable(GL.GL_CULL_FACE); | |
224 | 216 | } |
225 | 217 | } |
@@ -33,7 +33,6 @@ package jme.locale.external.feature; | ||
33 | 33 | |
34 | 34 | import jme.exception.MonkeyRuntimeException; |
35 | 35 | import jme.math.Vector; |
36 | -import jme.system.DisplaySystem; | |
37 | 36 | import jme.texture.TextureManager; |
38 | 37 | |
39 | 38 | import org.lwjgl.opengl.GL; |
@@ -46,7 +45,7 @@ import org.lwjgl.opengl.GL; | ||
46 | 45 | * the texture sliding across the plane. |
47 | 46 | * |
48 | 47 | * @author Mark Powell |
49 | - * @version 1 | |
48 | + * @version $Id: WaterPlane.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
50 | 49 | */ |
51 | 50 | public class WaterPlane implements Water { |
52 | 51 |
@@ -77,8 +76,6 @@ public class WaterPlane implements Water { | ||
77 | 76 | private float changeX = 0.0f; |
78 | 77 | private float changeZ = 0.0f; |
79 | 78 | |
80 | - //opengl object | |
81 | - private GL gl; | |
82 | 79 | |
83 | 80 | /** |
84 | 81 | * Constructor instantiates a new <code>WaterPlane</code> object. |
@@ -97,7 +94,6 @@ public class WaterPlane implements Water { | ||
97 | 94 | this.baseLevel = baseLevel; |
98 | 95 | this.variation = variation; |
99 | 96 | |
100 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
101 | 97 | } |
102 | 98 | |
103 | 99 | /** |
@@ -111,8 +107,8 @@ public class WaterPlane implements Water { | ||
111 | 107 | } |
112 | 108 | texId = TextureManager.getTextureManager().loadTexture( |
113 | 109 | filename, |
114 | - GL.LINEAR_MIPMAP_LINEAR, | |
115 | - GL.LINEAR, | |
110 | + GL.GL_LINEAR_MIPMAP_LINEAR, | |
111 | + GL.GL_LINEAR, | |
116 | 112 | true); |
117 | 113 | } |
118 | 114 |
@@ -197,34 +193,34 @@ public class WaterPlane implements Water { | ||
197 | 193 | * texture, color and location. |
198 | 194 | */ |
199 | 195 | public void render() { |
200 | - gl.enable(GL.BLEND); | |
201 | - gl.enable(GL.TEXTURE_2D); | |
202 | - gl.enable(GL.DEPTH_TEST); | |
203 | - gl.disable(GL.CULL_FACE); | |
204 | - gl.blendFunc(GL.SRC_ALPHA, GL.ONE); | |
196 | + GL.glEnable(GL.GL_BLEND); | |
197 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
198 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
199 | + GL.glDisable(GL.GL_CULL_FACE); | |
200 | + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); | |
205 | 201 | |
206 | - gl.color4f(color.x, color.y, color.z, transparency); | |
202 | + GL.glColor4f(color.x, color.y, color.z, transparency); | |
207 | 203 | |
208 | 204 | TextureManager.getTextureManager().bind(texId); |
209 | 205 | |
210 | - gl.begin(GL.TRIANGLE_STRIP); | |
206 | + GL.glBegin(GL.GL_TRIANGLE_STRIP); | |
211 | 207 | |
212 | 208 | |
213 | - gl.texCoord2f(changeX, changeZ); | |
214 | - gl.vertex3f(0.0f, currentLevel, 0.0f); | |
215 | - gl.texCoord2f(changeX + repeat, changeZ); | |
216 | - gl.vertex3f(size, currentLevel, 0.0f); | |
217 | - gl.texCoord2f(changeX, changeZ+repeat); | |
218 | - gl.vertex3f(0.0f, currentLevel, size); | |
219 | - gl.texCoord2f(changeX + repeat, changeZ + repeat); | |
220 | - gl.vertex3f(size, currentLevel, size); | |
209 | + GL.glTexCoord2f(changeX, changeZ); | |
210 | + GL.glVertex3f(0.0f, currentLevel, 0.0f); | |
211 | + GL.glTexCoord2f(changeX + repeat, changeZ); | |
212 | + GL.glVertex3f(size, currentLevel, 0.0f); | |
213 | + GL.glTexCoord2f(changeX, changeZ+repeat); | |
214 | + GL.glVertex3f(0.0f, currentLevel, size); | |
215 | + GL.glTexCoord2f(changeX + repeat, changeZ + repeat); | |
216 | + GL.glVertex3f(size, currentLevel, size); | |
221 | 217 | |
222 | - gl.end(); | |
218 | + GL.glEnd(); | |
223 | 219 | |
224 | - gl.disable(GL.BLEND); | |
225 | - gl.disable(GL.TEXTURE_2D); | |
226 | - gl.disable(GL.DEPTH_TEST); | |
227 | - gl.enable(GL.CULL_FACE); | |
220 | + GL.glDisable(GL.GL_BLEND); | |
221 | + GL.glDisable(GL.GL_TEXTURE_2D); | |
222 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
223 | + GL.glEnable(GL.GL_CULL_FACE); | |
228 | 224 | } |
229 | 225 | |
230 | 226 | } |
@@ -48,11 +48,11 @@ import jme.utility.LoggingSystem; | ||
48 | 48 | |
49 | 49 | import org.lwjgl.Display; |
50 | 50 | import org.lwjgl.DisplayMode; |
51 | -import org.lwjgl.Sys; | |
52 | 51 | import org.lwjgl.input.Keyboard; |
53 | 52 | import org.lwjgl.input.Mouse; |
54 | 53 | import org.lwjgl.opengl.GL; |
55 | -import org.lwjgl.opengl.GLU; | |
54 | +import org.lwjgl.opengl.GLCaps; | |
55 | +import org.lwjgl.opengl.Window; | |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * <code>DisplaySystem</code> manages the Window and OpenGL context of the |
@@ -82,10 +82,6 @@ public class DisplaySystem { | ||
82 | 82 | //Singleton reference. |
83 | 83 | private static DisplaySystem instance = null; |
84 | 84 | |
85 | - //the OpenGL objects | |
86 | - private static GL gl; | |
87 | - private static GLU glu; | |
88 | - | |
89 | 85 | //attributes of the window |
90 | 86 | private int height; |
91 | 87 | private int width; |
@@ -179,7 +175,7 @@ public class DisplaySystem { | ||
179 | 175 | this.title = title; |
180 | 176 | |
181 | 177 | //recreate the display |
182 | - gl.destroy(); | |
178 | + Window.destroy(); | |
183 | 179 | initDisplay(); |
184 | 180 | Keyboard.destroy(); |
185 | 181 | Mouse.destroy(); |
@@ -280,30 +276,6 @@ public class DisplaySystem { | ||
280 | 276 | } |
281 | 277 | |
282 | 278 | /** |
283 | - * <code>getGL</code> returns the OpenGL core object. This <code>GL</code> | |
284 | - * object can be used to make any calls to the OpenGL core gl functions. | |
285 | - * | |
286 | - * @return the <code>GL</code> object referred to this display. If | |
287 | - * <code>createDisplaySystem</code> has not been called before invoking | |
288 | - * this method, null will be returned. | |
289 | - */ | |
290 | - public GL getGL() { | |
291 | - return gl; | |
292 | - } | |
293 | - | |
294 | - /** | |
295 | - * <code>getGLU</code> returns the OpenGL utility object. This <code>GLU</code> | |
296 | - * object can be used to make any calls to the OpenGL utility functions. | |
297 | - * | |
298 | - * @return the <code>GLU</code> object referred to this display. If | |
299 | - * <code>createDisplaySystem</code> has not been called before invoking | |
300 | - * this method, null will be returned. | |
301 | - */ | |
302 | - public GLU getGLU() { | |
303 | - return glu; | |
304 | - } | |
305 | - | |
306 | - /** | |
307 | 279 | * <code>getDisplaySystem</code> returns the reference to the singleton |
308 | 280 | * object of the <code>DisplaySystem</code>. After a call to |
309 | 281 | * <code>createDisplaySystem</code> is made, you can retrieve any |
@@ -359,11 +331,11 @@ public class DisplaySystem { | ||
359 | 331 | * @param on true turn on culling, false turn it off. |
360 | 332 | */ |
361 | 333 | public void cullMode(int mode, boolean on) { |
362 | - gl.cullFace(mode); | |
334 | + GL.glCullFace(mode); | |
363 | 335 | if (on) { |
364 | - gl.enable(GL.CULL_FACE); | |
336 | + GL.glEnable(GL.GL_CULL_FACE); | |
365 | 337 | } else { |
366 | - gl.disable(GL.CULL_FACE); | |
338 | + GL.glDisable(GL.GL_CULL_FACE); | |
367 | 339 | } |
368 | 340 | } |
369 | 341 |
@@ -395,15 +367,14 @@ public class DisplaySystem { | ||
395 | 367 | .allocateDirect(width * height * 4) |
396 | 368 | .order(ByteOrder.nativeOrder()) |
397 | 369 | .asIntBuffer(); |
398 | - int buffh = Sys.getDirectBufferAddress(buff); | |
399 | - gl.readPixels( | |
370 | + GL.glReadPixels( | |
400 | 371 | 0, |
401 | 372 | 0, |
402 | 373 | width, |
403 | 374 | height, |
404 | - GL.BGRA, | |
405 | - GL.UNSIGNED_BYTE, | |
406 | - buffh); | |
375 | + GL.GL_BGRA, | |
376 | + GL.GL_UNSIGNED_BYTE, | |
377 | + buff); | |
407 | 378 | BufferedImage img = |
408 | 379 | new BufferedImage( |
409 | 380 | width, |
@@ -452,7 +423,7 @@ public class DisplaySystem { | ||
452 | 423 | |
453 | 424 | if (fullscreen) { |
454 | 425 | Display.setDisplayMode(mode); |
455 | - gl = new GL(title, bpp, 0, 16, 0); | |
426 | + Window.create(title, bpp, 0, 16, 0); | |
456 | 427 | } else { |
457 | 428 | int x, y; |
458 | 429 | x = |
@@ -462,11 +433,10 @@ public class DisplaySystem { | ||
462 | 433 | (Toolkit.getDefaultToolkit().getScreenSize().height |
463 | 434 | - height) |
464 | 435 | / 2; |
465 | - gl = new GL(title, x, y, width, height, bpp, 0, 16, 0); | |
436 | + Window.create(title, x, y, width, height, bpp, 0, 16, 0); | |
466 | 437 | } |
467 | 438 | |
468 | - gl.create(); | |
469 | - gl.determineAvailableExtensions(); | |
439 | + GLCaps.determineAvailableExtensions(); | |
470 | 440 | |
471 | 441 | LoggingSystem.getLoggingSystem().getLogger().log( |
472 | 442 | Level.INFO, |
@@ -477,7 +447,5 @@ public class DisplaySystem { | ||
477 | 447 | "Failed to create display due to " + e); |
478 | 448 | System.exit(1); |
479 | 449 | } |
480 | - | |
481 | - glu = new GLU(gl); | |
482 | 450 | } |
483 | 451 | } |
@@ -55,12 +55,11 @@ import javax.swing.ImageIcon; | ||
55 | 55 | |
56 | 56 | import jme.exception.MonkeyGLException; |
57 | 57 | import jme.exception.MonkeyRuntimeException; |
58 | -import jme.system.DisplaySystem; | |
59 | 58 | import jme.utility.LoggingSystem; |
60 | 59 | |
61 | -import org.lwjgl.Sys; | |
62 | 60 | import org.lwjgl.opengl.GL; |
63 | 61 | import org.lwjgl.opengl.GLU; |
62 | +import org.lwjgl.opengl.Window; | |
64 | 63 | |
65 | 64 | /** |
66 | 65 | * <code>TextureManager</code> maintains all textures within the running |
@@ -122,13 +121,10 @@ public class TextureManager { | ||
122 | 121 | * @throws MonkeyGLException if OpenGL context has not been created. |
123 | 122 | */ |
124 | 123 | private TextureManager() { |
125 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
126 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
127 | 124 | |
128 | - if (null == gl || null == glu) { | |
125 | + if (!Window.isCreated()) { | |
129 | 126 | throw new MonkeyGLException( |
130 | - "GL/GLU must be initialized before " | |
131 | - + "calling TextureManager."); | |
127 | + "Window must be created before " + "TextureManager."); | |
132 | 128 | } |
133 | 129 | textureList = new HashMap(); |
134 | 130 | keyList = new ArrayList(); |
@@ -330,7 +326,7 @@ public class TextureManager { | ||
330 | 326 | |
331 | 327 | if (id != boundID) { |
332 | 328 | boundID = id; |
333 | - gl.bindTexture(GL.TEXTURE_2D, id); | |
329 | + GL.glBindTexture(GL.GL_TEXTURE_2D, id); | |
334 | 330 | } |
335 | 331 | |
336 | 332 | return true; |
@@ -353,7 +349,7 @@ public class TextureManager { | ||
353 | 349 | public void bind(int id) { |
354 | 350 | if (id != boundID) { |
355 | 351 | boundID = id; |
356 | - gl.bindTexture(GL.TEXTURE_2D, id); | |
352 | + GL.glBindTexture(GL.GL_TEXTURE_2D, id); | |
357 | 353 | } |
358 | 354 | } |
359 | 355 |
@@ -378,9 +374,7 @@ public class TextureManager { | ||
378 | 374 | .order(ByteOrder.nativeOrder()) |
379 | 375 | .asIntBuffer(); |
380 | 376 | buf.put(id); |
381 | - int bufPtr = Sys.getDirectBufferAddress(buf); | |
382 | - | |
383 | - gl.deleteTextures(1, bufPtr); | |
377 | + GL.glDeleteTextures(buf); | |
384 | 378 | textureList.remove(file); |
385 | 379 | return true; |
386 | 380 | } |
@@ -404,16 +398,14 @@ public class TextureManager { | ||
404 | 398 | for (int i = 0; i < keyList.size(); i++) { |
405 | 399 | key = ((TextureData) keyList.get(i)).name; |
406 | 400 | id = ((Integer) textureList.get(key)).intValue(); |
407 | - if (gl.isTexture(id)) { | |
401 | + if (GL.glIsTexture(id)) { | |
408 | 402 | IntBuffer buf = |
409 | 403 | ByteBuffer |
410 | 404 | .allocateDirect(4) |
411 | 405 | .order(ByteOrder.nativeOrder()) |
412 | 406 | .asIntBuffer(); |
413 | 407 | buf.put(id); |
414 | - int bufPtr = Sys.getDirectBufferAddress(buf); | |
415 | - | |
416 | - gl.deleteTextures(1, bufPtr); | |
408 | + GL.glDeleteTextures(buf); | |
417 | 409 | } |
418 | 410 | } |
419 | 411 |
@@ -505,8 +497,6 @@ public class TextureManager { | ||
505 | 497 | //Get a pointer to the image memory |
506 | 498 | ByteBuffer scratch = |
507 | 499 | ByteBuffer.allocateDirect(4 * tex.getWidth() * tex.getHeight()); |
508 | - int dataAddress = Sys.getDirectBufferAddress(scratch); | |
509 | - | |
510 | 500 | byte data[] = |
511 | 501 | (byte[]) tex.getRaster().getDataElements( |
512 | 502 | 0, |
@@ -516,47 +506,53 @@ public class TextureManager { | ||
516 | 506 | null); |
517 | 507 | scratch.clear(); |
518 | 508 | scratch.put(data); |
509 | + scratch.rewind(); | |
519 | 510 | |
520 | - //Create A IntBuffer For Image Address In Memory | |
511 | + // Create A IntBuffer For Image Address In Memory | |
521 | 512 | IntBuffer buf = |
522 | 513 | ByteBuffer |
523 | 514 | .allocateDirect(4) |
524 | 515 | .order(ByteOrder.nativeOrder()) |
525 | 516 | .asIntBuffer(); |
526 | - int bufPtr = Sys.getDirectBufferAddress(buf); | |
527 | 517 | |
528 | 518 | //Create the texture |
529 | - gl.genTextures(1, bufPtr); | |
519 | + GL.glGenTextures(buf); | |
530 | 520 | |
531 | - gl.bindTexture(GL.TEXTURE_2D, buf.get(0)); | |
521 | + GL.glBindTexture(GL.GL_TEXTURE_2D, buf.get(0)); | |
532 | 522 | |
533 | 523 | // Linear Filtering |
534 | - gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, minFilter); | |
524 | + GL.glTexParameteri( | |
525 | + GL.GL_TEXTURE_2D, | |
526 | + GL.GL_TEXTURE_MIN_FILTER, | |
527 | + minFilter); | |
535 | 528 | // Linear Filtering |
536 | - gl.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, magFilter); | |
529 | + GL.glTexParameteri( | |
530 | + GL.GL_TEXTURE_2D, | |
531 | + GL.GL_TEXTURE_MAG_FILTER, | |
532 | + magFilter); | |
537 | 533 | |
538 | 534 | if (isMipmapped) { |
539 | 535 | //generate the mipmaps |
540 | - glu.build2DMipmaps( | |
541 | - GL.TEXTURE_2D, | |
536 | + GLU.gluBuild2DMipmaps( | |
537 | + GL.GL_TEXTURE_2D, | |
542 | 538 | 3, |
543 | 539 | tex.getWidth(), |
544 | 540 | tex.getHeight(), |
545 | - GL.RGB, | |
546 | - GL.UNSIGNED_BYTE, | |
547 | - dataAddress); | |
541 | + GL.GL_RGB, | |
542 | + GL.GL_UNSIGNED_BYTE, | |
543 | + scratch); | |
548 | 544 | } else { |
549 | 545 | // Generate The Texture |
550 | - gl.texImage2D( | |
551 | - GL.TEXTURE_2D, | |
546 | + GL.glTexImage2D( | |
547 | + GL.GL_TEXTURE_2D, | |
552 | 548 | 0, |
553 | - GL.RGB, | |
549 | + GL.GL_RGB, | |
554 | 550 | tex.getWidth(), |
555 | 551 | tex.getHeight(), |
556 | 552 | 0, |
557 | - GL.RGB, | |
558 | - GL.UNSIGNED_BYTE, | |
559 | - dataAddress); | |
553 | + GL.GL_RGB, | |
554 | + GL.GL_UNSIGNED_BYTE, | |
555 | + scratch); | |
560 | 556 | } |
561 | 557 | |
562 | 558 | LoggingSystem.getLoggingSystem().getLogger().log( |
@@ -893,8 +889,7 @@ public class TextureManager { | ||
893 | 889 | |
894 | 890 | private short constructShort(byte[] in, int offset) { |
895 | 891 | short ret = (short) (in[offset + 1] & 0xff); |
896 | - ret = | |
897 | - (short) ((ret << 8) | (short) (in[offset + 0] & 0xff)); | |
892 | + ret = (short) ((ret << 8) | (short) (in[offset + 0] & 0xff)); | |
898 | 893 | return (ret); |
899 | 894 | } |
900 | 895 |
@@ -43,7 +43,6 @@ import jme.locale.Locale; | ||
43 | 43 | import jme.locale.external.feature.Water; |
44 | 44 | import jme.entity.camera.Camera; |
45 | 45 | import jme.entity.effects.ParticleSystem; |
46 | -import jme.system.DisplaySystem; | |
47 | 46 | import jme.utility.LoggingSystem; |
48 | 47 | |
49 | 48 | /** |
@@ -78,7 +77,7 @@ public class World { | ||
78 | 77 | */ |
79 | 78 | public World() { |
80 | 79 | entityList = new ArrayList(); |
81 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
80 | + //gl = DisplaySystem.getDisplaySystem().getGL(); | |
82 | 81 | LoggingSystem.getLoggingSystem().getLogger().log(Level.INFO, |
83 | 82 | "Created World"); |
84 | 83 | } |
@@ -230,9 +229,9 @@ public class World { | ||
230 | 229 | |
231 | 230 | if(null != locale) { |
232 | 231 | if(o instanceof ParticleSystem && locale.useDistanceFog()) { |
233 | - gl.disable(GL.FOG); | |
232 | + GL.glDisable(GL.GL_FOG); | |
234 | 233 | } else if(locale.useDistanceFog()) { |
235 | - gl.enable(GL.FOG); | |
234 | + GL.glEnable(GL.GL_FOG); | |
236 | 235 | } |
237 | 236 | } |
238 | 237 |
@@ -241,9 +240,9 @@ public class World { | ||
241 | 240 | |
242 | 241 | if(null != locale) { |
243 | 242 | if(o instanceof ParticleSystem && locale.useDistanceFog()) { |
244 | - gl.enable(GL.FOG); | |
243 | + GL.glEnable(GL.GL_FOG); | |
245 | 244 | } else if(locale.useDistanceFog()) { |
246 | - gl.disable(GL.FOG); | |
245 | + GL.glDisable(GL.GL_FOG); | |
247 | 246 | } |
248 | 247 | } |
249 | 248 | } |
@@ -31,9 +31,11 @@ | ||
31 | 31 | */ |
32 | 32 | |
33 | 33 | package test.application; |
34 | - | |
34 | + | |
35 | 35 | import org.lwjgl.Display; |
36 | 36 | import org.lwjgl.opengl.GL; |
37 | +import org.lwjgl.opengl.GLU; | |
38 | +import org.lwjgl.opengl.Window; | |
37 | 39 | |
38 | 40 | import jme.AbstractGame; |
39 | 41 | import jme.system.DisplaySystem; |
@@ -44,7 +46,7 @@ import jme.system.DisplaySystem; | ||
44 | 46 | * You will can use this basic construct to build more complex jME applications |
45 | 47 | * |
46 | 48 | * @author Samuel Wasson |
47 | - * @version $Id: TestApplication.java,v 1.2 2003-08-08 02:16:56 mojomonkey Exp $ | |
49 | + * @version $Id: TestApplication.java,v 1.3 2003-09-03 16:20:51 mojomonkey Exp $ | |
48 | 50 | */ |
49 | 51 | |
50 | 52 | //Edit: Mark Powell - altered comments slightly. 8/7/03 |
@@ -60,8 +62,8 @@ public class TestApplication extends AbstractGame { | ||
60 | 62 | * Render is called once per frame to display the data. |
61 | 63 | */ |
62 | 64 | protected void render() { |
63 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
64 | - gl.loadIdentity(); | |
65 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
66 | + GL.glLoadIdentity(); | |
65 | 67 | } |
66 | 68 | |
67 | 69 | /** |
@@ -71,7 +73,7 @@ public class TestApplication extends AbstractGame { | ||
71 | 73 | |
72 | 74 | DisplaySystem.createDisplaySystem( |
73 | 75 | "TestApplication", |
74 | - "jme/data/Images/Monkey.jpg", | |
76 | + "data/Images/Monkey.jpg", | |
75 | 77 | true |
76 | 78 | ); |
77 | 79 | } |
@@ -80,27 +82,23 @@ public class TestApplication extends AbstractGame { | ||
80 | 82 | |
81 | 83 | // Here we create the OpenGL bindings. |
82 | 84 | |
83 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
84 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
85 | - | |
86 | - | |
87 | 85 | //Define the clear color to be black |
88 | 86 | |
89 | - gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
87 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
90 | 88 | |
91 | - gl.matrixMode(GL.PROJECTION); | |
92 | - gl.loadIdentity(); | |
89 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
90 | + GL.glLoadIdentity(); | |
93 | 91 | |
94 | 92 | |
95 | 93 | // Calculate the aspect ratio |
96 | - glu.perspective( | |
94 | + GLU.gluPerspective( | |
97 | 95 | 45.0f, |
98 | 96 | (float)Display.getWidth() / (float)Display.getHeight(), |
99 | 97 | 0.01f, |
100 | 98 | 750.0f); |
101 | 99 | |
102 | - gl.matrixMode(GL.MODELVIEW); | |
103 | - gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); | |
100 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
101 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
104 | 102 | } |
105 | 103 | |
106 | 104 | /** |
@@ -126,7 +124,7 @@ public class TestApplication extends AbstractGame { | ||
126 | 124 | * Clean up the OpenGL resources |
127 | 125 | */ |
128 | 126 | protected void cleanup() { |
129 | - gl.destroy(); | |
127 | + Window.destroy(); | |
130 | 128 | } |
131 | 129 | |
132 | 130 | /** |
@@ -66,7 +66,7 @@ public class TestController extends TrackingController { | ||
66 | 66 | if (isKeyDown("exit")) { |
67 | 67 | return false; |
68 | 68 | } |
69 | - | |
69 | + | |
70 | 70 | if (isKeyDown("640x480")) { |
71 | 71 | if (smode != 0) { |
72 | 72 | smode = 0; |
@@ -89,15 +89,15 @@ public class TestController extends TrackingController { | ||
89 | 89 | } |
90 | 90 | |
91 | 91 | if (isKeyDown("linemode")) { |
92 | - DisplaySystem.getDisplaySystem().getGL().polygonMode( | |
93 | - GL.FRONT_AND_BACK, | |
94 | - GL.LINE); | |
92 | + GL.glPolygonMode( | |
93 | + GL.GL_FRONT_AND_BACK, | |
94 | + GL.GL_LINE); | |
95 | 95 | } |
96 | 96 | |
97 | 97 | if (isKeyDown("fillmode")) { |
98 | - DisplaySystem.getDisplaySystem().getGL().polygonMode( | |
99 | - GL.FRONT_AND_BACK, | |
100 | - GL.FILL); | |
98 | + GL.glPolygonMode( | |
99 | + GL.GL_FRONT_AND_BACK, | |
100 | + GL.GL_FILL); | |
101 | 101 | } |
102 | 102 | |
103 | 103 | if (isKeyDown("screenshot")) { |
@@ -39,6 +39,10 @@ import org.lwjgl.Display; | ||
39 | 39 | import org.lwjgl.input.Keyboard; |
40 | 40 | import org.lwjgl.input.Mouse; |
41 | 41 | import org.lwjgl.opengl.GL; |
42 | +import org.lwjgl.opengl.GLCaps; | |
43 | +import org.lwjgl.opengl.GLU; | |
44 | +import org.lwjgl.opengl.Window; | |
45 | + | |
42 | 46 | import jme.AbstractGame; |
43 | 47 | import jme.entity.Entity; |
44 | 48 | import jme.geometry.model.md3.Md3Model; |
@@ -83,10 +87,11 @@ public class TestMain extends AbstractGame { | ||
83 | 87 | SplashScreen ss; |
84 | 88 | |
85 | 89 | static { |
86 | - if (GL.WGL_EXT_swap_control) { | |
90 | + if (GLCaps.WGL_EXT_swap_control) { | |
87 | 91 | GL.wglSwapIntervalEXT(1); |
88 | 92 | } |
89 | 93 | } |
94 | + | |
90 | 95 | |
91 | 96 | int tex1, tex2, tex3; |
92 | 97 |
@@ -181,8 +186,8 @@ public class TestMain extends AbstractGame { | ||
181 | 186 | |
182 | 187 | } |
183 | 188 | protected void render() { |
184 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
185 | - gl.loadIdentity(); | |
189 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
190 | + GL.glLoadIdentity(); | |
186 | 191 | cc.render(); |
187 | 192 | world.render(); |
188 | 193 | font.print( |
@@ -230,25 +235,23 @@ public class TestMain extends AbstractGame { | ||
230 | 235 | } |
231 | 236 | |
232 | 237 | private void initGL() { |
233 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
234 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
235 | - gl.shadeModel(GL.SMOOTH); | |
236 | - gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
237 | - gl.clearDepth(1.0); | |
238 | - gl.enable(GL.DEPTH_TEST); | |
239 | - gl.depthFunc(GL.LESS); | |
240 | - gl.matrixMode(GL.PROJECTION); | |
241 | - gl.loadIdentity(); | |
238 | + GL.glShadeModel(GL.GL_SMOOTH); | |
239 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
240 | + GL.glClearDepth(1.0); | |
241 | + GL.glEnable(GL.GL_DEPTH_TEST); | |
242 | + GL.glDepthFunc(GL.GL_LESS); | |
243 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
244 | + GL.glLoadIdentity(); | |
242 | 245 | // Calculate The Aspect Ratio Of The Window |
243 | - glu.perspective( | |
246 | + GLU.gluPerspective( | |
244 | 247 | 45.0f, |
245 | 248 | (float) Display.getWidth() / (float) Display.getHeight(), |
246 | 249 | 0.1f, |
247 | - 750.0f); | |
248 | - gl.matrixMode(GL.MODELVIEW); | |
249 | - gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); | |
250 | - gl.blendFunc(GL.SRC_ALPHA, GL.ONE); | |
251 | - DisplaySystem.getDisplaySystem().cullMode(GL.BACK, true); | |
250 | + 500.0f); | |
251 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
252 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
253 | + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); | |
254 | + DisplaySystem.getDisplaySystem().cullMode(GL.GL_BACK, true); | |
252 | 255 | |
253 | 256 | } |
254 | 257 | protected void reinit() { |
@@ -267,7 +270,7 @@ public class TestMain extends AbstractGame { | ||
267 | 270 | } |
268 | 271 | |
269 | 272 | float[] color = { 0.5f, 0.5f, 0.5f, 1.0f }; |
270 | - l.setFogAttributes(GL.LINEAR, color, 0.35f, 100.0f, 750.0f); | |
273 | + l.setFogAttributes(GL.GL_LINEAR, color, 0.35f, 50.0f, 500.0f); | |
271 | 274 | l.setDistanceFog(true); |
272 | 275 | } |
273 | 276 | protected void initSystem() { |
@@ -376,7 +379,7 @@ public class TestMain extends AbstractGame { | ||
376 | 379 | world.setWater(wp); |
377 | 380 | world.setLocale(l); |
378 | 381 | float[] color = { 0.5f, 0.5f, 0.5f, 1.0f }; |
379 | - l.setFogAttributes(GL.LINEAR, color, 0.35f, 50.0f, 750.0f); | |
382 | + l.setFogAttributes(GL.GL_LINEAR, color, 0.35f, 50.0f, 750.0f); | |
380 | 383 | l.setDistanceFog(true); |
381 | 384 | l.setVolumetricFog(false); |
382 | 385 | l.setVolumetricFogDepth(100); |
@@ -426,7 +429,7 @@ public class TestMain extends AbstractGame { | ||
426 | 429 | protected void cleanup() { |
427 | 430 | Keyboard.destroy(); |
428 | 431 | Mouse.destroy(); |
429 | - gl.destroy(); | |
432 | + Window.destroy(); | |
430 | 433 | TextureManager.reset(); |
431 | 434 | } |
432 | 435 | public static void main(String[] args) { |
@@ -34,6 +34,8 @@ package test.general; | ||
34 | 34 | |
35 | 35 | import org.lwjgl.Display; |
36 | 36 | import org.lwjgl.opengl.GL; |
37 | +import org.lwjgl.opengl.GLU; | |
38 | +import org.lwjgl.opengl.Window; | |
37 | 39 | import org.lwjgl.vector.Vector3f; |
38 | 40 | |
39 | 41 | import jme.AbstractGame; |
@@ -57,30 +59,28 @@ public class TestParticleSystem extends AbstractGame { | ||
57 | 59 | } |
58 | 60 | |
59 | 61 | protected void render() { |
60 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
61 | - gl.loadIdentity(); | |
62 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
63 | + GL.glLoadIdentity(); | |
62 | 64 | ps.render(); |
63 | 65 | } |
64 | 66 | |
65 | 67 | protected void initSystem() { |
66 | 68 | //create the window |
67 | - DisplaySystem.createDisplaySystem("Particles", "jme/data/Images/Monkey.jpg", true); | |
68 | - //create the OpenGL bindings | |
69 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
70 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
69 | + DisplaySystem.createDisplaySystem("Particles", "data/Images/Monkey.jpg", true); | |
70 | + | |
71 | 71 | //Define what the clear color will be (black) |
72 | - gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
73 | - gl.matrixMode(GL.PROJECTION); | |
74 | - gl.loadIdentity(); | |
72 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
73 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
74 | + GL.glLoadIdentity(); | |
75 | 75 | // Calculate The Aspect Ratio Of The Window |
76 | - glu.perspective( | |
76 | + GLU.gluPerspective( | |
77 | 77 | 45.0f, |
78 | 78 | (float) Display.getWidth() / (float) Display.getHeight(), |
79 | 79 | 0.01f, |
80 | 80 | 750.0f); |
81 | - gl.matrixMode(GL.MODELVIEW); | |
82 | - gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); | |
83 | - gl.disable(GL.DEPTH_TEST); | |
81 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
82 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
83 | + GL.glDisable(GL.GL_DEPTH_TEST); | |
84 | 84 | } |
85 | 85 | |
86 | 86 | protected void initGame() { |
@@ -95,7 +95,7 @@ public class TestParticleSystem extends AbstractGame { | ||
95 | 95 | pe.setSpeed(1); |
96 | 96 | pe.setGravity(new Vector3f(0.0f,-100.0f,10.0f)); |
97 | 97 | pe.setFriction(1); |
98 | - pe.setTexture("jme/data/texture/star.png"); | |
98 | + pe.setTexture("data/texture/star.png"); | |
99 | 99 | pe.loopAnimation(true); |
100 | 100 | |
101 | 101 | ps = new ParticleSystem(); |
@@ -106,10 +106,11 @@ public class TestParticleSystem extends AbstractGame { | ||
106 | 106 | protected void reinit() { |
107 | 107 | //nothing here... YET! |
108 | 108 | } |
109 | + | |
109 | 110 | |
110 | 111 | protected void cleanup() { |
111 | 112 | //clean up the OpenGL resources |
112 | - gl.destroy(); | |
113 | + Window.destroy(); | |
113 | 114 | } |
114 | 115 | |
115 | 116 | public static void main(String[] args) { |
@@ -48,6 +48,7 @@ public class KeyController extends BaseFPSController { | ||
48 | 48 | |
49 | 49 | public void setKeys() { |
50 | 50 | key.set("triangle", Keyboard.KEY_1); |
51 | + key.set("screenshot", Keyboard.KEY_P); | |
51 | 52 | } |
52 | 53 | |
53 | 54 | protected boolean checkAdditionalKeys() { |
@@ -60,6 +61,11 @@ public class KeyController extends BaseFPSController { | ||
60 | 61 | app.setRenderObject(1); |
61 | 62 | return true; |
62 | 63 | } |
64 | + | |
65 | + if(isKeyDown("screenshot")) { | |
66 | + app.takeScreenShot(); | |
67 | + return true; | |
68 | + } | |
63 | 69 | return true; |
64 | 70 | } |
65 | 71 | } |
\ No newline at end of file |
@@ -34,6 +34,8 @@ package test.keycontroller; | ||
34 | 34 | |
35 | 35 | import org.lwjgl.Display; |
36 | 36 | import org.lwjgl.opengl.GL; |
37 | +import org.lwjgl.opengl.GLU; | |
38 | +import org.lwjgl.opengl.Window; | |
37 | 39 | |
38 | 40 | import jme.AbstractGame; |
39 | 41 | import jme.system.DisplaySystem; |
@@ -72,7 +74,7 @@ public class TestKeyController extends AbstractGame { | ||
72 | 74 | */ |
73 | 75 | protected void update() { |
74 | 76 | if(!controller.update(timer.getFrameRate())) { |
75 | - finish(); | |
77 | + finish(); | |
76 | 78 | } |
77 | 79 | timer.update(); |
78 | 80 | } |
@@ -83,26 +85,30 @@ public class TestKeyController extends AbstractGame { | ||
83 | 85 | protected void setRenderObject(int value) { |
84 | 86 | Flag = value; |
85 | 87 | } |
88 | + | |
89 | + public void takeScreenShot() { | |
90 | + DisplaySystem.getDisplaySystem().takeScreenShot("test"); | |
91 | + } | |
86 | 92 | |
87 | 93 | /** |
88 | 94 | * Render is called once per frame to display the data. |
89 | 95 | */ |
90 | 96 | protected void render() { |
91 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
92 | - gl.loadIdentity(); | |
97 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
98 | + GL.glLoadIdentity(); | |
93 | 99 | |
94 | 100 | controller.render(); |
95 | 101 | |
96 | 102 | // Enable texture mapping |
97 | - gl.enable(GL.TEXTURE_2D); | |
103 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
98 | 104 | |
99 | 105 | if(Flag == 1) { |
100 | - gl.pushMatrix(); | |
106 | + GL.glPushMatrix(); | |
101 | 107 | entity1.render(); |
102 | - gl.popMatrix(); | |
108 | + GL.glPopMatrix(); | |
103 | 109 | } |
104 | 110 | |
105 | - gl.end(); | |
111 | + GL.glEnd(); | |
106 | 112 | |
107 | 113 | /* |
108 | 114 | * Print out the frame rate. |
@@ -124,7 +130,7 @@ public class TestKeyController extends AbstractGame { | ||
124 | 130 | */ |
125 | 131 | protected void initDisplay() { |
126 | 132 | DisplaySystem.createDisplaySystem( |
127 | - "TestApplication", | |
133 | + "TestKeyController", | |
128 | 134 | "data/Images/Monkey.jpg", |
129 | 135 | true |
130 | 136 | ); |
@@ -132,26 +138,21 @@ public class TestKeyController extends AbstractGame { | ||
132 | 138 | |
133 | 139 | protected void initGL() { |
134 | 140 | |
135 | - // Here we create the OpenGL bindings. | |
136 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
137 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
138 | - | |
139 | - | |
140 | 141 | // Define the clear color to be black |
141 | - gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
142 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
142 | 143 | |
143 | - gl.matrixMode(GL.PROJECTION); | |
144 | - gl.loadIdentity(); | |
144 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
145 | + GL.glLoadIdentity(); | |
145 | 146 | |
146 | 147 | // Calculate the aspect ratio |
147 | - glu.perspective( | |
148 | + GLU.gluPerspective( | |
148 | 149 | 45.0f, |
149 | 150 | (float)Display.getWidth() / (float)Display.getHeight(), |
150 | 151 | 0.01f, |
151 | 152 | 750.0f); |
152 | 153 | |
153 | - gl.matrixMode(GL.MODELVIEW); | |
154 | - gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); | |
154 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
155 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
155 | 156 | } |
156 | 157 | |
157 | 158 | protected void initSystem() { |
@@ -162,7 +163,7 @@ public class TestKeyController extends AbstractGame { | ||
162 | 163 | protected void initGame() { |
163 | 164 | |
164 | 165 | // Blend the font together so it doesn't chop the letters off |
165 | - gl.blendFunc(GL.SRC_ALPHA, GL.ONE); | |
166 | + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); | |
166 | 167 | |
167 | 168 | //Instantiate a font object |
168 | 169 | font = new Font2D("data/Font/font.png"); |
@@ -207,7 +208,7 @@ public class TestKeyController extends AbstractGame { | ||
207 | 208 | * Clean up the OpenGL resources |
208 | 209 | */ |
209 | 210 | protected void cleanup() { |
210 | - gl.destroy(); | |
211 | + Window.destroy(); | |
211 | 212 | } |
212 | 213 | |
213 | 214 | public static void main(String[] args) { |
@@ -0,0 +1,153 @@ | ||
1 | +/* | |
2 | + * Copyright (c) 2003, jMonkeyEngine - Mojo Monkey Coding | |
3 | + * All rights reserved. | |
4 | + * | |
5 | + * Redistribution and use in source and binary forms, with or without | |
6 | + * modification, are permitted provided that the following conditions are met: | |
7 | + * | |
8 | + * Redistributions of source code must retain the above copyright notice, this | |
9 | + * list of conditions and the following disclaimer. | |
10 | + * | |
11 | + * Redistributions in binary form must reproduce the above copyright notice, | |
12 | + * this list of conditions and the following disclaimer in the documentation | |
13 | + * and/or other materials provided with the distribution. | |
14 | + * | |
15 | + * Neither the name of the Mojo Monkey Coding, jME, jMonkey Engine, nor the | |
16 | + * names of its contributors may be used to endorse or promote products derived | |
17 | + * from this software without specific prior written permission. | |
18 | + * | |
19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | + * POSSIBILITY OF SUCH DAMAGE. | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +package test.model; | |
34 | + | |
35 | +import org.lwjgl.Display; | |
36 | +import org.lwjgl.opengl.GL; | |
37 | +import org.lwjgl.opengl.GLU; | |
38 | +import org.lwjgl.opengl.Window; | |
39 | + | |
40 | +import jme.AbstractGame; | |
41 | +import jme.controller.BaseFPSController; | |
42 | +import jme.entity.camera.Camera; | |
43 | +import jme.geometry.model.ms.MilkshapeModel; | |
44 | +import jme.system.DisplaySystem; | |
45 | +import jme.utility.Timer; | |
46 | + | |
47 | +/** | |
48 | + * | |
49 | + * @author Mark Powell | |
50 | + */ | |
51 | + | |
52 | +public class TestMilkshape extends AbstractGame { | |
53 | + //our model object | |
54 | + private MilkshapeModel model; | |
55 | + | |
56 | + BaseFPSController controller; | |
57 | + Timer timer; | |
58 | + Camera camera; | |
59 | + /** | |
60 | + * This is where we'll do any updating | |
61 | + */ | |
62 | + protected void update() { | |
63 | + timer.update(); | |
64 | + if(!controller.update(timer.getFrameRate())) { | |
65 | + finish(); | |
66 | + } | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * Render is called once per frame to display the data. | |
71 | + */ | |
72 | + protected void render() { | |
73 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
74 | + GL.glLoadIdentity(); | |
75 | + controller.render(); | |
76 | + model.render(); | |
77 | + } | |
78 | + | |
79 | + /** | |
80 | + * This is where we create and initialize the window. | |
81 | + */ | |
82 | + protected void initDisplay() { | |
83 | + | |
84 | + DisplaySystem.createDisplaySystem( | |
85 | + "TestMilkshape", | |
86 | + "data/Images/Monkey.jpg", | |
87 | + true | |
88 | + ); | |
89 | + } | |
90 | + | |
91 | + protected void initGL() { | |
92 | + | |
93 | + // Here we create the OpenGL bindings. | |
94 | + | |
95 | + //Define the clear color to be black | |
96 | + | |
97 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
98 | + | |
99 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
100 | + GL.glLoadIdentity(); | |
101 | + | |
102 | + | |
103 | + // Calculate the aspect ratio | |
104 | + GLU.gluPerspective( | |
105 | + 45.0f, | |
106 | + (float)Display.getWidth() / (float)Display.getHeight(), | |
107 | + 0.01f, | |
108 | + 750.0f); | |
109 | + | |
110 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
111 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
112 | + } | |
113 | + | |
114 | + /** | |
115 | + * Called first to initialize system attributes. | |
116 | + */ | |
117 | + protected void initSystem() { | |
118 | + initDisplay(); | |
119 | + initGL(); | |
120 | + } | |
121 | + /** | |
122 | + * Nothing here yet. | |
123 | + */ | |
124 | + protected void initGame() { | |
125 | + model = new MilkshapeModel("./data/model/arab/ak47.ms3d"); | |
126 | + camera = new Camera(1,0,0,100,0,10,0,0,1,0); | |
127 | + controller = new BaseFPSController(camera); | |
128 | + timer = Timer.getTimer(); | |
129 | + } | |
130 | + | |
131 | + /** | |
132 | + * Nothing here yet. | |
133 | + */ | |
134 | + protected void reinit() { | |
135 | + } | |
136 | + | |
137 | + /** | |
138 | + * Clean up the OpenGL resources | |
139 | + */ | |
140 | + protected void cleanup() { | |
141 | + Window.destroy(); | |
142 | + } | |
143 | + | |
144 | + /** | |
145 | + * <code>main</code> entry point for application. | |
146 | + * @param args comman line arguments, none used. | |
147 | + */ | |
148 | + public static void main(String[] args) { | |
149 | + TestMilkshape testApp = new TestMilkshape(); | |
150 | + testApp.start(); | |
151 | + } | |
152 | +} | |
153 | + | |
\ No newline at end of file |
@@ -29,13 +29,15 @@ | ||
29 | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | * |
31 | 31 | */ |
32 | - | |
32 | + | |
33 | 33 | package test.polygon; |
34 | - | |
35 | -import org.lwjgl.Display; | |
36 | -import org.lwjgl.opengl.GL; | |
37 | 34 | |
38 | -import jme.AbstractGame; | |
35 | +import org.lwjgl.Display; | |
36 | +import org.lwjgl.opengl.GL; | |
37 | +import org.lwjgl.opengl.GLU; | |
38 | +import org.lwjgl.opengl.Window; | |
39 | + | |
40 | +import jme.AbstractGame; | |
39 | 41 | import jme.system.DisplaySystem; |
40 | 42 | import jme.utility.Timer; |
41 | 43 | import jme.math.Vector; |
@@ -48,134 +50,133 @@ import jme.geometry.primitive.Triangle; | ||
48 | 50 | * You will can use this basic construct to build more complex jME applications |
49 | 51 | * |
50 | 52 | * @author Samuel Wasson |
51 | - * @version 0.1.0 | |
53 | + * @version $Id: TestPolygon.java,v 1.4 2003-09-03 16:20:51 mojomonkey Exp $ | |
52 | 54 | */ |
53 | 55 | |
54 | 56 | public class TestPolygon extends AbstractGame { |
55 | - | |
56 | - private Timer timer; | |
57 | - private Font2D font; | |
58 | - private Triangle triangle; | |
59 | - private Vector[] points; | |
60 | - | |
61 | - /** | |
62 | - * This is where we'll do any updating. | |
63 | - */ | |
64 | - protected void update() { | |
65 | - // Update each frame to calculate the framerate | |
66 | - timer.getFrameRate(); | |
67 | - timer.update(); | |
68 | - } | |
69 | - | |
70 | - /** | |
71 | - * Render is called once per frame to display the data. | |
72 | - */ | |
73 | - protected void render() { | |
74 | - gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT); | |
75 | - gl.loadIdentity(); | |
76 | - | |
77 | - | |
78 | - // Enable texture mapping | |
79 | - gl.enable(GL.TEXTURE_2D); | |
80 | - | |
81 | - triangle.render(); | |
82 | - | |
83 | - /* | |
84 | - * Print out the frame rate. | |
85 | - * The print method takes 4 parameters | |
86 | - * (int, int, string, int). The first two | |
87 | - * ints are the coordinates to start the text. | |
88 | - * These are screen coordinates in pixels where | |
89 | - * (0, 0) is the lower left hand of the screen. | |
90 | - * The String is whatever you want to display. | |
91 | - * The last parameter is the font type where 0 | |
92 | - * is normal and 1 is italics | |
93 | - */ | |
94 | - font.print(1,1,"Frame Rate - " + timer.getFrameRate(), 0); | |
95 | - | |
96 | - } | |
97 | - | |
98 | - /** | |
99 | - * This is where we create and initialize the window. | |
100 | - */ | |
101 | - protected void initDisplay() { | |
102 | - DisplaySystem.createDisplaySystem( | |
103 | - "TestApplication", | |
104 | - "jme/data/Images/Monkey.jpg", | |
105 | - true | |
106 | - ); | |
107 | - } | |
108 | - | |
109 | - protected void initGL() { | |
110 | - | |
111 | - // Here we create the OpenGL bindings. | |
112 | - gl = DisplaySystem.getDisplaySystem().getGL(); | |
113 | - glu = DisplaySystem.getDisplaySystem().getGLU(); | |
114 | - | |
115 | - | |
116 | - // Define the clear color to be black | |
117 | - gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
118 | - | |
119 | - gl.matrixMode(GL.PROJECTION); | |
120 | - gl.loadIdentity(); | |
121 | - | |
122 | - // Calculate the aspect ratio | |
123 | - glu.perspective( | |
124 | - 45.0f, | |
125 | - (float)Display.getWidth() / (float)Display.getHeight(), | |
126 | - 0.01f, | |
127 | - 750.0f); | |
128 | - | |
129 | - gl.matrixMode(GL.MODELVIEW); | |
130 | - gl.hint(GL.PERSPECTIVE_CORRECTION_HINT, GL.NICEST); | |
131 | - } | |
132 | - | |
133 | - protected void initSystem() { | |
134 | - initDisplay(); | |
135 | - initGL(); | |
136 | - } | |
137 | - | |
138 | - protected void initGame() { | |
139 | - | |
140 | - // Blend the font together so it doesn't chop the letters off | |
141 | - gl.blendFunc(GL.SRC_ALPHA, GL.ONE); | |
142 | - | |
143 | - //Instantiate a font object | |
144 | - font = new Font2D("jme/data/Font/font.png"); | |
145 | - | |
146 | - // Instantiate a new timer object | |
147 | - timer = Timer.getTimer(); | |
148 | - | |
149 | - // Initiate a new Vector class | |
150 | - points = new Vector[3]; | |
151 | - | |
152 | - // Initialize the Vector array | |
153 | - for (int i = 0; i < 3; i++) { | |
154 | - points[i] = new Vector(); | |
155 | - } | |
156 | - | |
157 | - // Add points to the Vector array | |
158 | - points[0].x = 0.0f; points[0].y = 1.0f; points[0].z = -5.0f; | |
159 | - points[1].x = -1.0f; points[1].y = -1.0f; points[1].z = -5.0f; | |
160 | - points[2].x = 1.0f; points[2].y = -1.0f; points[2].z = -5.0f; | |
161 | - | |
162 | - // Instantiate a new Triangle object | |
163 | - triangle = new Triangle(points); | |
164 | - } | |
165 | - | |
166 | - protected void reinit() { | |
167 | - // Nothing here yet. | |
168 | - } | |
169 | - | |
170 | - /** | |
171 | - * Clean up the OpenGL resources | |
172 | - */ | |
173 | - protected void cleanup() { | |
174 | - gl.destroy(); | |
175 | - } | |
176 | - | |
177 | - public static void main(String[] args) { | |
178 | - TestPolygon testPoly = new TestPolygon(); | |
179 | - testPoly.start(); | |
180 | - } | |
57 | + | |
58 | + private Timer timer; | |
59 | + private Font2D font; | |
60 | + private Triangle triangle; | |
61 | + private Vector[] points; | |
62 | + | |
63 | + /** | |
64 | + * This is where we'll do any updating. | |
65 | + */ | |
66 | + protected void update() { | |
67 | + // Update each frame to calculate the framerate | |
68 | + timer.getFrameRate(); | |
69 | + timer.update(); | |
70 | + } | |
71 | + | |
72 | + /** | |
73 | + * Render is called once per frame to display the data. | |
74 | + */ | |
75 | + protected void render() { | |
76 | + GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); | |
77 | + GL.glLoadIdentity(); | |
78 | + | |
79 | + // Enable texture mapping | |
80 | + GL.glEnable(GL.GL_TEXTURE_2D); | |
81 | + | |
82 | + triangle.render(); | |
83 | + | |
84 | + /* | |
85 | + * Print out the frame rate. | |
86 | + * The print method takes 4 parameters | |
87 | + * (int, int, string, int). The first two | |
88 | + * ints are the coordinates to start the text. | |
89 | + * These are screen coordinates in pixels where | |
90 | + * (0, 0) is the lower left hand of the screen. | |
91 | + * The String is whatever you want to display. | |
92 | + * The last parameter is the font type where 0 | |
93 | + * is normal and 1 is italics | |
94 | + */ | |
95 | + font.print(1, 1, "Frame Rate - " + timer.getFrameRate(), 0); | |
96 | + | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * This is where we create and initialize the window. | |
101 | + */ | |
102 | + protected void initDisplay() { | |
103 | + DisplaySystem.createDisplaySystem( | |
104 | + "TestPolygon", | |
105 | + "data/Images/Monkey.jpg", | |
106 | + true); | |
107 | + } | |
108 | + | |
109 | + protected void initGL() { | |
110 | + | |
111 | + // Define the clear color to be black | |
112 | + GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | |
113 | + | |
114 | + GL.glMatrixMode(GL.GL_PROJECTION); | |
115 | + GL.glLoadIdentity(); | |
116 | + | |
117 | + // Calculate the aspect ratio | |
118 | + GLU.gluPerspective( | |
119 | + 45.0f, | |
120 | + (float) Display.getWidth() / (float) Display.getHeight(), | |
121 | + 0.01f, | |
122 | + 750.0f); | |
123 | + | |
124 | + GL.glMatrixMode(GL.GL_MODELVIEW); | |
125 | + GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); | |
126 | + } | |
127 | + | |
128 | + protected void initSystem() { | |
129 | + initDisplay(); | |
130 | + initGL(); | |
131 | + } | |
132 | + | |
133 | + protected void initGame() { | |
134 | + | |
135 | + // Blend the font together so it doesn't chop the letters off | |
136 | + GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); | |
137 | + | |
138 | + //Instantiate a font object | |
139 | + font = new Font2D("data/Font/font.png"); | |
140 | + | |
141 | + // Instantiate a new timer object | |
142 | + timer = Timer.getTimer(); | |
143 | + | |
144 | + // Initiate a new Vector class | |
145 | + points = new Vector[3]; | |
146 | + | |
147 | + // Initialize the Vector array | |
148 | + for (int i = 0; i < 3; i++) { | |
149 | + points[i] = new Vector(); | |
150 | + } | |
151 | + | |
152 | + // Add points to the Vector array | |
153 | + points[0].x = 0.0f; | |
154 | + points[0].y = 1.0f; | |
155 | + points[0].z = -5.0f; | |
156 | + points[1].x = -1.0f; | |
157 | + points[1].y = -1.0f; | |
158 | + points[1].z = -5.0f; | |
159 | + points[2].x = 1.0f; | |
160 | + points[2].y = -1.0f; | |
161 | + points[2].z = -5.0f; | |
162 | + | |
163 | + // Instantiate a new Triangle object | |
164 | + triangle = new Triangle(points); | |
165 | + } | |
166 | + | |
167 | + protected void reinit() { | |
168 | + // Nothing here yet. | |
169 | + } | |
170 | + | |
171 | + /** | |
172 | + * Clean up the OpenGL resources | |
173 | + */ | |
174 | + protected void cleanup() { | |
175 | + Window.destroy(); | |
176 | + } | |
177 | + | |
178 | + public static void main(String[] args) { | |
179 | + TestPolygon testPoly = new TestPolygon(); | |
180 | + testPoly.start(); | |
181 | + } | |
181 | 182 | } |
\ No newline at end of file |