Jason Sams | a89371c | 2009-06-30 14:13:04 -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_MESH_H |
| 18 | #define ANDROID_RS_MESH_H |
| 19 | |
| 20 | |
| 21 | #include "RenderScript.h" |
| 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | |
| 28 | // An element is a group of Components that occupies one cell in a structure. |
| 29 | class Mesh : public ObjectBase |
| 30 | { |
| 31 | public: |
Jason Sams | e514b45 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 32 | Mesh(Context *); |
Jason Sams | a89371c | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 33 | ~Mesh(); |
| 34 | |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 35 | // Contains vertex data |
| 36 | // Position, normal, texcoord, etc could either be strided in one allocation |
| 37 | // of provided separetely in multiple ones |
| 38 | ObjectBaseRef<Allocation> *mVertexBuffers; |
| 39 | ObjectBaseRef<const Type> *mVertexTypes; |
| 40 | uint32_t mVertexBufferCount; |
Jason Sams | a5597fc | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 41 | |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 42 | // Either mIndexBuffer, mPrimitiveBuffer or both could have a NULL reference |
| 43 | // If both are null, mPrimitive only would be used to render the mesh |
Jason Sams | a89371c | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 44 | struct Primitive_t |
| 45 | { |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 46 | ObjectBaseRef<Allocation> mIndexBuffer; |
| 47 | ObjectBaseRef<Allocation> mPrimitiveBuffer; |
| 48 | ObjectBaseRef<const Type> mIndexType; |
| 49 | ObjectBaseRef<const Type> mPrimitiveType; |
Jason Sams | a89371c | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 50 | |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 51 | RsPrimitive mPrimitive; |
| 52 | uint32_t mGLPrimitive; |
Jason Sams | a89371c | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Jason Sams | a5597fc | 2009-07-08 18:01:53 -0700 | [diff] [blame] | 55 | Primitive_t ** mPrimitives; |
| 56 | uint32_t mPrimitivesCount; |
| 57 | |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 58 | void render(Context *) const; |
| 59 | void renderPrimitive(Context *, uint32_t primIndex) const; |
| 60 | void renderPrimitiveRange(Context *, uint32_t primIndex, uint32_t start, uint32_t len) const; |
| 61 | void uploadAll(Context *); |
| 62 | void updateGLPrimitives(); |
| 63 | |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 64 | virtual void serialize(OStream *stream) const; |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 65 | virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_MESH; } |
Alex Sakhartchouk | fb6b614 | 2010-05-21 12:53:13 -0700 | [diff] [blame] | 66 | static Mesh *createFromStream(Context *rsc, IStream *stream); |
Alex Sakhartchouk | b825f67 | 2010-06-04 10:06:50 -0700 | [diff] [blame] | 67 | |
Jason Sams | a89371c | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 68 | protected: |
| 69 | }; |
| 70 | |
| 71 | class MeshContext |
| 72 | { |
| 73 | public: |
| 74 | MeshContext(); |
| 75 | ~MeshContext(); |
| 76 | |
| 77 | }; |
| 78 | |
| 79 | |
| 80 | } |
| 81 | } |
| 82 | #endif //ANDROID_RS_TRIANGLE_MESH_H |
| 83 | |
| 84 | |
Alex Sakhartchouk | 4e9a7a8 | 2010-07-01 16:14:06 -0700 | [diff] [blame^] | 85 | |