本文整理汇总了Java中android.opengl.GLES20.glScissor方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glScissor方法的具体用法?Java GLES20.glScissor怎么用?Java GLES20.glScissor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glScissor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Generates a frame of data using GL commands. We have an 8-frame animation
* sequence that wraps around. It looks like this:
* <pre>
* 0 1 2 3
* 7 6 5 4
* </pre>
* We draw one of the eight rectangles and leave the rest set to the clear color.
*/
private void generateFrame(int frameIndex) {
frameIndex %= 8;
int startX, startY;
if (frameIndex < 4) {
// (0,0) is bottom-left in GL
startX = frameIndex * (WIDTH / 4);
startY = HEIGHT / 2;
} else {
startX = (7 - frameIndex) * (WIDTH / 4);
startY = 0;
}
GLES20.glClearColor(TEST_R0 / 255.0f, TEST_G0 / 255.0f, TEST_B0 / 255.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(startX, startY, WIDTH / 4, HEIGHT / 2);
GLES20.glClearColor(TEST_R1 / 255.0f, TEST_G1 / 255.0f, TEST_B1 / 255.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
示例2: draw
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Draws the scene.
*/
private void draw() {
GlUtil.checkGlError("draw start");
GLES20.glClearColor(0f, 0f, 0f, 1f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(mPosition, mHeight * 2 / 8, mBlockWidth, mHeight / 8);
GLES20.glClearColor(1f, 1f * (mDroppedFrames & 0x01),
1f * (mChoreographerSkips & 0x01), 1f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
GlUtil.checkGlError("draw done");
}
示例3: generateFrame
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Generates a frame of data using GL commands.
*/
private void generateFrame(int frameIndex) {
final int BOX_SIZE = 80;
frameIndex %= 240;
int xpos, ypos;
int absIndex = Math.abs(frameIndex - 120);
xpos = absIndex * WIDTH / 120;
ypos = absIndex * HEIGHT / 120;
float lumaf = absIndex / 120.0f;
GLES20.glClearColor(lumaf, lumaf, lumaf, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(BOX_SIZE / 2, ypos, BOX_SIZE, BOX_SIZE);
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glScissor(xpos, BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
示例4: drawExtra
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Adds a bit of extra stuff to the display just to give it flavor.
*/
private static void drawExtra(int frameNum, int width, int height) {
// We "draw" with the scissor rect and clear calls. Note this uses window coordinates.
int val = frameNum % 3;
switch (val) {
case 0: GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f); break;
case 1: GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f); break;
case 2: GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f); break;
}
int xpos = (int) (width * ((frameNum % 100) / 100.0f));
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(xpos, 0, width / 32, height / 32);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
示例5: setupRightEye
import android.opengl.GLES20; //导入方法依赖的package包/类
private void setupRightEye() {
Matrix.setLookAtM(mCamera, 0, mRightEyePos[0], mRightEyePos[1], mRightEyePos[2], 0.0f, 0.0f, -SCREEN_FAR, 0.0f, 1.0f, 0.0f);
if (HEAD_TRACKING) Matrix.rotateM(mCamera, 0, (float)mOrientation*90.0f, 0.0f, 0.0f, -1.0f);
Matrix.multiplyMM(mMVP, 0, mCamera, 0, mHeadTransform, 0);
Matrix.multiplyMM(mMVP, 0, mPersp, 0, mMVP, 0);
GLES20.glDisable(GLES20.GL_BLEND);
if (getEffectMode() == VideoEffect.ANAGLYPH_MODE) {
mColorFilter = RED_COLOR_FILTER;
}
GLES20.glScissor(mViewWidth/2, 0, mViewWidth/2, mViewHeight);
GLES20.glViewport(mViewWidth / 2, 0, mViewWidth / 2, mViewHeight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");
GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
false, 0, mVideoTextureCoordRight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
}
示例6: setupLeftEye
import android.opengl.GLES20; //导入方法依赖的package包/类
private void setupLeftEye() {
Matrix.setLookAtM(mCamera, 0, mLeftEyePos[0], mLeftEyePos[1], mLeftEyePos[2], 0.0f, 0.0f, -SCREEN_FAR, 0.0f, 1.0f, 0.0f);
if (HEAD_TRACKING) Matrix.rotateM(mCamera, 0, (float)mOrientation*90.0f, 0.0f, 0.0f, -1.0f);
Matrix.multiplyMM(mMVP, 0, mCamera, 0, mHeadTransform, 0);
Matrix.multiplyMM(mMVP, 0, mPersp, 0, mMVP, 0);
GLES20.glDisable(GLES20.GL_BLEND);
if (getEffectMode() == VideoEffect.ANAGLYPH_MODE) {
mColorFilter = CYAN_COLOR_FILTER;
}
GLES20.glScissor(0, 0, mViewWidth / 2, mViewHeight);
GLES20.glViewport(0, 0, mViewWidth / 2, mViewHeight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");
GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
false, 0, mVideoTextureCoordLeft);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
}
示例7: drawBox
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Draws a red box in the corner.
*/
private void drawBox() {
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(0, 0, 100, 100);
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
示例8: drawBox
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Draws a box, with position offset.
*/
private void drawBox(int posn) {
final int width = mInputWindowSurface.getWidth();
int xpos = (posn * 4) % (width - 50);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(xpos, 0, 100, 100);
GLES20.glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
}
示例9: clipForCamera
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Perform clipping using normal Scene coordinate transformations
* @param pGLState
* @param pCamera
*/
private void clipForCamera(GLState pGLState, Camera pCamera) {
final int surfaceHeight = pCamera.getSurfaceHeight();
/* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */
/* Determine clipping coordinates of each corner in surface coordinates. */
final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0, new float[2]));
final int lowerLeftX = (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerLeftY = surfaceHeight - (int)Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight, new float[2]));
final int upperLeftX = (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperLeftY = surfaceHeight - (int)Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight, new float[2]));
final int upperRightX = (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int upperRightY = surfaceHeight - (int)Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0, new float[2]));
final int lowerRightX = (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]);
final int lowerRightY = surfaceHeight - (int)Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]);
/* Determine minimum and maximum x clipping coordinates. */
final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX);
/* Determine minimum and maximum y clipping coordinates. */
final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY);
/* Determine clipping width and height. */
final int clippingWidth = maxClippingX - minClippingX;
final int clippingHeight = maxClippingY - minClippingY;
//Debug.d("ClippingY: min="+minClippingY+", max="+maxClippingY);
//Debug.d("clipForCamera: GLES20.glScissor("+minClippingX+", "+minClippingY+", "+clippingWidth+", "+clippingHeight+")");
GLES20.glScissor(minClippingX, minClippingY, clippingWidth, clippingHeight);
}
示例10: clipForHUD
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Perform clipping using HUD coordinate transformations
* @param pGLState
* @param pCamera
*/
private void clipForHUD(GLState pGLState, Camera pCamera) {
float[] coordinates = this.getParent().convertLocalCoordinatesToSceneCoordinates(this.mX, this.mY, new float[2]);
float[] size = this.getParent().convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight, new float[2]);
final float zoom = ((ZoomCamera)pCamera).getZoomFactor();
final float screenRatioX = pCamera.getSurfaceWidth()/pCamera.getWidth();
final float screenRatioY = pCamera.getSurfaceHeight()/pCamera.getHeight();
final float left = (this.mX - (this.mWidth/2)) * screenRatioX / zoom;
final float bottom = (this.mY - (this.mHeight/2)) * screenRatioY / zoom;
final float width = this.mWidth * screenRatioX / zoom;
final float height = this.mHeight * screenRatioY / zoom;
if (print_debug) {
Debug.d("Scrollable X: " + this.mX);
Debug.d("Scrollable Y: " + this.mY);
Debug.d("Scrollable W: " + this.mWidth);
Debug.d("Scrollable H: " + this.mHeight);
Debug.d("Scrollable x,y: "+coordinates[Constants.VERTEX_INDEX_X]+","+coordinates[Constants.VERTEX_INDEX_Y]);
Debug.d("Scrollable w,h: " + size[Constants.VERTEX_INDEX_X]+","+size[Constants.VERTEX_INDEX_Y]);
Debug.d("clipForHUD: GLES20.glScissor("+left+", "+bottom+", "+width+", "+height+")");
Debug.d("Scrollable camera zoom: " + zoom);
Debug.d("Scrollable screenRatioX: " + pCamera.getSurfaceWidth()/pCamera.getWidth());
Debug.d("Scrollable screenRatioY: " + pCamera.getSurfaceHeight()/pCamera.getHeight());
print_debug = false;
}
GLES20.glScissor((int)left, (int)bottom, (int)width, (int)height);
// Math.round(((clipX + point.x)) * screenRatioX),
// Math.round((cameraH - ((clipY + point.y) + clipH)) * screenRatioY),
// Math.round(clipW * screenRatioX),
// Math.round(clipH * screenRatioY));
}
示例11: clipToProgress
import android.opengl.GLES20; //导入方法依赖的package包/类
private void clipToProgress(GLState pGLState, Camera pCamera) {
final float zoom = ((ZoomCamera)pCamera).getZoomFactor();
final float screenRatioX = pCamera.getSurfaceWidth()/pCamera.getWidth();
final float screenRatioY = pCamera.getSurfaceHeight()/pCamera.getHeight();
final float left = (this.mX - (this.mWidth/2)) * screenRatioX / zoom;
final float bottom = (this.mY - (this.mHeight/2)) * screenRatioY / zoom;
final float width = (this.mWidth * screenRatioX / zoom) * this.progress;
final float height = this.mHeight * screenRatioY / zoom;
GLES20.glScissor((int) left, (int) bottom, (int) width, (int) height);
}
示例12: glScissor
import android.opengl.GLES20; //导入方法依赖的package包/类
public static void glScissor(final int aX, final int aY, final int aWidth, final int aHeight)
{
//.if DESKTOP
//|gl.glScissor (aX,aY,aWidth,aHeight);
//.elseif ANDROID
GLES20.glScissor (aX,aY,aWidth,aHeight);
//.endif
}
示例13: setupMonoEye
import android.opengl.GLES20; //导入方法依赖的package包/类
private void setupMonoEye() {
Matrix.setIdentityM(mMVP, 0);
GLES20.glDisable(GLES20.GL_BLEND);
GLES20.glScissor(0, 0, mViewWidth, mViewHeight);
GLES20.glViewport(0, 0, mViewWidth, mViewHeight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glViewport");
GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT,
false, 0, mVideoTextureCoordRight);
if (CHECK_GL_ERRORS) OpenGLUtils.checkGlError("glVertexAttribPointer");
}
示例14: drawRectSurface
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Clears the surface, then draws some alpha-blended rectangles with GL.
* <p>
* Creates a temporary EGL context just for the duration of the call.
*/
private void drawRectSurface(Surface surface, int left, int top, int width, int height) {
EglCore eglCore = new EglCore();
WindowSurface win = new WindowSurface(eglCore, surface, false);
win.makeCurrent();
GLES20.glClearColor(0, 0, 0, 0);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
for (int i = 0; i < 4; i++) {
int x, y, w, h;
if (width < height) {
// vertical
w = width / 4;
h = height;
x = left + w * i;
y = top;
} else {
// horizontal
w = width;
h = height / 4;
x = left;
y = top + h * i;
}
GLES20.glScissor(x, y, w, h);
switch (i) {
case 0: // 50% blue at 25% alpha, pre-multiplied
GLES20.glClearColor(0.0f, 0.0f, 0.125f, 0.25f);
break;
case 1: // 100% blue at 25% alpha, pre-multiplied
GLES20.glClearColor(0.0f, 0.0f, 0.25f, 0.25f);
break;
case 2: // 200% blue at 25% alpha, pre-multiplied (should get clipped)
GLES20.glClearColor(0.0f, 0.0f, 0.5f, 0.25f);
break;
case 3: // 100% white at 25% alpha, pre-multiplied
GLES20.glClearColor(0.25f, 0.25f, 0.25f, 0.25f);
break;
}
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
}
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
win.swapBuffers();
win.release();
eglCore.release();
}
示例15: doAnimation
import android.opengl.GLES20; //导入方法依赖的package包/类
/**
* Draws updates as fast as the system will allow.
* <p>
* In 4.4, with the synchronous buffer queue queue, the frame rate will be limited.
* In previous (and future) releases, with the async queue, many of the frames we
* render may be dropped.
* <p>
* The correct thing to do here is use Choreographer to schedule frame updates off
* of vsync, but that's not nearly as much fun.
*/
private void doAnimation(WindowSurface eglSurface) {
final int BLOCK_WIDTH = 80;
final int BLOCK_SPEED = 2;
float clearColor = 0.0f;
int xpos = -BLOCK_WIDTH / 2;
int xdir = BLOCK_SPEED;
int width = eglSurface.getWidth();
int height = eglSurface.getHeight();
Log.d(TAG, "Animating " + width + "x" + height + " EGL surface");
while (true) {
// Check to see if the TextureView's SurfaceTexture is still valid.
synchronized (mLock) {
SurfaceTexture surfaceTexture = mSurfaceTexture;
if (surfaceTexture == null) {
Log.d(TAG, "doAnimation exiting");
return;
}
}
// Still alive, render a frame.
GLES20.glClearColor(clearColor, clearColor, clearColor, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
GLES20.glScissor(xpos, height / 4, BLOCK_WIDTH, height / 2);
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
// Publish the frame. If we overrun the consumer, frames will be dropped,
// so on a sufficiently fast device the animation will run at faster than
// the display refresh rate.
//
// If the SurfaceTexture has been destroyed, this will throw an exception.
eglSurface.swapBuffers();
// Advance state
clearColor += 0.015625f;
if (clearColor > 1.0f) {
clearColor = 0.0f;
}
xpos += xdir;
if (xpos <= -BLOCK_WIDTH / 2 || xpos >= width - BLOCK_WIDTH / 2) {
Log.d(TAG, "change direction");
xdir = -xdir;
}
}
}