diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-19 13:51:33 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-19 13:51:33 -0700 |
commit | 3d706595b238cadd6f449e30e486f61dd4c0e0b4 (patch) | |
tree | 797533d401a215c6f49a2a3f43f08ab0d618d423 | |
parent | a00c76524c3e4ffc12eb309459b74c50a3da3ad7 (diff) | |
parent | 1259e205f5e4b4a5c4bed1dc84f5798f48e11eab (diff) |
Merge pull request #359 from prenaux/develop
library.js, added llvm_invariant_start/end & llvm_bswap_i16 ; hello_world_gles.c, added F11 for fullscreen ;
-rw-r--r-- | src/library.js | 24 | ||||
-rw-r--r-- | src/library_gl.js | 2 | ||||
-rw-r--r-- | src/library_glut.js | 7 | ||||
-rw-r--r-- | tests/hello_world_gles.c | 63 |
4 files changed, 61 insertions, 35 deletions
diff --git a/src/library.js b/src/library.js index c491f078..7a46a68f 100644 --- a/src/library.js +++ b/src/library.js @@ -1867,7 +1867,7 @@ LibraryManager.library = { #if CATCH_EXIT_CODE throw new ExitStatus(); -#else +#else throw 'exit(' + status + ') called, at ' + new Error().stack; #endif }, @@ -4394,6 +4394,21 @@ LibraryManager.library = { */ }, + llvm_bswap_i16: function(x) { + x = unSign(x, 32); + var bytes = []; + bytes[0] = x & 255; + x >>= 8; + bytes[1] = x & 255; + x >>= 8; + var ret = 0; + ret <<= 8; + ret += bytes[0]; + ret <<= 8; + ret += bytes[1]; + return ret; + }, + llvm_bswap_i32: function(x) { x = unSign(x, 32); var bytes = []; @@ -4408,7 +4423,7 @@ LibraryManager.library = { } return ret; }, - + llvm_ctlz_i32: function(x) { for (var i=0; i<32; i++) { if ( (x & (1 << (31-i))) != 0 ) { @@ -4711,6 +4726,9 @@ LibraryManager.library = { llvm_lifetime_start: function() {}, llvm_lifetime_end: function() {}, + llvm_invariant_start: function() {}, + llvm_invariant_end: function() {}, + // ========================================================================== // math.h // ========================================================================== @@ -4935,7 +4953,7 @@ LibraryManager.library = { if (isNaN(x)) return {{{ cDefine('FP_NAN') }}}; if (!isFinite(x)) return {{{ cDefine('FP_INFINITE') }}}; if (x == 0) return {{{ cDefine('FP_ZERO') }}}; - // FP_SUBNORMAL..? + // FP_SUBNORMAL..? return {{{ cDefine('FP_NORMAL') }}}; }, __fpclassifyd: '__fpclassifyf', diff --git a/src/library_gl.js b/src/library_gl.js index deb39a03..983d1e2c 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -116,6 +116,8 @@ var LibraryGL = { return allocate(intArrayFromString(Module.ctx.getParameter(name_)), 'i8', ALLOC_NORMAL); case 0x1F03 /* GL_EXTENSIONS */: return allocate(intArrayFromString(Module.ctx.getSupportedExtensions().join(' ')), 'i8', ALLOC_NORMAL); + case 0x8B8C /*GL_SHADING_LANGUAGE_VERSION*/: + return allocate(intArrayFromString("OpenGL ES GLSL ES 1.00 (WebGL)"), 'i8', ALLOC_NORMAL); default: throw 'Failure: Invalid glGetString value: ' + name_; } diff --git a/src/library_glut.js b/src/library_glut.js index e4b2d138..9ad83684 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -226,13 +226,13 @@ var LibraryGLUT = { onFullScreenEventChange: function(event){ var width; var height; - if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) { + if (document["fullScreen"] || document["mozFullScreen"] || document["webkitIsFullScreen"]) { width = screen["width"]; height = screen["height"]; } else { width = GLUT.windowWidth; height = GLUT.windowHeight; - // TODO set position + // TODO set position document.removeEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true); document.removeEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true); document.removeEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true); @@ -241,6 +241,7 @@ var LibraryGLUT = { Module['canvas'].height = height; /* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */ if (GLUT.reshapeFunc) { + // console.log("GLUT.reshapeFunc (from FS): " + width + ", " + height); FUNCTION_TABLE[GLUT.reshapeFunc](width, height); } _glutPostRedisplay(); @@ -378,9 +379,11 @@ var LibraryGLUT = { glutReshapeWindow__deps: ['$GLUT', 'glutPostRedisplay'], glutReshapeWindow: function(width, height) { GLUT.cancelFullScreen(); + // console.log("glutReshapeWindow: " + width + ", " + height); Module['canvas'].width = width; Module['canvas'].height = height; if (GLUT.reshapeFunc) { + // console.log("GLUT.reshapeFunc: " + width + ", " + height); FUNCTION_TABLE[GLUT.reshapeFunc](width, height); } _glutPostRedisplay(); diff --git a/tests/hello_world_gles.c b/tests/hello_world_gles.c index 6f7a4324..78595a49 100644 --- a/tests/hello_world_gles.c +++ b/tests/hello_world_gles.c @@ -1,16 +1,16 @@ /* * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -23,7 +23,7 @@ * Ported to GLES2. * Kristian Høgsberg <krh@bitplanet.net> * May 3, 2010 - * + * * Improve GLES2 port: * * Refactor gear drawing. * * Use correct normals for surfaces. @@ -113,15 +113,15 @@ static GLfloat ProjectionMatrix[16]; /** The direction of the directional light for the scene */ static const GLfloat LightSourcePosition[4] = { 5.0, 5.0, 10.0, 1.0}; -/** +/** * Fills a gear vertex. - * + * * @param v the vertex to fill * @param x the x coordinate * @param y the y coordinate * @param z the z coortinate - * @param n pointer to the normal table - * + * @param n pointer to the normal table + * * @return the operation error code */ static GearVertex * @@ -139,13 +139,13 @@ vert(GearVertex *v, GLfloat x, GLfloat y, GLfloat z, GLfloat n[3]) /** * Create a gear wheel. - * + * * @param inner_radius radius of hole at center * @param outer_radius radius at center of teeth * @param width width of gear * @param teeth number of teeth * @param tooth_depth depth of tooth - * + * * @return pointer to the constructed struct gear */ static struct gear * @@ -289,11 +289,11 @@ create_gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, return gear; } -/** +/** * Multiplies two 4x4 matrices. - * + * * The result is stored in matrix m. - * + * * @param m the first matrix to multiply * @param n the second matrix to multiply */ @@ -316,9 +316,9 @@ multiply(GLfloat *m, const GLfloat *n) memcpy(m, &tmp, sizeof tmp); } -/** +/** * Rotates a 4x4 matrix. - * + * * @param[in,out] m the matrix to rotate * @param angle the angle to rotate * @param x the x component of the direction to rotate to @@ -333,7 +333,7 @@ rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) sincos(angle, &s, &c); GLfloat r[16] = { x * x * (1 - c) + c, y * x * (1 - c) + z * s, x * z * (1 - c) - y * s, 0, - x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0, + x * y * (1 - c) - z * s, y * y * (1 - c) + c, y * z * (1 - c) + x * s, 0, x * z * (1 - c) + y * s, y * z * (1 - c) - x * s, z * z * (1 - c) + c, 0, 0, 0, 0, 1 }; @@ -342,9 +342,9 @@ rotate(GLfloat *m, GLfloat angle, GLfloat x, GLfloat y, GLfloat z) } -/** +/** * Translates a 4x4 matrix. - * + * * @param[in,out] m the matrix to translate * @param x the x component of the direction to translate to * @param y the y component of the direction to translate to @@ -358,9 +358,9 @@ translate(GLfloat *m, GLfloat x, GLfloat y, GLfloat z) multiply(m, t); } -/** +/** * Creates an identity 4x4 matrix. - * + * * @param m the matrix make an identity matrix */ static void @@ -376,12 +376,12 @@ identity(GLfloat *m) memcpy(m, t, sizeof(t)); } -/** +/** * Transposes a 4x4 matrix. * * @param m the matrix to transpose */ -static void +static void transpose(GLfloat *m) { GLfloat t[16] = { @@ -420,9 +420,9 @@ invert(GLfloat *m) multiply(m, t); } -/** +/** * Calculate a perspective projection transformation. - * + * * @param m the matrix to save the transformation in * @param fovy the field of view in the y direction * @param aspect the view aspect ratio @@ -485,7 +485,7 @@ draw_gear(struct gear *gear, GLfloat *transform, glUniformMatrix4fv(ModelViewProjectionMatrix_location, 1, GL_FALSE, model_view_projection); - /* + /* * Create and set the NormalMatrix. It's the inverse transpose of the * ModelView matrix. */ @@ -520,7 +520,7 @@ draw_gear(struct gear *gear, GLfloat *transform, glDisableVertexAttribArray(0); } -/** +/** * Draws the gears. */ static void @@ -549,9 +549,9 @@ gears_draw(void) glutSwapBuffers(); } -/** +/** * Handles a new window size or exposure. - * + * * @param width the window width * @param height the window height */ @@ -565,9 +565,9 @@ gears_reshape(int width, int height) glViewport(0, 0, (GLint) width, (GLint) height); } -/** +/** * Handles special glut events. - * + * * @param special the event to handle. */ static void @@ -586,6 +586,9 @@ gears_special(int special, int crap, int morecrap) case GLUT_KEY_DOWN: view_rot[0] -= 5.0; break; + case GLUT_KEY_F11: + glutFullScreen(); + break; } } |