本文整理汇总了Java中android.opengl.GLES20.glClearColor方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glClearColor方法的具体用法?Java GLES20.glClearColor怎么用?Java GLES20.glClearColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glClearColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
if (scene != null) {
Matrix.setLookAtM(mViewMatrix, 0,
0, 0, -4,
0f, 0f, 0f,
0f, 1.0f, 0.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
Matrix.rotateM(mMVPMatrix, 0, angle, 0.8f, 2.f, 1.f);
GLES20.glUseProgram(shaderProgram);
int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
scene.render(shaderProgram, "vPosition", "aColor");
}
}
示例2: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
mScreenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
mScreenHeight = mContext.getResources().getDisplayMetrics().heightPixels;
// Set the clear color to black. TODO: Remove this later once there's an actual background
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1);
// Object shaders
int vertexShader = ShaderInfo.loadShader(GLES20.GL_VERTEX_SHADER, ShaderInfo.vs_Image);
int fragmentShader = ShaderInfo.loadShader(GLES20.GL_FRAGMENT_SHADER, ShaderInfo.fs_Image);
ShaderInfo.sp_Image = GLES20.glCreateProgram(); // create empty OpenGL ES Program
GLES20.glAttachShader(ShaderInfo.sp_Image, vertexShader); // add the vertex shader to program
GLES20.glAttachShader(ShaderInfo.sp_Image, fragmentShader); // add the fragment shader to program
GLES20.glLinkProgram(ShaderInfo.sp_Image); // creates OpenGL ES program executables
// Set our shader program
GLES20.glUseProgram(ShaderInfo.sp_Image);
// Enable blending
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
}
示例3: initShaders
import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShaders() {
String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
if (strGLVersion != null)
Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);
GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
progOES = loadShader(vss, fssOES);
vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
vTCOES = GLES20.glGetAttribLocation(progOES, "vTexCoord");
GLES20.glEnableVertexAttribArray(vPosOES);
GLES20.glEnableVertexAttribArray(vTCOES);
prog2D = loadShader(vss, fss2D);
vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
vTC2D = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
GLES20.glEnableVertexAttribArray(vPos2D);
GLES20.glEnableVertexAttribArray(vTC2D);
}
示例4: onDraw
import android.opengl.GLES20; //导入方法依赖的package包/类
@SuppressLint("WrongCall")
@Override
public void onDraw(final int textureId, final FloatBuffer cubeBuffer, final FloatBuffer textureBuffer) {
runPendingOnDrawTasks();
if (!isInitialized() || mFrameBuffers == null || mFrameBufferTextures == null) {
return;
}
if (mMergedFilters != null) {
int size = mMergedFilters.size();
int previousTexture = textureId;
for (int i = 0; i < size; i++) {
CameraFilter filter = mMergedFilters.get(i);
boolean isNotLast = i < size - 1;
if (isNotLast) {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[i]);
GLES20.glClearColor(0, 0, 0, 0);
}
if (i == 0) {
filter.onDraw(previousTexture, cubeBuffer, textureBuffer);
} else if (i == size - 1) {
filter.onDraw(previousTexture, mGLCubeBuffer, (size % 2 == 0) ? mGLTextureFlipBuffer : mGLTextureBuffer);
} else {
filter.onDraw(previousTexture, mGLCubeBuffer, mGLTextureBuffer);
}
if (isNotLast) {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
previousTexture = mFrameBufferTextures[i];
}
}
}
}
示例5: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
GLES20.glDisable(GL10.GL_DITHER);
GLES20.glClearColor(0,0,0,0);
GLES20.glEnable(GL10.GL_CULL_FACE);
GLES20.glEnable(GL10.GL_DEPTH_TEST);
MagicFilterParam.initMagicFilterParam(gl);
mCameraInputFilter.init();
}
示例6: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* The method is called when the surface is first created.
* It will also be called if we lose our surface context and
* it is later recreated by the system.
*/
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Set the background clear color to gray.
GLES20.glClearColor(0.5F, 0.5F, 0.5F, 0.5F);
mTriangle1 = new Triangle(Triangle.Triangle1VerticesData);
}
示例7: run
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void run() {
if (!initialized || shuttingDown) {
return;
}
setCurrentContext();
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GLES20.glViewport(0, 0, bufferWidth, bufferHeight);
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
painting.render();
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
egl10.eglSwapBuffers(eglDisplay, eglSurface);
if (!ready) {
queue.postRunnable(new Runnable() {
@Override
public void run() {
ready = true;
}
}, 200);
}
}
示例8: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
// Set the background clear color to black.
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Use culling to remove back face.
GLES20.glEnable(GLES20.GL_CULL_FACE);
// Enable depth testing
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
mCube = new Cube();
}
示例9: onDraw
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override public void onDraw(float[] mvpMatrix, FloatBuffer vertexBuffer, int firstVertex,
int vertexCount, int coordsPerVertex, int vertexStride, float[] texMatrix,
FloatBuffer texBuffer, int textureId, int texStride) {
// TODO
int size = mFilters.size();
int previousTextureId = textureId;
for (int i = 0; i < size; i++) {
T filter = mFilters.get(i);
boolean isNotLast = i < size - 1;
if (isNotLast) {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffers[i]);
GLES20.glClearColor(0, 0, 0, 0);
}
if (i == 0) {
filter.onDraw(mvpMatrix, vertexBuffer, firstVertex, vertexCount, coordsPerVertex,
vertexStride, texMatrix, texBuffer, previousTextureId, texStride);
} else if (i == size - 1) {
filter.onDraw(mvpMatrix, mDrawable2d.getVertexArray(), firstVertex, vertexCount,
coordsPerVertex, vertexStride, texMatrix,
(size % 2 == 0) ? mDrawableFlipVertical2d.getTexCoordArray()
: mDrawable2d.getTexCoordArray(), previousTextureId, texStride);
} else {
filter.onDraw(mvpMatrix, mDrawable2d.getVertexArray(), firstVertex, vertexCount,
coordsPerVertex, vertexStride, texMatrix, mDrawable2d.getTexCoordArray(),
previousTextureId, texStride);
}
if (isNotLast) {
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
previousTextureId = mFrameBufferTextures[i];
}
}
}
示例10: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
scroller.computeScrollOffset();
if (scroller.isFinished()) {
int lastX = scroller.getCurrX();
int modulo = lastX % 90;
int snapX = (lastX / 90) * 90;
if (modulo >= 45) snapX += 90;
if (modulo <- 45) snapX -= 90;
if (lastX != snapX) {
scroller.startScroll(lastX, 0, snapX - lastX, 0);
}
}
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
Matrix.setLookAtM(mViewMatrix, 0,
0, 0, -3,
0f, 0f, 0f,
0f, 1.0f, 0.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
Matrix.rotateM(mMVPMatrix, 0, scroller.getCurrX(), 0.f, 1.f, 0.f);
Matrix.rotateM(mMVPMatrix, 0, 5.f, 1.f, 0.f, 0.f);
GLES20.glUseProgram(shaderProgram);
int positionHandle = GLES20.glGetAttribLocation(shaderProgram, "vPosition");
GLES20.glVertexAttribPointer(positionHandle, 3,
GLES20.GL_FLOAT, false,
0, vertexBuffer);
int colorHandle = GLES20.glGetAttribLocation(shaderProgram, "aColor");
GLES20.glVertexAttribPointer(colorHandle, 4,
GLES20.GL_FLOAT, false,
4 * 4, colorBuffer);
int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
GLES20.glEnableVertexAttribArray(colorHandle);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glDrawElements(
GLES20.GL_TRIANGLES, index.length,
GLES20.GL_UNSIGNED_SHORT, indexBuffer);
GLES20.glDisableVertexAttribArray(positionHandle);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
}
示例11: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw(int paramInt1, int paramInt2, FloatBuffer paramFloatBuffer1, FloatBuffer paramFloatBuffer2)
{
z();
C();
start();
if ((!isInitialized()) || (this.bD == null) || (this.bE == null) || (null == H())) {
return;
}
if (paramInt1 == -1) {
return;
}
int i = H().size();
int j = paramInt1;
for (int k = 0; k < i; k++)
{
GPUImageFilter localGPUImageFilter = (GPUImageFilter)H().get(k);
int m = k < i - 1 ? 1 : 0;
if (m != 0)
{
GLES20.glBindFramebuffer(36160, this.bD[(k % 2)]);
GLES20.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
}
else if (-1 != paramInt2)
{
GLES20.glBindFramebuffer(36160, paramInt2);
GLES20.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
}
if (k == 0)
{
localGPUImageFilter.d(false);
localGPUImageFilter.onDraw(j, paramFloatBuffer1, paramFloatBuffer2);
}
else if (k == i - 1)
{
localGPUImageFilter.d(i % 2 == 0);
localGPUImageFilter.onDraw(j, this.bF, i % 2 == 0 ? this.bH : this.bG);
}
else
{
localGPUImageFilter.d(false);
localGPUImageFilter.onDraw(j, this.bF, this.bG);
}
if (null != this.bK) {
this.bK.onSingleFilterDrawed(this.aS, this.aT);
}
if (m != 0)
{
GLES20.glBindFramebuffer(36160, 0);
j = this.bE[(k % 2)];
}
else
{
GLES20.glBindFramebuffer(36160, 0);
}
}
}
示例12: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
void draw() {
EGLDisplay mSavedEglDisplay = EGL14.eglGetCurrentDisplay();
EGLSurface mSavedEglDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
EGLSurface mSavedEglReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
EGLContext mSavedEglContext = EGL14.eglGetCurrentContext();
{
AndroidUntil.checkGlError("draw_S");
if (mRecorderImpl.isFirstSetup()) {
mRecorderImpl.startSwapAsync();
mRecorderImpl.makeCurrent();
AndroidUntil.checkGlError("initGL_S");
mProgram = AndroidUntil.createProgram();
maPositionHandle = GLES20.glGetAttribLocation(mProgram, "position");
maTextCodeHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
muSamplerHandle = GLES20.glGetUniformLocation(mProgram, "uSampler");
muPosMtxHandle = GLES20.glGetUniformLocation(mProgram, "uPosMtx");
Matrix.scaleM(mSymmetryMtx, 0, -1, 1, 1);
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glDisable(GLES20.GL_CULL_FACE);
GLES20.glDisable(GLES20.GL_BLEND);
AndroidUntil.checkGlError("initGL_E");
} else {
mRecorderImpl.makeCurrent();
}
GLES20.glViewport(0, 0, mVideoWidth, mVideoHeight);
GLES20.glClearColor(0f, 0f, 0f, 1f);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glUseProgram(mProgram);
mNormalVtxBuf.position(0);
GLES20.glVertexAttribPointer(maPositionHandle,
3, GLES20.GL_FLOAT, false, 4 * 3, mNormalVtxBuf);
GLES20.glEnableVertexAttribArray(maPositionHandle);
mCameraVertexCoordinatesBuffer.position(0);
GLES20.glVertexAttribPointer(maTextCodeHandle,
2, GLES20.GL_FLOAT, false, 4 * 2, mCameraVertexCoordinatesBuffer);
GLES20.glEnableVertexAttribArray(maTextCodeHandle);
GLES20.glUniform1i(muSamplerHandle, 0);
GLES20.glUniformMatrix4fv(muPosMtxHandle, 1, false, mNormalMtx, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mFboTexId);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
mRecorderImpl.swapBuffers();
AndroidUntil.checkGlError("draw_E");
}
if (!EGL14.eglMakeCurrent(
mSavedEglDisplay,
mSavedEglDrawSurface,
mSavedEglReadSurface,
mSavedEglContext)) {
throw new RuntimeException("eglMakeCurrent failed");
}
}
示例13: onSurfaceCreated
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
heightMap = new HeightMap();
// Set the background clear color to black.
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Enable depth testing
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
// Position the eye in front of the origin.
final float eyeX = 0.0f;
final float eyeY = 0.0f;
final float eyeZ = -0.5f;
// We are looking toward the distance
final float lookX = 0.0f;
final float lookY = 0.0f;
final float lookZ = -5.0f;
// Set our up vector. This is where our head would be pointing were we
// holding the camera.
final float upX = 0.0f;
final float upY = 1.0f;
final float upZ = 0.0f;
// Set the view matrix. This matrix can be said to represent the camera
// position.
// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination
// of a model and view matrix. In OpenGL 2, we can keep track of these
// matrices separately if we choose.
Matrix.setLookAtM(viewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
final String vertexShader = RawResourceReader.readTextFileFromRawResource(lessonEightActivity,
R.raw.per_pixel_vertex_shader_no_tex);
final String fragmentShader = RawResourceReader.readTextFileFromRawResource(lessonEightActivity,
R.raw.per_pixel_fragment_shader_no_tex);
final int vertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
final int fragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
program = Utils.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, new String[]{
POSITION_ATTRIBUTE, NORMAL_ATTRIBUTE, COLOR_ATTRIBUTE});
// Initialize the accumulated rotation matrix
Matrix.setIdentityM(accumulatedRotation, 0);
}
示例14: drawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
public void drawFrame(SurfaceTexture st) {
checkGlError("onDrawFrame start");
st.getTransformMatrix(mSTMatrix);
GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glUseProgram(mProgram);
checkGlError("glUseProgram");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maPosition");
GLES20.glEnableVertexAttribArray(maPositionHandle);
checkGlError("glEnableVertexAttribArray maPositionHandle");
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maTextureHandle");
GLES20.glEnableVertexAttribArray(maTextureHandle);
checkGlError("glEnableVertexAttribArray maTextureHandle");
Matrix.setIdentityM(mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
checkGlError("glDrawArrays");
if (mFingerDown) {
float[] scratch = new float[16];
// Set the camera position (View matrix)
Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
mViewMatrix[12] = (float) (mTouchX * 2.0f / mWidth - 1.0);
mViewMatrix[13] = (float) (mTouchY * -2.0f / mHeight + 1.0);
// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
// Create a rotation for the triangle
// Use the following code to generate constant rotation.
// Leave this code out when using TouchEvents.
long time = SystemClock.uptimeMillis() % 4000L;
float mAngle = 0.090f * ((int) time);
Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, 1.0f);
// Combine the rotation matrix with the projection and camera view
// Note that the mMVPMatrix factor *must be first* in order
// for the matrix multiplication product to be correct.
Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, mRotationMatrix, 0);
// Draw triangle
mTriangle.draw(scratch);
}
GLES20.glFinish();
}
示例15: onDrawFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
GLES20.glUseProgram(shaderProgram);
int positionHandle = GLES20.glGetAttribLocation(shaderProgram, "vPosition");
GLES20.glVertexAttribPointer(positionHandle, 3,
GLES20.GL_FLOAT, false,
3 * 4, vertexBuffer);
int colorHandle = GLES20.glGetUniformLocation(shaderProgram, "vColor");
GLES20.glUniform4fv(colorHandle, 1, color, 0);
int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glEnableVertexAttribArray(positionHandle);
GLES20.glDrawElements(
GLES20.GL_TRIANGLES, index.length,
GLES20.GL_UNSIGNED_SHORT, indexBuffer);
GLES20.glDisableVertexAttribArray(positionHandle);
}