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


Java GL10.glTranslatef方法代码示例

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


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

示例4: 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

示例5: drawTranslatedCube

import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
 * Draws a translated cube
 * 
 * @param gl the surface
 * @param translateX x-translation
 * @param translateY y-translation
 * @param translateZ z-translation
 */
private void drawTranslatedCube(GL10 gl, float translateX, float translateY, float translateZ) {
    gl.glPushMatrix();
    gl.glTranslatef(translateX, translateY, translateZ);

    // draw our object
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

    mCube.draw(gl);
    gl.glPopMatrix();
}
 
开发者ID:peter10110,项目名称:Android-SteamVR-controller,代码行数:20,代码来源:CubeRenderer.java

示例6: 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

示例7: 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


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