Convert x to openGL - Android android.opengl

Android examples for android.opengl:OpenGL

Description

Convert x to openGL

Demo Code


//package com.book2s;

public class Main {
    /**/*from w w  w. j  a va2s. c  o m*/
     * Convert x to openGL
     * 
     * @param x
     *            Screen x offset top left
     * @return Screen x offset top left in OpenGL
     */
    public static float toGLX(float x, float ratio, float screenWidth) {
        return -1.0f * ratio + toGLWidth(x, ratio, screenWidth);
    }

    /**
     * Convert width to openGL width
     * 
     * @param width
     * @return Width in openGL
     */
    public static float toGLWidth(float width, float ratio,
            float screenWidth) {
        return 2.0f * (width / screenWidth) * ratio;
    }
}

Related Tutorials