1/*
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
33Mesh::Primitive Mesh::getPrimitive() const {
34    return mPrimitive;
35}
36
37
38float const* Mesh::getPositions() const {
39    return mVertices;
40}
41float* Mesh::getPositions() {
42    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 */
74