Convert y to openGL y - Android android.opengl

Android examples for android.opengl:OpenGL

Description

Convert y to openGL y

Demo Code


//package com.book2s;

public class Main {
    /**//w w w.  j a v a  2 s  .  c o m
     * Convert y to openGL y
     * 
     * @param y
     *            Screen y offset top left
     * @return Screen y offset top left in OpenGL
     */
    public static float toGLY(float y, float screenHeight) {
        return 1.0f - toGLHeight(y, screenHeight);
    }

    /**
     * Convert height to openGL height
     * 
     * @param height
     * @return Height in openGL
     */
    public static float toGLHeight(float height, float screenHeight) {
        return 2.0f * (height / screenHeight);
    }
}

Related Tutorials