Java Code Examples for javax.microedition.khronos.opengles.GL10

The following examples show how to use javax.microedition.khronos.opengles.GL10. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: PanoramaGL   Source File: GLWrapper.java    License: Apache License 2.0 6 votes vote down vote up
/**init methods*/

public GLWrapper(GL gl, GLSurfaceView glSurfaceView)
{
	mGL = (GL10)gl;
	if(gl instanceof GL10Ext)
	{
           mGL10Ext = (GL10Ext)gl;
       }
       if(gl instanceof GL11)
       {
           mGL11 = (GL11)gl;
       }
       if(gl instanceof GL11Ext)
       {
           mGL11Ext = (GL11Ext)gl;
       }
       if(gl instanceof GL11ExtensionPack)
       {
       	mGL11ExtPack = (GL11ExtensionPack)gl;
       }
       mGLSurfaceView = glSurfaceView;
}
 
Example 2
private static void drawWaveForm(
        GL10 gl, int width, int height,
        FloatBuffer vertices, int n, int vposition, float yrange, FloatColor color) {

    gl.glPushMatrix();

    // viewport
    gl.glViewport(0, (height / 2) * (1 - vposition), width, (height / 2));

    // X: [0:1], Y: [-1:+1] (scaled)
    gl.glOrthof(0.0f, 1.0f, -yrange, yrange, -1.0f, 1.0f);

    gl.glColor4f(color.red, color.green, color.blue, color.alpha);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(2, GL10.GL_FLOAT, (2 * Float.SIZE / 8), vertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, n);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

    gl.glPopMatrix();
}
 
Example 3
@Override
public final void onDrawFrame(final GL10 gl) {
    synchronized (runOnDraw) {
        while (!runOnDraw.isEmpty()) {
            runOnDraw.poll().run();
        }
    }
    framebufferObject.enable();

    onDrawFrame(framebufferObject);

    GLES20.glBindFramebuffer(GL_FRAMEBUFFER, 0);

    GLES20.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    normalShader.draw(framebufferObject.getTexName(), null);

}
 
Example 4
Source Project: opengl   Source File: TexCubeSmallGLUT.java    License: Apache License 2.0 6 votes vote down vote up
void setTex (GL10 gl, Context c, int textureID, int drawableID) {
mCoordBuffer = getFloatBufferFromFloatArray(texCoords);

mTextureID = textureID;

gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);

Bitmap bitmap = BitmapFactory.decodeResource(c.getResources(), drawableID);
Bitmap bitmap256 = Bitmap.createScaledBitmap(bitmap, 256, 256, false);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap256, 0);
bitmap.recycle();
bitmap256.recycle();

       gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
               GL10.GL_NEAREST);
       gl.glTexParameterf(GL10.GL_TEXTURE_2D,
               GL10.GL_TEXTURE_MAG_FILTER,
               GL10.GL_LINEAR);
       texEnabled = true;
       
   }
 
Example 5
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    super.onSurfaceCreated(glUnused, config);

    Bitmap bitmap = BitmapFactory.decodeResource(mSurfaceView.getResources(), R.drawable.video_brightness_6_white_36dp);
    //创建bitmap
    GLES20.glGenTextures(1, mTexturesBitmap, 0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexturesBitmap[0]);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    bitmap.recycle();
}
 
Example 6
Source Project: MD360Player4Android   Source File: GLTextureView.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void checkGLDriver(GL10 gl) {
    if (! mGLESDriverCheckComplete) {
        checkGLESVersion();
        String renderer = gl.glGetString(GL10.GL_RENDERER);
        if (mGLESVersion < kGLES_20) {
            mMultipleGLESContextsAllowed =
                    ! renderer.startsWith(kMSM7K_RENDERER_PREFIX);
            notifyAll();
        }
        mLimitedGLESContexts = !mMultipleGLESContextsAllowed;
        if (LOG_SURFACE) {
            Log.w(TAG, "checkGLDriver renderer = \"" + renderer + "\" multipleContextsAllowed = "
                    + mMultipleGLESContextsAllowed
                    + " mLimitedGLESContexts = " + mLimitedGLESContexts);
        }
        mGLESDriverCheckComplete = true;
    }
}
 
