正如我在opengl中看到的那样,坐标在-1和1之间,我想使用opengl渲染对象,我在像素坐标中渲染对象的第一个位置,但是我不知道如何将像素坐标转换为opengl坐标。我正在使用Java开发Android应用程序。
公共类FirstOpenGLProjectRenderer实现GLSurfaceView.Renderer {
private static final String A_POSITION = "a_Position";
private static final String A_COLOR = "a_Color";
private static final int POSITION_COMPONENT_COUNT = 4;
private static final int COLOR_COMPONENT_COUNT = 3;
private static final int BYTES_PER_FLOAT = 4;
private static final int STRIDE =
(POSITION_COMPONENT_COUNT + COLOR_COMPONENT_COUNT) * BYTES_PER_FLOAT;
private final FloatBuffer vertexData;
private final Context context;
private int program;
private int aPositionLocation;
private int aColorLocation;
private static final String U_MATRIX = "u_Matrix";
private final float[] projectionMatrix = new float[16]; …Run Code Online (Sandbox Code Playgroud)