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


Java GLES20.glGetAttribLocation方法代码示例

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


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

示例1: initShaders

import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShaders() {
    String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
    if (strGLVersion != null)
        Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);

    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    progOES = loadShader(vss, fssOES);
    vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
    vTCOES  = GLES20.glGetAttribLocation(progOES, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPosOES);
    GLES20.glEnableVertexAttribArray(vTCOES);

    prog2D  = loadShader(vss, fss2D);
    vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
    vTC2D  = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vPos2D);
    GLES20.glEnableVertexAttribArray(vTC2D);
}
 
开发者ID:jmpaaak,项目名称:EyeShopping,代码行数:20,代码来源:CameraGLRendererBase.java

示例2: GLSurfaceFilter

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Constructor
 * this should be called in GL context
 */
public GLSurfaceFilter() {
    mCoordsPerVertex = 2;
    mVertexStride = mCoordsPerVertex * SIZEOF_FLOAT; // 8
    mVertexCount = FULL_RECTANGLE_COORDS.length / mCoordsPerVertex; //4
    mTexCoordStride = 2 * SIZEOF_FLOAT; //8

    hProgram = GLUtil.loadProgram(VERTEX_SHADER, FRAGMENT_SHADER);
    mTextureTarget = GLES11Ext.GL_TEXTURE_EXTERNAL_OES;

    // get locations of attributes and uniforms

    maPositionLoc = GLES20.glGetAttribLocation(hProgram, "aPosition");
    GLUtil.checkLocation(maPositionLoc, "aPosition");
    maTextureCoordLoc = GLES20.glGetAttribLocation(hProgram, "aTextureCoord");
    GLUtil.checkLocation(maTextureCoordLoc, "aTextureCoord");
    muMVPMatrixLoc = GLES20.glGetUniformLocation(hProgram, "uMVPMatrix");
    GLUtil.checkLocation(muMVPMatrixLoc, "uMVPMatrix");
    muTexMatrixLoc = GLES20.glGetUniformLocation(hProgram, "uTexMatrix");
    GLUtil.checkLocation(muTexMatrixLoc, "uTexMatrix");
}
 
开发者ID:LeonHover,项目名称:MediaCodecRecorder,代码行数:25,代码来源:GLSurfaceFilter.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: onCreate

import android.opengl.GLES20; //导入方法依赖的package包/类
protected void onCreate(){
    if(mRes!=null){
        mGLProgram= GpuUtils.createGLProgramByAssetsFile(mRes,mVertex,mFragment);
    }else{
        mGLProgram= GpuUtils.createGLProgram(mVertex,mFragment);
    }
    mGLVertexCo= GLES20.glGetAttribLocation(mGLProgram,"aVertexCo");
    mGLTextureCo=GLES20.glGetAttribLocation(mGLProgram,"aTextureCo");
    mGLVertexMatrix=GLES20.glGetUniformLocation(mGLProgram,"uVertexMatrix");
    mGLTextureMatrix=GLES20.glGetUniformLocation(mGLProgram,"uTextureMatrix");
    mGLTexture=GLES20.glGetUniformLocation(mGLProgram,"uTexture");

    if(isUseSize){
        mGLWidth=GLES20.glGetUniformLocation(mGLProgram,"uWidth");
        mGLHeight=GLES20.glGetUniformLocation(mGLProgram,"uHeight");
    }
}
 
开发者ID:aiyaapp,项目名称:AAVT,代码行数:18,代码来源:BaseFilter.java

示例5: MyShader

import android.opengl.GLES20; //导入方法依赖的package包/类
/** Creates the shader. This will compile and link the shader. */
public MyShader() {
  // Compile and link the shader program.
  int vertexShader = MyGLUtils.loadShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_SOURCE);
  int fragmentShader = MyGLUtils.loadShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_SOURCE);
  program = GLES20.glCreateProgram();
  GLES20.glAttachShader(program, vertexShader);
  GLES20.glAttachShader(program, fragmentShader);
  GLES20.glLinkProgram(program);
  MyGLUtils.checkGlError("link program");

  // Get the handles to our shader parameters.
  GLES20.glUseProgram(program);
  positionHandle = GLES20.glGetAttribLocation(program, "aPosition");
  colorHandle = GLES20.glGetAttribLocation(program, "aColor");
  mvpMatrixHandle = GLES20.glGetUniformLocation(program, "uMVPMatrix");
  GLES20.glUseProgram(0);
  MyGLUtils.checkGlError("get handles");
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:20,代码来源:MyShader.java

示例6: handle

import android.opengl.GLES20; //导入方法依赖的package包/类
@Override
protected int handle() {
    if (mHandle == 0) {
        mHandle = GLES20.glGetAttribLocation(mProgram.handle, mName);
    }
    return mHandle;
}
 
