當前位置: 首頁>>代碼示例>>Java>>正文


Java GLES20.glCreateProgram方法代碼示例

本文整理匯總了Java中android.opengl.GLES20.glCreateProgram方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glCreateProgram方法的具體用法?Java GLES20.glCreateProgram怎麽用?Java GLES20.glCreateProgram使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.opengl.GLES20的用法示例。


在下文中一共展示了GLES20.glCreateProgram方法的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: GlShader

import android.opengl.GLES20; //導入方法依賴的package包/類
public GlShader(String vertexSource, String fragmentSource) {
  final int vertexShader = compileShader(GLES20.GL_VERTEX_SHADER, vertexSource);
  final int fragmentShader = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
  program = GLES20.glCreateProgram();
  if (program == 0) {
    throw new RuntimeException("glCreateProgram() failed. GLES20 error: " + GLES20.glGetError());
  }
  GLES20.glAttachShader(program, vertexShader);
  GLES20.glAttachShader(program, fragmentShader);
  GLES20.glLinkProgram(program);
  int[] linkStatus = new int[] {GLES20.GL_FALSE};
  GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
  if (linkStatus[0] != GLES20.GL_TRUE) {
    Logging.e(TAG, "Could not link program: " + GLES20.glGetProgramInfoLog(program));
    throw new RuntimeException(GLES20.glGetProgramInfoLog(program));
  }
  // According to the documentation of glLinkProgram():
  // "After the link operation, applications are free to modify attached shader objects, compile
  // attached shader objects, detach shader objects, delete shader objects, and attach additional
  // shader objects. None of these operations affects the information log or the program that is
  // part of the program object."
  // But in practice, detaching shaders from the program seems to break some devices. Deleting the
  // shaders are fine however - it will delete them when they are no longer attached to a program.
  GLES20.glDeleteShader(vertexShader);
  GLES20.glDeleteShader(fragmentShader);
  GlUtil.checkNoGLES2Error("Creating GlShader");
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:28,代碼來源:GlShader.java

示例3: GLShape

import android.opengl.GLES20; //導入方法依賴的package包/類
public GLShape(float[] color) {
  this.color = color;
  int vertexShader = GLRenderer.loadShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_CODE);
  int fragmentShader = GLRenderer.loadShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_CODE);
  program = GLES20.glCreateProgram();
  GLES20.glAttachShader(program, vertexShader);
  GLES20.glAttachShader(program, fragmentShader);
  GLES20.glLinkProgram(program);
}
 
開發者ID:Arjun-sna,項目名稱:Android-AudioRecorder-App,代碼行數:10,代碼來源:GLShape.java

示例4: initShaders

import android.opengl.GLES20; //導入方法依賴的package包/類
private void initShaders() {
    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderCode);
    int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderCode);

    shaderProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(shaderProgram, vertexShader);
    GLES20.glAttachShader(shaderProgram, fragmentShader);
    GLES20.glLinkProgram(shaderProgram);
}
 
開發者ID:PacktPublishing,項目名稱:Building-Android-UIs-with-Custom-Views,代碼行數:10,代碼來源:GLDrawer.java

示例5: createProgram

import android.opengl.GLES20; //導入方法依賴的package包/類
private int createProgram(String vertexSource, String fragmentSource) {
    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
    if (vertexShader == 0) {
        return 0;
    }
    int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
    if (pixelShader == 0) {
        return 0;
    }
    int program = GLES20.glCreateProgram();
    checkGlError("glCreateProgram");
    if (program == 0) {
        Log.e(TAG, "Could not create program");
    }
    GLES20.glAttachShader(program, vertexShader);
    checkGlError("glAttachShader");
    GLES20.glAttachShader(program, pixelShader);
    checkGlError("glAttachShader");
    GLES20.glLinkProgram(program);
    int[] linkStatus = new int[1];
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
    if (linkStatus[0] != GLES20.GL_TRUE) {
        Log.e(TAG, "Could not link program: ");
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
    }
    return program;
}
 
開發者ID:livio,項目名稱:sdl_video_streaming_android_sample,代碼行數:30,代碼來源:TextureRender.java

示例6: loadProgram

import android.opengl.GLES20; //導入方法依賴的package包/類
public static int loadProgram(String vertexShaderSource, String fragmentShaderSource) {
    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexShaderSource);
    if (vertexShader == 0) {
        return 0;
    }

    int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShaderSource);
    if (fragmentShader == 0) {
        GLES20.glDeleteShader(vertexShader);
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vertexShader);
    GLES20.glAttachShader(program, fragmentShader);
    GLES20.glLinkProgram(program);

    GLES20.glDeleteShader(vertexShader);
    GLES20.glDeleteShader(fragmentShader);

    int[] status = new int[1];
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] <= 0) {
        mLog.e("link program failed");
        return 0;
    }
    return program;
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:29,代碼來源:OpenGLUtils.java

