Code example for GL10

Methods: glBlendFunc, glClear, glClearColor, glDrawArrays, glEnable, glLoadIdentity, glScalef, glTranslatef

0
            float sizeX = (float) w / (float) getWindowWidth() * 2;
            float sizeY = (float) h / (float) getWindowHeight() * 2;
            float sx = (float) x / (float) getWindowWidth() * 2;
            float sy = (float) y / (float) getWindowHeight() * 2;
 
            gl10.glLoadIdentity();
            gl10.glTranslatef(-1.0f + sizeX / 2.0f + sx, 1.0f - sizeY / 2.0f - sy, 0.0f);
            gl10.glScalef(sizeX, sizeY, 1.0f);
            gl10.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
        } 
 
        /** 
         * テクスチャの描画エリアを指定する。 
         * 
         * @param gl10 
         * @param x 
         * @param y 
         * @param w 
         * @param h 
         */ 
        @SuppressWarnings("all") 
        private void setTextureArea(GL10 gl10, int x, int y, int w, int h) {
            float tw = (float) w / (float) textureWidth, th = (float) h / (float) textureHeight, tx = (float) x / (float) textureWidth, ty = (float) y
                    / (float) textureHeight;
 
            gl10.glMatrixMode(GL10.GL_TEXTURE);
            gl10.glLoadIdentity();
 
            gl10.glTranslatef(tx, ty, 0.0f);
            gl10.glScalef(tw, th, 1.0f);
 
            gl10.glMatrixMode(GL10.GL_MODELVIEW);
        } 
 
        @Override 
        public void onDrawFrame(GL10 gl10) {
            if (bitmaps != null)
                bitmaps[0] = bitmaps[0];
            gl10.glClearColor(0, 1, 1, 1);
            gl10.glClear(GL10.GL_COLOR_BUFFER_BIT);
 
            // ! アルファブレンドを有効にする 
            { 
                gl10.glEnable(GL10.GL_BLEND);
                gl10.glEnable(GL10.GL_ALPHA);
 
                gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
            } 
            // setTextureArea( gl10, 0, 0, 128, 64 ); 
            drawQuad(gl10, 0, 0, 256, 256);
        } 
    };