Commits

Michael Ludwig committed 3b40a08

Update LWJGL renderer to use new math library

  • Participants
  • Parent commits ffdc815

Comments (0)

Files changed (4)

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/LwjglFixedFunctionRenderer.java

 import org.lwjgl.opengl.GL11;
 import org.lwjgl.opengl.GL13;
 
-import com.ferox.math.ReadOnlyMatrix4f;
-import com.ferox.math.ReadOnlyVector3f;
-import com.ferox.math.ReadOnlyVector4f;
+import com.ferox.math.Const;
+import com.ferox.math.Matrix4;
+import com.ferox.math.Vector3;
+import com.ferox.math.Vector4;
 import com.ferox.renderer.RenderCapabilities;
 import com.ferox.renderer.impl.AbstractFixedFunctionRenderer;
 import com.ferox.renderer.impl.AbstractSurface;
     }
 
     @Override
-    protected void glSetMatrix(ReadOnlyMatrix4f matrix) {
+    protected void glSetMatrix(@Const Matrix4 matrix) {
         matrix.get(matrixBuffer, 0, false);
         GL11.glLoadMatrix(matrixBuffer);
     }
     }
 
     @Override
-    protected void glFogColor(ReadOnlyVector4f color) {
+    protected void glFogColor(@Const Vector4 color) {
         color.get(vector4Buffer, 0);
         GL11.glFog(GL11.GL_FOG_COLOR, vector4Buffer);
     }
     }
 
     @Override
-    protected void glGlobalLighting(ReadOnlyVector4f ambient) {
+    protected void glGlobalLighting(@Const Vector4 ambient) {
         ambient.get(vector4Buffer, 0);
         GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, vector4Buffer);
     }
     
 
     @Override
