当前位置: 首页>>代码示例>>Java>>正文


Java GL10.glClear方法代码示例

本文整理汇总了Java中javax.microedition.khronos.opengles.GL10.glClear方法的典型用法代码示例。如果您正苦于以下问题:Java GL10.glClear方法的具体用法?Java GL10.glClear怎么用?Java GL10.glClear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.khronos.opengles.GL10的用法示例。


在下文中一共展示了GL10.glClear方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
    gl.glClearColor(1.f, 0.f, 0.f, 1.f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    gl.glLoadIdentity();
    gl.glTranslatef(0.f, 0.f, -50.f);

    long time = SystemClock.uptimeMillis() % 4000L;
    float angle = 0.090f * ((int) time);
    gl.glRotatef(angle, 0.f, 0.f, 1.f);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glColor4f(1.f, 1.f, 1.f, 1.f);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:20,代码来源:GLDrawerES1.java

示例2: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public synchronized void onDrawFrame(GL10 gl) {

	mObserver.onDrawFrame();

	gl.glClearColor(Color.red(mBackgroundColor) / 255f,
			Color.green(mBackgroundColor) / 255f,
			Color.blue(mBackgroundColor) / 255f,
			Color.alpha(mBackgroundColor) / 255f);
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	gl.glLoadIdentity();

	if (USE_PERSPECTIVE_PROJECTION) {
		gl.glTranslatef(0, 0, -6f);
	}

	for (int i = 0; i < mCurlMeshes.size(); ++i) {
		mCurlMeshes.get(i).onDrawFrame(gl);
	}
}
 
开发者ID:ichason,项目名称:PageCurl,代码行数:21,代码来源:CurlRenderer.java

示例3: RenderStart

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public boolean RenderStart(GL10 gl) {
	// Log.d("TextureAndFBO", ""+renderTex[0] + " And " +fb[0]);
	// Bind the framebuffer
	((GL11ExtensionPack) gl).glBindFramebufferOES(
			GL11ExtensionPack.GL_FRAMEBUFFER_OES, fb[0]);

	// specify texture as color attachment
	((GL11ExtensionPack) gl).glFramebufferTexture2DOES(
			GL11ExtensionPack.GL_FRAMEBUFFER_OES,
			GL11ExtensionPack.GL_COLOR_ATTACHMENT0_OES, GL10.GL_TEXTURE_2D,
			renderTex[0], 0);
	// Log.e("TEXTURE ID =", "Texture ID  =" +renderTex[0] );
	int error = gl.glGetError();
	if (error != GL10.GL_NO_ERROR) {
		Log.d("err", "FIRST Background Load GLError: " + error + "      ");
	}
	int status = ((GL11ExtensionPack) gl)
			.glCheckFramebufferStatusOES(GL11ExtensionPack.GL_FRAMEBUFFER_OES);
	if (status != GL11ExtensionPack.GL_FRAMEBUFFER_COMPLETE_OES) {
		Log.d("err", "SECOND Background Load GLError: " + status + "      ");
		;
		return true;
	}
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	return true;
}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:27,代码来源:FBO.java

示例4: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
    // clear Screen and Depth Buffer
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    gl.glMatrixMode(GL10.GL_MODELVIEW);     //Select The Projection Matrix
    gl.glLoadIdentity();                     //Reset The Projection Matrix

    // Drawing
    /*gl.glTranslatef(0.0f, 0.0f, -10.0f);        // move 10 units INTO the screen
                                            // is the same as moving the camera 10 units away
                                            // now the visible z range is from -9.9 to 90, and view port
                                            // is still the 480 * 800 screen . The fvof angle and y/x
                                            // does not change.
     * 
     */
    draw(gl);
    if (mbTakeSnapshot == true)	{
    	mbitmapScreenSnapshot = takeScreenSnapshot(gl);
    }
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:22,代码来源:OGLChart.java

示例5: endGLElements

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
void endGLElements(GL10 gl) {
    vertexListManager.end();

    gl.glEnable(GL10.GL_DITHER);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    gl.glLineWidth(2);

    vertexListManager.render(gl);
}
 
开发者ID:StringMon,项目名称:homescreenarcade,代码行数:13,代码来源:GLFieldView.java

示例6: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void onDrawFrame(GL10 gl) {
    /*
     * Usually, the first thing one might want to do is to clear
     * the screen. The most efficient way of doing this is to use
     * glClear().
     */

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    /*
     * Now we're ready to draw some 3D objects
     */

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();
    gl.glTranslatef(0, 0, -2);

    /*
     * All the magic happens here. The rotation matrix mR reported by
     * SensorManager.getRotationMatrix() is a 4x4 row-major matrix.
     * We need to use its inverse for rendering. The inverse is
     * simply calculated by taking the matrix' transpose. However, since
     * glMultMatrixf() expects a column-major matrix, we can use mR
     * directly!
     */
    gl.glMultMatrixf(mR, 0);
    // some test code which will be used/cleaned up before we ship this.
    //gl.glMultMatrixf(mI, 0);

    gl.glVertexPointer(3, GL_FLOAT, 0, mVertexBuffer);
    gl.glColorPointer(4, GL_FLOAT, 0, mColorBuffer);
    gl.glDrawElements(GL_LINES, 6, GL_UNSIGNED_BYTE, mIndexBuffer);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:34,代码来源:CompassActivity.java

示例7: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {

    // Draw background color
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    // Set GL_MODELVIEW transformation mode
    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();   // reset the matrix to its default state

    // When using GL_MODELVIEW, you must set the view point
    GLU.gluLookAt(gl, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

    // Draw square
    mSquare.draw(gl);

    // 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 angle = 0.090f * ((int) time);

    gl.glRotatef(mAngle, 0.0f, 0.0f, 1.0f);

    // Draw triangle
    mTriangle.draw(gl);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:29,代码来源:MyGLRenderer.java

示例8: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
        public void onDrawFrame(GL10 gl) {
//            gl.glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
//            Log.d(TAG,"5->" + System.currentTimeMillis());
            gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
            gl.glTranslatef(0, 0, -4);
            gl.glLoadIdentity();
            mGraph.draw(gl);
        }
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:10,代码来源:OpenGLActivity.java

示例9: RenderEnd

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
public void RenderEnd(GL10 gl) {
	((GL11ExtensionPack) gl).glBindFramebufferOES(
			GL11ExtensionPack.GL_FRAMEBUFFER_OES, 0);
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

	gl.glEnable(GL10.GL_TEXTURE_2D);
	gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
	gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	gl.glDisable(GL10.GL_TEXTURE_2D);
}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:11,代码来源:FBO.java

示例10: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl10) {
    long now = SystemClock.uptimeMillis();         // Current time
    long timeElapsed = (long) OPTIMAL_TIME;        // Amount of time the frame took

    gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl10.glMatrixMode(GL10.GL_PROJECTION);
    gl10.glLoadIdentity();

    if (lastTime > 0) {
        timeElapsed = now - lastTime;                  // The amount of time the last frame took
    }

    if (frames < OPTIMAL_FPS) {
        frames++;
        averageDelta = (timeElapsed + averageDelta * (frames - 1)) / frames;     // Update the average amount of time a frame takes
    } else {
        averageDelta = (timeElapsed + averageDelta * (OPTIMAL_FPS - 1)) / OPTIMAL_FPS;           // Update the average amount of time a frame takes
    }

    mEngine.getTextureLibrary().LoadTextures(gl10);

    // draws and updated the scene from engine
    mEngine.onDrawFrame(gl10, averageDelta);


    if (mEngine.isCameraActive() && mEngine.getCamera() != null)
        mEngine.getCamera().update(mEngine.getViewWidth(), mEngine.getViewHeight());

    lastTime = now;

    if (mEngine.isFpsOutput() && frames % 60 == 0) {
        double fps = (double) 1000 / (double) averageDelta;

        if (1000.0 / timeElapsed < low || low == -1) {
            low = 1000.0 / timeElapsed;
        }

        if (1000.0 / timeElapsed > high || high == -1) {
            high = 1000.0 / timeElapsed;
        }

        if (1000.0 / timeElapsed < FRAME_DROP_THRES) {
            Log.d("fps", "FRAME DROPPED. FPS: " + (1000.0 / timeElapsed));
        }

        if (SystemClock.uptimeMillis() % 100 <= 10) {
            Log.d("fps", "FPS: " + fps + "    LOW: " + low + "    HIGH: " + high); // Show FPS in logcat
        }
    }

}
 
开发者ID:ondramisar,项目名称:AdronEngine,代码行数:53,代码来源:AdrGlRenderer.java

示例11: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
	public void onDrawFrame(GL10 gl) {
		if (bufferCounter < 1) {
			return;
		}
		bufferCounter--;

		gl.glLoadIdentity();
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

		gl.glTranslatef(positionX, -positionY, 0);

		// rotation and apply Z-axis
		gl.glTranslatef(0, 0, translation_z);
		gl.glRotatef(angleX, 0, 1, 0);
		gl.glRotatef(angleY, 1, 0, 0);
		scale_rember=scale_now*scale;
		gl.glScalef(scale_rember, scale_rember, scale_rember);
		gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
		
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		// draw X-Y field
		if (displayGrids) {
			drawGrids(gl);
		}

//		// draw axis
//		if (displayAxes) {
//			gl.glLineWidth(3f);
//			float[] vertexArray = { -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100 };
//			FloatBuffer lineBuffer = getFloatBufferFromArray(vertexArray);
//			gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);
//
//			// X : red
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 1.0f, 0f, 0f, 0.75f }, 0);
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 1.0f, 0f, 0f, 0.5f }, 0);
//			gl.glDrawArrays(GL10.GL_LINES, 0, 2);
//
//			// Y : blue
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 0f, 1.0f, 0.75f }, 0);
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 0f, 1.0f, 0.5f }, 0);
//			gl.glDrawArrays(GL10.GL_LINES, 2, 2);
//
//			// Z : green
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 1.0f, 0f, 0.75f }, 0);
//			gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 1.0f, 0f, 0.5f }, 0);
//			gl.glDrawArrays(GL10.GL_LINES, 4, 2);
//		}

		// draw object
		if (stlObject != null) {

			gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_AMBIENT, new float[] { 0.75f,0.75f,0.75f,1.0f }, 0);
			
			gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_DIFFUSE, new float[] { 0.75f,0.75f,0.75f,1.0f }, 0);
			
			gl.glEnable(GL10.GL_COLOR_MATERIAL);
			gl.glPushMatrix();
			gl.glColor4f(red,green,blue, 1.0f);
			stlObject.draw(gl);
			gl.glPopMatrix();
			gl.glDisable(GL10.GL_COLOR_MATERIAL);
		}
	}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:65,代码来源:STLRenderer.java