示例7: Triangle

import android.opengl.GLES20; //導入方法依賴的package包/類
public Triangle() {
    // initialize vertex byte buffer for shape coordinates
    ByteBuffer bb = ByteBuffer.allocateDirect(
            // (number of coordinate values * 4 bytes per float)
            triangleCoords.length * 4);
    // use the device hardware's native byte order
    bb.order(ByteOrder.nativeOrder());

    // create a floating point buffer from the ByteBuffer
    FloatBuffer vertexBuffer = bb.asFloatBuffer();
    // add the coordinates to the FloatBuffer
    vertexBuffer.put(triangleCoords);
    // set the buffer to read the first coordinate
    vertexBuffer.position(0);

    // prepare shaders and OpenGL program
    String vertexShaderCode = "uniform mat4 uMVPMatrix;" +

            "attribute vec4 vPosition;" +
            "void main() {" +
            // the matrix must be included as a modifier of gl_Position
            "  gl_Position = vPosition * uMVPMatrix;" +
            "}";
    int vertexShader = GLRenderer.loadShader(GLES20.GL_VERTEX_SHADER,
            vertexShaderCode);
    String fragmentShaderCode = "precision mediump float;" +
            "uniform vec4 vColor;" +
            "void main() {" +
            "  gl_FragColor = vColor;" +
            "}";
    int fragmentShader = GLRenderer.loadShader(GLES20.GL_FRAGMENT_SHADER,
            fragmentShaderCode);

    int mProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(mProgram, vertexShader);   // add the vertex shader to program
    GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program
    GLES20.glLinkProgram(mProgram);                  // create OpenGL program executables

}
 
開發者ID:efroemling,項目名稱:bombsquad-remote-android,代碼行數:40,代碼來源:GLRenderer.java

示例8: createProgram

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * Creates a new program from the supplied vertex and fragment shaders.
 *
 * @return A handle to the program, or 0 on failure.
 */
public static int createProgram(String vertexSource, String fragmentSource) {
    int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
    if (vertexShader == 0) {
        return 0;
    }
    int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
    if (pixelShader == 0) {
        return 0;
    }

    int program = GLES20.glCreateProgram();
    checkGlError("glCreateProgram");
    if (program == 0) {
        Log.e(TAG, "Could not create program");
    }
    GLES20.glAttachShader(program, vertexShader);
    checkGlError("glAttachShader");
    GLES20.glAttachShader(program, pixelShader);
    checkGlError("glAttachShader");
    GLES20.glLinkProgram(program);
    int[] linkStatus = new int[1];
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
    if (linkStatus[0] != GLES20.GL_TRUE) {
        Log.e(TAG, "Could not link program: ");
        Log.e(TAG, GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
    }
    return program;
}
 
開發者ID:SbName,項目名稱:SbCamera,代碼行數:36,代碼來源:GlUtil.java

示例9: 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.
 */
public void createOnGlThread(Context context) {
    ShaderUtil.checkGLError(TAG, "before create");

    int buffers[] = new int[1];
    GLES20.glGenBuffers(1, buffers, 0);
    mVbo = buffers[0];
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVbo);

    mVboSize = INITIAL_BUFFER_POINTS * BYTES_PER_POINT;
    GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mVboSize, null, GLES20.GL_DYNAMIC_DRAW);
    GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);

    ShaderUtil.checkGLError(TAG, "buffer alloc");

    int vertexShader = ShaderUtil.loadGLShader(TAG, context,
        GLES20.GL_VERTEX_SHADER, R.raw.point_cloud_vertex);
    int passthroughShader = ShaderUtil.loadGLShader(TAG, context,
        GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment);

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

    ShaderUtil.checkGLError(TAG, "program");

    mPositionAttribute = GLES20.glGetAttribLocation(mProgramName, "a_Position");
    mColorUniform = GLES20.glGetUniformLocation(mProgramName, "u_Color");
    mModelViewProjectionUniform = GLES20.glGetUniformLocation(
        mProgramName, "u_ModelViewProjection");
    mPointSizeUniform = GLES20.glGetUniformLocation(mProgramName, "u_PointSize");

    ShaderUtil.checkGLError(TAG, "program  params");
}
 
開發者ID:googlevr,項目名稱:poly-sample-android,代碼行數:43,代碼來源:PointCloudRenderer.java

示例10: createAndLinkProgram

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * Helper function to compile and link a program.
 * 
 * @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
 * @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
 * @param attributes Attributes that need to be bound to the program.
 * @return An OpenGL handle to the program.
 */
