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


Java GLES20.glBindTexture方法代碼示例

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


在下文中一共展示了GLES20.glBindTexture方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTexture

import android.opengl.GLES20; //導入方法依賴的package包/類
private int createTexture(Bitmap bitmap, boolean recycled, int target) {
    int[] textures = new int[1];
    GLES20.glGenTextures(1, textures, 0);
    checkGLESError("gen texture");
    GLES20.glBindTexture(target, textures[0]);
    checkGLESError("bind texture");
    GLES20.glTexParameteri(target, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(target, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(target, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(target, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLUtils.texImage2D(target, 0, bitmap, 0);
    if (recycled && !bitmap.isRecycled()) {
        bitmap.recycle();
    }
    checkGLESError("tex image 2d");
    return textures[0];
}
 
開發者ID:TedaLIEz,項目名稱:ParsingPlayer,代碼行數:18,代碼來源:VideoRenderThread.java

示例2: onDrawFrame

import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public int onDrawFrame(int textureId) {
       GLES20.glUseProgram(mGLProgId);
       if(!isInitialized()) {
           return OpenGLUtils.NOT_INIT;
       }
       mGLCubeBuffer.position(0);
       GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, mGLCubeBuffer);
       GLES20.glEnableVertexAttribArray(mGLAttribPosition);
       mGLTextureBuffer.position(0);
       GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, mGLTextureBuffer);
       GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);
       GLES20.glUniformMatrix4fv(mTextureTransformMatrixLocation, 1, false, mTextureTransformMatrix, 0);
       
       if(textureId != OpenGLUtils.NO_TEXTURE){
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId);
        GLES20.glUniform1i(mGLUniformTexture, 0);
       }
       
       GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
       GLES20.glDisableVertexAttribArray(mGLAttribPosition);
       GLES20.glDisableVertexAttribArray(mGLAttribTextureCoordinate);
       GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
       return OpenGLUtils.ON_DRAWN;
   }
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:27,代碼來源:MagicVideoInputFilter.java

示例3: onDrawArraysPre

import android.opengl.GLES20; //導入方法依賴的package包/類
protected void onDrawArraysPre(){
	if (mToneCurveTexture[0] != -1){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]);
		GLES20.glUniform1i(mToneCurveTextureUniformLocation, 3);
    }
	if (mMaskGrey1TextureId != -1){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE4);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey1TextureId);
		GLES20.glUniform1i(mMaskGrey1UniformLocation, 4);
    }
    if (mMaskGrey2TextureId != -1){
    	GLES20.glActiveTexture(GLES20.GL_TEXTURE5);
    	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mMaskGrey2TextureId);
     	GLES20.glUniform1i(mMaskGrey2UniformLocation, 5);
    }
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:18,代碼來源:MagicSunsetFilter.java

示例4: onDraw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void onDraw(final int textureId, final FloatBuffer cubeBuffer, final FloatBuffer textureBuffer) {
    if (!mIsInitialized) {
        return;
    }

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    GLES20.glUseProgram(mGLProgId);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureId);
    GLES20.glUniform1i(mGLUniformTexture, 0);

    GLES20.glVertexAttribPointer(mGLAttribPosition, 2, GLES20.GL_FLOAT, false, 0, cubeBuffer);
    GLES20.glVertexAttribPointer(mGLAttribTextureCoordinate, 2, GLES20.GL_FLOAT, false, 0, textureBuffer);
    GLES20.glEnableVertexAttribArray(mGLAttribPosition);
    GLES20.glEnableVertexAttribArray(mGLAttribTextureCoordinate);

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();
}
 
開發者ID:vipycm,項目名稱:mao-android,代碼行數:21,代碼來源:CameraFilter.java

示例5: initFBO

import android.opengl.GLES20; //導入方法依賴的package包/類
private void initFBO(int width, int height)
{
    Log.d(LOGTAG, "initFBO("+width+"x"+height+")");

    deleteFBO();

    GLES20.glGenTextures(1, texDraw, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

    GLES20.glGenTextures(1, texFBO, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]);
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

    //int hFBO;
    GLES20.glGenFramebuffers(1, FBO, 0);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]);
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0);
    Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError());

    int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
    if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE)
        Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus);

    mFBOWidth  = width;
    mFBOHeight = height;
}
 
開發者ID:csarron,項目名稱:renderscript_examples,代碼行數:36,代碼來源:CameraGLRendererBase.java

示例6: draw

