public void uniformMatrix4fv(__WebGLUniformLocation u, int p1, bool p2, float[] mMVPMatrix, int p3) { // see also: http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml // see also: http://developer.android.com/reference/android/opengl/GLES20.html#glUniformMatrix4fv(int, int, boolean, float[], int) //void glUniformMatrix4fv( GLint location, // GLsizei count, // GLboolean transpose, // const GLfloat * value); GLES20.glUniformMatrix4fv(u.value, p1, p2, mMVPMatrix, p3); }
public void uniformMatrix4fv(__WebGLUniformLocation location, bool transpose, float[] value) { // see also: http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml // see also: http://developer.android.com/reference/android/opengl/GLES20.html#glUniformMatrix4fv(int, int, boolean, float[], int) //void glUniformMatrix4fv( GLint location, // GLsizei count, // GLboolean transpose, // const GLfloat * value); GLES20.glUniformMatrix4fv(location.value, /* count */ 1, transpose, value, /* offset */ 0); }
public void uniform3fv(__WebGLUniformLocation u, float[] p1) { GLES20.glUniform3fv(u, p1.Length * 4, p1, 0); }
public void uniform3f(__WebGLUniformLocation u, float p1, float p2, float p3) { GLES20.glUniform3f(u, p1, p2, p3); }
internal void vertexAttrib3f(__WebGLUniformLocation pointPositionHandle, float p1, float p2, float p3) { GLES20.glVertexAttrib3f(pointPositionHandle.value, p1, p2, p3); }
public void uniform2f(__WebGLUniformLocation u, float x, float y) { GLES20.glUniform2f(u, x, y); }
public void onDrawFrame(GL10 glUnused) { if (_width < _height) gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); else gl.clearColor(1.0f, 1.0f, 1.0f, 0.0f); gl.clear(opengl.GL_COLOR_BUFFER_BIT | opengl.GL_DEPTH_BUFFER_BIT); // Do a complete rotation every 10 seconds. long time = SystemClock.uptimeMillis() % 20000L; float angleInDegrees = (360.0f / 20000.0f) * ((int)time); // Set our per-vertex lighting program. gl.useProgram(mProgramHandle); // Set program handles for cube drawing. mMVPMatrixHandle = gl.getUniformLocation(mProgramHandle, "u_MVPMatrix"); mMVMatrixHandle = gl.getUniformLocation(mProgramHandle, "u_MVMatrix"); mLightPosHandle = gl.getUniformLocation(mProgramHandle, "u_LightPos"); mTextureUniformHandle = gl.getUniformLocation(mProgramHandle, "u_Texture"); mPositionHandle = gl.getAttribLocation(mProgramHandle, "a_Position"); mColorHandle = gl.getAttribLocation(mProgramHandle, "a_Color"); mNormalHandle = gl.getAttribLocation(mProgramHandle, "a_Normal"); mTextureCoordinateHandle = gl.getAttribLocation(mProgramHandle, "a_TexCoordinate"); // Set the active texture unit to texture unit 0. opengl.glActiveTexture(opengl.GL_TEXTURE0); // Bind the texture to this unit. if (_width < _height) opengl.glBindTexture(opengl.GL_TEXTURE_2D, mTextureDataHandle2); else opengl.glBindTexture(opengl.GL_TEXTURE_2D, mTextureDataHandle); // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0. gl.uniform1i(mTextureUniformHandle, 0); // Calculate position of the light. Rotate and then push into the distance. Matrix.setIdentityM(mLightModelMatrix, 0); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f); Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f); Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0); Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0); // Draw some cubes. //#region cube on right //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f); //drawCube(); //#endregion Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f); Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -4.0f); Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, -1.0f, 0.0f); drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f); //drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f); //drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 0.0f); //drawCube(); // Draw a point to indicate the light. //gl.useProgram(mPointProgramHandle); //drawLight(); }
public void uniform1i(__WebGLUniformLocation u, int p) { // webgl is using int64 instead of in32. why? is the idl being used correctly? GLES20.glUniform1i(u.value, p); }
internal void disableVertexAttribArray(__WebGLUniformLocation pointPositionHandle) { GLES20.glDisableVertexAttribArray(pointPositionHandle.value); }
public void uniform1i(__WebGLUniformLocation u, int p) { GLES20.glUniform1i(u, p); }
public void uniform1f(__WebGLUniformLocation u, float x) { GLES20.glUniform1f(u, x); }
public void onDrawFrame(GL10 glUnused) { if (_width < _height) { gl.clearColor(0.0f, 0.0f, 0.0f, 0.0f); } else { gl.clearColor(1.0f, 1.0f, 1.0f, 0.0f); } gl.clear(opengl.GL_COLOR_BUFFER_BIT | opengl.GL_DEPTH_BUFFER_BIT); // Do a complete rotation every 10 seconds. long time = SystemClock.uptimeMillis() % 20000L; float angleInDegrees = (360.0f / 20000.0f) * ((int)time); // Set our per-vertex lighting program. gl.useProgram(mProgramHandle); // Set program handles for cube drawing. mMVPMatrixHandle = gl.getUniformLocation(mProgramHandle, "u_MVPMatrix"); mMVMatrixHandle = gl.getUniformLocation(mProgramHandle, "u_MVMatrix"); mLightPosHandle = gl.getUniformLocation(mProgramHandle, "u_LightPos"); mTextureUniformHandle = gl.getUniformLocation(mProgramHandle, "u_Texture"); mPositionHandle = gl.getAttribLocation(mProgramHandle, "a_Position"); mColorHandle = gl.getAttribLocation(mProgramHandle, "a_Color"); mNormalHandle = gl.getAttribLocation(mProgramHandle, "a_Normal"); mTextureCoordinateHandle = gl.getAttribLocation(mProgramHandle, "a_TexCoordinate"); // Set the active texture unit to texture unit 0. opengl.glActiveTexture(opengl.GL_TEXTURE0); // Bind the texture to this unit. if (_width < _height) { opengl.glBindTexture(opengl.GL_TEXTURE_2D, mTextureDataHandle2); } else { opengl.glBindTexture(opengl.GL_TEXTURE_2D, mTextureDataHandle); } // Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0. gl.uniform1i(mTextureUniformHandle, 0); // Calculate position of the light. Rotate and then push into the distance. Matrix.setIdentityM(mLightModelMatrix, 0); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f); Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f); Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f); Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0); Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0); // Draw some cubes. //#region cube on right //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f); //drawCube(); //#endregion Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f); Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -4.0f); Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, -1.0f, 0.0f); drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f); //drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f); //drawCube(); //Matrix.setIdentityM(mModelMatrix, 0); //Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f); //Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 0.0f); //drawCube(); // Draw a point to indicate the light. //gl.useProgram(mPointProgramHandle); //drawLight(); }