blob: c2d10e628c0efdb842cd77f9dd27612117f0b5ea [file] [log] [blame]
Jason Samsc460e552009-11-25 13:22:07 -08001/*
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// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27class ShaderCache;
28
29// An element is a group of Components that occupies one cell in a structure.
30class VertexArray
31{
32public:
Jason Sams433eca32010-01-06 11:57:52 -080033 class Attrib {
34 public:
Jason Samsc460e552009-11-25 13:22:07 -080035 uint32_t buffer;
Jason Sams760f1f72010-06-25 12:45:41 -070036 const uint8_t * ptr;
Jason Samsc460e552009-11-25 13:22:07 -080037 uint32_t offset;
38 uint32_t type;
39 uint32_t size;
40 uint32_t stride;
41 bool normalized;
Jason Sams433eca32010-01-06 11:57:52 -080042 String8 name;
43
44 Attrib();
Jason Sams433eca32010-01-06 11:57:52 -080045 void clear();
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080046 void set(uint32_t type, uint32_t size, uint32_t stride, bool normalized, uint32_t offset, const char *name);
Jason Sams433eca32010-01-06 11:57:52 -080047 };
Jason Samsc460e552009-11-25 13:22:07 -080048
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080049 VertexArray(const Attrib *attribs, uint32_t numAttribs);
50 virtual ~VertexArray();
Jason Samsc460e552009-11-25 13:22:07 -080051
Jason Samsd01d9702009-12-23 14:35:29 -080052 void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
Jason Sams433eca32010-01-06 11:57:52 -080053 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsc460e552009-11-25 13:22:07 -080054
55protected:
Jason Samsbe504f22010-01-25 12:31:24 -080056 void clear(uint32_t index);
Jason Samsc460e552009-11-25 13:22:07 -080057 uint32_t mActiveBuffer;
Jason Sams760f1f72010-06-25 12:45:41 -070058 const uint8_t * mActivePointer;
Jason Samsbe504f22010-01-25 12:31:24 -080059 uint32_t mCount;
60
Alex Sakhartchouk54929cc2010-11-08 15:10:52 -080061 const Attrib *mAttribs;
Jason Samsc460e552009-11-25 13:22:07 -080062};
63
64
65class VertexArrayState {
66public:
67 void init(Context *);
68
Jason Sams3eb28f02010-01-27 14:41:43 -080069 uint32_t mLastEnableCount;
Jason Samsc460e552009-11-25 13:22:07 -080070};
71
72
73}
74}
Alex Sakhartchoukc8fb69e2010-10-05 13:23:55 -070075#endif //ANDROID_VERTEX_ARRAY_H
Jason Samsc460e552009-11-25 13:22:07 -080076
77
78