import android.opengl.GLES20; //導入方法依賴的package包/類
public void draw(int texture) {
    GLES20.glUseProgram(mProgram);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    if (mOesTexture)
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, texture);
    else
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);

    int positionHandle = GLES20.glGetAttribLocation(mProgram, "position");
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glVertexAttribPointer(positionHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, vertexBuffer);

    int textureCoordHandle = GLES20.glGetAttribLocation(mProgram, "inputTextureCoordinate");
    GLES20.glEnableVertexAttribArray(textureCoordHandle);
    GLES20.glVertexAttribPointer(textureCoordHandle, COORDS_PER_VERTEX, GLES20.GL_FLOAT, false, vertexStride, textureVerticesBuffer);

    GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);

    GLES20.glDrawElements(GLES20.GL_TRIANGLES, drawOrder.length, GLES20.GL_UNSIGNED_SHORT, drawListBuffer);

    // Disable vertex array
    GLES20.glDisableVertexAttribArray(positionHandle);
    GLES20.glDisableVertexAttribArray(textureCoordHandle);

    GLES20.glUseProgram(0);
}
 
開發者ID:AgoraIO,項目名稱:Agora-Video-Source-Android,代碼行數:29,代碼來源:TextureRenderer.java

示例7: onDrawArraysAfter

import android.opengl.GLES20; //導入方法依賴的package包/類
protected void onDrawArraysAfter(){
	for(int i = 0; i < inputTextureHandles.length
			&& inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3));
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:9,代碼來源:MagicRiseFilter.java

示例8: closeTexture

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * Release a texture.
 * @param texture existing texture
 */
public static void closeTexture(int texture, int level) {
    GLES20.glActiveTexture(level);
    checkError();

    try {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
        checkError();
    } finally {
        GLES20.glDeleteTextures(1, new int[] {texture}, 0);
        checkError();
    }

    logDebug("Texture " + texture + " destroyed");
}
 
開發者ID:Nik-Gleb,項目名稱:mpeg-encoder,代碼行數:19,代碼來源:GLTools.java

示例9: drawTex

import android.opengl.GLES20; //導入方法依賴的package包/類
private void drawTex(int tex, boolean isOES, int fbo)
{
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo);

    if(fbo == 0)
        GLES20.glViewport(0, 0, mView.getWidth(), mView.getHeight());
    else
        GLES20.glViewport(0, 0, mFBOWidth, mFBOHeight);

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    if(isOES) {
        GLES20.glUseProgram(progOES);
        GLES20.glVertexAttribPointer(vPosOES, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTCOES,  2, GLES20.GL_FLOAT, false, 4*2, texOES);
    } else {
        GLES20.glUseProgram(prog2D);
        GLES20.glVertexAttribPointer(vPos2D, 2, GLES20.GL_FLOAT, false, 4*2, vert);
        GLES20.glVertexAttribPointer(vTC2D,  2, GLES20.GL_FLOAT, false, 4*2, tex2D);
    }

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

    if(isOES) {
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(progOES, "sTexture"), 0);
    } else {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
        GLES20.glUniform1i(GLES20.glGetUniformLocation(prog2D, "sTexture"), 0);
    }

    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    GLES20.glFlush();
}
 
開發者ID:johnhany,項目名稱:MOAAP,代碼行數:35,代碼來源:CameraGLRendererBase.java

示例10: initTexOES

import android.opengl.GLES20; //導入方法依賴的package包/類
private void initTexOES(int[] tex) {
    if(tex.length == 1) {
        GLES20.glGenTextures(1, tex, 0);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex[0]);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
        GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    }
}
 
開發者ID:SCHS-Robotics,項目名稱:Team9261-2017-2018,代碼行數:11,代碼來源:CameraGLRendererBase.java

示例11: onDrawArraysPre

import android.opengl.GLES20; //導入方法依賴的package包/類
protected void onDrawArraysPre(){
	for(int i = 0; i < inputTextureHandles.length 
			&& inputTextureHandles[i] != OpenGLUtils.NO_TEXTURE; i++){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + (i+3) );
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, inputTextureHandles[i]);
		GLES20.glUniform1i(inputTextureUniformLocations[i], (i+3));
	}
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:9,代碼來源:MagicToasterFilter.java

示例12: setSize

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * (Re)allocate texture. Will do nothing if the requested size equals the current size. An
 * EGLContext must be bound on the current thread when calling this function. Must be called at
 * least once before using the framebuffer. May be called multiple times to change size.
 */
