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


Java GLES20.glEnable方法代码示例

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


在下文中一共展示了GLES20.glEnable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    mScreenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
    mScreenHeight = mContext.getResources().getDisplayMetrics().heightPixels;

    // Set the clear color to black. TODO: Remove this later once there's an actual background
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1);

    // Object shaders
    int vertexShader = ShaderInfo.loadShader(GLES20.GL_VERTEX_SHADER, ShaderInfo.vs_Image);
    int fragmentShader = ShaderInfo.loadShader(GLES20.GL_FRAGMENT_SHADER, ShaderInfo.fs_Image);

    ShaderInfo.sp_Image = GLES20.glCreateProgram();             // create empty OpenGL ES Program
    GLES20.glAttachShader(ShaderInfo.sp_Image, vertexShader);   // add the vertex shader to program
    GLES20.glAttachShader(ShaderInfo.sp_Image, fragmentShader); // add the fragment shader to program
    GLES20.glLinkProgram(ShaderInfo.sp_Image);                  // creates OpenGL ES program executables

    // Set our shader program
    GLES20.glUseProgram(ShaderInfo.sp_Image);

    // Enable blending
    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
}
 
开发者ID:kaidenho,项目名称:spellcaster,代码行数:24,代码来源:GameRenderer.java

示例2: onDraw

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected void onDraw() {
    super.onDraw();

    // 开启混合
    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);

    for (ComponentRender componentRender : mComponentRenders) {
        componentRender.setScreenAnchor(mScreenAnchor);
        componentRender.updateRenderVertices(getWidth(), getHeight());
        componentRender.onDraw(mTextureHandle, mPositionHandle, mTextureCoordHandle, mTextureVertices[2]);
    }

    GLES20.glDisable(GLES20.GL_BLEND);
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:17,代码来源:StickerRender.java

示例3: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw() {
    GLES20.glEnable(GLES20.GL_BLEND);
    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
    GLES20.glUseProgram(mProgram);

    int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
    GLES20.glEnableVertexAttribArray(mPositionHandle);
    int vertexStride = COORDS_PER_VERTEX * 4;
    GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, mVertexBuffer);

    GLES20.glUniform4fv(GLES20.glGetUniformLocation(mProgram, "aColor"), 1, mColor, 0);
    GLES20.glUniform2f(GLES20.glGetUniformLocation(mProgram, "aCirclePosition"), mCenterX, mCenterY);
    GLES20.glUniform1f(GLES20.glGetUniformLocation(mProgram, "aRadius"), mRadius);
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawOrder.length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer);
    GLES20.glDisableVertexAttribArray(mPositionHandle);
}
 
开发者ID:beetsolutions,项目名称:opengl_circle,代码行数:17,代码来源:GLCircleSprite.java

示例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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:19,代码来源:ContinuousCaptureActivity.java

示例5: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
    public void draw(GL10 gl){
        gl.glRotatef(45f,0,0,0);
        GLES20.glFrontFace(GL10.GL_CCW);
        GLES20.glEnable(GL10.GL_CULL_FACE);
        GLES20.glCullFace(GL10.GL_BACK);
        gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(3, GL10.GL_FLOAT,0,mVertexBuffer);
        gl.glColorPointer(4,GL10.GL_FIXED,0,mColorBuffer);
//        gl.glDrawArrays(GL10.GL_TRIANGLES,0,3);
        GLES20.glDrawElements(GL10.GL_TRIANGLES,indices.length,GL10.GL_UNSIGNED_SHORT,mIndexBuffer);
//        gl.glDrawElements(GL10.GL_COLOR_ARRAY,colors.length,GL10.GL_FLOAT,mColorBuffer);

        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
        GLES20.glDisable(GL10.GL_CULL_FACE);
    }
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:19,代码来源:Square20.java

示例6: 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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:27,代码来源:MovieSliders.java

示例7: 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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:32,代码来源:MovieEightRects.java

示例8: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    mImageLR = new ImageLR(getContext());
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    initTexture();
    GLES20.glDisable(GLES20.GL_CULL_FACE);
}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:9,代码来源:TextureImgSurfaceView.java

示例9: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
	GLES20.glEnable(GL10.GL_BLEND);
	GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

	TextureCache.reload();
	RenderedText.reloadCache();
	Vertexbuffer.refreshAllBuffers();
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:10,代码来源:Game.java

示例10: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

    // Set the background clear color to black.
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // Use culling to remove back face.
    GLES20.glEnable(GLES20.GL_CULL_FACE);

    // Enable depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    mCube = new Cube();
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:15,代码来源:LessonThreeRenderer.java

示例11: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {

    // Set the background clear color to black.
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    // Use culling to remove back face.
    GLES20.glEnable(GLES20.GL_CULL_FACE);

    // Enable depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    mCube = new Cube(mActivity);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:15,代码来源:LessonFourRenderer.java

示例12: 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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:11,代码来源:CameraCaptureActivity.java

示例13: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
    mImageAngle = new ImageAngle(getContext());
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    initTexture();
    GLES20.glDisable(GLES20.GL_CULL_FACE);
}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:9,代码来源:TextureAngleSurfaceView.java

