webgl-tools

changeset 4:06d05a65bd77

- added glass_resize and glass_reshape_func
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 18 Jun 2011 05:13:48 +0300
parents 56ae66e32998
children 7b3ed284e4bb
files glass.js
diffstat 1 files changed, 51 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/glass.js	Sat Jun 18 05:13:01 2011 +0300
     1.2 +++ b/glass.js	Sat Jun 18 05:13:48 2011 +0300
     1.3 @@ -16,6 +16,37 @@
     1.4  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     1.5  */
     1.6  
     1.7 +/* public interface
     1.8 +
     1.9 +bool glass_init(canvas-id, optional-console-textarea-id);
    1.10 +void glass_start(void);
    1.11 +
    1.12 +void glass_display_func(callback);
    1.13 +void glass_reshape_func(callback);
    1.14 +void glass_mouse_func(callback);
    1.15 +void glass_motion_func(callback);
    1.16 +
    1.17 +void glass_resize(x, y);
    1.18 +
    1.19 +WebGLTexture load_texture(uri);
    1.20 +
    1.21 +WebGLShader load_shader(uri, type);
    1.22 +WebGLShader create_shader(source, type, optional-sdrname);
    1.23 +WebGLProgram load_program(vertex-uri, fragment-uri);
    1.24 +WebGLProgram create_program(vertex-shader, fragment-shader);
    1.25 +
    1.26 +void set_uniform1i(program, uniform-name, value);
    1.27 +void set_uniform1f(program, uniform-name, value);
    1.28 +void set_uniform2f(program, uniform-name, x, y);
    1.29 +void set_uniform3f(program, uniform-name, x, y, z);
    1.30 +void set_uniform4f(program, uniform-name, x, y, z, w);
    1.31 +void set_uniform_matrix4fv(program, uniform-name, matrix);
    1.32 +
    1.33 +void request_redisplay(void);
    1.34 +
    1.35 +void logmsg(string);
    1.36 +*/
    1.37 +
    1.38  var gl;
    1.39  var canvas, console;
    1.40  var glass_data_loaded, glass_data_count;
    1.41 @@ -23,6 +54,7 @@
    1.42  var glass_start_time = 0;
    1.43  
    1.44  var glass_cb_disp = null;
    1.45 +var glass_cb_reshape = null;
    1.46  var glass_cb_mouse = null;
    1.47  var glass_cb_motion = null;
    1.48  
    1.49 @@ -73,6 +105,10 @@
    1.50  	}
    1.51  
    1.52  	glass_start_time = get_msec();
    1.53 +
    1.54 +	if(glass_cb_reshape) {
    1.55 +		glass_cb_reshape(canvas.width, canvas.height);
    1.56 +	}
    1.57  	glass_redraw();
    1.58  }
    1.59  
    1.60 @@ -81,6 +117,11 @@
    1.61  	glass_cb_disp = func;
    1.62  }
    1.63  
    1.64 +function glass_reshape_func(func)
    1.65 +{
    1.66 +	glass_cb_reshape = func;
    1.67 +}
    1.68 +
    1.69  function glass_mouse_func(func)
    1.70  {
    1.71  	glass_cb_mouse = func;
    1.72 @@ -91,6 +132,16 @@
    1.73  	glass_cb_motion = func;
    1.74  }
    1.75  
    1.76 +function glass_resize(x, y)
    1.77 +{
    1.78 +	canvas.width = x;
    1.79 +	canvas.height = y;
    1.80 +
    1.81 +	if(glass_cb_reshape) {
    1.82 +		glass_cb_reshape(x, y);
    1.83 +	}
    1.84 +}
    1.85 +
    1.86  
    1.87  function glass_redraw()
    1.88  {