src/render/direct3d11/SDL_render_d3d11.cpp
author David Ludwig <dludwig@pobox.com>
Sat, 02 Feb 2013 19:32:44 -0500
changeset 8400 1315402d9028
child 8401 29ecd2eca4af
permissions -rw-r--r--
WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
/*
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     4
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     7
  arising from the use of this software.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     8
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    12
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    16
     appreciated but is not required.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    20
*/
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    21
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    22
#include "SDL_config.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    23
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    24
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    25
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    26
extern "C" {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    27
#include "../../core/windows/SDL_windows.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    28
//#include "SDL_hints.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    29
//#include "SDL_loadso.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    30
#include "SDL_syswm.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    31
#include "../SDL_sysrender.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    32
//#include "stdio.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    33
}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    34
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    35
#include "SDL_render_d3d11_cpp.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    36
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    37
/* Direct3D renderer implementation */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    38
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    39
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    40
//static void D3D11_WindowEvent(SDL_Renderer * renderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    41
//                            const SDL_WindowEvent *event);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    42
//static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    43
//static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    44
//                             const SDL_Rect * rect, const void *pixels,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    45
//                             int pitch);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    46
//static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    47
//                           const SDL_Rect * rect, void **pixels, int *pitch);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    48
//static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    49
//static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    50
static int D3D11_UpdateViewport(SDL_Renderer * renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    51
//static int D3D11_RenderClear(SDL_Renderer * renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    52
//static int D3D11_RenderDrawPoints(SDL_Renderer * renderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    53
//                                const SDL_FPoint * points, int count);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    54
//static int D3D11_RenderDrawLines(SDL_Renderer * renderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    55
//                               const SDL_FPoint * points, int count);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    56
//static int D3D11_RenderFillRects(SDL_Renderer * renderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    57
//                               const SDL_FRect * rects, int count);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    58
//static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    59
//                          const SDL_Rect * srcrect, const SDL_FRect * dstrect);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    60
//static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    61
//                          const SDL_Rect * srcrect, const SDL_FRect * dstrect,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    62
//                          const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    63
//static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    64
//                                Uint32 format, void * pixels, int pitch);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    65
//static void D3D11_RenderPresent(SDL_Renderer * renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    66
//static void D3D11_DestroyTexture(SDL_Renderer * renderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    67
//                               SDL_Texture * texture);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    68
//static void D3D11_DestroyRenderer(SDL_Renderer * renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    69
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    70
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    71
extern "C" {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    72
    SDL_RenderDriver D3D11_RenderDriver = {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    73
    D3D11_CreateRenderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    74
    {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    75
     "direct3d",
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    76
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    77
     1,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    78
     {SDL_PIXELFORMAT_ARGB8888},
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    79
     0,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    80
     0}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    81
    };
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    82
}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    83
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    84
//typedef struct
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    85
//{
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    86
//    float x, y, z;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    87
//    DWORD color;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    88
//    float u, v;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    89
//} Vertex;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    90
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    91
SDL_Renderer *
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    92
D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    93
{
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    94
    SDL_Renderer *renderer;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    95
    D3D11_RenderData *data;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    96
//    SDL_SysWMinfo windowinfo;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    97
 //   HRESULT result;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    98
 //   D3DPRESENT_PARAMETERS pparams;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    99
 //   IDirect3DSwapChain9 *chain;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   100
 //   D3DCAPS9 caps;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   101
 //   Uint32 window_flags;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   102
 //   int w, h;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   103
 //   SDL_DisplayMode fullscreen_mode;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   104
 //   D3DMATRIX matrix;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   105
 //   int d3dxVersion;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   106
	//char d3dxDLLFile[50];
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   107
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   108
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   109
    if (!renderer) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   110
        SDL_OutOfMemory();
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   111
        return NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   112
    }
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   113
    SDL_zerop(renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   114
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   115
    data = new D3D11_RenderData;    // Use the C++ 'new' operator to make sure the struct's members initialize using C++ rules
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   116
    if (!data) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   117
        delete data;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   118
        SDL_OutOfMemory();
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   119
        return NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   120
    }
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   121
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   122
    // TODO: Create Direct3D Object(s)
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   123
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   124
    //renderer->WindowEvent = D3D11_WindowEvent;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   125
    //renderer->CreateTexture = D3D11_CreateTexture;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   126
    //renderer->UpdateTexture = D3D11_UpdateTexture;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   127
    //renderer->LockTexture = D3D11_LockTexture;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   128
    //renderer->UnlockTexture = D3D11_UnlockTexture;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   129
    //renderer->SetRenderTarget = D3D11_SetRenderTarget;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   130
    renderer->UpdateViewport = D3D11_UpdateViewport;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   131
    //renderer->RenderClear = D3D11_RenderClear;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   132
    //renderer->RenderDrawPoints = D3D11_RenderDrawPoints;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   133
    //renderer->RenderDrawLines = D3D11_RenderDrawLines;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   134
    //renderer->RenderFillRects = D3D11_RenderFillRects;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   135
    //renderer->RenderCopy = D3D11_RenderCopy;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   136
    //renderer->RenderCopyEx = D3D11_RenderCopyEx;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   137
    //renderer->RenderReadPixels = D3D11_RenderReadPixels;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   138
    //renderer->RenderPresent = D3D11_RenderPresent;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   139
    //renderer->DestroyTexture = D3D11_DestroyTexture;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   140
    //renderer->DestroyRenderer = D3D11_DestroyRenderer;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   141
    renderer->info = D3D11_RenderDriver.info;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   142
    renderer->driverdata = data;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   143
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   144
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   145
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   146
    //SDL_VERSION(&windowinfo.version);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   147
    //SDL_GetWindowWMInfo(window, &windowinfo);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   148
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   149
    //window_flags = SDL_GetWindowFlags(window);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   150
    //SDL_GetWindowSize(window, &w, &h);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   151
    //SDL_GetWindowDisplayMode(window, &fullscreen_mode);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   152
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   153
    //SDL_zero(pparams);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   154
    //pparams.hDeviceWindow = windowinfo.info.win.window;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   155
    //pparams.BackBufferWidth = w;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   156
    //pparams.BackBufferHeight = h;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   157
    //if (window_flags & SDL_WINDOW_FULLSCREEN) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   158
    //    pparams.BackBufferFormat =
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   159
    //        PixelFormatToD3DFMT(fullscreen_mode.format);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   160
    //} else {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   161
    //    pparams.BackBufferFormat = D3DFMT_UNKNOWN;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   162
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   163
    //pparams.BackBufferCount = 1;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   164
    //pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   165
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   166
    //if (window_flags & SDL_WINDOW_FULLSCREEN) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   167
    //    pparams.Windowed = FALSE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   168
    //    pparams.FullScreen_RefreshRateInHz =
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   169
    //        fullscreen_mode.refresh_rate;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   170
    //} else {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   171
    //    pparams.Windowed = TRUE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   172
    //    pparams.FullScreen_RefreshRateInHz = 0;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   173
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   174
    //if (flags & SDL_RENDERER_PRESENTVSYNC) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   175
    //    pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   176
    //} else {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   177
    //    pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   178
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   179
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   180
    ///* FIXME: Which adapter? */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   181
    //data->adapter = D3DADAPTER_DEFAULT;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   182
    //IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   183
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   184
    //result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   185
    //                                 D3DDEVTYPE_HAL,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   186
    //                                 pparams.hDeviceWindow,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   187
    //                                 D3DCREATE_FPU_PRESERVE | ((caps.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   188
    //                                  DevCaps &
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   189
    //                                  D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   190
    //                                 D3DCREATE_HARDWARE_VERTEXPROCESSING :
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   191
    //                                 D3DCREATE_SOFTWARE_VERTEXPROCESSING),
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   192
    //                                 &pparams, &data->device);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   193
    //if (FAILED(result)) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   194
    //    D3D11_DestroyRenderer(renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   195
    //    D3D11_SetError("CreateDevice()", result);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   196
    //    return NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   197
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   198
    //data->beginScene = SDL_TRUE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   199
    //data->scaleMode = D3DTEXF_FORCE_DWORD;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   200
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   201
    ///* Get presentation parameters to fill info */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   202
    //result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   203
    //if (FAILED(result)) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   204
    //    D3D11_DestroyRenderer(renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   205
    //    D3D11_SetError("GetSwapChain()", result);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   206
    //    return NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   207
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   208
    //result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   209
    //if (FAILED(result)) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   210
    //    IDirect3DSwapChain9_Release(chain);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   211
    //    D3D11_DestroyRenderer(renderer);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   212
    //    D3D11_SetError("GetPresentParameters()", result);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   213
    //    return NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   214
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   215
    //IDirect3DSwapChain9_Release(chain);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   216
    //if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   217
    //    renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   218
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   219
    //data->pparams = pparams;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   220
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   221
    //IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   222
    //renderer->info.max_texture_width = caps.MaxTextureWidth;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   223
    //renderer->info.max_texture_height = caps.MaxTextureHeight;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   224
    //if (caps.NumSimultaneousRTs >= 2) {
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   225
    //    renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   226
    //}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   227
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   228
    ///* Set up parameters for rendering */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   229
    //IDirect3DDevice9_SetVertexShader(data->device, NULL);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   230
    //IDirect3DDevice9_SetFVF(data->device,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   231
    //                        D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   232
    //IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   233
    //IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   234
    //                                D3DCULL_NONE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   235
    //IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   236
    ///* Enable color modulation by diffuse color */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   237
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   238
    //                                      D3DTOP_MODULATE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   239
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   240
    //                                      D3DTA_TEXTURE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   241
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   242
    //                                      D3DTA_DIFFUSE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   243
    ///* Enable alpha modulation by diffuse alpha */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   244
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   245
    //                                      D3DTOP_MODULATE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   246
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   247
    //                                      D3DTA_TEXTURE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   248
    //IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   249
    //                                      D3DTA_DIFFUSE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   250
    ///* Disable second texture stage, since we're done */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   251
    //IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   252
    //                                      D3DTOP_DISABLE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   253
    //IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   254
    //                                      D3DTOP_DISABLE);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   255
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   256
    ///* Store the default render target */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   257
    //IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget );
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   258
    //data->currentRenderTarget = NULL;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   259
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   260
    ///* Set an identity world and view matrix */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   261
    //matrix.m[0][0] = 1.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   262
    //matrix.m[0][1] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   263
    //matrix.m[0][2] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   264
    //matrix.m[0][3] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   265
    //matrix.m[1][0] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   266
    //matrix.m[1][1] = 1.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   267
    //matrix.m[1][2] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   268
    //matrix.m[1][3] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   269
    //matrix.m[2][0] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   270
    //matrix.m[2][1] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   271
    //matrix.m[2][2] = 1.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   272
    //matrix.m[2][3] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   273
    //matrix.m[3][0] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   274
    //matrix.m[3][1] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   275
    //matrix.m[3][2] = 0.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   276
    //matrix.m[3][3] = 1.0f;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   277
    //IDirect3DDevice9_SetTransform(data->device, D3DTS_WORLD, &matrix);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   278
    //IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, &matrix);
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   279
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   280
    return renderer;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   281
}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   282
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   283
static int
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   284
D3D11_UpdateViewport(SDL_Renderer * renderer)
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   285
{
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   286
    return 0;
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   287
}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   288
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   289
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   290
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   291
/* vi: set ts=4 sw=4 expandtab: */