Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 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 | |
| 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 | |
| 29 | Mesh::~Mesh() { |
| 30 | delete [] mVertices; |
| 31 | } |
| 32 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 33 | Mesh::Primitive Mesh::getPrimitive() const { |
| 34 | return mPrimitive; |
| 35 | } |
| 36 | |
| 37 | |
Mathias Agopian | 5cdc899 | 2013-08-13 20:51:23 -0700 | [diff] [blame^] | 38 | float const* Mesh::getPositions() const { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 39 | return mVertices; |
| 40 | } |
Mathias Agopian | 5cdc899 | 2013-08-13 20:51:23 -0700 | [diff] [blame^] | 41 | float* Mesh::getPositions() { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 42 | return mVertices; |
| 43 | } |
| 44 | |
| 45 | float const* Mesh::getTexCoords() const { |
| 46 | return mVertices + mVertexSize; |
| 47 | } |
| 48 | float* Mesh::getTexCoords() { |
| 49 | return mVertices + mVertexSize; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | size_t Mesh::getVertexCount() const { |
| 54 | return mVertexCount; |
| 55 | } |
| 56 | |
| 57 | size_t Mesh::getVertexSize() const { |
| 58 | return mVertexSize; |
| 59 | } |
| 60 | |
| 61 | size_t Mesh::getTexCoordsSize() const { |
| 62 | return mTexCoordsSize; |
| 63 | } |
| 64 | |
| 65 | size_t Mesh::getByteStride() const { |
| 66 | return mStride*sizeof(float); |
| 67 | } |
| 68 | |
| 69 | size_t Mesh::getStride() const { |
| 70 | return mStride; |
| 71 | } |
| 72 | |
| 73 | } /* namespace android */ |