开发者ID:gplibs,项目名称:android-magic-surface-view,代码行数:8,代码来源:GLAttributeParameter.java

示例7: glGetAttribLocation

import android.opengl.GLES20; //导入方法依赖的package包/类
public static int glGetAttribLocation(final int aProgramHandle, final String aAttributeName)
{
    //.if DESKTOP
    //|return gl.glGetAttribLocation(aProgramHandle, aAttributeName);
    //.elseif ANDROID
    return GLES20.glGetAttribLocation(aProgramHandle, aAttributeName);
    //.endif
    
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:10,代码来源:GL.java

示例8: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Encapsulates the OpenGL ES instructions for drawing this shape.
 *
 * @param mvpMatrix - The Model View Project matrix in which to draw
 * this shape.
 */
public void draw(float[] mvpMatrix) {
    // Add program to OpenGL environment
    GLES20.glUseProgram(mProgram);

    // get handle to vertex shader's vPosition member
    mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");

    // Enable a handle to the triangle vertices
    GLES20.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    GLES20.glVertexAttribPointer(
            mPositionHandle, COORDS_PER_VERTEX,
            GLES20.GL_FLOAT, false,
            vertexStride, vertexBuffer);

    // get handle to fragment shader's vColor member
    mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");

    // Set color for drawing the triangle
    GLES20.glUniform4fv(mColorHandle, 1, color, 0);

    // get handle to shape's transformation matrix
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    MyGLRenderer.checkGlError("glGetUniformLocation");

    // Apply the projection and view transformation
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
    MyGLRenderer.checkGlError("glUniformMatrix4fv");

    // Draw the triangle
    GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, vertexCount);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(mPositionHandle);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:43,代码来源:Triangle.java

示例9: initShader

import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShader(Context context) {
    mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_texture.sh" , context.getResources());

    mFragShader = ShaderUtil.loadFromAssetsFile("frag_texture.sh" , context.getResources());

    mProgram = ShaderUtil.createProgram(mVertexShader , mFragShader);

    maPositionHandle = GLES20.glGetAttribLocation(mProgram , "aPosition");
    maTexCoorHandle = GLES20.glGetAttribLocation(mProgram , "aTexCoor");
    muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram , "uMVPMatrix");
}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:12,代码来源:Triangle.java

示例10: initShader

import android.opengl.GLES20; //导入方法依赖的package包/类
private void initShader(Context context) {
    mVertexShader = ShaderUtil.loadFromAssetsFile("vertex_angle.sh" , context.getResources());

    mFragShader = ShaderUtil.loadFromAssetsFile("frag_angle.sh" , context.getResources());

    mProgram = ShaderUtil.createProgram(mVertexShader , mFragShader);

    maPositionHandle = GLES20.glGetAttribLocation(mProgram , "aPosition");
    maTexCoorHandle = GLES20.glGetAttribLocation(mProgram , "aTexCoor");
    muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram , "uMVPMatrix");
}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:12,代码来源:ImageAngle.java

示例11: ImageProgram

import android.opengl.GLES20; //导入方法依赖的package包/类
public ImageProgram() {
    mProgram = OpenGLUtils.loadProgram(VERTEX_SHADER_CODE, FRAGMENT_SHADER_CODE);

    mAPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
    mATextureCoordinateHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoordinate");
    mUTextureHandle = GLES20.glGetUniformLocation(mProgram, "uTexture");
    mUMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    mUOpacityHandle = GLES20.glGetUniformLocation(mProgram, "uOpacity");
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:10,代码来源:GLImageView.java

示例12: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw(float[] mvpMatrix, float r, float g, float b, float a) {
    // Add program to OpenGL environment
    GLES20.glUseProgram(mProgram);

    // get handle to vertex shader's vPosition member
    int mPositionHandle = GLES20.glGetAttribLocation(mProgram, "vPosition");

    // Enable a handle to the triangle vertices
    GLES20.glEnableVertexAttribArray(mPositionHandle);

    // Prepare the triangle coordinate data
    int vertexStride = COORDS_PER_VERTEX * 4;
    GLES20.glVertexAttribPointer(mPositionHandle, COORDS_PER_VERTEX,
                                 GLES20.GL_FLOAT, false,
            vertexStride, vertexBuffer);

    // get handle to fragment shader's vColor member
    int mColorHandle = GLES20.glGetUniformLocation(mProgram, "vColor");

    // Set color for drawing the triangle
    float[] color = {r,g,b,a};

    GLES20.glUniform4fv(mColorHandle, 1, color, 0);

    // get handle to shape's transformation matrix
    int mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
    GLRenderer.checkGlError("glGetUniformLocation");

    // Apply the projection and view transformation
    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
    GLRenderer.checkGlError("glUniformMatrix4fv");

    // Draw the square
    GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length,
                          GLES20.GL_UNSIGNED_SHORT, drawListBuffer);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(mPositionHandle);
}
 
开发者ID:efroemling,项目名称:bombsquad-remote-android,代码行数:40,代码来源:GLRenderer.java

示例13: ColorShaderProgram

import android.opengl.GLES20; //导入方法依赖的package包/类
public ColorShaderProgram(final Context context) {
    super(context, R.raw.vertex, R.raw.fragment);

    // Retrieve uniform locations for the shader program.
    mUMatrixLocation = GLES20.glGetUniformLocation(mProgram, U_MATRIX);
    // Retrieve attribute locations for the shader program.
    mAPositionLocation = GLES20.glGetAttribLocation(mProgram, A_POSITION);
    mAColorLocation = GLES20.glGetAttribLocation(mProgram, A_COLOR);
}
 
开发者ID:Piasy,项目名称:OpenGLESTutorial-Android,代码行数:10,代码来源:ColorShaderProgram.java

示例14: createOnGlThread

import android.opengl.GLES20; //导入方法依赖的package包/类
/**
 * Allocates and initializes OpenGL resources needed by the plane renderer.  Must be
 * called on the OpenGL thread, typically in
 * {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
 *
 * @param context                 Needed to access shader source and texture PNG.
 * @param gridDistanceTextureName Name of the PNG file containing the grid texture.
 */
public void createOnGlThread(Context context, String gridDistanceTextureName)
        throws IOException {
    int vertexShader = ShaderUtil.loadGLShader(TAG, context,
            GLES20.GL_VERTEX_SHADER, R.raw.plane_vertex);
    int passthroughShader = ShaderUtil.loadGLShader(TAG, context,
            GLES20.GL_FRAGMENT_SHADER, R.raw.plane_fragment);

    mPlaneProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(mPlaneProgram, vertexShader);
    GLES20.glAttachShader(mPlaneProgram, passthroughShader);
    GLES20.glLinkProgram(mPlaneProgram);
    GLES20.glUseProgram(mPlaneProgram);

    ShaderUtil.checkGLError(TAG, "Program creation");

    // Read the texture.
    Bitmap textureBitmap = BitmapFactory.decodeStream(
            context.getAssets().open(gridDistanceTextureName));

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glGenTextures(mTextures.length, mTextures, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[0]);

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, textureBitmap, 0);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);

    ShaderUtil.checkGLError(TAG, "Texture loading");

    mPlaneXZPositionAlphaAttribute = GLES20.glGetAttribLocation(mPlaneProgram,
            "a_XZPositionAlpha");

    mPlaneModelUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_Model");
    mPlaneModelViewProjectionUniform =
            GLES20.glGetUniformLocation(mPlaneProgram, "u_ModelViewProjection");
    mTextureUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_Texture");
    mLineColorUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_lineColor");
    mDotColorUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_dotColor");
    mGridControlUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_gridControl");
    mPlaneUvMatrixUniform = GLES20.glGetUniformLocation(mPlaneProgram, "u_PlaneUvMatrix");

    ShaderUtil.checkGLError(TAG, "Program parameters");
}
 
开发者ID:nimbl3,项目名称:nimbl3-arcore,代码行数:56,代码来源:PlaneRenderer.java

示例15: draw

import android.opengl.GLES20; //导入方法依赖的package包/类
public void draw() {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    // Do a compile rotation every 10 seconds.
    long time = SystemClock.uptimeMillis() % 10000L;
    float angleInDegrees = (360.0f / 10000.0f) * ((int) time);

    // Set our pre-vertex lighting program.
    GLES20.glUseProgram(mPerVertexProgramHandle);

    // Set program handle for cube drawing.
    mMVPMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVPMatrix");
    mMVMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVMatrix");
    mLightPosHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_LightPos");
    mPositionHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Position");
    mColorHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Color");
    mNormalHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Normal");

    // Calculate position of the light.
    // Rotate and then push into the distance.
    Matrix.setIdentityM(mLightModelMatrix, 0);
    Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f);
    Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0F, 0.0f);
    Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f);

    Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);
    Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);

    // right
    Matrix.setIdentityM(mModelMatrix, 0);
    Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f);
    Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f);
    drawCube();

    // left
    Matrix.setIdentityM(mModelMatrix, 0);
    Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f);
    Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
    drawCube();

    // top
    Matrix.setIdentityM(mModelMatrix, 0);
    Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f);
    Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
    drawCube();

    // bottom
    Matrix.setIdentityM(mModelMatrix, 0);
    Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f);
    Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
    drawCube();

    // center
    Matrix.setIdentityM(mModelMatrix, 0);
    Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f);
    Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 1.0f);
    drawCube();

    // Draw a point to indicate the light.
    GLES20.glUseProgram(mPointProgramHandle);
    drawLight();
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:63,代码来源:Cube.java


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