-    protected void glLightColor(int light, LightColor lc, ReadOnlyVector4f color) {
+    protected void glLightColor(int light, LightColor lc, @Const Vector4 color) {
         color.get(vector4Buffer, 0);
         int c = getGLLight(lc);
         GL11.glLight(GL11.GL_LIGHT0 + light, c, vector4Buffer);
     }
 
     @Override
-    protected void glLightPosition(int light, ReadOnlyVector4f pos) {
+    protected void glLightPosition(int light, @Const Vector4 pos) {
         pos.get(vector4Buffer, 0);
         GL11.glLight(GL11.GL_LIGHT0 + light, GL11.GL_POSITION, vector4Buffer);
     }
 
     @Override
-    protected void glLightDirection(int light, ReadOnlyVector3f dir) {
+    protected void glLightDirection(int light, @Const Vector3 dir) {
         dir.get(vector3Buffer, 0);
         GL11.glLight(GL11.GL_LIGHT0 + light, GL11.GL_SPOT_DIRECTION, vector3Buffer);
     }
     }
 
     @Override
-    protected void glMaterialColor(LightColor component, ReadOnlyVector4f color) {
+    protected void glMaterialColor(LightColor component, @Const Vector4 color) {
         int c = getGLLight(component);
         if (component == LightColor.DIFFUSE) {
-            GL11.glColor4f(color.getX(), color.getY(), color.getZ(), color.getW());
+            GL11.glColor4d(color.x, color.y, color.z, color.w);
         } else {
             color.get(vector4Buffer, 0);
             GL11.glMaterial(GL11.GL_FRONT_AND_BACK, c, vector4Buffer);
     }
 
     @Override
-    protected void glTextureColor(ReadOnlyVector4f color) {
+    protected void glTextureColor(@Const Vector4 color) {
         color.get(vector4Buffer, 0);
         GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, vector4Buffer);
     }
     }
 
     @Override
-    protected void glTexEyePlane(TexCoord coord, ReadOnlyVector4f plane) {
+    protected void glTexEyePlane(TexCoord coord, @Const Vector4 plane) {
         plane.get(vector4Buffer, 0);
         int tc = Utils.getGLTexCoord(coord, false);
         GL11.glTexGen(tc, GL11.GL_EYE_PLANE, vector4Buffer);
     }
 
     @Override
-    protected void glTexObjPlane(TexCoord coord, ReadOnlyVector4f plane) {
+    protected void glTexObjPlane(TexCoord coord, @Const Vector4 plane) {
         plane.get(vector4Buffer, 0);
         int tc = Utils.getGLTexCoord(coord, false);
         GL11.glTexGen(tc, GL11.GL_OBJECT_PLANE, vector4Buffer);

ferox-renderer/ferox-renderer-lwjgl/src/main/java/com/ferox/renderer/impl/lwjgl/LwjglRendererDelegate.java

 import org.lwjgl.opengl.GL14;
 import org.lwjgl.opengl.GL20;
 
-import com.ferox.math.ReadOnlyVector4f;
-import com.ferox.math.Vector4f;
+import com.ferox.math.Const;
+import com.ferox.math.Vector4;
 import com.ferox.renderer.RenderCapabilities;
 import com.ferox.renderer.Renderer.BlendFactor;
 import com.ferox.renderer.Renderer.BlendFunction;
     private boolean initialized;
     
     // state tracking for buffer clearing
-    private final Vector4f clearColor = new Vector4f(0f, 0f, 0f, 0f);
+    private final Vector4 clearColor = new Vector4(0f, 0f, 0f, 0f);
     private float clearDepth = 1f;
     private int clearStencil = 0;
     
     private int backPolyMode = GL11.GL_FILL;
     
     @Override
-    protected void glBlendColor(ReadOnlyVector4f color) {
+    protected void glBlendColor(@Const Vector4 color) {
         if (supportsBlending)
-            GL14.glBlendColor(color.getX(), color.getY(), color.getZ(), color.getW());
+            GL14.glBlendColor((float) color.x, (float) color.y, (float) color.z, (float) color.w);
     }
 
     @Override
 
     @Override
     public void clear(boolean clearColor, boolean clearDepth, boolean clearStencil,
-                      ReadOnlyVector4f color, float depth, int stencil) {
+                      @Const Vector4 color, float depth, int stencil) {
         if (color == null)
             throw new NullPointerException("Clear color cannot be null");
         if (depth < 0f || depth > 1f)
         
         if (!this.clearColor.equals(color)) {
             this.clearColor.set(color);
-            GL11.glClearColor(color.getX(), color.getY(), color.getZ(), color.getW());
+            GL11.glClearColor((float) color.x, (float) color.y, (float) color.z, (float) color.w);
         }
         if (this.clearDepth != depth) {
             this.clearDepth = depth;

ferox-renderer/ferox-renderer-lwjgl/src/test/java/com/ferox/renderer/impl/lwjgl/FixedFunctionRenderTest.java

 package com.ferox.renderer.impl.lwjgl;
 
-import com.ferox.math.Matrix4f;
-import com.ferox.math.Vector3f;
-import com.ferox.math.Vector4f;
+import com.ferox.math.Matrix4;
+import com.ferox.math.Vector3;
+import com.ferox.math.Vector4;
 import com.ferox.math.bounds.Frustum;
 import com.ferox.renderer.Context;
 import com.ferox.renderer.FixedFunctionRenderer;
             teapot = new Sphere(2f, 32, StorageMode.GPU_STATIC); //new Teapot(.5f, StorageMode.GPU_STATIC);
             
             f = new Frustum(60f, surface.getWidth() / (float) surface.getHeight(), 1f, 100f);
-            f.setOrientation(new Vector3f(0f, 3f, 10f), new Vector3f(0f, 0f, -1f), new Vector3f(0f, 1f, 0f));
+            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f), new Vector3(0f, 1f, 0f));
             
             int width = 256;
             int height = 256;
             
             FixedFunctionRenderer g = context.getFixedFunctionRenderer();
             if (g != null) {
-                g.clear(true, true, true, new Vector4f(.2f, .2f, .2f, 1f), 1, 0);
+                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
                 
                 g.setDrawStyle(DrawStyle.SOLID);
                 
                 g.setProjectionMatrix(f.getProjectionMatrix());
                 
                 Geometry shape;
-                Matrix4f t = new Matrix4f();
+                Matrix4 t = new Matrix4();
                 int rendered = 0;
                 int num = 10000;
                 int thirds = num / 3;

ferox-renderer/ferox-renderer-lwjgl/src/test/java/com/ferox/renderer/impl/lwjgl/GlslRenderTest.java

 import java.util.Map;
 import java.util.Map.Entry;
 
-import com.ferox.math.Vector3f;
-import com.ferox.math.Vector4f;
+import com.ferox.math.Vector3;
+import com.ferox.math.Vector4;
 import com.ferox.math.bounds.Frustum;
 import com.ferox.renderer.Context;
 import com.ferox.renderer.DisplayMode;
             shader.setShader(ShaderType.FRAGMENT, FRAGMENT_SHADER);
             
             f = new Frustum(60f, surface.getWidth() / (float) surface.getHeight(), 1f, 100f);
-            f.setOrientation(new Vector3f(0f, 3f, 10f), new Vector3f(0f, 0f, -1f), new Vector3f(0f, 1f, 0f));
+            f.setOrientation(new Vector3(0f, 3f, 10f), new Vector3(0f, 0f, -1f), new Vector3(0f, 1f, 0f));
             
             int width = 256;
             int height = 256;
             
             GlslRenderer g = context.getGlslRenderer();
             if (g != null) {
-                g.clear(true, true, true, new Vector4f(.2f, .2f, .2f, 1f), 1, 0);
+                g.clear(true, true, true, new Vector4(.2f, .2f, .2f, 1f), 1, 0);
                 
                 g.setShader(shader);
                 g.bindAttribute("vertex", shape.getVertices());
                 g.setUniform("projection", f.getProjectionMatrix());
                 g.setUniform("modelview", f.getViewMatrix());
                 
-                g.setUniform("color", new Vector4f(1f, 1f, 1f, 1f));
+                g.setUniform("color", new Vector4(1f, 1f, 1f, 1f));
                 g.setUniform("texture", volume);
                 
                 g.setUniform("transform", 2f, .25f);