public static int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) 
{
	int programHandle = GLES20.glCreateProgram();
	
	if (programHandle != 0) 
	{
		// Bind the vertex shader to the program.
		GLES20.glAttachShader(programHandle, vertexShaderHandle);			

		// Bind the fragment shader to the program.
		GLES20.glAttachShader(programHandle, fragmentShaderHandle);
		
		// Bind attributes
		if (attributes != null)
		{
			final int size = attributes.length;
			for (int i = 0; i < size; i++)
			{
				GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
			}						
		}
		
		// Link the two shaders together into a program.
		GLES20.glLinkProgram(programHandle);

		// Get the link status.
		final int[] linkStatus = new int[1];
		GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);

		// If the link failed, delete the program.
		if (linkStatus[0] == 0) 
		{				
			Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
			GLES20.glDeleteProgram(programHandle);
			programHandle = 0;
		}
	}
	
	if (programHandle == 0)
	{
		throw new RuntimeException("Error creating program.");
	}
	
	return programHandle;
}
 
開發者ID:biezhihua,項目名稱:Android_OpenGL_Demo,代碼行數:54,代碼來源:ShaderHelper.java

示例11: loadShader

import android.opengl.GLES20; //導入方法依賴的package包/類
private static int loadShader(String vss, String fss) {
    Log.d("CameraGLRendererBase", "loadShader");
    int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
    GLES20.glShaderSource(vshader, vss);
    GLES20.glCompileShader(vshader);
    int[] status = new int[1];
    GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
        GLES20.glDeleteShader(vshader);
        vshader = 0;
        return 0;
    }

    int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
    GLES20.glShaderSource(fshader, fss);
    GLES20.glCompileShader(fshader);
    GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
        GLES20.glDeleteShader(vshader);
        GLES20.glDeleteShader(fshader);
        fshader = 0;
        return 0;
    }

    int program = GLES20.glCreateProgram();
    GLES20.glAttachShader(program, vshader);
    GLES20.glAttachShader(program, fshader);
    GLES20.glLinkProgram(program);
    GLES20.glDeleteShader(vshader);
    GLES20.glDeleteShader(fshader);
    GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
    if (status[0] == 0) {
        Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
        program = 0;
        return 0;
    }
    GLES20.glValidateProgram(program);
    GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
    if (status[0] == 0)
    {
        Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
        GLES20.glDeleteProgram(program);
        program = 0;
        return 0;
    }

    Log.d("CameraGLRendererBase", "Shader program is built OK");

    return program;
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:53,代碼來源:CameraGLRendererBase.java

示例12: SquareTex

import android.opengl.GLES20; //導入方法依賴的package包/類
public SquareTex() {
    // initialize vertex byte buffer for shape coordinates
    ByteBuffer bb = ByteBuffer.allocateDirect(
    // (# of coordinate values * 4 bytes per float)
            squareCoords.length * 4);
    bb.order(ByteOrder.nativeOrder());
    vertexBuffer = bb.asFloatBuffer();
    vertexBuffer.put(squareCoords);
    vertexBuffer.position(0);

    bb = ByteBuffer.allocateDirect(
    // (# of coordinate values * 4 bytes per float)
            squareUVs.length * 4);
    bb.order(ByteOrder.nativeOrder());
    uvBuffer = bb.asFloatBuffer();
    uvBuffer.put(squareUVs);
    uvBuffer.position(0);

    // initialize byte buffer for the draw list
    ByteBuffer dlb = ByteBuffer.allocateDirect(
    // (# of coordinate values * 2 bytes per short)
            drawOrder.length * 2);
    dlb.order(ByteOrder.nativeOrder());
    drawListBuffer = dlb.asShortBuffer();
    drawListBuffer.put(drawOrder);
    drawListBuffer.position(0);

    // prepare shaders and OpenGL program
    String vertexShaderCode = "uniform mat4 uMVPMatrix;" +
            "attribute vec4 vPosition;" +
            "attribute vec2 uv;" +
            "varying vec2 vUV;\n" +
            "void main() {" +
            // the matrix must be included as a modifier of gl_Position
            "  gl_Position = vPosition * uMVPMatrix;" +
            "  vUV = uv;" +
            "}";
    int vertexShader = GLRenderer.loadShader(GLES20.GL_VERTEX_SHADER,
            vertexShaderCode);
    String fragmentShaderCode = "precision mediump float;" +
            "uniform vec4 vColor;" +
            "uniform sampler2D tex;" +
            "varying mediump vec2 vUV;" +
            "void main() {" +
            "  gl_FragColor = vColor * (texture2D(tex,vUV));" +
            "}";
    int fragmentShader = GLRenderer.loadShader(GLES20.GL_FRAGMENT_SHADER,
            fragmentShaderCode);

    mProgram = GLES20.glCreateProgram();             // create empty OpenGL Program
    GLES20.glAttachShader(mProgram, vertexShader);   // add the vertex shader to program
    GLES20.glAttachShader(mProgram, fragmentShader); // add the fragment shader to program
    GLES20.glLinkProgram(mProgram);                  // create OpenGL program executables
}
 