Example 7
Source Project: In77Camera   Source File: GLRender.java    License: MIT License 6 votes vote down vote up
@Override
    public void onDrawFrame(GL10 glUnused) {
        long timeStamp=cameraEngine.doTextureUpdate(oesFilter.getSTMatrix());
        //filterGroup.setFboToRebind(fbo);
        filterGroup.onDrawFrame(oesFilter.getGlOESTexture().getTextureId());
        if(mVideoEncoder!=null){
            Log.d(TAG, "onDrawFrame: "+mVideoEncoder.toString());
            mVideoEncoder.frameAvailableSoon();
        }
        //TODO:正确的录像过程,生成的视频可以用MediaPlayer播放
//        fbo.unbind();
//        lastProcessFilter.setSavedTextureId(fbo.getFrameBufferTextureId());
//        screenDrawer.onFilterChanged(surfaceWidth,surfaceHeight);
        //screenDrawer.onDrawFrame(fbo.getFrameBufferTextureId());
        runPostDrawTasks();
    }
 
Example 8
Source Project: augmentedreality   Source File: LightingRenderer.java    License: Apache License 2.0 6 votes vote down vote up
public final void setupEnv(GL10 gl) {
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambientLightBuffer0);
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuseLightBuffer0);
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_SPECULAR, specularLightBuffer0);
	gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPositionBuffer0);
	gl.glEnable(GL10.GL_LIGHT0);
	gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_AMBIENT, ambientLightBuffer1);
	gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_DIFFUSE, diffuseLightBuffer1);
	gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_SPECULAR, specularLightBuffer1);
	gl.glLightfv(GL10.GL_LIGHT1, GL10.GL_POSITION, lightPositionBuffer1);
	gl.glEnable(GL10.GL_LIGHT1);
	gl.glLightfv(GL10.GL_LIGHT2, GL10.GL_AMBIENT, ambientLightBuffer2);
	gl.glLightfv(GL10.GL_LIGHT2, GL10.GL_DIFFUSE, diffuseLightBuffer2);
	gl.glLightfv(GL10.GL_LIGHT2, GL10.GL_SPECULAR, specularLightBuffer2);
	gl.glLightfv(GL10.GL_LIGHT2, GL10.GL_POSITION, lightPositionBuffer2);
	gl.glEnable(GL10.GL_LIGHT2);
	gl.glLightfv(GL10.GL_LIGHT3, GL10.GL_AMBIENT, ambientLightBuffer3);
	gl.glLightfv(GL10.GL_LIGHT3, GL10.GL_DIFFUSE, diffuseLightBuffer3);
	gl.glLightfv(GL10.GL_LIGHT3, GL10.GL_SPECULAR, specularLightBuffer3);
	gl.glLightfv(GL10.GL_LIGHT3, GL10.GL_POSITION, lightPositionBuffer3);
	gl.glEnable(GL10.GL_LIGHT3);
	initGL(gl);
}
 
Example 9
Source Project: opengl   Source File: SolarSystemRenderer.java    License: Apache License 2.0 6 votes vote down vote up
public void onDrawFrame(GL10 gl) 
{
     gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
     gl.glClearColor(0.0f,0.0f,0.0f,1.0f);
     gl.glMatrixMode(GL10.GL_MODELVIEW);
     gl.glLoadIdentity();
	
     gl.glTranslatef(0.0f,(float)Math.sin(mTransY), -4.0f);
	
     gl.glRotatef(mAngle, 1, 0, 0);
     gl.glRotatef(mAngle, 0, 1, 0);
		
     mPlanet.draw(gl);
	     
     mTransY+=.075f; 
     mAngle+=.4;
}
 
Example 10
Source Project: opengl   Source File: CubeSmallGLUT.java    License: Apache License 2.0 6 votes vote down vote up
void drawSimpleCube (GL10 gl) {
    float vertices[] = {
            -1,1,1, 1,1,1, 1,-1,1, -1,-1,1,
            1,1,-1, -1,1,-1, -1,-1,-1, 1,-1,-1
    };
    byte indices[] = {
            0,1,2, 2,3,0,  1,4,7, 7,2,1,  0,3,6, 6,5,0,
            3,2,7, 7,6,3,  0,1,4, 4,5,0,  5,6,7, 7,4,5
    };
    FloatBuffer vertexBuffer = getFloatBufferFromFloatArray(vertices);
    ByteBuffer indexBuffer = getByteBufferFromByteArray(indices);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer);
    //gl.glDrawElements(GL10.GL_LINE_LOOP, indices.length, GL10.GL_UNSIGNED_BYTE, indexBuffer);
    
}
 
Example 11
Source Project: android-MediaEffects   Source File: MediaEffectsFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    if (!mInitialized) {
        //Only need to do this once
        mEffectContext = EffectContext.createWithCurrentGlContext();
        mTexRenderer.init();
        loadTextures();
        mInitialized = true;
    }
    if (mCurrentEffect != R.id.none) {
        //if an effect is chosen initialize it and apply it to the texture
        initEffect();
        applyEffect();
    }
    renderResult();
}
 
Example 12
Source Project: MegviiFacepp-Android-SDK   Source File: OpenGLUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static int createTextureID() {
	int[] texture = new int[1];

	GLES20.glGenTextures(1, texture, 0);
	GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, texture[0]);
	GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
			GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
	GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
			GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
	GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
			GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
	GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES,
			GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);

	return texture[0];
}
 
Example 13
Source Project: AndroidPlayground   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void onDrawFrame(GL10 unused) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    GLES20.glUseProgram(mProgram);

    GLES20.glEnableVertexAttribArray(mPositionHandle);
    GLES20.glVertexAttribPointer(mPositionHandle, 3, GLES20.GL_FLOAT, false, 0,
            mVertexBuffer);

    GLES20.glEnableVertexAttribArray(mTexCoordHandle);
    GLES20.glVertexAttribPointer(mTexCoordHandle, 2, GLES20.GL_FLOAT, false, 0,
            mUvTexVertexBuffer);

    GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix, 0);
    GLES20.glUniform1i(mTexSamplerHandle, 0);

    GLES20.glDrawElements(GLES20.GL_TRIANGLES, VERTEX_INDEX.length,
            GLES20.GL_UNSIGNED_SHORT, mVertexIndexBuffer);

    GLES20.glDisableVertexAttribArray(mPositionHandle);
    GLES20.glDisableVertexAttribArray(mTexCoordHandle);

    //Utils.sendImage(mWidth, mHeight);
}
 
Example 14
Source Project: remixed-dungeon   Source File: Game.java    License: GNU General Public License v3.0 6 votes vote down vote up
@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);

    GLES20.glEnable(GL10.GL_SCISSOR_TEST);


    SystemText.invalidate();
    TextureCache.reload();

    paused = false;

    if (scene != null) {
        scene.resume();
    }
}
 
Example 15
Source Project: MD360Player4Android   Source File: MD360VideoTexture.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected int createTextureId() {
    int[] textures = new int[1];

    // Generate the texture to where android view will be rendered
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glGenTextures(1, textures, 0);
    glCheck("Texture generate");

    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
    glCheck("Texture bind");

    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);

    return textures[0];
}
 
Example 16
Source Project: TimeLapseRecordingSample   Source File: CameraGLView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * drawing to GLSurface
 * we set renderMode to GLSurfaceView.RENDERMODE_WHEN_DIRTY,
 * this method is only called when #requestRender is called(= when texture is required to update)
 * if you don't set RENDERMODE_WHEN_DIRTY, this method is called at maximum 60fps
 */
@Override
public void onDrawFrame(GL10 unused) {
	GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

	if (requestUpdateTex) {
		requestUpdateTex = false;
		// update texture(came from camera)
		mSTexture.updateTexImage();
		// get texture matrix
		mSTexture.getTransformMatrix(mStMatrix);
	}
	// draw to preview screen
	mDrawer.draw(hTex, mStMatrix);
	flip = !flip;
	if (flip) {	// ~30fps
		synchronized (this) {
			if (mVideoEncoder != null) {
				// notify to capturing thread that the camera frame is available.
				mVideoEncoder.frameAvailableSoon(mStMatrix);
			}
		}
	}
}
 
Example 17
Source Project: NewsMe   Source File: GLSurfaceView.java    License: Apache License 2.0 6 votes vote down vote up
public synchronized void checkGLDriver(GL10 gl) {
	if (!mGLESDriverCheckComplete) {
		checkGLESVersion();
		String renderer = gl.glGetString(GL10.GL_RENDERER);
		if (mGLESVersion < kGLES_20) {
			mMultipleGLESContextsAllowed = !renderer
					.startsWith(kMSM7K_RENDERER_PREFIX);
			notifyAll();
		}
		mLimitedGLESContexts = !mMultipleGLESContextsAllowed
				|| renderer.startsWith(kADRENO);
		if (LOG_SURFACE) {
			Log.w(TAG, "checkGLDriver renderer = \"" + renderer
					+ "\" multipleContextsAllowed = "
					+ mMultipleGLESContextsAllowed
					+ " mLimitedGLESContexts = " + mLimitedGLESContexts);
		}
		mGLESDriverCheckComplete = true;
	}
}
 
