Nicolas Capens | 17b29fd | 2016-09-15 09:32:16 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "Direct3DVertexDeclaration8.hpp" |
| 16 | |
| 17 | #include "Debug.hpp" |
| 18 | |
| 19 | #include <d3d8types.h> |
| 20 | |
| 21 | namespace D3D8 |
| 22 | { |
| 23 | Direct3DVertexDeclaration8::Direct3DVertexDeclaration8(Direct3DDevice8 *device, const unsigned long *vertexElement) : device(device) |
| 24 | { |
| 25 | int size = sizeof(unsigned long); |
| 26 | const unsigned long *element = vertexElement; |
| 27 | |
| 28 | while(*element != 0xFFFFFFFF) |
| 29 | { |
| 30 | size += sizeof(unsigned long); |
| 31 | element++; |
| 32 | } |
| 33 | |
| 34 | declaration = new unsigned long[size / sizeof(unsigned long)]; |
| 35 | memcpy(declaration, vertexElement, size); |
| 36 | } |
| 37 | |
| 38 | Direct3DVertexDeclaration8::~Direct3DVertexDeclaration8() |
| 39 | { |
| 40 | delete[] declaration; |
| 41 | declaration = 0; |
| 42 | } |
| 43 | |
| 44 | long Direct3DVertexDeclaration8::QueryInterface(const IID &iid, void **object) |
| 45 | { |
| 46 | TRACE(""); |
| 47 | |
| 48 | ASSERT(false); // Internal object |
| 49 | |
| 50 | return NOINTERFACE(iid); |
| 51 | } |
| 52 | |
| 53 | unsigned long Direct3DVertexDeclaration8::AddRef() |
| 54 | { |
| 55 | TRACE(""); |
| 56 | |
| 57 | return Unknown::AddRef(); |
| 58 | } |
| 59 | |
| 60 | unsigned long Direct3DVertexDeclaration8::Release() |
| 61 | { |
| 62 | TRACE(""); |
| 63 | |
| 64 | return Unknown::Release(); |
| 65 | } |
| 66 | |
| 67 | const unsigned long *Direct3DVertexDeclaration8::getDeclaration() const |
| 68 | { |
| 69 | return declaration; |
| 70 | } |
| 71 | } |