示例12: onDrawFrame

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public synchronized void onDrawFrame(GL10 gl) {

	if (CreatePNG) {
		saveBmp(gl);
		CreatePNG = false;

	}
	mObserver.onDrawFrame();
	// glClearColor miad rangi ke maa entekhaab kardim ro tooye carde
	// Graphic register mikone
	gl.glClearColor(Color.red(mBackgroundColor) / 255f,
			Color.green(mBackgroundColor) / 255f,
			Color.blue(mBackgroundColor) / 255f,
			Color.alpha(mBackgroundColor) / 255f);
	// glClear miad oon rangi ke bala register karde boodim ro dige az
	// buffer paak mikone
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

	// miad matris ro be MabdaEsh barmigardoone, ke bAd baraye glRotate va
	// glTranslate moshkeli ijaad nashe
	// chon maa asle jaabejaa kardan hamoon baraye safhe, baste be makaane
	// avalieye
	// kaaghazemoon hast, na oon makani ke dar haale hazer gharaar dare
	gl.glLoadIdentity();
	if (capture) {
		// Log.e("Capturing..", "Capturing..");
		if (BeforeStart) {
			// Log.e("BeforeStartCalled", "BeforeStartCalled");
			frameBuffer.BeforeStart(gl);
			BeforeStart = false;
		}
		if (AttachTexture) {
			// Log.e("SETUP", "SETUP Ran");
			int h = gl.glGetError();
			frameBuffer.setup(gl);
			if (h != 0) {
				// Log.d("ERROR", "ERROR Happend" + h + "");
			}
			AttachTexture = false;
		}
		frameBuffer.RenderStart(gl);
		if (USE_PERSPECTIVE_PROJECTION) {
			double x = mCurlMesh.GetMinX() * mCurlMesh.GetMinY();
			gl.glTranslatef((float) (-1.000 - mCurlMesh.GetMinX()),
					(float) (-1.000 - mCurlMesh.GetMinY()), -6f);
		}
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();
		GLU.gluOrtho2D(gl, (float) mCurlMesh.GetMinX(),
				(float) mCurlMesh.GetMaxX(), (float) mCurlMesh.GetMinY(),
				(float) mCurlMesh.GetMaxY());
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
		gl.glViewport(0, 0, texW, texH);
		mCurlMesh.onDrawFrame(gl, false);

		frameBuffer.RenderEnd(gl);

	}

	// Reset Every Thing to Its Normal State
	gl.glMatrixMode(GL10.GL_PROJECTION);
	gl.glLoadIdentity();
	GLU.gluOrtho2D(gl, -1.2f, 1.2f, -1.2f, 1.2f);
	gl.glMatrixMode(GL10.GL_MODELVIEW);
	gl.glLoadIdentity();
	gl.glViewport(0, 0, mViewportWidth, mViewportHeight);

	mCurlMesh.onDrawFrame(gl, true);
	// Log.e("Rendered", "Rendered");

	if (DelPrevious) {
		// Log.e("DeleTing", "Deleting Texture = " +DelTextureId[0]);
		gl.glDeleteTextures(1, DelTextureId, 0);
		DelPrevious = false;
		Counter++;
	}
	DoneRender = true;
}
 
开发者ID:AmulaySoftGroup,项目名称:TaBeTa,代码行数:81,代码来源:CurlRenderer.java

示例13: onSurfaceChanged

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
	float aspectRatio = (float) width / height;

	gl.glViewport(0, 0, width, height);
	
	gl.glLoadIdentity();
	gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);


	GLU.gluPerspective(gl, 45f, aspectRatio, 1f, 5000f);// (stlObject.maxZ - stlObject.minZ) * 10f + 100f);

	gl.glMatrixMode(GL10.GL_MODELVIEW);
	GLU.gluLookAt(gl, 100f, 0, 0, 0, 0, 0, 0, 0, 1f);
}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:16,代码来源:STLRenderer.java


注:本文中的javax.microedition.khronos.opengles.GL10.glClear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。