1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 package android.opengl.cts; 19 20 import java.nio.ByteBuffer; 21 import java.nio.ByteOrder; 22 import java.nio.FloatBuffer; 23 import java.nio.IntBuffer; 24 import java.nio.ShortBuffer; 25 import java.util.concurrent.CountDownLatch; 26 import javax.microedition.khronos.egl.EGLConfig; 27 import javax.microedition.khronos.opengles.GL10; 28 29 import android.content.Context; 30 import android.opengl.GLES20; 31 import android.opengl.GLSurfaceView; 32 import android.opengl.GLU; 33 import android.util.Log; 34 35 public class NativeRendererOneColorBufferTest extends RendererBase { 36 private int mProgramObject; 37 private int mWidth; 38 private int mHeight; 39 private FloatBuffer mVertices; 40 private ShortBuffer mIndexBuffer; 41 42 private static String TAG = "HelloTriangleRenderer"; 43 44 // Our vertices. 45 private float mVerticesData[] = { 46 -0.5f, 0.5f, 0.0f, // 0, Top Left 47 -0.5f, -0.5f, 0.0f, // 1, Bottom Left 48 0.5f, -0.5f, 0.0f, // 2, Bottom Right 49 0.5f, 0.5f, 0.0f, // 3, Top Right 50 }; 51 52 private float[] mVertexColor = {}; 53 54 private short[] mIndices = { 0, 1, 2, 0, 2, 3 }; 55 private FloatBuffer mColor; 56 57 public NativeRendererOneColorBufferTest(Context context, CountDownLatch latch) { 58 super(latch); 59 } 60 61 public NativeRendererOneColorBufferTest(Context context, float[] color, CountDownLatch latch) { 62 super(latch); 63 this.mVertexColor = color; 64 } 65 66 public void onSurfaceCreated(GL10 glUnused, EGLConfig config) { 67 68 } 69 70 public void doOnDrawFrame(GL10 glUnused) { 71 Log.i(TAG,"onDrawFrame start"); 72 73 float[] result = GL2JniLibOne.draw(3, 1, mVertexColor); 74 mColorOne = result; 75 } 76 77 public float[] getActualRGBA() { 78 return this.mColorOne; 79 } 80 81 public void onSurfaceChanged(GL10 glUnused, int width, int height) { 82 mWidth = width; 83 mHeight = height; 84 Log.i(TAG,"onSurfaceCreated start"); 85 GL2JniLibOne.init(3,1, width, height); 86 Log.i(TAG,"onSurfaceCreated finish"); 87 } 88 } 89