Example 18
Source Project: opengl   Source File: BasicGL.java    License: Apache License 2.0 5 votes vote down vote up
public void initGL( ) {
    int width = sv.getWidth();
    int height = sv.getHeight();
    mGL.glViewport(0, 0, width, height);
    mGL.glMatrixMode(GL10.GL_PROJECTION);
    mGL.glLoadIdentity();
    float aspect = (float) width/height;
    GLU.gluPerspective(mGL, 45.0f, aspect, 1.0f, 30.0f);
     mGL.glClearColor(0.5f,0.5f,0.5f,1);
     
     // the only way to draw primitives with OpenGL ES
     mGL.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    Log.i("GL", "GL initialized");
}
 
Example 19
Source Project: TikTok   Source File: MagicBaseView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glDisable(GL10.GL_DITHER);
    GLES20.glClearColor(0,0, 0, 0);
    GLES20.glEnable(GL10.GL_CULL_FACE);
    GLES20.glEnable(GL10.GL_DEPTH_TEST);
}
 
Example 20
Source Project: opengl   Source File: MyGLRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {

    // Set the background frame color
    GLES31.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    mTriangle = new Triangle();
    mSquare   = new Square();
}
 
Example 21
Source Project: GPUVideo-android   Source File: GlFrameBufferObjectRenderer.java    License: MIT License 5 votes vote down vote up
@Override
public final void onSurfaceCreated(final GL10 gl, final EGLConfig config) {
    framebufferObject = new GlFramebufferObject();
    normalShader = new GlFilter();
    normalShader.setup();
    onSurfaceCreated(config);
}
 
Example 22
Source Project: MOAAP   Source File: CameraGLRendererBase.java    License: MIT License 5 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    //Log.i(LOGTAG, "onDrawFrame start");

    if (!mHaveFBO)
        return;

    synchronized(this) {
        if (mUpdateST) {
            mSTexture.updateTexImage();
            mUpdateST = false;
        }

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

        CameraTextureListener texListener = mView.getCameraTextureListener();
        if(texListener != null) {
            //Log.d(LOGTAG, "haveUserCallback");
            // texCamera(OES) -> texFBO
            drawTex(texCamera[0], true, FBO[0]);

            // call user code (texFBO -> texDraw)
            boolean modified = texListener.onCameraTexture(texFBO[0], texDraw[0], mCameraWidth, mCameraHeight);

            if(modified) {
                // texDraw -> screen
                drawTex(texDraw[0], false, 0);
            } else {
                // texFBO -> screen
                drawTex(texFBO[0], false, 0);
            }
        } else {
            Log.d(LOGTAG, "texCamera(OES) -> screen");
            // texCamera(OES) -> screen
            drawTex(texCamera[0], true, 0);
        }
        //Log.i(LOGTAG, "onDrawFrame end");
    }
}
 
Example 23
Source Project: GPUVideo-android   Source File: BaseCameraActivity.java    License: MIT License 5 votes vote down vote up
private Bitmap createBitmapFromGLSurface(int w, int h, GL10 gl) {

        int bitmapBuffer[] = new int[w * h];
        int bitmapSource[] = new int[w * h];
        IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer);
        intBuffer.position(0);

        try {
            gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer);
            int offset1, offset2, texturePixel, blue, red, pixel;
            for (int i = 0; i < h; i++) {
                offset1 = i * w;
                offset2 = (h - i - 1) * w;
                for (int j = 0; j < w; j++) {
                    texturePixel = bitmapBuffer[offset1 + j];
                    blue = (texturePixel >> 16) & 0xff;
                    red = (texturePixel << 16) & 0x00ff0000;
                    pixel = (texturePixel & 0xff00ff00) | red | blue;
                    bitmapSource[offset2 + j] = pixel;
                }
            }
        } catch (GLException e) {
            Log.e("CreateBitmap", "createBitmapFromGLSurface: " + e.getMessage(), e);
            return null;
        }

        return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
    }
 
