Commits

Roi Atalla committed bd0e267

Small updates to Mesh and Matrix4.

Comments (0)

Files changed (2)

src/main/java/com/ra4king/opengl/util/Mesh.java

 import java.io.InputStream;
 import java.net.URL;
 import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
 import java.util.ArrayList;
 import java.util.HashMap;
 
 						b.put(Byte.parseByte(s));
 					break;
 				case GL_UNSIGNED_SHORT:
-					ShortBuffer sb = b.asShortBuffer();
 					for(String s : data)
-						sb.put(Short.parseShort(s));
+						b.putShort(Short.parseShort(s));
 					break;
 				case GL_UNSIGNED_INT:
-					IntBuffer ib = b.asIntBuffer();
 					for(String s : data)
-						ib.put(Integer.parseInt(s));
+						b.putInt(Integer.parseInt(s));
 					break;
 			}
 			
 		public void store(ByteBuffer b, String[] data) {
 			switch(dataType) {
 				case GL_FLOAT:
-					FloatBuffer fb = b.asFloatBuffer();
 					for(String s : data)
-						fb.put(Float.parseFloat(s));
+						b.putFloat(Float.parseFloat(s));
 					break;
 				case GL_INT:
 				case GL_UNSIGNED_INT:
-					IntBuffer ib = b.asIntBuffer();
 					for(String s : data)
-						ib.put(Integer.parseInt(s));
+						b.putInt(Integer.parseInt(s));
 					break;
 				case GL_SHORT:
 				case GL_UNSIGNED_SHORT:
-					ShortBuffer sb = b.asShortBuffer();
 					for(String s : data)
-						sb.put(Short.parseShort(s));
+						b.putShort(Short.parseShort(s));
 					break;
 				case GL_BYTE:
 				case GL_UNSIGNED_BYTE:

src/main/java/com/ra4king/opengl/util/math/Matrix4.java

 	}
 	
 	public Matrix4 clearToOrtho(float left, float right, float bottom, float top, float near, float far) {
-		return clear().put(0,2/(right-left)).put(5,2/(top-bottom)).put(10,-2/(far-near)).put(12,-(right+left)/(right-left)).put(13,-(top+bottom)/(top-bottom)).put(14,-(far+near)/(far-near)).put(15,1);
+		return clear().put(0, 2/(right-left))
+					  .put(5, 2/(top-bottom))
+					  .put(10,-2/(far-near))
+					  .put(12,-(right+left)/(right-left))
+					  .put(13,-(top+bottom)/(top-bottom))
+					  .put(14,-(far+near)/(far-near))
+					  .put(15,1);
 	}
 	
 	public Matrix4 clearToPerspective(float fovRad, float width, float height, float near, float far) {
 		float fov = 1 / (float)Math.tan(fovRad/2);
-		return clear().put(0,fov/(width/height)).put(5,fov).put(10,(far+near)/(near-far)).put(14,(2*far*near)/(near-far)).put(11,-1);
+		return clear().put(0, fov/(width/height))
+					  .put(5, fov).put(10,(far+near)/(near-far))
+					  .put(14,(2*far*near)/(near-far))
+					  .put(11,-1);
 	}
 	
 	public Matrix4 clearToPerspectiveDeg(float fov, float width, float height, float near, float far) {