Results 1 to 4 of 4

Thread: addition to standard

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    8

    addition to standard

    let WebGLFloatArray.set() return itself.
    Becuase that would spare a few lines of code while it now returns undefined (which is useless).

    http://ewgl.wordpress.com/2009/12/20...rray-overhead/

    btw this is still not implemented in minefield.

    PS this should also account for the other objects in Webgl that have a set method.

  2. #2
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: addition to standard

    In my GoogleWebToolkit-Module for WebGL (I'm calling it WebGLToolkit) the WebGLFloatArray overlay does currently look like this:
    Code :
    package com.delphigl.wgt.overlay;
     
    import com.google.gwt.json.client.JSONArray;
    import com.google.gwt.core.client.JsArrayNumber;
    import com.delphigl.wgt.math.*;
     
    public class WebGLFloatArray extends WebGLArrayBuffer {
    	protected WebGLFloatArray() { }
     
    	public static WebGLFloatArray create(JSONArray array) {
    		return create((JsArrayNumber)array.getJavaScriptObject());
    	}
     
    	public static native WebGLFloatArray create(int size) /*-{
    		return new WebGLFloatArray(size);
    	}-*/;
     
    	public static native WebGLFloatArray create(JsArrayNumber array) /*-{
    		return new WebGLFloatArray(array);
    	}-*/;
     
    	public final native double get(int index) /*-{
    		return this.get(index);
    	}-*/;
     
    	public final native void set(int index, double value) /*-{
    		this.set(index, value);
    	}-*/;
     
    	public final native void set(int offset, Vector2d value) /*-{
    		this.set(offset  , value.@com.delphigl.wgt.math.Vector2d::x);
    		this.set(offset+1, value.@com.delphigl.wgt.math.Vector2d::y);
    	}-*/;
     
    	public final native void set(int offset, Vector3d value) /*-{
    		this.set(offset  , value.@com.delphigl.wgt.math.Vector3d::x);
    		this.set(offset+1, value.@com.delphigl.wgt.math.Vector3d::y);
    		this.set(offset+2, value.@com.delphigl.wgt.math.Vector3d::z);
    	}-*/;
     
    	public final native void set(int offset, Vector4d value) /*-{
    		this.set(offset  , value.@com.delphigl.wgt.math.Vector4d::x);
    		this.set(offset+1, value.@com.delphigl.wgt.math.Vector4d::y);
    		this.set(offset+2, value.@com.delphigl.wgt.math.Vector4d::z);
    		this.set(offset+3, value.@com.delphigl.wgt.math.Vector4d::w);
    	}-*/;
     
    	public final native WebGLFloatArray slice(int offset, int length) /*-{
    		return this.slice(offset, length);
    	}-*/;
    }

    The vector extensions have already proven very helpful. E.g. something like this:
    Code :
    		int lineCount = 0;
    		WebGLFloatArray coords = lineRenderer.getCoordArray();
    		WebGLUnsignedByteArray colors = lineRenderer.getColorArray();
    		Vector4i color = new Vector4i(255, 0, 0, 255);
     
    		// set course projection lines
    		if (semiMajorAxis != 0.0 || parent != null) {
    			for (int i=0; i<positions.length-1; ++i) {
    				coords.set(lineCount*6+0, positions[i]); 
    				coords.set(lineCount*6+3, positions[i+1]); 				
    				colors.set(lineCount*8+0, color);
    				color.w = 255 - (255*(i+1)) / positions.length;
    				colors.set(lineCount*8+4, color);
    				lineCount++;
    			}
    		}

    I could also add your idea.

    However, would need to use GoogleWebToolkit and my framework/module. I haven't released the source yet, but I can send you an the current version, if you wish.

    (I'm using my framework for my "UltimateConquest")

  3. #3
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: addition to standard

    Sorry, I forgot to mention: The above code is Java code, not JavaScript. The GoogleWebToolkit does compile Java-Code to JavaScript.

  4. #4
    Junior Member
    Join Date
    Dec 2009
    Posts
    8

    Re: addition to standard

    I don't like editing native objects,
    so this is a bit out of question,
    I'll probably just use a container function to fix this.

Similar Threads

  1. Replies: 1
    Last Post: 08-07-2011, 09:41 AM
  2. RGB Internal Texture formats in SC standard
    By Xuzuthor in forum OpenGL SC for Safety Critical Markets
    Replies: 3
    Last Post: 04-05-2010, 07:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •