blob: 3f50cb0a96414996af1e58055848ce11225a5e28 [file] [log] [blame]
Mathias Agopian3f844832013-08-07 21:24:32 -07001/*
2 * Copyright 2013 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#include "Mesh.h"
18
19namespace android {
20
21Mesh::Mesh(Primitive primitive, size_t vertexCount, size_t vertexSize, size_t texCoordSize)
22 : mVertexCount(vertexCount), mVertexSize(vertexSize), mTexCoordsSize(texCoordSize),
23 mPrimitive(primitive)
24{
25 mVertices = new float[(vertexSize + texCoordSize) * vertexCount];
26 mStride = mVertexSize + mTexCoordsSize;
27}
28
29Mesh::~Mesh() {
30 delete [] mVertices;
31}
32
Mathias Agopian3f844832013-08-07 21:24:32 -070033Mesh::Primitive Mesh::getPrimitive() const {
34 return mPrimitive;
35}
36
37
Mathias Agopian5cdc8992013-08-13 20:51:23 -070038float const* Mesh::getPositions() const {
Mathias Agopian3f844832013-08-07 21:24:32 -070039 return mVertices;
40}
Mathias Agopian5cdc8992013-08-13 20:51:23 -070041float* Mesh::getPositions() {
Mathias Agopian3f844832013-08-07 21:24:32 -070042 return mVertices;
43}
44
45float const* Mesh::getTexCoords() const {
46 return mVertices + mVertexSize;
47}
48float* Mesh::getTexCoords() {
49 return mVertices + mVertexSize;
50}
51
52
53size_t Mesh::getVertexCount() const {
54 return mVertexCount;
55}
56
57size_t Mesh::getVertexSize() const {
58 return mVertexSize;
59}
60
61size_t Mesh::getTexCoordsSize() const {
62 return mTexCoordsSize;
63}
64
65size_t Mesh::getByteStride() const {
66 return mStride*sizeof(float);
67}
68
69size_t Mesh::getStride() const {
70 return mStride;
71}
72
73} /* namespace android */