public void setSize(int width, int height) {
  if (width == 0 || height == 0) {
    throw new IllegalArgumentException("Invalid size: " + width + "x" + height);
  }
  if (width == this.width && height == this.height) {
    return;
  }
  this.width = width;
  this.height = height;

  // Allocate texture.
  GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
  GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, pixelFormat, width, height, 0, pixelFormat,
      GLES20.GL_UNSIGNED_BYTE, null);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
  GlUtil.checkNoGLES2Error("GlTextureFrameBuffer setSize");

  // Attach the texture to the framebuffer as color attachment.
  GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBufferId);
  GLES20.glFramebufferTexture2D(
      GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textureId, 0);

  // Check that the framebuffer is in a good state.
  final int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
  if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
    throw new IllegalStateException("Framebuffer not complete, status: " + status);
  }

  GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
}
 
開發者ID:Piasy,項目名稱:VideoCRE,代碼行數:37,代碼來源:GlTextureFrameBuffer.java

示例13: createImageTexture

import android.opengl.GLES20; //導入方法依賴的package包/類
/**
 * Creates a texture from raw data.
 *
 * @param data Image data, in a "direct" ByteBuffer.
 * @param width Texture width, in pixels (not bytes).
 * @param height Texture height, in pixels.
 * @param format Image data format (use constant appropriate for glTexImage2D(), e.g. GL_RGBA).
 * @return Handle to texture.
 */
public static int createImageTexture(ByteBuffer data, int width, int height, int format) {
    int[] textureHandles = new int[1];
    int textureHandle;

    GLES20.glGenTextures(1, textureHandles, 0);
    textureHandle = textureHandles[0];
    GlUtil.checkGlError("glGenTextures");

    // Bind the texture handle to the 2D texture target.
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle);

    // Configure min/mag filtering, i.e. what scaling method do we use if what we're rendering
    // is smaller or larger than the source image.
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
            GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
            GLES20.GL_LINEAR);
    GlUtil.checkGlError("loadImageTexture");

    // Load the data from the buffer into the texture handle.
    GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, /*level*/ 0, format,
            width, height, /*border*/ 0, format, GLES20.GL_UNSIGNED_BYTE, data);
    GlUtil.checkGlError("loadImageTexture");

    return textureHandle;
}
 
開發者ID:regar007,項目名稱:ShapesInOpenGLES2.0,代碼行數:36,代碼來源:GlUtil.java

示例14: onDrawArraysPre

import android.opengl.GLES20; //導入方法依賴的package包/類
protected void onDrawArraysPre(){
	if (this.mToneCurveTexture[0] != -1){
		GLES20.glActiveTexture(GLES20.GL_TEXTURE3);
		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mToneCurveTexture[0]);
		GLES20.glUniform1i(this.mToneCurveTextureUniformLocation, 3);
    }
}
 
開發者ID:smartbeng,項目名稱:PaoMovie,代碼行數:8,代碼來源:MagicAntiqueFilter.java

示例15: onDrawFrame

import android.opengl.GLES20; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 glUnused) {
	GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
	final String vertexShader = getVertexShader();
	final String fragmentShader = getFragmentShader();

	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_TexCoordinate" });

	// Set our per-vertex lighting program.
	GLES20.glUseProgram(mProgramHandle);

	// Set program handles for cube drawing.
	mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle,
			"u_MVPMatrix");
	mTextureUniformHandle0 = GLES20.glGetUniformLocation(mProgramHandle,
			"u_Texture0");
	mTextureUniformHandle1 = GLES20.glGetUniformLocation(mProgramHandle,
			"u_Texture1");
	mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle,
			"a_Position");
	mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle,
			"a_TexCoordinate");

	/**
	 * First texture map
	 */
	// Set the active texture0 unit to texture unit 0.
	GLES20.glActiveTexture(GLES20.GL_TEXTURE0);

	// Bind the texture to this unit.
	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle0);

	// Tell the texture uniform sampler to use this texture in the shader by
	// binding to texture unit 0.
	GLES20.glUniform1i(mTextureUniformHandle0, 0);
	
	/**
	 * Second texture map
	 */
	// Set the active texture1 unit to texture unit 1.
	GLES20.glActiveTexture(GLES20.GL_TEXTURE1);

	// Bind the texture to this unit.
	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle1);

	// Tell the texture uniform sampler to use this texture in the shader by
	// binding to texture unit 1.
	GLES20.glUniform1i(mTextureUniformHandle1, 1);

	// Draw some cubes.
	Matrix.setIdentityM(mModelMatrix, 0);
	Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -3.2f);
	Matrix.rotateM(mModelMatrix, 0, 0.0f, 1.0f, 1.0f, 0.0f);
	drawCube();
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:63,代碼來源:GLLayer.java


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