本文整理汇总了Java中android.opengl.GLU类的典型用法代码示例。如果您正苦于以下问题:Java GLU类的具体用法?Java GLU怎么用?Java GLU使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GLU类属于android.opengl包,在下文中一共展示了GLU类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Ray
import android.opengl.GLU; //导入依赖的package包/类
public Ray(MatrixGrabber matrixGrabber,int[] viewPort,float xTouch, float yTouch){
float[] temp = new float[4];
float winy =(float)viewPort[3] - yTouch;
int result = GLU.gluUnProject(xTouch, winy, 1f, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewPort, 0, temp, 0);
if(result == GL10.GL_TRUE){
farCoords[0] = temp[0] / temp[3] * Cube3.one;
farCoords[1] = temp[1] / temp[3] * Cube3.one;
farCoords[2] = temp[2] / temp[3] * Cube3.one;
}
result = GLU.gluUnProject(xTouch, winy, 0, matrixGrabber.mModelView, 0, matrixGrabber.mProjection, 0, viewPort, 0, temp, 0);
if(result == GL10.GL_TRUE){
nearCoords[0] = temp[0] / temp[3] * Cube3.one;
nearCoords[1] = temp[1] / temp[3] * Cube3.one;
nearCoords[2] = temp[2] / temp[3] * Cube3.one;
}
}
示例2: onSurfaceChanged
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
mViewportWidth = width;
mViewportHeight = height;
float ratio = (float) width / height;
mViewRect.top = 1.0f;
mViewRect.bottom = -1.0f;
mViewRect.left = -ratio;
mViewRect.right = ratio;
updatePageRects();
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
if (USE_PERSPECTIVE_PROJECTION) {
GLU.gluPerspective(gl, 20f, (float) width / height, .1f, 100f);
} else {
GLU.gluOrtho2D(gl, mViewRect.left, mViewRect.right,
mViewRect.bottom, mViewRect.top);
}
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例3: onSurfaceChanged
import android.opengl.GLU; //导入依赖的package包/类
public void onSurfaceChanged(GL10 gl, int width, int height) {
if(height == 0) {
height = 1;
}
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
if(height>width)
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
else
GLU.gluPerspective(gl, 45.0f, (float) height / (float) width, 0.1f, 100.0f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例4: onSurfaceChanged
import android.opengl.GLU; //导入依赖的package包/类
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
/*
* Set our projection matrix. This doesn't have to be done each time we
* draw, but usually a new projection needs to be set when the viewport
* is resized.
*/
float ratio = (float)width / height;
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluPerspective(gl, 60.0f, ratio, 2.0f, 3000.0f);
mCameraDirty = true;
}
示例5: checkError
import android.opengl.GLU; //导入依赖的package包/类
/**
* As of version 4.2 Android offers an option called "Enable OpenGL traces" in the phone's
* developer options. If you set this to "Call stack on glGetError" you'll see error logs if
* OpenGL error happens.
*
* @return true if found, otherwise false.
*/
public static boolean checkError()
{
boolean found = false;
int error_code = GLES20.GL_NO_ERROR;
do
{
/*
If more than one flag has recorded an error, glGetError returns and clears an
arbitrary error flag value. Thus, glGetError should always be called in a loop, until
it returns GL_NO_ERROR, if all error flags are to be reset.
*/
error_code = GLES20.glGetError();
if(error_code != GLES20.GL_NO_ERROR)
{
found = true;
Log.e(TAG, "Error: " + GLU.gluErrorString(error_code));
}
} while(error_code != GLES20.GL_NO_ERROR);
return found;
}
示例6: draw2D
import android.opengl.GLU; //导入依赖的package包/类
private void draw2D(GL10 gl, boolean actionPlaneDrawn) {
gl.glDisable(GL10.GL_DEPTH_TEST);
gl.glDisable(GL10.GL_CULL_FACE);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL10.GL_BLEND);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, -1.0f, 1.0f, -1.0f, 1.0f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
ui.draw(gl, actionPlaneDrawn);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glEnable(GL10.GL_CULL_FACE);
}
示例7: onDrawFrame
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
// clear frame
gl.glClearColor(mR, mG, mB, mA);
// Set GL_MODELVIEW transformation mode
gl.glMatrixMode(GL10.GL_MODELVIEW);
// reset the matrix to its default state
gl.glLoadIdentity();
// When using GL_MODELVIEW, you must set the camera view
GLU.gluLookAt(gl, 0, 0, -5, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
}
示例8: onDrawFrame
import android.opengl.GLU; //导入依赖的package包/类
@Override public void onDrawFrame(GL10 gl)
{
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, 0,0,-5, 0,0,0, 0,1,0);
gl.glScalef(1.25f, 1.25f,1.25f);
gl.glRotatef(tilt * 180 / (float) Math.PI, 1, 0, 0);
gl.glRotatef(rotation * 180 / (float) Math.PI, 0, 0, 1);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glColor4f(0.8f,0.2f,0.2f,1);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glDrawElements(GL10.GL_TRIANGLE_FAN, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer);
}
示例9: onSurfaceChanged
import android.opengl.GLU; //导入依赖的package包/类
@Override
public final void onSurfaceChanged(GL10 gl, int width, int height) {
// Camera.
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluPerspective(gl, 90, (float) (width) / height, 1, 2 * VIEW_SIZE);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
// GL configuration.
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glEnable(GL10.GL_DEPTH_TEST);
// Styles.
gl.glClearColor(1, 1, 1, 1);
gl.glLineWidth(10);
}
示例10: onDrawFrame
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
GLU.gluLookAt(gl, eye.x, eye.y, eye.z, center.x,
center.y, center.z, up.x, up.y, up.z);
gl.glRotatef(mDegree , 0, 1, 0);
gl.glScalef(mScalef, mScalef, mScalef);
gl.glTranslatef(-mCenterPoint.x, -mCenterPoint.y, -mCenterPoint.z);
gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glNormalPointer(GL10.GL_FLOAT, 0, model.getVnormsBuffer());
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, model.getVertBuffer());
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, model.getFacetCount()*3);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
}
示例11: onSurfaceChanged
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
if (height == 0)
height = 1; // To prevent divide by zero
float aspect = (float) width / height;
// Set the viewport (display area) to cover the entire window
gl.glViewport(0, 0, width, height);
// Setup perspective projection, with aspect ratio matches viewport
gl.glMatrixMode(GL10.GL_PROJECTION); // Select projection matrix
gl.glLoadIdentity(); // Reset projection matrix
// Use perspective projection
GLU.gluPerspective(gl, 45, aspect, 0.1f, 100.f);
gl.glMatrixMode(GL10.GL_MODELVIEW); // Select model-view matrix
gl.glLoadIdentity(); // Reset
}
示例12: updateCamera
import android.opengl.GLU; //导入依赖的package包/类
/***
* 更新摄像机
* @param gl
*/
public void updateCamera(GL10 gl)
{
//设置摄像机位置与观察目标
GLU.gluLookAt(gl,
this._position.x,
this._position.y,
this._position.z,
this._target.x,
this._target.y,
this._target.z,
0.0f,
1.0f,
0.0f);
//旋转摄像机
gl.glRotatef(this._rotation.x,1.0f,0.0f,0.0f);
gl.glRotatef(this._rotation.y,0.0f,1.0f,0.0f);
gl.glRotatef(this._rotation.z,0.0f,0.0f,1.0f);
}
示例13: onDrawFrame
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
if(AugmentedModelViewerActivity.DEBUG) {
frame++;
time=System.currentTimeMillis();
if (time - timebase > 1000) {
Log.d("fps: ", String.valueOf(frame*1000.0f/(time-timebase)));
timebase = time;
frame = 0;
}
}
//String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
GLU.gluLookAt(gl, cameraPosition.x, cameraPosition.y, cameraPosition.z,
0, 0, 0, 0, 1, 0);
for (Iterator<Model3D> iterator = models.iterator(); iterator.hasNext();) {
Model3D model = iterator.next();
model.draw(gl);
}
}
示例14: onSurfaceChanged
import android.opengl.GLU; //导入依赖的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);
if (stlObject != null) {
Log.i("maxX:" + stlObject.maxX);
Log.i("minX:" + stlObject.minX);
Log.i("maxY:" + stlObject.maxY);
Log.i("minY:" + stlObject.minY);
Log.i("maxZ:" + stlObject.maxZ);
Log.i("minZ:" + stlObject.minZ);
}
GLU.gluPerspective(gl, 45f, aspectRatio, 1f, 5000f);// (stlObject.maxZ - stlObject.minZ) * 10f + 100f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
GLU.gluLookAt(gl, 0, 0, 100f, 0, 0, 0, 0, 1f, 0);
}
示例15: onDrawFrame
import android.opengl.GLU; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
if (animation != null) {
animation.nextFrame();
}
gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, eye[0], eye[1], eye[2], center[0], center[1], center[2], upVector[0], upVector[1], upVector[2]);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glShadeModel(GL10.GL_FLAT);
gl.glFrontFace(GL10.GL_SMOOTH);
gl.glEnable(GL10.GL_DEPTH_TEST);
Cube3.getInstance().draw(gl);
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}