Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [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_VERTEX_ARRAY_H |
| 18 | #define ANDROID_VERTEX_ARRAY_H |
| 19 | |
| 20 | |
| 21 | #include "rsObjectBase.h" |
| 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | class ShaderCache; |
| 28 | |
| 29 | // An element is a group of Components that occupies one cell in a structure. |
| 30 | class VertexArray |
| 31 | { |
| 32 | public: |
| 33 | VertexArray(); |
| 34 | virtual ~VertexArray(); |
| 35 | |
| 36 | enum AttribName { |
| 37 | POSITION, |
| 38 | COLOR, |
| 39 | NORMAL, |
| 40 | POINT_SIZE, |
| 41 | TEXTURE_0, |
| 42 | TEXTURE_1, |
| 43 | _LAST |
| 44 | }; |
| 45 | |
| 46 | typedef struct { |
| 47 | uint32_t buffer; |
| 48 | uint32_t offset; |
| 49 | uint32_t type; |
| 50 | uint32_t size; |
| 51 | uint32_t stride; |
| 52 | bool normalized; |
| 53 | } Attrib; |
| 54 | |
| 55 | |
| 56 | void clearAll(); |
| 57 | void clear(AttribName); |
| 58 | |
| 59 | void setActiveBuffer(uint32_t id) {mActiveBuffer = id;} |
| 60 | |
| 61 | void setPosition(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset); |
| 62 | void setColor(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset); |
| 63 | void setNormal(uint32_t type, uint32_t stride, uint32_t offset); |
| 64 | void setPointSize(uint32_t type, uint32_t stride, uint32_t offset); |
| 65 | void setTexture(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset, uint32_t num); |
| 66 | |
| 67 | void setupGL(class VertexArrayState *) const; |
| 68 | void setupGL2(class VertexArrayState *, ShaderCache *) const; |
| 69 | void logAttrib(uint32_t idx) const; |
| 70 | |
| 71 | protected: |
| 72 | uint32_t mActiveBuffer; |
| 73 | Attrib mAttribs[_LAST]; |
| 74 | }; |
| 75 | |
| 76 | |
| 77 | class VertexArrayState { |
| 78 | public: |
| 79 | void init(Context *); |
| 80 | |
| 81 | VertexArray::Attrib mAttribs[VertexArray::_LAST]; |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | } |
| 86 | } |
| 87 | #endif //ANDROID_LIGHT_H |
| 88 | |
| 89 | |
| 90 | |