Commits

Michael Ludwig committed ffdc815

Update JOGL renderer to use new math library.

  • Participants
  • Parent commits dd47e35

Comments (0)

Files changed (4)

File ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/JoglFixedFunctionRenderer.java

 import javax.media.opengl.GL;
 import javax.media.opengl.GL2;
 
-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);
         getGL().glLoadMatrixf(matrixBuffer, 0);
     }
     }
 
     @Override
-    protected void glFogColor(ReadOnlyVector4f color) {
+    protected void glFogColor(@Const Vector4 color) {
         color.get(vector4Buffer, 0);
         getGL().glFogfv(GL2.GL_FOG_COLOR, vector4Buffer, 0);
     }
     }
 
     @Override
-    protected void glGlobalLighting(ReadOnlyVector4f ambient) {
+    protected void glGlobalLighting(@Const Vector4 ambient) {
         ambient.get(vector4Buffer, 0);
         getGL().glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, vector4Buffer, 0);
     }
     
 
     @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);
         getGL().glLightfv(GL2.GL_LIGHT0 + light, c, vector4Buffer, 0);
     }
 
     @Override
-    protected void glLightPosition(int light, ReadOnlyVector4f pos) {
+    protected void glLightPosition(int light, @Const Vector4 pos) {
         pos.get(vector4Buffer, 0);
         getGL().glLightfv(GL2.GL_LIGHT0 + light, GL2.GL_POSITION, vector4Buffer, 0);
     }
 
     @Override
-    protected void glLightDirection(int light, ReadOnlyVector3f dir) {
+    protected void glLightDirection(int light, @Const Vector3 dir) {
         dir.get(vector3Buffer, 0);
         getGL().glLightfv(GL2.GL_LIGHT0 + light, GL2.GL_SPOT_DIRECTION, vector3Buffer, 0);
     }
     }
 
     @Override
-    protected void glMaterialColor(LightColor component, ReadOnlyVector4f color) {
+    protected void glMaterialColor(LightColor component, @Const Vector4 color) {
         color.get(vector4Buffer, 0);
         int c = getGLLight(component);
         if (component == LightColor.DIFFUSE)
     }
 
     @Override
-    protected void glTextureColor(ReadOnlyVector4f color) {
+    protected void glTextureColor(@Const Vector4 color) {
         color.get(vector4Buffer, 0);
         getGL().glTexEnvfv(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_COLOR, vector4Buffer, 0);
     }
     }
 
     @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);
         getGL().glTexGenfv(tc, GL2.GL_EYE_PLANE, vector4Buffer, 0);
     }
 
     @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);
         getGL().glTexGenfv(tc, GL2.GL_OBJECT_PLANE, vector4Buffer, 0);

File ferox-renderer/ferox-renderer-jogl/src/main/java/com/ferox/renderer/impl/jogl/JoglRendererDelegate.java

 import javax.media.opengl.GL2;
 import javax.media.opengl.GL2GL3;
 
-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;
     
     }
     
     @Override
-    protected void glBlendColor(ReadOnlyVector4f color) {
+    protected void glBlendColor(@Const Vector4 color) {
         if (supportsBlending)
-            getGL().glBlendColor(color.getX(), color.getY(), color.getZ(), color.getW());
+            getGL().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);
-            gl.glClearColor(color.getX(), color.getY(), color.getZ(), color.getW());
+            gl.glClearColor((float) color.x, (float) color.y, (float) color.z, (float) color.w);
         }
         if (this.clearDepth != depth) {
             this.clearDepth = depth;

File ferox-renderer/ferox-renderer-jogl/src/test/java/com/ferox/renderer/impl/jogl/FixedFunctionRenderTest.java

 package com.ferox.renderer.impl.jogl;
 
-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.DisplayMode;
             shape = new Sphere(2f, 32, 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());
                 
-                Matrix4f t = new Matrix4f();
+                Matrix4 t = new Matrix4();
                 int rendered = 0;
                 for (int i = 0; i < 10000; i++) {
                     t.setIdentity();

File ferox-renderer/ferox-renderer-jogl/src/test/java/com/ferox/renderer/impl/jogl/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;
+import com.ferox.renderer.DisplayMode.PixelFormat;
 import com.ferox.renderer.Framework;
 import com.ferox.renderer.GlslRenderer;
 import com.ferox.renderer.HardwareAccessLayer;
 import com.ferox.renderer.OnscreenSurface;
 import com.ferox.renderer.OnscreenSurfaceOptions;
-import com.ferox.renderer.DisplayMode.PixelFormat;
 import com.ferox.renderer.OnscreenSurfaceOptions.DepthFormat;
 import com.ferox.renderer.Surface;
 import com.ferox.renderer.Task;
             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);