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
19 namespace android {
20
Mesh(Primitive primitive,size_t vertexCount,size_t vertexSize,size_t texCoordSize)21 Mesh::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
~Mesh()29 Mesh::~Mesh() {
30 delete [] mVertices;
31 }
32
getPrimitive() const33 Mesh::Primitive Mesh::getPrimitive() const {
34 return mPrimitive;
35 }
36
37
getPositions() const38 float const* Mesh::getPositions() const {
39 return mVertices;
40 }
getPositions()41 float* Mesh::getPositions() {
42 return mVertices;
43 }
44
getTexCoords() const45 float const* Mesh::getTexCoords() const {
46 return mVertices + mVertexSize;
47 }
getTexCoords()48 float* Mesh::getTexCoords() {
49 return mVertices + mVertexSize;
50 }
51
52
getVertexCount() const53 size_t Mesh::getVertexCount() const {
54 return mVertexCount;
55 }
56
getVertexSize() const57 size_t Mesh::getVertexSize() const {
58 return mVertexSize;
59 }
60
getTexCoordsSize() const61 size_t Mesh::getTexCoordsSize() const {
62 return mTexCoordsSize;
63 }
64
getByteStride() const65 size_t Mesh::getByteStride() const {
66 return mStride*sizeof(float);
67 }
68
getStride() const69 size_t Mesh::getStride() const {
70 return mStride;
71 }
72
73 } /* namespace android */
74