Example 24
Source Project: CameraDemo   Source File: CameraGLSurfaceView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    Log.d(TAG, "onSurfaceChanged. thread: " + Thread.currentThread().getName());
    Log.d(TAG, "onSurfaceChanged. width: " + width + ", height: " + height);
    int previewWidth = mCameraProxy.getPreviewWidth();
    int previewHeight = mCameraProxy.getPreviewHeight();
    if (width > height) {
        setAspectRatio(previewWidth, previewHeight);
    } else {
        setAspectRatio(previewHeight, previewWidth);
    }
    GLES20.glViewport(0, 0, width, height);
    mCameraProxy.startPreview(mSurfaceTexture);
}
 
Example 25
Source Project: opengl   Source File: TriangleSmallGLUT.java    License: Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CW);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
    gl.glNormal3f(0f, 0f, 1f);
    
    gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
    
}
 
Example 26
Source Project: RobotCA   Source File: LaserScanRenderer.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called when the surface changed size.
 *
 * @param gl The GL interface.
 * @param width The width of the view
 * @param height The height of the view
 */
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    this.width = width;
    this.height = height;

    xStart = 0.0f;
    yStart = 0.0f;
    offX = 0.0f;
    offY = 0.0f;

    gl.glViewport(0, 0, width, height);
}
 
Example 27
Source Project: LicensePlateDiscern   Source File: CameraGLRendererBase.java    License: MIT License 5 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
    //Log.i(LOGTAG, "onDrawFrame start");

    if (!mHaveFBO)
        return;

    synchronized(this) {
        if (mUpdateST) {
            mSTexture.updateTexImage();
            mUpdateST = false;
        }

        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

        CameraTextureListener texListener = mView.getCameraTextureListener();
        if(texListener != null) {
            //Log.d(LOGTAG, "haveUserCallback");
            // texCamera(OES) -> texFBO
            drawTex(texCamera[0], true, FBO[0]);

            // call user code (texFBO -> texDraw)
            boolean modified = texListener.onCameraTexture(texFBO[0], texDraw[0], mCameraWidth, mCameraHeight);

            if(modified) {
                // texDraw -> screen
                drawTex(texDraw[0], false, 0);
            } else {
                // texFBO -> screen
                drawTex(texFBO[0], false, 0);
            }
        } else {
            Log.d(LOGTAG, "texCamera(OES) -> screen");
            // texCamera(OES) -> screen
            drawTex(texCamera[0], true, 0);
        }
        //Log.i(LOGTAG, "onDrawFrame end");
    }
}
 
Example 28
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) 
{
    logger.info("GL Surface changed, width: " + width + " height: " + height);
    settings.setResolution(width, height);
    listener.reshape(width, height);
}
 
Example 29
Source Project: CameraDemo   Source File: Camera2GLSurfaceView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
    Log.d(TAG, "onSurfaceChanged. thread: " + Thread.currentThread().getName());
    Log.d(TAG, "onSurfaceChanged. width: " + width + ", height: " + height);
    int previewWidth = mCameraProxy.getPreviewSize().getWidth();
    int previewHeight = mCameraProxy.getPreviewSize().getHeight();
    if (width > height) {
        setAspectRatio(previewWidth, previewHeight);
    } else {
        setAspectRatio(previewHeight, previewWidth);
    }
    GLES20.glViewport(0, 0, width, height);
}
 
Example 30
Source Project: Spectaculum   Source File: GLRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
    Log.d(TAG, "onSurfaceCreated");
    GLUtils.init();
    //GLUtils.printSysConfig();

    // set the background color
    GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);

    // set up the "camera"
    Matrix.setLookAtM(mViewMatrix, 0,
            0.0f, 0.0f, 1.0f,   // eye x,y,z
            0.0f, 0.0f, 0.0f,  // look x,y,z
            0.0f, 1.0f, 0.0f);  // up x,y,z

    if(mExternalSurfaceTexture != null) {
        // Delete input texture from previous context to free RAM
        mExternalSurfaceTexture.delete();
    }

    mExternalSurfaceTexture = new ExternalSurfaceTexture();
    mReadExternalTextureShaderProgram = new ReadExternalTextureShaderProgram();

    mDefaultShaderProgram = new TextureShaderProgram();

    mTextureToScreenShaderProgram = new TextureShaderProgram();

    if(mOnExternalSurfaceTextureCreatedListener != null) {
        mOnExternalSurfaceTextureCreatedListener.onExternalSurfaceTextureCreated(mExternalSurfaceTexture);
    }

    mFrameRateCalculator = new FrameRateCalculator(30);

    mInitializeStuff = true;
}