Merge branch 'master' into libcxx
This commit is contained in:
Коммит
02cf5021ed
1
AUTHORS
1
AUTHORS
|
@ -12,5 +12,6 @@ under the licensing terms detailed in LICENSE.
|
|||
* David Claughton <dave@eclecticdave.com>
|
||||
* David Yip <yipdw@member.fsf.org>
|
||||
* Julien Hamaide <julien.hamaide@gmail.com>
|
||||
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (copyright owned by Mozilla Foundation)
|
||||
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ var LibraryGL = {
|
|||
|
||||
glGetString: function(name_) {
|
||||
switch(name_) {
|
||||
case Module.ctxGL.VENDOR:
|
||||
case Module.ctxGL.RENDERER:
|
||||
case Module.ctxGL.VERSION:
|
||||
return allocate(intArrayFromString(Module.ctxGL.getParameter(name_)), 'i8', ALLOC_NORMAL);
|
||||
case Module.ctx.VENDOR:
|
||||
case Module.ctx.RENDERER:
|
||||
case Module.ctx.VERSION:
|
||||
return allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL);
|
||||
case 0x1F03: // Extensions
|
||||
return allocate(intArrayFromString(Module.ctxGL.getSupportedExtensions().join(' ')), 'i8', ALLOC_NORMAL);
|
||||
return allocate(intArrayFromString(Module.ctx.getSupportedExtensions().join(' ')), 'i8', ALLOC_NORMAL);
|
||||
default:
|
||||
throw 'Failure: Invalid glGetString value: ' + name_;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ var LibraryGL = {
|
|||
|
||||
glGetIntegerv: function(name_, p) {
|
||||
switch(name_) {
|
||||
case Module.ctxGL.MAX_TEXTURE_SIZE:
|
||||
IHEAP[p] = Module.ctxGL.getParameter(name_);
|
||||
case Module.ctx.MAX_TEXTURE_SIZE:
|
||||
IHEAP[p] = Module.ctx.getParameter(name_);
|
||||
break;
|
||||
default:
|
||||
throw 'Failure: Invalid glGetIntegerv value: ' + name_;
|
||||
|
@ -35,7 +35,7 @@ var LibraryGL = {
|
|||
glGenTextures: function(n, textures) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
var id = GL.textureCounter++;
|
||||
GL.textures[id] = Module.ctxGL.createTexture();
|
||||
GL.textures[id] = Module.ctx.createTexture();
|
||||
IHEAP[textures+QUANTUM_SIZE*i] = id;
|
||||
}
|
||||
},
|
||||
|
@ -43,7 +43,7 @@ var LibraryGL = {
|
|||
glDeleteTextures: function(n, textures) {
|
||||
for (var i = 0; i < n; i++) {
|
||||
var id = IHEAP[textures+QUANTUM_SIZE*i];
|
||||
Module.ctxGL.deleteTexture(GL.textures[id]);
|
||||
Module.ctx.deleteTexture(GL.textures[id]);
|
||||
delete GL.textures[id];
|
||||
}
|
||||
},
|
||||
|
@ -52,18 +52,34 @@ var LibraryGL = {
|
|||
if (pixels) {
|
||||
pixels = new Uint8Array(IHEAP.slice(pixels, pixels + width*height*4)); // TODO: optimize
|
||||
}
|
||||
Module.ctxGL.texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
Module.ctx.texImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
},
|
||||
|
||||
glTexSubImage2D: function(target, level, xoffset, yoffset, width, height, format, type, pixels) {
|
||||
if (pixels) {
|
||||
pixels = new Uint8Array(IHEAP.slice(pixels, pixels + width*height*4)); // TODO: optimize
|
||||
}
|
||||
Module.ctxGL.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
Module.ctx.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
},
|
||||
|
||||
glBindTexture: function(target, texture) {
|
||||
Module.ctxGL.bindTexture(target, GL.textures[texture]);
|
||||
Module.ctx.bindTexture(target, GL.textures[texture]);
|
||||
},
|
||||
|
||||
glClearColor: function(red, green, blue, alpha) {
|
||||
Module.ctx.clearColor(red, green, blue, alpha);
|
||||
},
|
||||
|
||||
glClear: function(mask) {
|
||||
Module.ctx.clear(mask);
|
||||
},
|
||||
|
||||
glEnable: function(cap) {
|
||||
Module.ctx.enable(cap);
|
||||
},
|
||||
|
||||
glScissor: function(x, y, width, height) {
|
||||
Module.ctx.scissor(x, y, width, height);
|
||||
},
|
||||
|
||||
};
|
||||
|
@ -83,7 +99,7 @@ var LibraryGL = {
|
|||
var num = data[0];
|
||||
var names = data[1];
|
||||
var args = range(num).map(function(i) { return 'x' + i }).join(', ');
|
||||
var stub = '(function(' + args + ') { ' + (num > 0 ? 'Module.ctxGL.NAME(' + args + ')' : '') + ' })';
|
||||
var stub = '(function(' + args + ') { ' + (num > 0 ? 'Module.ctx.NAME(' + args + ')' : '') + ' })';
|
||||
names.split(' ').forEach(function(name_) {
|
||||
var cName = 'gl' + name_[0].toUpperCase() + name_.substr(1);
|
||||
LibraryGL[cName] = eval(stub.replace('NAME', name_));
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
//"use strict";
|
||||
|
||||
// To use emscripten's SDL library here, you need to define
|
||||
// Module.canvas and at least one of Module.ctx2D, Module.ctxGL.
|
||||
// Module.canvas.
|
||||
//
|
||||
// More specifically, for 2D our SDL implementation will look for
|
||||
// Module.canvas and Module.ctx2D. You should fill them using
|
||||
// something like
|
||||
// More specifically, our SDL implementation will look for
|
||||
// Module.canvas. You should fill it using something like
|
||||
//
|
||||
// function onLoad() {
|
||||
// // Pass canvas and context to the generated code
|
||||
// Module.canvas = document.getElementById('canvas');
|
||||
// Module.ctx2D = Module.canvas.getContext('2d');
|
||||
// }
|
||||
//
|
||||
// Note that this must be called during onload, since you will
|
||||
|
@ -49,11 +47,6 @@
|
|||
function onLoad() {
|
||||
// Pass canvas and context to the generated code, and do the actual run() here
|
||||
Module.canvas = document.getElementById('canvas');
|
||||
Module.ctx2D = Module.canvas.getContext('2d');
|
||||
if (!Module.ctx2D) {
|
||||
alert('Canvas not available :(');
|
||||
return;
|
||||
}
|
||||
Module.run();
|
||||
}
|
||||
</script>
|
||||
|
@ -70,9 +63,6 @@
|
|||
//
|
||||
// * Make sure alpha values are proper in your input. If they are all 0, everything will be transparent!
|
||||
//
|
||||
// * It's best to set the ctx stuff in your html file, as above. Otherwise you will need
|
||||
// to edit the generated .js file each time you generate it.
|
||||
//
|
||||
// * Your code should not write a 32-bit value and expect that to set an RGBA pixel.
|
||||
// The reason is that that data will be read as 8-bit values, and according to the
|
||||
// load-store consistency assumption, it should be written that way (see docs/paper.pdf).
|
||||
|
@ -166,11 +156,14 @@ mergeInto(LibraryManager.library, {
|
|||
{{{ makeSetValue('pixelFormat + SDL.structs.PixelFormat.Bmask', '0', '0xff', 'i32') }}}
|
||||
{{{ makeSetValue('pixelFormat + SDL.structs.PixelFormat.Amask', '0', '0xff', 'i32') }}}
|
||||
|
||||
// Decide if we want to use WebGL or not
|
||||
var useWebGL = (flags & 0x04000000) != 0; // SDL_OPENGL
|
||||
|
||||
SDL.surfaces[surf] = {
|
||||
width: width,
|
||||
height: height,
|
||||
canvas: Module['canvas'],
|
||||
ctx: Module['ctx2D'],
|
||||
ctx: SDL.createContext(useWebGL),
|
||||
surf: surf,
|
||||
buffer: buffer,
|
||||
pixelFormat: pixelFormat,
|
||||
|
@ -179,6 +172,17 @@ mergeInto(LibraryManager.library, {
|
|||
return surf;
|
||||
},
|
||||
|
||||
createContext: function(useWebGL) {
|
||||
try {
|
||||
var ctx = Module.canvas.getContext(useWebGL ? 'experimental-webgl' : '2d');
|
||||
if (!ctx) throw 'Could not create canvas :(';
|
||||
return Module.ctx = ctx;
|
||||
} catch (e) {
|
||||
Module.print('(canvas not available)');
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
freeSurface: function(surf) {
|
||||
_free(SDL.surfaces[surf].buffer);
|
||||
_free(SDL.surfaces[surf].pixelFormat);
|
||||
|
|
|
@ -322,7 +322,7 @@ var LibraryManager = {
|
|||
load: function() {
|
||||
assert(!this.library);
|
||||
|
||||
for (var suffix in set('', '_sdl', '_browser')) {
|
||||
for (var suffix in set('', '_sdl', '_browser', '_gl')) {
|
||||
eval(processMacros(preprocess(read('library' + suffix + '.js'))));
|
||||
}
|
||||
},
|
||||
|
|
|
@ -19,12 +19,6 @@
|
|||
})(),
|
||||
canvas: document.getElementById('canvas')
|
||||
};
|
||||
try {
|
||||
Module.ctx2D = Module.canvas.getContext('2d');
|
||||
if (!Module.ctx2D) throw 'Could not create canvas :(';
|
||||
} catch (e) {
|
||||
Module.print('(canvas not available)');
|
||||
}
|
||||
|
||||
// The compiled code
|
||||
{{{ SCRIPT_CODE }}}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
Simple test runner
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче