Jason Sams | c460e55 | 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 | |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 36 | |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 37 | class Attrib { |
| 38 | public: |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 39 | uint32_t buffer; |
| 40 | uint32_t offset; |
| 41 | uint32_t type; |
| 42 | uint32_t size; |
| 43 | uint32_t stride; |
| 44 | bool normalized; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 45 | String8 name; |
| 46 | |
| 47 | Attrib(); |
| 48 | void set(const Attrib &); |
| 49 | void clear(); |
| 50 | }; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 51 | |
| 52 | |
| 53 | void clearAll(); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 54 | void setActiveBuffer(uint32_t id) {mActiveBuffer = id;} |
Jason Sams | 79f52df | 2010-06-01 15:47:01 -0700 | [diff] [blame] | 55 | void add(const Attrib &, uint32_t stride); |
| 56 | //void addLegacy(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset); |
| 57 | void add(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 58 | |
Jason Sams | d01d970 | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 59 | void setupGL(const Context *rsc, class VertexArrayState *) const; |
| 60 | void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 61 | void logAttrib(uint32_t idx, uint32_t slot) const; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 62 | |
| 63 | protected: |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 64 | void clear(uint32_t index); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 65 | uint32_t mActiveBuffer; |
Jason Sams | be504f2 | 2010-01-25 12:31:24 -0800 | [diff] [blame] | 66 | uint32_t mCount; |
| 67 | |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 68 | Attrib mAttribs[RS_MAX_ATTRIBS]; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | |
| 72 | class VertexArrayState { |
| 73 | public: |
| 74 | void init(Context *); |
| 75 | |
Jason Sams | 3eb28f0 | 2010-01-27 14:41:43 -0800 | [diff] [blame] | 76 | uint32_t mLastEnableCount; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 77 | //VertexArray::Attrib mAttribs[VertexArray::_LAST]; |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | |
| 81 | } |
| 82 | } |
| 83 | #endif //ANDROID_LIGHT_H |
| 84 | |
| 85 | |
| 86 | |