public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); }
public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glMatrixMode(GL10_GL_PROJECTION); float size = .01f * (float)java.lang.Math.tan(java.lang.Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int)_width, (int)_height); gl.glMatrixMode(GL10_GL_MODELVIEW); gl.glEnable(GL10_GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10_GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10_GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10_GL_BACK); gl.glEnableClientState(GL10_GL_VERTEX_ARRAY); gl.glEnableClientState(GL10_GL_COLOR_ARRAY); initTriangle(); }
public override void onDrawFrame(GL10 gl) { mFrameLock.@lock(); if (mCurrentFrame != null && !mVideoDisabled) { GLES20.glUseProgram(mProgram); if (mTextureWidth != mCurrentFrame.Width || mTextureHeight != mCurrentFrame.Height) { setupTextures(mCurrentFrame); } updateTextures(mCurrentFrame); Matrix.setIdentityM(mScaleMatrix, 0); float scaleX = 1.0f, scaleY = 1.0f; float ratio = (float)mCurrentFrame.Width / mCurrentFrame.Height; float vratio = (float)mViewportWidth / mViewportHeight; if (mVideoFitEnabled) { if (ratio > vratio) { scaleY = vratio / ratio; } else { scaleX = ratio / vratio; } } else { if (ratio < vratio) { scaleY = vratio / ratio; } else { scaleX = ratio / vratio; } } Matrix.scaleM(mScaleMatrix, 0, scaleX * (mCurrentFrame.MirroredX ? -1.0f : 1.0f), scaleY, 1); int mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mScaleMatrix, 0); GLES20.glDrawElements(GLES20.GL_TRIANGLES, mVertexIndex.Length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer); } else { //black frame when video is disabled gl.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); } mFrameLock.unlock(); }
private void Sync(bool pollEvents) { double dt = 1 / 60.0; double currentTime = GLFW.glfwGetTime(); // Main loop while (GLFW.glfwWindowShouldClose(Handle) == 0) { double newTime = GLFW.glfwGetTime(); double frameTime = newTime - currentTime; currentTime = newTime; while (frameTime > 0) { double deltaTime = Math.Min(frameTime, dt); frameTime -= deltaTime; for (var i = 0; i < blocks.Length; i++) { blocks[i].UseDelta = useDelta; blocks[i].Update(deltaTime, width, height); } } // Render a background and enable some stuff for 2d rendering with alpha GL10.glMatrixMode(GL11.GL_PROJECTION); GL10.glLoadIdentity(); GL10.glOrtho(0, width, height, 0, -1, 1); GL10.glMatrixMode(GL11.GL_MODELVIEW); GL10.glLoadIdentity(); GL10.glEnable(GL11.GL_BLEND); GL10.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL10.glViewport(0, 0, Width, Height); GL10.glClearColor(0, 0, 0, 1); GL10.glClear(GL11.GL_COLOR_BUFFER_BIT); // Render for (var i = 0; i < blocks.Length; i++) { blocks[i].Render(); } GLFW.glfwSwapBuffers(Handle); GLFW.glfwPollEvents(); } GLFW.glfwDestroyWindow(Handle); }
public override void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); mProgram = GLES20.glCreateProgram(); // create empty OpenGL ES // Program GLES20.glAttachShader(mProgram, vertexShader); // add the vertex // shader to program GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment // shader to // program GLES20.glLinkProgram(mProgram); int positionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition"); int textureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord"); GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, COORDS_PER_VERTEX * 4, mVertexBuffer); GLES20.glEnableVertexAttribArray(positionHandle); GLES20.glVertexAttribPointer(textureHandle, TEXTURECOORDS_PER_VERTEX, GLES20.GL_FLOAT, false, TEXTURECOORDS_PER_VERTEX * 4, mTextureBuffer); GLES20.glEnableVertexAttribArray(textureHandle); GLES20.glUseProgram(mProgram); int i = GLES20.glGetUniformLocation(mProgram, "Ytex"); GLES20.glUniform1i(i, 0); // Bind Ytex to texture unit 0 i = GLES20.glGetUniformLocation(mProgram, "Utex"); GLES20.glUniform1i(i, 1); // Bind Utex to texture unit 1 i = GLES20.glGetUniformLocation(mProgram, "Vtex"); GLES20.glUniform1i(i, 2); // Bind Vtex to texture unit 2 mTextureWidth = 0; mTextureHeight = 0; }
public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // reset the matrix - good to fix the rotation to a static angle gl.glLoadIdentity(); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); // set rotation gl.glRotatef(_xAngle, 1f, 0f, 0f); gl.glRotatef(_yAngle, 0f, 1f, 0f); //gl.glColor4f(0.5f, 0f, 0f, 0.5f); gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer); gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer); gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer); }
public override void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode); int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode); mProgram = GLES20.glCreateProgram(); // create empty OpenGL ES // Program GLES20.glAttachShader(mProgram, vertexShader); // add the vertex // shader to program GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment // shader to // program GLES20.glLinkProgram(mProgram); int positionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition"); int textureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord"); GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, COORDS_PER_VERTEX * 4, mVertexBuffer); GLES20.glEnableVertexAttribArray(positionHandle); GLES20.glVertexAttribPointer(textureHandle, TEXTURECOORDS_PER_VERTEX, GLES20.GL_FLOAT, false, TEXTURECOORDS_PER_VERTEX * 4, mTextureBuffer); GLES20.glEnableVertexAttribArray(textureHandle); GLES20.glUseProgram(mProgram); int i = GLES20.glGetUniformLocation(mProgram, "Ytex"); GLES20.glUniform1i(i, 0); // Bind Ytex to texture unit 0 i = GLES20.glGetUniformLocation(mProgram, "Utex"); GLES20.glUniform1i(i, 1); // Bind Utex to texture unit 1 i = GLES20.glGetUniformLocation(mProgram, "Vtex"); GLES20.glUniform1i(i, 2); // Bind Vtex to texture unit 2 mTextureWidth = 0; mTextureHeight = 0; }
public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); // set rotation gl.glRotatef(_angle, 0f, 1f, 0f); // set the color of our element gl.glColor4f(0.5f, 0f, 0f, 0.5f); // define the vertices we want to draw gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer); // finally draw the vertices gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer); }
private void Sync(bool pollEvents) { // Main loop while (GLFW.glfwWindowShouldClose(Handle) == 0) { // Update // Render a background and enable some stuff for 2d rendering with alpha GL10.glEnable(GL11.GL_BLEND); GL10.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL10.glViewport(0, 0, Width, Height); GL10.glClearColor(0, 0, 0, 1); GL10.glClear(GL11.GL_COLOR_BUFFER_BIT); // Render GLFW.glfwSwapBuffers(Handle); GLFW.glfwPollEvents(); } GLFW.glfwDestroyWindow(Handle); }
public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); // reset the matrix - good to fix the rotation to a static angle gl.glLoadIdentity(); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); // set rotation for the non-static triangle gl.glRotatef(_angle, 0f, 1f, 0f); gl.glColor4f(0.5f, 0f, 0f, 0.5f); gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer); gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer); // gl.glColor4f(0.5f, 0f, 0f, 0.5f); gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer); gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer); gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer); }
public void onSurfaceCreated(GL10 gl, EGLConfig config) { gl.glMatrixMode(GL10_GL_PROJECTION); float size = .01f * (float)java.lang.Math.tan(java.lang.Math.toRadians(45.0) / 2); float ratio = _width / _height; // perspective: gl.glFrustumf(-size, size, -size / ratio, size / ratio, 0.01f, 100.0f); // orthographic: //gl.glOrthof(-1, 1, -1 / ratio, 1 / ratio, 0.01f, 100.0f); gl.glViewport(0, 0, (int)_width, (int)_height); gl.glMatrixMode(GL10_GL_MODELVIEW); gl.glEnable(GL10_GL_DEPTH_TEST); // define the color we want to be displayed as the "clipping wall" gl.glClearColor(0f, 0f, 0f, 1.0f); // enable the differentiation of which side may be visible gl.glEnable(GL10_GL_CULL_FACE); // which is the front? the one which is drawn counter clockwise gl.glFrontFace(GL10_GL_CCW); // which one should NOT be drawn gl.glCullFace(GL10_GL_BACK); gl.glEnableClientState(GL10_GL_VERTEX_ARRAY); gl.glEnableClientState(GL10_GL_COLOR_ARRAY); initTriangle(); }
public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10_GL_COLOR_BUFFER_BIT); // set rotation gl.glRotatef(_angle, 0f, 1f, 0f); // set the color of our element gl.glColor4f(0.5f, 0f, 0f, 0.5f); // define the vertices we want to draw gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer); // finally draw the vertices gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer); }
public override void onDrawFrame(GL10 gl) { mFrameLock.@lock(); if (mCurrentFrame != null && !mVideoDisabled) { GLES20.glUseProgram(mProgram); if (mTextureWidth != mCurrentFrame.Width || mTextureHeight != mCurrentFrame.Height) { setupTextures(mCurrentFrame); } updateTextures(mCurrentFrame); Matrix.setIdentityM(mScaleMatrix, 0); float scaleX = 1.0f, scaleY = 1.0f; float ratio = (float) mCurrentFrame.Width / mCurrentFrame.Height; float vratio = (float) mViewportWidth / mViewportHeight; if (mVideoFitEnabled) { if (ratio > vratio) { scaleY = vratio / ratio; } else { scaleX = ratio / vratio; } } else { if (ratio < vratio) { scaleY = vratio / ratio; } else { scaleX = ratio / vratio; } } Matrix.scaleM(mScaleMatrix, 0, scaleX * (mCurrentFrame.MirroredX ? - 1.0f : 1.0f), scaleY, 1); int mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix"); GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mScaleMatrix, 0); GLES20.glDrawElements(GLES20.GL_TRIANGLES, mVertexIndex.Length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer); } else { //black frame when video is disabled gl.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); } mFrameLock.unlock(); }
public virtual void onDrawFrame(GL10 gl) { gl.glClearColor((float)0.5, (float)0.5, (float)0.5, (float)1.0); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); }
public virtual void onDrawFrame(GL10 gl) { gl.glClearColor((float) 0.5, (float) 0.5, (float) 0.5, (float) 1.0); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); }