本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
}
示例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;
}