示例14: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    // Set the background clear color to black
    GLES20.glClearColor(0.0f, 0f, 0f, 0f);

    // Use culling to remove back faces
    GLES20.glEnable(GLES20.GL_CULL_FACE);

    // Enable depth testing
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    // Position the eye in front of the origin.
    final float eyeX = 0.0f;
    final float eyeY = 0.0f;
    final float eyeZ = -0.5f;

    // We are looking toward the distance
    final float lookX = 0.0f;
    final float lookY = 0.0f;
    final float lookZ = -5.0f;

    // Set our up vector. This is where our head would be pointing were we holding the camera.
    final float upX = 0.0f;
    final float upY = 1.0f;
    final float upZ = 0.0f;

    // Set the view matrix. This matrix can be said to represent the camera position.
    // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
    // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
    Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

    final String vertexShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.per_pixel_vertex_shader_tex_and_light);
    final String fragmentShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.per_pixel_fragment_shader_tex_and_light);

    final int vertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    final int fragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);

    mProgramHandle = Utils.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle,
            new String[]{"a_Position", "a_Normal", "a_TexCoordinate"});

    // Define a simple shader program for our point.
    final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.point_vertex_shader);
    final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mActivity, R.raw.point_fragment_shader);

    final int pointVertexShaderHandle = Utils.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);
    final int pointFragmentShaderHandle = Utils.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);
    mPointProgramHandle = Utils.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle,
            new String[]{"a_Position"});

    // Load the texture
    mBrickDataHandle = Utils.loadTexture(mActivity, R.drawable.stone_wall_public_domain);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    mGrassDataHandle = Utils.loadTexture(mActivity, R.drawable.noisy_grass_public_domain);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    if (mQueuedMinFilter != 0) {
        setMinFilter(mQueuedMinFilter);
    }

    if (mQueuedMagFilter != 0) {
        setMagFilter(mQueuedMagFilter);
    }

    // Initialize the accumulated rotation matrix
    Matrix.setIdentityM(mAccumulatedRotation, 0);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:68,代码来源:LessonSixRenderer.java

示例15: onSurfaceCreated

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
{
	// Set the background clear color to black.
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	
	// Use culling to remove back faces.
	GLES20.glEnable(GLES20.GL_CULL_FACE);
	
	// Enable depth testing
	GLES20.glEnable(GLES20.GL_DEPTH_TEST);
	
	// The below glEnable() call is a holdover from OpenGL ES 1, and is not needed in OpenGL ES 2.
	// Enable texture mapping
	// GLES20.glEnable(GLES20.GL_TEXTURE_2D);
		
	// Position the eye in front of the origin.
	final float eyeX = 0.0f;
	final float eyeY = 0.0f;
	final float eyeZ = -0.5f;

	// We are looking toward the distance
	final float lookX = 0.0f;
	final float lookY = 0.0f;
	final float lookZ = -5.0f;

	// Set our up vector. This is where our head would be pointing were we holding the camera.
	final float upX = 0.0f;
	final float upY = 1.0f;
	final float upZ = 0.0f;

	// Set the view matrix. This matrix can be said to represent the camera position.
	// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
	// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
	Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);		

	final String vertexShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_vertex_shader_tex_and_light);   		
		final String fragmentShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.per_pixel_fragment_shader_tex_and_light);			
	
	final int vertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);		
	final int fragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);		
	
	mProgramHandle = ShaderHelper.createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, 
			new String[] {"a_Position",  "a_Normal", "a_TexCoordinate"});								                                							       
       
       // Define a simple shader program for our point.
       final String pointVertexShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.point_vertex_shader);        	       
       final String pointFragmentShader = RawResourceReader.readTextFileFromRawResource(mActivityContext, R.raw.point_fragment_shader);
       
       final int pointVertexShaderHandle = ShaderHelper.compileShader(GLES20.GL_VERTEX_SHADER, pointVertexShader);
       final int pointFragmentShaderHandle = ShaderHelper.compileShader(GLES20.GL_FRAGMENT_SHADER, pointFragmentShader);
       mPointProgramHandle = ShaderHelper.createAndLinkProgram(pointVertexShaderHandle, pointFragmentShaderHandle, 
       		new String[] {"a_Position"}); 
       
       // Load the texture
       mBrickDataHandle = TextureHelper.loadTexture(mActivityContext, R.drawable.stone_wall_public_domain);        
       GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
       
       mGrassDataHandle = TextureHelper.loadTexture(mActivityContext, R.drawable.noisy_grass_public_domain);
       GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
       
       if (mQueuedMinFilter != 0)
       {
       	setMinFilter(mQueuedMinFilter);
       }
       
       if (mQueuedMagFilter != 0)
       {
       	setMagFilter(mQueuedMagFilter);
       }
       
       // Initialize the accumulated rotation matrix
       Matrix.setIdentityM(mAccumulatedRotation, 0);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:75,代码来源:LessonSixRenderer.java


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