blob: 26e6f849d51a2d72dccfcb5261871eb1d82540ac [file] [log] [blame]
Jason Samsbb51c402009-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:
33 VertexArray();
34 virtual ~VertexArray();
35
36 enum AttribName {
37 POSITION,
38 COLOR,
39 NORMAL,
40 POINT_SIZE,
Jason Samsa09a6e12010-01-06 11:57:52 -080041 TEXTURE,
Jason Samsbb51c402009-11-25 13:22:07 -080042 _LAST
43 };
44
Jason Samsa09a6e12010-01-06 11:57:52 -080045 class Attrib {
46 public:
Jason Samsbb51c402009-11-25 13:22:07 -080047 uint32_t buffer;
48 uint32_t offset;
49 uint32_t type;
50 uint32_t size;
51 uint32_t stride;
52 bool normalized;
Jason Samsa09a6e12010-01-06 11:57:52 -080053 String8 name;
54
55 Attrib();
56 void set(const Attrib &);
57 void clear();
58 };
Jason Samsbb51c402009-11-25 13:22:07 -080059
60
61 void clearAll();
62 void clear(AttribName);
63
64 void setActiveBuffer(uint32_t id) {mActiveBuffer = id;}
65
Jason Samsa09a6e12010-01-06 11:57:52 -080066 void setUser(const Attrib &, uint32_t stride);
Jason Samsbb51c402009-11-25 13:22:07 -080067 void setPosition(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset);
68 void setColor(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset);
69 void setNormal(uint32_t type, uint32_t stride, uint32_t offset);
70 void setPointSize(uint32_t type, uint32_t stride, uint32_t offset);
Jason Samsa09a6e12010-01-06 11:57:52 -080071 void setTexture(uint32_t size, uint32_t type, uint32_t stride, uint32_t offset);
Jason Samsbb51c402009-11-25 13:22:07 -080072
Jason Sams718cd1f2009-12-23 14:35:29 -080073 void setupGL(const Context *rsc, class VertexArrayState *) const;
74 void setupGL2(const Context *rsc, class VertexArrayState *, ShaderCache *) const;
Jason Samsa09a6e12010-01-06 11:57:52 -080075 void logAttrib(uint32_t idx, uint32_t slot) const;
Jason Samsbb51c402009-11-25 13:22:07 -080076
77protected:
78 uint32_t mActiveBuffer;
Jason Samsa09a6e12010-01-06 11:57:52 -080079 Attrib mAttribs[RS_MAX_ATTRIBS];
Jason Samsbb51c402009-11-25 13:22:07 -080080};
81
82
83class VertexArrayState {
84public:
85 void init(Context *);
86
Jason Samsa09a6e12010-01-06 11:57:52 -080087 //VertexArray::Attrib mAttribs[VertexArray::_LAST];
Jason Samsbb51c402009-11-25 13:22:07 -080088};
89
90
91}
92}
93#endif //ANDROID_LIGHT_H
94
95
96