Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Copyright (c) 2009-2011 Ardor Labs, Inc. (http://ardorlabs.com/)
 *   
 * This file is part of Ardor3D-Android (http://ardor3d.com/).
 *   
 * Ardor3D-Android is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *   
 * Ardor3D-Android is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *   
 * You should have received a copy of the GNU Lesser General Public License
 * along with Ardor3D-Android.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.microedition.khronos.opengles.GL10;

public class Main {
    public static int bytesPerPixel(final int format, final int type) {
        int n, m;

        switch (format) {
        case GL10.GL_ALPHA:
        case GL10.GL_LUMINANCE:
            n = 1;
            break;
        case GL10.GL_LUMINANCE_ALPHA:
            n = 2;
            break;
        case GL10.GL_RGB:
            n = 3;
            break;
        case GL10.GL_RGBA:
            n = 4;
            break;
        // case GL10.GL_COLOR_INDEX:
        // case GL10.GL_STENCIL_INDEX:
        // case GL10.GL_DEPTH_COMPONENT:
        // case GL10.GL_RED:
        // case GL10.GL_GREEN:
        // case GL10.GL_BLUE:
        // case GL10.GL_BGR:
        // case GL12.GL_BGRA:
        default:
            n = 0;
        }

        switch (type) {
        case GL10.GL_UNSIGNED_BYTE:
        case GL10.GL_BYTE:
            m = 1;
            break;
        case GL10.GL_UNSIGNED_SHORT:
        case GL10.GL_SHORT:
            m = 2;
            break;
        case GL10.GL_FLOAT:
            m = 4;
            break;
        // case GL11.GL_BITMAP:
        // case GL11.GL_HALF_FLOAT:
        // case GL11.GL_UNSIGNED_INT:
        // case GL11.GL_INT:
        default:
            m = 0;
        }

        return n * m;
    }
}