開發者ID:efroemling,項目名稱:bombsquad-remote-android,代碼行數:55,代碼來源:GLRenderer.java

示例13: Shader

import android.opengl.GLES20; //導入方法依賴的package包/類
public Shader(String vertexShader, String fragmentShader, String attributes[], String uniforms[]) {
    this.program = GLES20.glCreateProgram();

    CompilationResult vResult = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
    if (vResult.status == GLES20.GL_FALSE) {
        FileLog.e("tmessages", "Vertex shader compilation failed");
        destroyShader(vResult.shader, 0, program);
        return;
    }

    CompilationResult fResult = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
    if (fResult.status == GLES20.GL_FALSE) {
        FileLog.e("tmessages", "Fragment shader compilation failed");
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    GLES20.glAttachShader(program, vResult.shader);
    GLES20.glAttachShader(program, fResult.shader);

    for (int i = 0; i < attributes.length; i++) {
        GLES20.glBindAttribLocation(program, i, attributes[i]);
    }

    if (linkProgram(program) == GLES20.GL_FALSE) {
        destroyShader(vResult.shader, fResult.shader, program);
        return;
    }

    for (String uniform : uniforms) {
        uniformsMap.put(uniform, GLES20.glGetUniformLocation(program, uniform));
    }

    if (vResult.shader != 0) {
        GLES20.glDeleteShader(vResult.shader);
    }

    if (fResult.shader != 0) {
        GLES20.glDeleteShader(fResult.shader);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:42,代碼來源:Shader.java

示例14: Program

import android.opengl.GLES20; //導入方法依賴的package包/類
public Program() {
	handle = GLES20.glCreateProgram();
}
 
開發者ID:G2159687,項目名稱:ESPD,代碼行數:4,代碼來源:Program.java

示例15: createOnGlThread

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * Allocates and initializes OpenGL resources needed by the background renderer.  Must be
 * called on the OpenGL thread, typically in
 * {@link GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)}.
 *
 * @param context Needed to access shader source.
 */
public void createOnGlThread(Context context) {
    // Generate the background texture.
    int textures[] = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    mTextureId = textures[0];
    GLES20.glBindTexture(mTextureTarget, mTextureId);
    GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(mTextureTarget, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

    int numVertices = 4;
    if (numVertices != QUAD_COORDS.length / COORDS_PER_VERTEX) {
      throw new RuntimeException("Unexpected number of vertices in BackgroundRenderer.");
    }

    ByteBuffer bbVertices = ByteBuffer.allocateDirect(QUAD_COORDS.length * FLOAT_SIZE);
    bbVertices.order(ByteOrder.nativeOrder());
    mQuadVertices = bbVertices.asFloatBuffer();
    mQuadVertices.put(QUAD_COORDS);
    mQuadVertices.position(0);

    ByteBuffer bbTexCoords = ByteBuffer.allocateDirect(
            numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE);
    bbTexCoords.order(ByteOrder.nativeOrder());
    mQuadTexCoord = bbTexCoords.asFloatBuffer();
    mQuadTexCoord.put(QUAD_TEXCOORDS);
    mQuadTexCoord.position(0);

    ByteBuffer bbTexCoordsTransformed = ByteBuffer.allocateDirect(
        numVertices * TEXCOORDS_PER_VERTEX * FLOAT_SIZE);
    bbTexCoordsTransformed.order(ByteOrder.nativeOrder());
    mQuadTexCoordTransformed = bbTexCoordsTransformed.asFloatBuffer();

    int vertexShader = ShaderUtil.loadGLShader(TAG, context,
            GLES20.GL_VERTEX_SHADER, R.raw.screenquad_vertex);
    int fragmentShader = ShaderUtil.loadGLShader(TAG, context,
            GLES20.GL_FRAGMENT_SHADER, R.raw.screenquad_fragment_oes);

    mQuadProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(mQuadProgram, vertexShader);
    GLES20.glAttachShader(mQuadProgram, fragmentShader);
    GLES20.glLinkProgram(mQuadProgram);
    GLES20.glUseProgram(mQuadProgram);

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

    mQuadPositionParam = GLES20.glGetAttribLocation(mQuadProgram, "a_Position");
    mQuadTexCoordParam = GLES20.glGetAttribLocation(mQuadProgram, "a_TexCoord");

    ShaderUtil.checkGLError(TAG, "Program parameters");
}
 
開發者ID:googlevr,項目名稱:poly-sample-android,代碼行數:60,代碼來源:BackgroundRenderer.java


注:本文中的android.opengl.GLES20.glCreateProgram方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。