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 "Direct3D8.hpp" |
| 16 | |
| 17 | #include "resource.h" |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | #include <assert.h> |
| 21 | |
| 22 | extern "C" |
| 23 | { |
| 24 | HINSTANCE dllInstance; |
| 25 | |
| 26 | int __stdcall DllMain(HINSTANCE instance, unsigned long reason, void *reserved) |
| 27 | { |
| 28 | dllInstance = instance; |
| 29 | |
| 30 | switch(reason) |
| 31 | { |
| 32 | case DLL_PROCESS_DETACH: |
| 33 | break; |
| 34 | case DLL_PROCESS_ATTACH: |
| 35 | DisableThreadLibraryCalls(instance); |
| 36 | break; |
| 37 | case DLL_THREAD_ATTACH: |
| 38 | break; |
| 39 | case DLL_THREAD_DETACH: |
| 40 | break; |
| 41 | default: |
| 42 | SetLastError(ERROR_INVALID_PARAMETER); |
| 43 | return FALSE; |
| 44 | } |
| 45 | |
| 46 | return TRUE; |
| 47 | } |
| 48 | |
| 49 | IDirect3D8 *__stdcall Direct3DCreate8(unsigned int version) |
| 50 | { |
| 51 | // D3D_SDK_VERSION check |
| 52 | if(version != 120 && // 8.0 |
| 53 | version != 220) // 8.1 |
| 54 | { |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | #ifndef NDEBUG |
| 59 | FILE *file = fopen("debug.txt", "w"); // Clear debug log |
| 60 | fclose(file); |
| 61 | #endif |
| 62 | |
| 63 | IDirect3D8 *device = new D3D8::Direct3D8(version, dllInstance); |
| 64 | |
| 65 | if(device) |
| 66 | { |
| 67 | device->AddRef(); |
| 68 | } |
| 69 | |
| 70 | return device; |
| 71 | } |
| 72 | |
| 73 | int __stdcall CheckFullscreen() // FIXME: __cdecl or __stdcall? |
| 74 | { |
| 75 | #ifndef NDEBUG |
| 76 | // ASSERT(false); // FIXME |
| 77 | #endif |
| 78 | |
| 79 | return FALSE; |
| 80 | } |
| 81 | |
| 82 | void __cdecl DebugSetMute(long mute) // FIXME: Return type |
| 83 | { |
| 84 | // ASSERT(false); // FIXME |
| 85 | } |
| 86 | |
| 87 | int __stdcall ValidatePixelShader(long *shader, int x, int y, int z) // FIXME: __cdecl or __stdcall? // FIXME: Argument meanings |
| 88 | { |
| 89 | // ASSERT(false); // FIXME |
| 90 | |
| 91 | return TRUE; |
| 92 | } |
| 93 | |
| 94 | int __stdcall ValidateVertexShader(long *shader, int x, int y, int z) // FIXME: __cdecl or __stdcall? // FIXME: Argument meanings |
| 95 | { |
| 96 | // ASSERT(false); // FIXME |
| 97 | |
| 98 | return TRUE; |
| 99 | } |
| 100 | } |