From 038ffdee1f8bc77b2f9d42c5f7734d31bbffb3e7 Mon Sep 17 00:00:00 2001 From: aSydiK Date: Thu, 22 Jul 2010 13:09:05 -0400 Subject: [PATCH] added runDefault function to set functions to default, working within resize atm [#24 state:review-requested] --- psapi.js | 67 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/psapi.js b/psapi.js index 6c395be..814333b 100644 --- a/psapi.js +++ b/psapi.js @@ -503,34 +503,12 @@ function PointStream(){ }, /** - Resize the viewport. - This can be called after setup - - width - height + Sets variables to default values. */ - resize: function(width, height){ - // delete old program object? - // delete old context? - - canvas.setAttribute("width", width); - canvas.setAttribute("height", height); - - // check if style exists? how? can't just query it... - canvas.style.width = xb.width = width; - canvas.style.height = xb.height = height; - - ctx = canvas.getContext("experimental-webgl"); - ctx.viewport(0, 0, width, height); - ctx.enable(ctx.DEPTH_TEST); - - xb.background(bk); - - progObj = createProgramObject(ctx, vertexShaderSource, fragmentShaderSource); - ctx.useProgram(progObj); - + runDefault: function(){ + var fovy = 60; - var aspect = width/height; + var aspect = this.width/this.height; var znear = 0.001; var zfar = 1000; @@ -550,16 +528,47 @@ function PointStream(){ var B = (top + bottom) / (top - bottom); var C = -(zfar + znear) / (zfar - znear); var D = -2 * zfar * znear / (zfar - znear); - + projection = M4x4.$( X, 0, A, 0, 0, Y, B, 0, 0, 0, C, D, 0, 0, -1, 0); - view = M4x4.$(1,0,0,0,0,1,0,0,0,0,1, 0,0,0,0,1); + view = M4x4.$(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); model = M4x4.$(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); - normalTransform = M4x4.$(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); + normalTransform = M4x4.$(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1); + + }, + + /** + Resize the viewport. + This can be called after setup + + width + height + */ + resize: function(width, height){ + // delete old program object? + // delete old context? + + canvas.setAttribute("width", width); + canvas.setAttribute("height", height); + + // check if style exists? how? can't just query it... + canvas.style.width = xb.width = width; + canvas.style.height = xb.height = height; + + ctx = canvas.getContext("experimental-webgl"); + ctx.viewport(0, 0, width, height); + ctx.enable(ctx.DEPTH_TEST); + + xb.background(bk); + + progObj = createProgramObject(ctx, vertexShaderSource, fragmentShaderSource); + ctx.useProgram(progObj); + + xb.runDefault(); // if VBOs already exist, recreate them if(VBOs) {