diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-05-15 17:10:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-05-15 17:10:29 -0700 |
commit | 1169a930d7b7ea6db76aa046eb6a3751cb568659 (patch) | |
tree | 039619cf5758827165046135606dbec0c05ac5f3 | |
parent | aec9ccfeac86729ec0306934d40df32503fd6354 (diff) | |
parent | ab692411e4a9f3fc6374a48c7a153962fa5d3059 (diff) |
Merge pull request #428 from ehsan/fixes
A bunch of random fixes
-rw-r--r-- | src/library.js | 34 | ||||
-rw-r--r-- | src/library_gl.js | 7 | ||||
-rw-r--r-- | src/library_sdl.js | 4 | ||||
-rw-r--r-- | tests/sdl_image.c | 26 |
4 files changed, 44 insertions, 27 deletions
diff --git a/src/library.js b/src/library.js index 9e56d42e..ea44f259 100644 --- a/src/library.js +++ b/src/library.js @@ -90,18 +90,18 @@ LibraryManager.library = { #if FS_LOG var inputPath = path; function log() { - print('FS.analyzePath("' + inputPath + '", ' + - dontResolveLastLink + ', ' + - linksVisited + ') => {' + - 'isRoot: ' + ret.isRoot + ', ' + - 'exists: ' + ret.exists + ', ' + - 'error: ' + ret.error + ', ' + - 'name: "' + ret.name + '", ' + - 'path: "' + ret.path + '", ' + - 'object: ' + ret.object + ', ' + - 'parentExists: ' + ret.parentExists + ', ' + - 'parentPath: "' + ret.parentPath + '", ' + - 'parentObject: ' + ret.parentObject + '}'); + Module['print']('FS.analyzePath("' + inputPath + '", ' + + dontResolveLastLink + ', ' + + linksVisited + ') => {' + + 'isRoot: ' + ret.isRoot + ', ' + + 'exists: ' + ret.exists + ', ' + + 'error: ' + ret.error + ', ' + + 'name: "' + ret.name + '", ' + + 'path: "' + ret.path + '", ' + + 'object: ' + ret.object + ', ' + + 'parentExists: ' + ret.parentExists + ', ' + + 'parentPath: "' + ret.parentPath + '", ' + + 'parentObject: ' + ret.parentObject + '}'); } #endif path = FS.absolutePath(path); @@ -177,11 +177,11 @@ LibraryManager.library = { // Creates a file system record: file, link, device or folder. createObject: function(parent, name, properties, canRead, canWrite) { #if FS_LOG - print('FS.createObject("' + parent + '", ' + - '"' + name + '", ' + - JSON.stringify(properties) + ', ' + - canRead + ', ' + - canWrite + ')'); + Module['print']('FS.createObject("' + parent + '", ' + + '"' + name + '", ' + + JSON.stringify(properties) + ', ' + + canRead + ', ' + + canWrite + ')'); #endif if (!parent) parent = '/'; if (typeof parent === 'string') parent = FS.findObject(parent); diff --git a/src/library_gl.js b/src/library_gl.js index 8867a830..72246df3 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -1835,6 +1835,8 @@ var LibraryGL = { glPolygonMode: function(){}, // TODO + glAlphaFunc: function(){}, // TODO + // ClientState/gl*Pointer glEnableClientState: function(cap, disable) { @@ -1964,6 +1966,7 @@ var LibraryGL = { GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], GL.immediate.matrix.lib.mat4.ortho(left, right, bottom, top_, nearVal, farVal)); }, + glOrthof: 'glOrtho', glScaled: function(x, y, z) { GL.immediate.matrix.lib.mat4.scale(GL.immediate.matrix[GL.immediate.currentMatrix], [x, y, z]); @@ -2042,8 +2045,8 @@ var LibraryGL = { // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name [[0, 'shadeModel fogi fogfv getError* finish flush'], - [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear enableVertexAttribArray disableVertexAttribArray lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation polygonOffset hint sampleCoverage isEnabled*'], - [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate'], + [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear enableVertexAttribArray disableVertexAttribArray lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation polygonOffset sampleCoverage isEnabled*'], + [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint'], [3, 'texParameteri texParameterf drawArrays vertexAttrib2f stencilFunc stencilOp'], [4, 'viewport clearColor scissor vertexAttrib3f colorMask drawElements renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'], [5, 'vertexAttrib4f'], diff --git a/src/library_sdl.js b/src/library_sdl.js index d6e205ee..472228c1 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -756,6 +756,10 @@ var LibrarySDL = { IMG_Load__deps: ['SDL_LockSurface'], IMG_Load: function(filename) { filename = FS.standardizePath(Pointer_stringify(filename)); + if (filename[0] == '/') { + // Convert the path to relative + filename = filename.substr(1); + } var raw = preloadedImages[filename]; if (!raw) { Runtime.warnOnce('Cannot find preloaded image ' + filename); diff --git a/tests/sdl_image.c b/tests/sdl_image.c index d934f863..9d8c36f2 100644 --- a/tests/sdl_image.c +++ b/tests/sdl_image.c @@ -4,30 +4,40 @@ #include <assert.h> #include <emscripten.h> -int main() { - SDL_Init(SDL_INIT_VIDEO); - SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE); - - SDL_Surface *image = IMG_Load("screenshot.jpg"); +int testImage(SDL_Surface* screen, const char* fileName) { + SDL_Surface *image = IMG_Load(fileName); if (!image) { printf("IMG_Load: %s\n", IMG_GetError()); - return 1; + return 0; } assert(image->format->BitsPerPixel == 32); assert(image->format->BytesPerPixel == 4); assert(image->pitch == 4*image->w); + int result = image->w; SDL_BlitSurface (image, NULL, screen, NULL); SDL_FreeSurface (image); - SDL_Flip(screen); + return result; +} + +int main() { + SDL_Init(SDL_INIT_VIDEO); + SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_SWSURFACE); + + int result = 0; + result = testImage(screen, "screenshot.jpg"); // relative path + assert(result != 0); + result |= testImage(screen, "/screenshot.jpg"); // absolute path + assert(result != 0); + + SDL_Flip(screen); printf("you should see an image.\n"); SDL_Quit(); - int result = image->w; REPORT_RESULT(); return 0; |