@@ -151,6 +151,7 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
152 var gl = model.cache.gl;
152 var gl = model.cache.gl;
154+ gl.viewport(0, 0, model.w, model.h);
154 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
155 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
155 console.log("Drawing");
156 console.log("Drawing");
@@ -226,24 +227,40 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
227 function render(model) {
228 function render(model) {
230+ var div = newNode('div');
231+ div.style.overflow = 'hidden';
229− var node = newNode('canvas');
232+ var canvas = newNode('canvas');
230− var gl = node.getContext('webgl') || node.getContext('experimental-webgl');
233+ var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
231 gl.enable(gl.DEPTH_TEST);
234 gl.enable(gl.DEPTH_TEST);
233 model.cache.gl = gl;
236 model.cache.gl = gl;
237+ model.cache.canvas = canvas;
234 model.cache.programs = [];
238 model.cache.programs = [];
235 model.cache.buffers = [];
239 model.cache.buffers = [];
237− drawGL(model);
241+ update(div, model, model);
238− return node;
243+ return div;
242− function update(_node, oldModel, newModel) {
247+ function update(div, oldModel, newModel) {
244 newModel.cache = oldModel.cache;
249 newModel.cache = oldModel.cache;
251+ var canvas = newModel.cache.canvas;
253+ canvas.style.width = oldModel.w + 'px';
254+ canvas.style.height = oldModel.h + 'px';
255+ canvas.style.display = "block";
256+ canvas.style.position = "absolute";
257+ canvas.width = oldModel.w;
258+ canvas.height = oldModel.h;
245 drawGL(newModel);
260 drawGL(newModel);
262+ div.appendChild(canvas);
249 var elem = {
266 var elem = {
@@ -254,6 +271,8 @@ Elm.Native.Graphics.WebGL.make = function(elm) {
255 models: models,
272 models: models,
256 cache: {},
273 cache: {},