本文整理汇总了Java中javax.microedition.khronos.opengles.GL10类的典型用法代码示例。如果您正苦于以下问题:Java GL10类的具体用法?Java GL10怎么用?Java GL10使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GL10类属于javax.microedition.khronos.opengles包,在下文中一共展示了GL10类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height)
{
// Set the OpenGL viewport to the same size as the surface.
GLES20.glViewport(0, 0, width, height);
// Create a new perspective projection matrix. The height will stay the same
// while the width will vary as per aspect ratio.
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 10.0f;
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例2: onDrawFrame
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public void onDrawFrame ( GL10 glUnused )
{
// Set the viewport
GLES30.glViewport ( 0, 0, mWidth, mHeight );
// Clear the color buffer
GLES30.glClear ( GLES30.GL_COLOR_BUFFER_BIT );
// Use the program object
GLES30.glUseProgram ( mProgramObject );
// Set the vertex color to red
GLES30.glVertexAttrib4f ( 0, 1.0f, 0.0f, 0.0f, 1.0f );
// Load the vertex position
mVertices.position ( 0 );
GLES30.glVertexAttribPointer ( 1, 3, GLES30.GL_FLOAT,
false,
0, mVertices );
GLES30.glEnableVertexAttribArray ( 1 );
GLES30.glDrawArrays ( GLES30.GL_TRIANGLES, 0, 3 );
GLES30.glDisableVertexAttribArray ( 1 );
}
示例3: draw
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void draw(GL10 gl10) {
for (int i = 0; i < hitBoxes.size(); i++) { // Update all the hit boxes.
hitBoxes.get(i).update();
}
for (int i = 0; i < hitBoxes.size(); i++) { // Find all the CollisionHandlers.
HitBox h1 = hitBoxes.get(i);
if (h1.c.getCollisionHandler() != null) { // Is this hit box for a CollisionHandler?
for (int j = 0; j < hitBoxes.size(); j++) { // Compare hit box h1 to all other hit boxes.
HitBox h2 = hitBoxes.get(j);
if (h1.c != h2.c) { // Make sure it isn't the same CollisionBox!
boolean collided = (h1.x < h2.x + h2.w) && (h1.x + h1.w > h2.x) && (h1.y < h2.y + h2.h) && (h1.y + h1.h > h2.y);
if (collided) {
h1.c.getCollisionHandler().onCollision(h2.c);
}
}
}
}
}
}
示例4: checkGLDriver
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public synchronized void checkGLDriver(GL10 gl) {
if (! mGLESDriverCheckComplete) {
checkGLESVersion();
String renderer = gl.glGetString(GL10.GL_RENDERER);
if (mGLESVersion < kGLES_20) {
mMultipleGLESContextsAllowed =
! renderer.startsWith(kMSM7K_RENDERER_PREFIX);
notifyAll();
}
mLimitedGLESContexts = !mMultipleGLESContextsAllowed;
if (LOG_SURFACE) {
Log.w(TAG, "checkGLDriver renderer = \"" + renderer + "\" multipleContextsAllowed = "
+ mMultipleGLESContextsAllowed
+ " mLimitedGLESContexts = " + mLimitedGLESContexts);
}
mGLESDriverCheckComplete = true;
}
}
示例5: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
mRenderListener.onSurfaceChanged(gl, width, height);
mEngine.setUpScene();
if (mEngine.isCameraActive() && mEngine.getCamera() != null)
mEngine.getCamera().update(width, height);
// Sets the current view port to the new size.
gl.glViewport(0, 0, width, height);
// Select the projection matrix
gl.glMatrixMode(GL10.GL_PROJECTION);
// Reset the projection matrix
gl.glLoadIdentity();
// Select the modelview matrix
gl.glMatrixMode(GL10.GL_MODELVIEW);
// Reset the modelview matrix
gl.glOrthof(0, width, height, 0, 0, 1f);
}
示例6: draw
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public void draw(GL10 gl, float alpha) {
gl.glDisable(GL_TEXTURE_2D);
gl.glEnable(GL_BLEND);
gl.glEnableClientState(GL_VERTEX_ARRAY);
gl.glDisableClientState(GL_COLOR_ARRAY);
// Use mColorBuffer as a global alpha mask:
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL11.GL_COMBINE);
glTexEnvx(GL_TEXTURE_ENV, GL11.GL_COMBINE_RGB, GL11.GL_REPLACE);
glTexEnvx(GL_TEXTURE_ENV, GL11.GL_COMBINE_ALPHA, GL11.GL_MODULATE); // mix with alpha from glColor
// Alpha from glColor will be used thanks to GL_MODULATE mode
glColor4f(1f, 1f, 1f, 1f-alpha);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
glDrawElements(GL_TRIANGLE_STRIP, VERTS, GL_UNSIGNED_SHORT, mIndexBuffer);
}
示例7: onDrawFrame
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
//清楚深度和颜色缓冲
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
//保护现场
MatrixState.pushMatrix();
//绘制原来的立方体
mCube.drawSelf();
//恢复现场
MatrixState.popMatrix();
//绘制变换后的立方体
MatrixState.pushMatrix();
//X轴移动4
MatrixState.translate(4 , 0 , 0);
//绕Z轴旋转30度
MatrixState.rotate(30 , 0 , 0 , 1);
mCube.drawSelf();
//恢复现场
MatrixState.popMatrix();
}
示例8: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public void onSurfaceChanged(GL10 unused, int width, int height) {
GLES20.glViewport(0, 0, width, height);
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 2.0f;
final float far = 10.0f;
// this projection matrix is applied to object coordinates
// in the onDrawFrame() method
// Matrix.frustumM(mProjectionMatrix, 0, -ratio, ratio, -1, 1, 3, 7);
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例9: onSurfaceCreated
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
Log.d(TAG, "onSurfaceCreated");
final CameraView cameraView = mCameraViewRef.get();
if (cameraView != null) {
cameraView.mGLSurfaceFilter = new GLSurfaceFilter();
Matrix.setIdentityM(mMvpMatrix, 0);
mTextureId = cameraView.mGLSurfaceFilter.createTexture();
cameraView.mSurfaceTexture = new SurfaceTexture(mTextureId);
cameraView.mSurfaceTexture.setOnFrameAvailableListener(cameraView);
if (cameraView.mCameraSurfaceListener != null) {
cameraView.mCameraSurfaceListener.onCameraSurfaceCreate(cameraView.mSurfaceTexture);
}
}
}
示例10: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height)
{
// Set the OpenGL viewport to the same size as the surface.
GLES20.glViewport(0, 0, width, height);
// Create a new perspective projection matrix. The height will stay the same
// while the width will vary as per aspect ratio.
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 1000.0f;
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例11: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height)
{
_width = width;
_height = height;
// Set the OpenGL viewport to the same size as the surface.
GLES20.glViewport(0, 0, width, height);
// Create a new perspective projection matrix. The height will stay the same
// while the width will vary as per aspect ratio.
final float ratio = (float) width / height;
final float left = -ratio;
final float right = ratio;
final float bottom = -1.0f;
final float top = 1.0f;
final float near = 1.0f;
final float far = 5000.0f;
Matrix.frustumM(aProjectionMatrix, 0, left, right, bottom, top, near, far);
}
示例12: onSurfaceCreated
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
if(DBG) Log.d(TAG, "onSurfaceCreated");
// mGL = gl;
// Tell the listener as soon as GL stack is ready
if(DBG) Log.d(TAG,"GL_READY");
mListener.sendEmptyMessage(RendererListener.MSG_GL_READY);
// Depth management is done "by hand", by sorting covers. Because of Blending.
// Sometimes I even want to display cover behind, to mimic transparency
glDisable(GL_DEPTH_TEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
// Enable stuff (...)
glEnableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY); // This must be disabled to use glColor for covers
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
示例13: genTexture
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
public static int genTexture(int textureType) {
int[] genBuf = new int[1];
GLES20.glGenTextures(1, genBuf, 0);
GLES20.glBindTexture(textureType, genBuf[0]);
// Set texture default draw parameters
if (textureType == GLES11Ext.GL_TEXTURE_EXTERNAL_OES) {
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
} else {
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
}
return genBuf[0];
}
示例14: onDrawFrame
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
//Log.i(LOGTAG, "onDrawFrame start");
if (!mHaveFBO)
return;
synchronized(this) {
if (mUpdateST) {
mSTexture.updateTexImage();
mUpdateST = false;
}
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
CameraTextureListener texListener = mView.getCameraTextureListener();
if(texListener != null) {
//Log.d(LOGTAG, "haveUserCallback");
// texCamera(OES) -> texFBO
drawTex(texCamera[0], true, FBO[0]);
// call user code (texFBO -> texDraw)
boolean modified = texListener.onCameraTexture(texFBO[0], texDraw[0], mCameraWidth, mCameraHeight);
if(modified) {
// texDraw -> screen
drawTex(texDraw[0], false, 0);
} else {
// texFBO -> screen
drawTex(texFBO[0], false, 0);
}
} else {
Log.d(LOGTAG, "texCamera(OES) -> screen");
// texCamera(OES) -> screen
drawTex(texCamera[0], true, 0);
}
//Log.i(LOGTAG, "onDrawFrame end");
}
}
示例15: onSurfaceChanged
import javax.microedition.khronos.opengles.GL10; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 gl, int surfaceWidth, int surfaceHeight) {
Log.i(LOGTAG, "onSurfaceChanged("+surfaceWidth+"x"+surfaceHeight+")");
mHaveSurface = true;
updateState();
setPreviewSize(surfaceWidth, surfaceHeight);
}