GL10 glViewport - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GL10 glViewport method.

This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
 
        mAngle += 1.2f;
    } 
 
    public void onSurfaceChanged(GL10 gl, int width, int height) {
         gl.glViewport(0, 0, width, height);
 
         /* 
          * Set our projection matrix. This doesn't have to be done 
          * each time we draw, but usually a new projection needs to 
          * be set when the viewport is resized. 
          */ 
 
         float ratio = (float) width / height;
         gl.glMatrixMode(GL10.GL_PROJECTION);
         gl.glLoadIdentity();
         gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
    } 
 
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {

7
CodeRank
This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
 
        mAngle += 1.2f;
    } 
 
    public void onSurfaceChanged(GL10 gl, int width, int height) {
         gl.glViewport(0, 0, width, height);
 
         /* 
          * Set our projection matrix. This doesn't have to be done 
          * each time we draw, but usually a new projection needs to 
          * be set when the viewport is resized. 
          */ 
 
         float ratio = (float) width / height;
         gl.glMatrixMode(GL10.GL_PROJECTION);
         gl.glLoadIdentity();
         gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
    } 
 
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {

6
CodeRank
This code example shows how to use the following methods:gluOrtho2D, glLoadIdentity, glMatrixMode, glViewport
    public void onSurfaceChanged(GL10 gl1, int width, int height) {
        Log.v(TAG, "onSurfaceChanged: " + width + "x" + height
                + ", gl10: " + gl1.toString());
        GL11 gl = (GL11) gl1;
        mGL = gl;
        gl.glViewport(0, 0, width, height);
 
        gl.glMatrixMode(GL11.GL_PROJECTION);
        gl.glLoadIdentity();
 
        GLU.gluOrtho2D(gl, 0, width, 0, height);
        Matrix matrix = mTransformation.getMatrix();
        matrix.reset();
        matrix.preTranslate(0, getHeight());
        matrix.preScale(1, -1);
    } 
 
    private void setAlphaValue(float alpha) {
        if (mLastAlpha == alpha) return;
 
6
CodeRank
This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
    } 
 
    public void onSurfaceChanged(GL10 gl, int w, int h) {
        mWidth = w;
        mHeight = h;
        gl.glViewport(0, 0, w, h);
        mProjector.setCurrentView(0, 0, w, h);
 
        /* 
        * Set our projection matrix. This doesn't have to be done 
        * each time we draw, but usually a new projection needs to 
        * be set when the viewport is resized. 
        */ 
 
        float ratio = (float) w / h;
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
        mProjector.getCurrentProjection(gl);
    } 

8
CodeRank
This code example shows how to use the following methods:gluPerspective, glLoadIdentity, glMatrixMode, glViewport
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		if (height == 0) { // Prevent A Divide By Zero By
			height = 1; // Making Height Equal One
		} 
 
		gl.glViewport(0, 0, width, height); // Reset The Current Viewport
		gl.glMatrixMode(GL10.GL_PROJECTION); // Select The Projection Matrix
		gl.glLoadIdentity(); // Reset The Projection Matrix
 
		// Calculate The Aspect Ratio Of The Window 
		GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f,
				100.0f); 
 
		gl.glMatrixMode(GL10.GL_MODELVIEW); // Select The Modelview Matrix
		gl.glLoadIdentity(); // Reset The Modelview Matrix
	} 
 
	/** 
	 * Override the touch screen listener. 
	 *  
8
CodeRank
This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
    /** 
     * Handle change of size. 
     */ 
    @Override 
    public void sizeChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        float ratio = (float) w / h;
        gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);
    } 
 
    /** 
     * Create some big objects that we want 
     * around only when we're drawing. 
     */ 
    @Override 
    public void surfaceCreated(GL10 gl) {
        // set up the surface 
        gl.glDisable(GL10.GL_DITHER);
8
CodeRank
This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
            mAngle += 1.2f;
        } 
 
        public void onSurfaceChanged(GL10 gl, int width, int height) {
            checkGLError(gl);
            gl.glViewport(0, 0, width, height);
            float ratio = (float) width / height;
            gl.glMatrixMode(GL10.GL_PROJECTION);
            gl.glLoadIdentity();
            gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);
            checkGLError(gl);
        } 
 
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
            checkGLError(gl);
            // This test needs to be done each time a context is created, 
            // because different contexts may support different extensions. 
            mContextSupportsCubeMap = checkIfContextSupportsCubeMap(gl);
 
            mGrid = generateTorusGrid(gl, 60, 60, 3.0f, 0.75f);
6
CodeRank
This code example shows how to use the following methods:glLoadIdentity, glMatrixMode, glOrthof, glViewport
		gl.glDisable(GL10.GL_BLEND);                // Disable Alpha Blend
		gl.glDisable(GL10.GL_TEXTURE_2D);            // Disable Texture Mapping
	} 
 
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		gl.glViewport(0, 0, width, height);
 
		// Setup orthographic projection 
		gl.glMatrixMode(GL10.GL_PROJECTION);        // Activate Projection Matrix
		gl.glLoadIdentity();                            // Load Identity Matrix
		gl.glOrthof(                                    // Set Ortho Projection (Left,Right,Bottom,Top,Front,Back)
				0, width,
				0, height,
				1.0f, -1.0f 
		); 
 
		// Save width and height 
		this.width = width;                            // Save Current Width
		this.height = height;                        // Save Current Height
	} 
7
CodeRank
This code example shows how to use the following methods:glFrustumf, glLoadIdentity, glMatrixMode, glViewport
 
        mTriangle.draw(gl);
    } 
 
    public void onSurfaceChanged(GL10 gl, int w, int h) {
        gl.glViewport(0, 0, w, h);
 
        /* 
        * Set our projection matrix. This doesn't have to be done 
        * each time we draw, but usually a new projection needs to 
        * be set when the viewport is resized. 
        */ 
 
        float ratio = (float) w / h;
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);
 
    } 
 

8
CodeRank
This code example shows how to use the following methods:gluPerspective, glLoadIdentity, glMatrixMode, glViewport
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
		 
	} 
 
	public void onSurfaceChanged(GL10 gl, int width, int height) {		
		gl.glViewport(0, 0, width, height);
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();
		GLU.gluPerspective(gl, 45.0f, ((float) width / (float) height), 0.1f, 100.0f);
		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
	} 
 
	public void onSurfaceCreated(GL10 gl, EGLConfig config) {
		gl.glClearColor(0.0f,0.0f, 0.0f, 0.5f);
		gl.glShadeModel(GL10.GL_SMOOTH);
		gl.glClearDepthf(1.0f);
		gl.glEnable(GL10.GL_DEPTH_TEST);
		gl.glDepthFunc(GL10.GL_DEPTH_TEST);
		gl.glEnable(GL10.GL_LEQUAL);
6
CodeRank

Related GL10 glViewport Questions & Answers: