Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | #ifndef ANDROID_RS_TRIANGLE_MESH_H |
| 18 | #define ANDROID_RS_TRIANGLE_MESH_H |
| 19 | |
| 20 | #include <stdlib.h> |
| 21 | #include <stdio.h> |
| 22 | |
| 23 | #include <math.h> |
| 24 | #include <EGL/egl.h> |
| 25 | #include <GLES/gl.h> |
| 26 | #include <GLES/glext.h> |
| 27 | |
| 28 | #include <utils/Vector.h> |
| 29 | |
| 30 | #include "RenderScript.h" |
| 31 | |
| 32 | // --------------------------------------------------------------------------- |
| 33 | namespace android { |
| 34 | namespace renderscript { |
| 35 | |
| 36 | |
| 37 | // An element is a group of Components that occupies one cell in a structure. |
| 38 | class TriangleMesh |
| 39 | { |
| 40 | public: |
| 41 | TriangleMesh(); |
| 42 | ~TriangleMesh(); |
| 43 | |
| 44 | const Element * mVertexElement; |
| 45 | const Element * mIndexElement; |
| 46 | |
| 47 | void * mVertexData; |
| 48 | void * mIndexData; |
| 49 | |
| 50 | size_t mVertexDataSize; |
| 51 | size_t mIndexDataSize; |
| 52 | uint32_t mTriangleCount; |
| 53 | |
| 54 | size_t mOffsetCoord; |
| 55 | size_t mOffsetTex; |
| 56 | size_t mOffsetNorm; |
| 57 | |
| 58 | size_t mSizeCoord; |
| 59 | size_t mSizeTex; |
| 60 | size_t mSizeNorm; |
| 61 | |
| 62 | // GL buffer info |
| 63 | GLuint mBufferObjects[2]; |
| 64 | |
| 65 | void analyzeElement(); |
| 66 | protected: |
| 67 | }; |
| 68 | |
| 69 | class TriangleMeshContext |
| 70 | { |
| 71 | public: |
| 72 | TriangleMeshContext(); |
| 73 | ~TriangleMeshContext(); |
| 74 | |
| 75 | const Element * mVertexElement; |
| 76 | const Element * mIndexElement; |
| 77 | size_t mVertexSizeBits; |
| 78 | size_t mIndexSizeBits; |
| 79 | |
| 80 | Vector<uint8_t> mVertexData; |
| 81 | Vector<uint16_t> mIndexData; |
| 82 | |
| 83 | uint32_t mTriangleCount; |
| 84 | |
| 85 | void clear(); |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | } |
| 90 | } |
| 91 | #endif //ANDROID_RS_TRIANGLE_MESH_H |
| 92 | |