src/render/direct3d/SDL_render_d3d.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 28 Sep 2013 14:07:05 -0700
changeset 7763 fc802d707136
parent 7762 51abf7664304
child 7764 0f48b5f28668
permissions -rw-r--r--
Added platform specific call: SDL_RenderGetD3DDevice()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6860
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
     7
  arising from the use of this software.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    11
  freely, subject to the following restrictions:
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5484
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
5226
710d00cb3a6a Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents: 5224
diff changeset
    23
#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
710d00cb3a6a Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents: 5224
diff changeset
    24
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    26
#include "../../core/windows/SDL_windows.h"
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    27
5484
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
    28
#include "SDL_hints.h"
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    29
#include "SDL_loadso.h"
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    30
#include "SDL_syswm.h"
7756
f45660a4974c Moved D3D_LoadDLL and SDL_Direct3D9GetAdapterIndex to SDL_windowswindow.c at Jorgen's insistence. That file is wrapped in a more appropriate define check so it will work if somebody builds a binary without D3D support.
Sam Lantinga <slouken@libsdl.org>
parents: 7742
diff changeset
    31
#include "SDL_system.h"
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    32
#include "../SDL_sysrender.h"
7762
51abf7664304 Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code.
Sam Lantinga <slouken@libsdl.org>
parents: 7761
diff changeset
    33
#include "../../video/windows/SDL_windowsvideo.h"
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    34
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    35
#if SDL_VIDEO_RENDER_D3D
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    36
#define D3D_DEBUG_INFO
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    37
#include <d3d9.h>
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
    38
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    40
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    41
typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    42
typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    43
typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    44
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    45
DEFINE_GUID(IID_ID3DXMatrixStack,
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    46
0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    47
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    48
#undef INTERFACE
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    49
#define INTERFACE ID3DXMatrixStack
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    50
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    51
DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    52
{
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    53
    STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    54
    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    55
    STDMETHOD_(ULONG,Release)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    56
    STDMETHOD(Pop)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    57
    STDMETHOD(Push)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    58
    STDMETHOD(LoadIdentity)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    59
    STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    60
    STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    61
    STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    62
    STDMETHOD(RotateAxis)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    63
    STDMETHOD(RotateAxisLocal)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    64
    STDMETHOD(RotateYawPitchRoll)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    65
    STDMETHOD(RotateYawPitchRollLocal)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    66
    STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    67
    STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    68
    STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    69
    STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    70
    STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    71
};
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    72
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    73
#undef INTERFACE
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    74
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    75
#if !defined(__cplusplus) || defined(CINTERFACE)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    76
#define ID3DXMatrixStack_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    77
#define ID3DXMatrixStack_AddRef(p)                        (p)->lpVtbl->AddRef(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    78
#define ID3DXMatrixStack_Release(p)                       (p)->lpVtbl->Release(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    79
#define ID3DXMatrixStack_Pop(p)                           (p)->lpVtbl->Pop(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    80
#define ID3DXMatrixStack_Push(p)                          (p)->lpVtbl->Push(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    81
#define ID3DXMatrixStack_LoadIdentity(p)                  (p)->lpVtbl->LoadIdentity(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    82
#define ID3DXMatrixStack_LoadMatrix(p,a)                  (p)->lpVtbl->LoadMatrix(p,a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    83
#define ID3DXMatrixStack_MultMatrix(p,a)                  (p)->lpVtbl->MultMatrix(p,a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    84
#define ID3DXMatrixStack_MultMatrixLocal(p,a)             (p)->lpVtbl->MultMatrixLocal(p,a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    85
#define ID3DXMatrixStack_RotateAxis(p,a,b)                (p)->lpVtbl->RotateAxis(p,a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    86
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b)           (p)->lpVtbl->RotateAxisLocal(p,a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    87
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c)      (p)->lpVtbl->RotateYawPitchRoll(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    88
#define ID3DXMatrixStack_RotateYawPitchRollLocal(p,a,b,c) (p)->lpVtbl->RotateYawPitchRollLocal(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    89
#define ID3DXMatrixStack_Scale(p,a,b,c)                   (p)->lpVtbl->Scale(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    90
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c)              (p)->lpVtbl->ScaleLocal(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    91
#define ID3DXMatrixStack_Translate(p,a,b,c)               (p)->lpVtbl->Translate(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    92
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c)          (p)->lpVtbl->TranslateLocal(p,a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    93
#define ID3DXMatrixStack_GetTop(p)                        (p)->lpVtbl->GetTop(p)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    94
#else
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    95
#define ID3DXMatrixStack_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    96
#define ID3DXMatrixStack_AddRef(p)                        (p)->AddRef()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    97
#define ID3DXMatrixStack_Release(p)                       (p)->Release()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    98
#define ID3DXMatrixStack_Pop(p)    (p)->Pop()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
    99
#define ID3DXMatrixStack_Push(p)    (p)->Push()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   100
#define ID3DXMatrixStack_LoadIdentity(p)    (p)->LoadIdentity()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   101
#define ID3DXMatrixStack_LoadMatrix(p,a)    (p)->LoadMatrix(a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   102
#define ID3DXMatrixStack_MultMatrix(p,a)    (p)->MultMatrix(a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   103
#define ID3DXMatrixStack_MultMatrixLocal(p,a)    (p)->MultMatrixLocal(a)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   104
#define ID3DXMatrixStack_RotateAxis(p,a,b)    (p)->RotateAxis(a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   105
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b)    (p)->RotateAxisLocal(a,b)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   106
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c)    (p)->RotateYawPitchRollLocal(a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   107
#define ID3DXMatrixStack_Scale(p,a,b,c)    (p)->Scale(a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   108
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c)    (p)->ScaleLocal(a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   109
#define ID3DXMatrixStack_Translate(p,a,b,c)    (p)->Translate(a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   110
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c)    (p)->TranslateLocal(a,b,c)
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   111
#define ID3DXMatrixStack_GetTop(p)    (p)->GetTop()
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   112
#endif
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   113
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   114
#ifdef __cplusplus
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   115
extern "C" {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   116
#endif
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   117
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   118
HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   119
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   120
#ifdef __cplusplus
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   121
}
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   122
#endif
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   123
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   124
#ifdef ASSEMBLE_SHADER
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   125
/**************************************************************************
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   126
 * ID3DXBuffer:
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   127
 * ------------
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   128
 * The buffer object is used by D3DX to return arbitrary size data.
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   129
 *
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   130
 * GetBufferPointer -
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   131
 *    Returns a pointer to the beginning of the buffer.
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   132
 *
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   133
 * GetBufferSize -
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   134
 *    Returns the size of the buffer, in bytes.
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   135
 **************************************************************************/
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   136
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   137
typedef interface ID3DXBuffer ID3DXBuffer;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   138
typedef interface ID3DXBuffer *LPD3DXBUFFER;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   139
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   140
/* {8BA5FB08-5195-40e2-AC58-0D989C3A0102} */
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   141
DEFINE_GUID(IID_ID3DXBuffer,
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   142
0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   143
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   144
#undef INTERFACE
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   145
#define INTERFACE ID3DXBuffer
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   146
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   147
typedef interface ID3DXBuffer {
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   148
    const struct ID3DXBufferVtbl FAR* lpVtbl;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   149
} ID3DXBuffer;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   150
typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   151
const struct ID3DXBufferVtbl
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   152
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   153
    /* IUnknown */
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   154
    STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   155
    STDMETHOD_(ULONG, AddRef)(THIS) PURE;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   156
    STDMETHOD_(ULONG, Release)(THIS) PURE;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   157
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   158
    /* ID3DXBuffer */
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   159
    STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   160
    STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   161
};
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   162
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   163
HRESULT WINAPI
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   164
    D3DXAssembleShader(
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   165
        LPCSTR                          pSrcData,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   166
        UINT                            SrcDataLen,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   167
        CONST LPVOID*                   pDefines,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   168
        LPVOID                          pInclude,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   169
        DWORD                           Flags,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   170
        LPD3DXBUFFER*                   ppShader,
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   171
        LPD3DXBUFFER*                   ppErrorMsgs);
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   172
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   173
static void PrintShaderData(LPDWORD shader_data, DWORD shader_size)
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   174
{
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   175
    OutputDebugStringA("const DWORD shader_data[] = {\n\t");
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   176
    {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   177
        SDL_bool newline = SDL_FALSE;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   178
        unsigned i;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   179
        for (i = 0; i < shader_size / sizeof(DWORD); ++i) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   180
            char dword[11];
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   181
            if (i > 0) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   182
                if ((i%6) == 0) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   183
                    newline = SDL_TRUE;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   184
                }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   185
                if (newline) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   186
                    OutputDebugStringA(",\n    ");
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   187
                    newline = SDL_FALSE;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   188
                } else {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   189
                    OutputDebugStringA(", ");
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   190
                }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   191
            }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   192
            SDL_snprintf(dword, sizeof(dword), "0x%8.8x", shader_data[i]);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   193
            OutputDebugStringA(dword);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   194
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   195
        OutputDebugStringA("\n};\n");
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   196
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   197
}
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   198
3556
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   199
#endif /* ASSEMBLE_SHADER */
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   200
9c2e92de786a Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents: 3553
diff changeset
   201
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
/* Direct3D renderer implementation */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   204
static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   205
static void D3D_WindowEvent(SDL_Renderer * renderer,
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   206
                            const SDL_WindowEvent *event);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   207
static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   208
static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   209
                             const SDL_Rect * rect, const void *pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   210
                             int pitch);
7761
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   211
static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   212
                                const SDL_Rect * rect,
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   213
                                const Uint8 *Yplane, int Ypitch,
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   214
                                const Uint8 *Uplane, int Upitch,
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   215
                                const Uint8 *Vplane, int Vpitch);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   216
static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   217
                           const SDL_Rect * rect, void **pixels, int *pitch);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   218
static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6247
b6212690f78d Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents: 6246
diff changeset
   219
static int D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   220
static int D3D_UpdateViewport(SDL_Renderer * renderer);
7141
e276777b4247 First pass on SDL render clip rect functionality
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   221
static int D3D_UpdateClipRect(SDL_Renderer * renderer);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   222
static int D3D_RenderClear(SDL_Renderer * renderer);
3599
0f958e527e5e Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 3556
diff changeset
   223
static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
6528
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   224
                                const SDL_FPoint * points, int count);
3599
0f958e527e5e Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 3556
diff changeset
   225
static int D3D_RenderDrawLines(SDL_Renderer * renderer,
6528
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   226
                               const SDL_FPoint * points, int count);
3599
0f958e527e5e Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 3556
diff changeset
   227
static int D3D_RenderFillRects(SDL_Renderer * renderer,
6528
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   228
                               const SDL_FRect * rects, int count);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   229
static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
6528
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   230
                          const SDL_Rect * srcrect, const SDL_FRect * dstrect);
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   231
static int D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
6528
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   232
                          const SDL_Rect * srcrect, const SDL_FRect * dstrect,
e978048ced60 Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents: 6404
diff changeset
   233
                          const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
3427
36cf454ba065 Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents: 3279
diff changeset
   234
static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
3480
cd763d104465 The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents: 3427
diff changeset
   235
                                Uint32 format, void * pixels, int pitch);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   236
static void D3D_RenderPresent(SDL_Renderer * renderer);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   237
static void D3D_DestroyTexture(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   238
                               SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   239
static void D3D_DestroyRenderer(SDL_Renderer * renderer);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   242
SDL_RenderDriver D3D_RenderDriver = {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   243
    D3D_CreateRenderer,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
    {
5186
97d0480b420c Updated the name of the Direct3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5184
diff changeset
   245
     "direct3d",
6237
240f1bced46b Added a renderer flag to expose whether a renderer supports render to texture.
Sam Lantinga <slouken@libsdl.org>
parents: 6236
diff changeset
   246
     (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   247
     1,
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   248
     {SDL_PIXELFORMAT_ARGB8888},
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
     0,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
     0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
};
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
typedef struct
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
{
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   255
    void* d3dDLL;
2973
ab0c00f1b070 Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents: 2972
diff changeset
   256
    IDirect3D9 *d3d;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    IDirect3DDevice9 *device;
3527
444cb12cadb6 Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
   258
    UINT adapter;
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   259
    D3DPRESENT_PARAMETERS pparams;
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   260
    SDL_bool updateSize;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   261
    SDL_bool beginScene;
7502
6ff02ff3cf06 Updated blend semantics so blending uses the following formula:
Sam Lantinga <slouken@libsdl.org>
parents: 7472
diff changeset
   262
    SDL_bool enableSeparateAlphaBlend;
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   263
    D3DTEXTUREFILTERTYPE scaleMode[8];
6232
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   264
    IDirect3DSurface9 *defaultRenderTarget;
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   265
    IDirect3DSurface9 *currentRenderTarget;
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   266
    void* d3dxDLL;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   267
    ID3DXMatrixStack *matrixStack;
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   268
    LPDIRECT3DPIXELSHADER9 ps_yuv;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   269
} D3D_RenderData;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
typedef struct
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
{
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   273
    IDirect3DTexture9 *texture;
5484
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   274
    D3DTEXTUREFILTERTYPE scaleMode;
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   275
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   276
    /* YV12 texture support */
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   277
    SDL_bool yuv;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   278
    IDirect3DTexture9 *utexture;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   279
    IDirect3DTexture9 *vtexture;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   280
    Uint8 *pixels;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   281
    int pitch;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   282
    SDL_Rect locked_rect;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   283
} D3D_TextureData;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   285
typedef struct
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   286
{
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   287
    float x, y, z;
1987
36a08379b3f2 Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
   288
    DWORD color;
1904
1a713f9d1f71 Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents: 1903
diff changeset
   289
    float u, v;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   290
} Vertex;
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   291
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   292
static int
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   293
D3D_SetError(const char *prefix, HRESULT result)
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   294
{
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   295
    const char *error;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   296
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   297
    switch (result) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   298
    case D3DERR_WRONGTEXTUREFORMAT:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   299
        error = "WRONGTEXTUREFORMAT";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   300
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   301
    case D3DERR_UNSUPPORTEDCOLOROPERATION:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   302
        error = "UNSUPPORTEDCOLOROPERATION";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   303
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   304
    case D3DERR_UNSUPPORTEDCOLORARG:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   305
        error = "UNSUPPORTEDCOLORARG";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   306
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   307
    case D3DERR_UNSUPPORTEDALPHAOPERATION:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   308
        error = "UNSUPPORTEDALPHAOPERATION";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   309
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   310
    case D3DERR_UNSUPPORTEDALPHAARG:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   311
        error = "UNSUPPORTEDALPHAARG";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   312
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   313
    case D3DERR_TOOMANYOPERATIONS:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   314
        error = "TOOMANYOPERATIONS";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   315
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   316
    case D3DERR_CONFLICTINGTEXTUREFILTER:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   317
        error = "CONFLICTINGTEXTUREFILTER";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   318
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   319
    case D3DERR_UNSUPPORTEDFACTORVALUE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   320
        error = "UNSUPPORTEDFACTORVALUE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   321
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   322
    case D3DERR_CONFLICTINGRENDERSTATE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   323
        error = "CONFLICTINGRENDERSTATE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   324
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   325
    case D3DERR_UNSUPPORTEDTEXTUREFILTER:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   326
        error = "UNSUPPORTEDTEXTUREFILTER";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   327
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   328
    case D3DERR_CONFLICTINGTEXTUREPALETTE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   329
        error = "CONFLICTINGTEXTUREPALETTE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   330
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   331
    case D3DERR_DRIVERINTERNALERROR:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   332
        error = "DRIVERINTERNALERROR";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   333
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   334
    case D3DERR_NOTFOUND:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   335
        error = "NOTFOUND";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   336
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   337
    case D3DERR_MOREDATA:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   338
        error = "MOREDATA";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   339
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   340
    case D3DERR_DEVICELOST:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   341
        error = "DEVICELOST";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   342
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   343
    case D3DERR_DEVICENOTRESET:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   344
        error = "DEVICENOTRESET";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   345
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   346
    case D3DERR_NOTAVAILABLE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   347
        error = "NOTAVAILABLE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   348
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   349
    case D3DERR_OUTOFVIDEOMEMORY:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   350
        error = "OUTOFVIDEOMEMORY";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   351
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   352
    case D3DERR_INVALIDDEVICE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   353
        error = "INVALIDDEVICE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   354
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   355
    case D3DERR_INVALIDCALL:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   356
        error = "INVALIDCALL";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   357
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   358
    case D3DERR_DRIVERINVALIDCALL:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   359
        error = "DRIVERINVALIDCALL";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   360
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   361
    case D3DERR_WASSTILLDRAWING:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   362
        error = "WASSTILLDRAWING";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   363
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   364
    default:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   365
        error = "UNKNOWN";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   366
        break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   367
    }
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   368
    return SDL_SetError("%s: %s", prefix, error);
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   369
}
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   370
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   371
static D3DFORMAT
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   372
PixelFormatToD3DFMT(Uint32 format)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
{
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   374
    switch (format) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1925
diff changeset
   375
    case SDL_PIXELFORMAT_RGB565:
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   376
        return D3DFMT_R5G6B5;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1925
diff changeset
   377
    case SDL_PIXELFORMAT_RGB888:
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   378
        return D3DFMT_X8R8G8B8;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1925
diff changeset
   379
    case SDL_PIXELFORMAT_ARGB8888:
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   380
        return D3DFMT_A8R8G8B8;
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   381
    case SDL_PIXELFORMAT_YV12:
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   382
    case SDL_PIXELFORMAT_IYUV:
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   383
        return D3DFMT_L8;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   384
    default:
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   385
        return D3DFMT_UNKNOWN;
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   386
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   389
static Uint32
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   390
D3DFMTToPixelFormat(D3DFORMAT format)
2973
ab0c00f1b070 Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents: 2972
diff changeset
   391
{
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   392
    switch (format) {
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   393
    case D3DFMT_R5G6B5:
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   394
        return SDL_PIXELFORMAT_RGB565;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   395
    case D3DFMT_X8R8G8B8:
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   396
        return SDL_PIXELFORMAT_RGB888;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   397
    case D3DFMT_A8R8G8B8:
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   398
        return SDL_PIXELFORMAT_ARGB8888;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   399
    default:
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   400
        return SDL_PIXELFORMAT_UNKNOWN;
2973
ab0c00f1b070 Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents: 2972
diff changeset
   401
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
7648
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   404
static void
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   405
D3D_InitRenderState(D3D_RenderData *data)
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   406
{
7651
e36a26e969c7 Fixed Windows build
Sam Lantinga <slouken@libsdl.org>
parents: 7648
diff changeset
   407
    D3DMATRIX matrix;
e36a26e969c7 Fixed Windows build
Sam Lantinga <slouken@libsdl.org>
parents: 7648
diff changeset
   408
e36a26e969c7 Fixed Windows build
Sam Lantinga <slouken@libsdl.org>
parents: 7648
diff changeset
   409
    IDirect3DDevice9 *device = data->device;
7648
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   410
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   411
    IDirect3DDevice9_SetVertexShader(device, NULL);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   412
    IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   413
    IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   414
    IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   415
    IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   416
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   417
    /* Enable color modulation by diffuse color */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   418
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   419
                                          D3DTOP_MODULATE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   420
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   421
                                          D3DTA_TEXTURE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   422
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   423
                                          D3DTA_DIFFUSE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   424
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   425
    /* Enable alpha modulation by diffuse alpha */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   426
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   427
                                          D3DTOP_MODULATE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   428
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   429
                                          D3DTA_TEXTURE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   430
    IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   431
                                          D3DTA_DIFFUSE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   432
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   433
    /* Enable separate alpha blend function, if possible */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   434
    if (data->enableSeparateAlphaBlend) {
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   435
        IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE, TRUE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   436
    }
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   437
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   438
    /* Disable second texture stage, since we're done */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   439
    IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   440
                                          D3DTOP_DISABLE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   441
    IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP,
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   442
                                          D3DTOP_DISABLE);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   443
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   444
    /* Set an identity world and view matrix */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   445
    matrix.m[0][0] = 1.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   446
    matrix.m[0][1] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   447
    matrix.m[0][2] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   448
    matrix.m[0][3] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   449
    matrix.m[1][0] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   450
    matrix.m[1][1] = 1.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   451
    matrix.m[1][2] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   452
    matrix.m[1][3] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   453
    matrix.m[2][0] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   454
    matrix.m[2][1] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   455
    matrix.m[2][2] = 1.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   456
    matrix.m[2][3] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   457
    matrix.m[3][0] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   458
    matrix.m[3][1] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   459
    matrix.m[3][2] = 0.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   460
    matrix.m[3][3] = 1.0f;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   461
    IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   462
    IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix);
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   463
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   464
    /* Reset our current scale mode */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   465
    SDL_memset(data->scaleMode, 0xFF, sizeof(data->scaleMode));
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   466
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   467
    /* Start the render with beginScene */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   468
    data->beginScene = SDL_TRUE;
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   469
}
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   470
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   471
static int
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   472
D3D_Reset(SDL_Renderer * renderer)
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   473
{
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   474
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   475
    HRESULT result;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   476
6860
c16fc4e46ae5 Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents: 6782
diff changeset
   477
    /* Release the default render target before reset */
6895
031a1fd143ec Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   478
    if (data->defaultRenderTarget) {
031a1fd143ec Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   479
        IDirect3DSurface9_Release(data->defaultRenderTarget);
031a1fd143ec Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   480
        data->defaultRenderTarget = NULL;
031a1fd143ec Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
   481
    }
6860
c16fc4e46ae5 Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents: 6782
diff changeset
   482
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   483
    result = IDirect3DDevice9_Reset(data->device, &data->pparams);
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   484
    if (FAILED(result)) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   485
        if (result == D3DERR_DEVICELOST) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   486
            /* Don't worry about it, we'll reset later... */
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   487
            return 0;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   488
        } else {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   489
            return D3D_SetError("Reset()", result);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   490
        }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   491
    }
7648
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   492
6860
c16fc4e46ae5 Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents: 6782
diff changeset
   493
    IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
7648
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   494
    D3D_InitRenderState(data);
7586
6f1539dc6b57 Reset the viewport when we reset the other D3D state.
Sam Lantinga <slouken@libsdl.org>
parents: 7577
diff changeset
   495
    D3D_UpdateViewport(renderer);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   496
    return 0;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   497
}
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   498
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   499
static int
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   500
D3D_ActivateRenderer(SDL_Renderer * renderer)
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   501
{
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   502
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   503
    HRESULT result;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   504
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   505
    if (data->updateSize) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   506
        SDL_Window *window = renderer->window;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   507
        int w, h;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   508
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   509
        SDL_GetWindowSize(window, &w, &h);
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   510
        data->pparams.BackBufferWidth = w;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   511
        data->pparams.BackBufferHeight = h;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   512
        if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   513
            data->pparams.BackBufferFormat =
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   514
                PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window));
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   515
        } else {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   516
            data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   517
        }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   518
        if (D3D_Reset(renderer) < 0) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   519
            return -1;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   520
        }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   521
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   522
        data->updateSize = SDL_FALSE;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   523
    }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   524
    if (data->beginScene) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   525
        result = IDirect3DDevice9_BeginScene(data->device);
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   526
        if (result == D3DERR_DEVICELOST) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   527
            if (D3D_Reset(renderer) < 0) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   528
                return -1;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   529
            }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   530
            result = IDirect3DDevice9_BeginScene(data->device);
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   531
        }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   532
        if (FAILED(result)) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   533
            return D3D_SetError("BeginScene()", result);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   534
        }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   535
        data->beginScene = SDL_FALSE;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   536
    }
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   537
    return 0;
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   538
}
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   539
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   540
SDL_Renderer *
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   541
D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   542
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   543
    SDL_Renderer *renderer;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   544
    D3D_RenderData *data;
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   545
    SDL_SysWMinfo windowinfo;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   546
    HRESULT result;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   547
    D3DPRESENT_PARAMETERS pparams;
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   548
    IDirect3DSwapChain9 *chain;
1925
411bfb37082b Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
   549
    D3DCAPS9 caps;
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   550
    Uint32 window_flags;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   551
    int w, h;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   552
    SDL_DisplayMode fullscreen_mode;
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   553
    int d3dxVersion;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   554
    char d3dxDLLFile[50];
7742
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   555
	int displayIndex;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   556
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
   557
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
    if (!renderer) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
        SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
        return NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
   563
    data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
    if (!data) {
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   565
        SDL_free(renderer);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   566
        SDL_OutOfMemory();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
        return NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
    }
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   569
7742
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   570
	if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) {
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   571
        for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) {
6971
5ded971ee761 Fixed compile errors on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6968
diff changeset
   572
            LPTSTR dllName;
5ded971ee761 Fixed compile errors on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6968
diff changeset
   573
            SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion);
5ded971ee761 Fixed compile errors on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6968
diff changeset
   574
            dllName = WIN_UTF8ToString(d3dxDLLFile);
5ded971ee761 Fixed compile errors on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6968
diff changeset
   575
            data->d3dxDLL = (void *)LoadLibrary(dllName); /* not using SDL_LoadObject() as we want silently fail - no error message */
5ded971ee761 Fixed compile errors on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 6968
diff changeset
   576
            SDL_free(dllName);
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   577
            if (data->d3dxDLL) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   578
                HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK*  ppStack);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   579
                D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack");
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   580
                if (D3DXCreateMatrixStack) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   581
                    D3DXCreateMatrixStack(0, &data->matrixStack);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   582
                    break;
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   583
                }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   584
            }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   585
        }
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   586
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   587
        if (!data->matrixStack) {
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   588
            if (data->d3dxDLL) SDL_UnloadObject(data->d3dxDLL);
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   589
        }
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   590
    }
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   591
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   592
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   593
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   594
    if (!data->d3d || !data->matrixStack) {
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   595
        SDL_free(renderer);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   596
        SDL_free(data);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   597
        SDL_SetError("Unable to create Direct3D interface");
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   598
        return NULL;
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   599
    }
4569
e1664f94f026 Andrey A.
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
   600
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   601
    renderer->WindowEvent = D3D_WindowEvent;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   602
    renderer->CreateTexture = D3D_CreateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   603
    renderer->UpdateTexture = D3D_UpdateTexture;
7761
bddbfca922cd Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga <slouken@libsdl.org>
parents: 7756
diff changeset
   604
	renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   605
    renderer->LockTexture = D3D_LockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   606
    renderer->UnlockTexture = D3D_UnlockTexture;
6247
b6212690f78d Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents: 6246
diff changeset
   607
    renderer->SetRenderTarget = D3D_SetRenderTarget;
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   608
    renderer->UpdateViewport = D3D_UpdateViewport;
7141
e276777b4247 First pass on SDL render clip rect functionality
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   609
    renderer->UpdateClipRect = D3D_UpdateClipRect;
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   610
    renderer->RenderClear = D3D_RenderClear;
3599
0f958e527e5e Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 3556
diff changeset
   611
    renderer->RenderDrawPoints = D3D_RenderDrawPoints;
0f958e527e5e Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 3556
diff changeset
   612
    renderer->RenderDrawLines = D3D_RenderDrawLines;
3675
e86edac50872 Fixed bug #932
Sam Lantinga <slouken@libsdl.org>
parents: 3599
diff changeset
   613
    renderer->RenderFillRects = D3D_RenderFillRects;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   614
    renderer->RenderCopy = D3D_RenderCopy;
6320
6077a1310907 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 6247
diff changeset
   615
    renderer->RenderCopyEx = D3D_RenderCopyEx;
3427
36cf454ba065 Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents: 3279
diff changeset
   616
    renderer->RenderReadPixels = D3D_RenderReadPixels;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   617
    renderer->RenderPresent = D3D_RenderPresent;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   618
    renderer->DestroyTexture = D3D_DestroyTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   619
    renderer->DestroyRenderer = D3D_DestroyRenderer;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   620
    renderer->info = D3D_RenderDriver.info;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
    renderer->driverdata = data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
6246
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   623
    renderer->info.flags = SDL_RENDERER_ACCELERATED;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   625
    SDL_VERSION(&windowinfo.version);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   626
    SDL_GetWindowWMInfo(window, &windowinfo);
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   627
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   628
    window_flags = SDL_GetWindowFlags(window);
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   629
    SDL_GetWindowSize(window, &w, &h);
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   630
    SDL_GetWindowDisplayMode(window, &fullscreen_mode);
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   631
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   632
    SDL_zero(pparams);
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   633
    pparams.hDeviceWindow = windowinfo.info.win.window;
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   634
    pparams.BackBufferWidth = w;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   635
    pparams.BackBufferHeight = h;
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   636
    if (window_flags & SDL_WINDOW_FULLSCREEN) {
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   637
        pparams.BackBufferFormat =
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   638
            PixelFormatToD3DFMT(fullscreen_mode.format);
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   639
    } else {
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   640
        pparams.BackBufferFormat = D3DFMT_UNKNOWN;
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   641
    }
5142
c8e049de174c Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
   642
    pparams.BackBufferCount = 1;
c8e049de174c Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
   643
    pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
c8e049de174c Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
   644
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   645
    if (window_flags & SDL_WINDOW_FULLSCREEN) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   646
        if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP )  {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   647
            pparams.Windowed = TRUE;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   648
            pparams.FullScreen_RefreshRateInHz = 0;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   649
        } else {
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   650
        pparams.Windowed = FALSE;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   651
        pparams.FullScreen_RefreshRateInHz =
5156
307ccc9c135e Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5154
diff changeset
   652
            fullscreen_mode.refresh_rate;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7183
diff changeset
   653
        }
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   654
    } else {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   655
        pparams.Windowed = TRUE;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   656
        pparams.FullScreen_RefreshRateInHz = 0;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   657
    }
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1925
diff changeset
   658
    if (flags & SDL_RENDERER_PRESENTVSYNC) {
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   659
        pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   660
    } else {
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   661
        pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   662
    }
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   663
7742
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   664
    /* Get the adapter for the display that the window is on */
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   665
	displayIndex = SDL_GetWindowDisplayIndex( window );
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   666
    data->adapter = SDL_Direct3D9GetAdapterIndex( displayIndex );
84e32c3d415c Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   667
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   668
    IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
3197
434ce3242e1c Alexei Tereschenko
Sam Lantinga <slouken@libsdl.org>
parents: 3013
diff changeset
   669
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   670
    result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   671
                                     D3DDEVTYPE_HAL,
5154
fb424691cfc7 Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents: 5149
diff changeset
   672
                                     pparams.hDeviceWindow,
6115
d4621a7e0faa Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Sam Lantinga <slouken@libsdl.org>
parents: 6076
diff changeset
   673
                                     D3DCREATE_FPU_PRESERVE | ((caps.
3197
434ce3242e1c Alexei Tereschenko
Sam Lantinga <slouken@libsdl.org>
parents: 3013
diff changeset
   674
                                      DevCaps &
434ce3242e1c Alexei Tereschenko
Sam Lantinga <slouken@libsdl.org>
parents: 3013
diff changeset
   675
                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
434ce3242e1c Alexei Tereschenko
Sam Lantinga <slouken@libsdl.org>
parents: 3013
diff changeset
   676
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
6115
d4621a7e0faa Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Sam Lantinga <slouken@libsdl.org>
parents: 6076
diff changeset
   677
                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING),
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   678
                                     &pparams, &data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   679
    if (FAILED(result)) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   680
        D3D_DestroyRenderer(renderer);
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   681
        D3D_SetError("CreateDevice()", result);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   682
        return NULL;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   683
    }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
   684
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   685
    /* Get presentation parameters to fill info */
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   686
    result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   687
    if (FAILED(result)) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   688
        D3D_DestroyRenderer(renderer);
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   689
        D3D_SetError("GetSwapChain()", result);
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   690
        return NULL;
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   691
    }
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   692
    result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   693
    if (FAILED(result)) {
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   694
        IDirect3DSwapChain9_Release(chain);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   695
        D3D_DestroyRenderer(renderer);
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   696
        D3D_SetError("GetPresentParameters()", result);
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   697
        return NULL;
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   698
    }
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   699
    IDirect3DSwapChain9_Release(chain);
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   700
    if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1925
diff changeset
   701
        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   702
    }
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   703
    data->pparams = pparams;
1907
06c27a737b7a Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1905
diff changeset
   704
1925
411bfb37082b Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
   705
    IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
411bfb37082b Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
   706
    renderer->info.max_texture_width = caps.MaxTextureWidth;
411bfb37082b Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
   707
    renderer->info.max_texture_height = caps.MaxTextureHeight;
6246
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   708
    if (caps.NumSimultaneousRTs >= 2) {
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   709
        renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   710
    }
1918
092bd3a019c5 Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents: 1917
diff changeset
   711
7502
6ff02ff3cf06 Updated blend semantics so blending uses the following formula:
Sam Lantinga <slouken@libsdl.org>
parents: 7472
diff changeset
   712
    if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND) {
6ff02ff3cf06 Updated blend semantics so blending uses the following formula:
Sam Lantinga <slouken@libsdl.org>
parents: 7472
diff changeset
   713
        data->enableSeparateAlphaBlend = SDL_TRUE;
6ff02ff3cf06 Updated blend semantics so blending uses the following formula:
Sam Lantinga <slouken@libsdl.org>
parents: 7472
diff changeset
   714
    }
6ff02ff3cf06 Updated blend semantics so blending uses the following formula:
Sam Lantinga <slouken@libsdl.org>
parents: 7472
diff changeset
   715
6232
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   716
    /* Store the default render target */
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   717
    IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget );
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   718
    data->currentRenderTarget = NULL;
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   719
7648
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   720
    /* Set up parameters for rendering */
297c43ff3d7e Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8.
Sam Lantinga <slouken@libsdl.org>
parents: 7586
diff changeset
   721
    D3D_InitRenderState(data);
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   722
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   723
    if (caps.MaxSimultaneousTextures >= 3)
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   724
    {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   725
#ifdef ASSEMBLE_SHADER
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   726
        /* This shader was created by running the following HLSL through the fxc compiler
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   727
           and then tuning the generated assembly.
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   728
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   729
           fxc /T fx_4_0 /O3 /Gfa /Fc yuv.fxc yuv.fx
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   730
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   731
           --- yuv.fx ---
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   732
           Texture2D g_txY;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   733
           Texture2D g_txU;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   734
           Texture2D g_txV;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   735
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   736
           SamplerState samLinear
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   737
           {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   738
               Filter = ANISOTROPIC;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   739
               AddressU = Clamp;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   740
               AddressV = Clamp;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   741
               MaxAnisotropy = 1;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   742
           };
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   743
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   744
           struct VS_OUTPUT
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   745
           {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   746
                float2 TextureUV  : TEXCOORD0;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   747
           };
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   748
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   749
           struct PS_OUTPUT
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   750
           {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   751
                float4 RGBAColor : SV_Target;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   752
           };
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   753
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   754
           PS_OUTPUT YUV420( VS_OUTPUT In ) 
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   755
           {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   756
               const float3 offset = {-0.0625, -0.5, -0.5};
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   757
               const float3 Rcoeff = {1.164,  0.000,  1.596};
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   758
               const float3 Gcoeff = {1.164, -0.391, -0.813};
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   759
               const float3 Bcoeff = {1.164,  2.018,  0.000};
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   760
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   761
               PS_OUTPUT Output;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   762
               float2 TextureUV = In.TextureUV;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   763
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   764
               float3 yuv;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   765
               yuv.x = g_txY.Sample( samLinear, TextureUV ).r;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   766
               yuv.y = g_txU.Sample( samLinear, TextureUV ).r;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   767
               yuv.z = g_txV.Sample( samLinear, TextureUV ).r;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   768
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   769
               yuv += offset;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   770
               Output.RGBAColor.r = dot(yuv, Rcoeff);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   771
               Output.RGBAColor.g = dot(yuv, Gcoeff);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   772
               Output.RGBAColor.b = dot(yuv, Bcoeff);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   773
               Output.RGBAColor.a = 1.0f;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   774
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   775
               return Output;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   776
           }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   777
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   778
           technique10 RenderYUV420
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   779
           {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   780
               pass P0
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   781
               {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   782
                    SetPixelShader( CompileShader( ps_4_0_level_9_0, YUV420() ) );
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   783
               }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   784
           }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   785
        */
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   786
        const char *shader_text =
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   787
            "ps_2_0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   788
            "def c0, -0.0625, -0.5, -0.5, 1\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   789
            "def c1, 1.16400003, 0, 1.59599996, 0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   790
            "def c2, 1.16400003, -0.391000003, -0.813000023, 0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   791
            "def c3, 1.16400003, 2.01799989, 0, 0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   792
            "dcl t0.xy\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   793
            "dcl v0.xyzw\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   794
            "dcl_2d s0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   795
            "dcl_2d s1\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   796
            "dcl_2d s2\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   797
            "texld r0, t0, s0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   798
            "texld r1, t0, s1\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   799
            "texld r2, t0, s2\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   800
            "mov r0.y, r1.x\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   801
            "mov r0.z, r2.x\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   802
            "add r0.xyz, r0, c0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   803
            "dp3 r1.x, r0, c1\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   804
            "dp3 r1.y, r0, c2\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   805
            "dp2add r1.z, r0, c3, c3.z\n"   /* Logically this is "dp3 r1.z, r0, c3" but the optimizer did its magic */
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   806
            "mov r1.w, c0.w\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   807
            "mul r0, r1, v0\n"              /* Not in the HLSL, multiply by vertex color */
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   808
            "mov oC0, r0\n"
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   809
        ;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   810
        LPD3DXBUFFER pCode;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   811
        LPD3DXBUFFER pErrorMsgs;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   812
        LPDWORD shader_data = NULL;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   813
        DWORD   shader_size = 0;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   814
        result = D3DXAssembleShader(shader_text, SDL_strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   815
        if (!FAILED(result)) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   816
            shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   817
            shader_size = pCode->lpVtbl->GetBufferSize(pCode);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   818
            PrintShaderData(shader_data, shader_size);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   819
        } else {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   820
            const char *error = (const char *)pErrorMsgs->lpVtbl->GetBufferPointer(pErrorMsgs);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   821
            SDL_SetError("Couldn't assemble shader: %s", error);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   822
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   823
#else
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   824
        const DWORD shader_data[] = {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   825
            0xffff0200, 0x05000051, 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   826
            0x3f800000, 0x05000051, 0xa00f0001, 0x3f94fdf4, 0x00000000, 0x3fcc49ba,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   827
            0x00000000, 0x05000051, 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   828
            0x00000000, 0x05000051, 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   829
            0x00000000, 0x0200001f, 0x80000000, 0xb0030000, 0x0200001f, 0x80000000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   830
            0x900f0000, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   831
            0xa00f0801, 0x0200001f, 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   832
            0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   833
            0x03000042, 0x800f0002, 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   834
            0x80000001, 0x02000001, 0x80040000, 0x80000002, 0x03000002, 0x80070000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   835
            0x80e40000, 0xa0e40000, 0x03000008, 0x80010001, 0x80e40000, 0xa0e40001,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   836
            0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   837
            0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   838
            0x03000005, 0x800f0000, 0x80e40001, 0x90e40000, 0x02000001, 0x800f0800,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   839
            0x80e40000, 0x0000ffff
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   840
        };
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   841
#endif
7547
abdea1385dbb Fixed compiler warning with gcc
Sam Lantinga <slouken@libsdl.org>
parents: 7505
diff changeset
   842
        if (shader_data != NULL) {
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   843
            result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_yuv);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   844
            if (!FAILED(result)) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   845
                renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   846
                renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   847
            } else {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   848
                D3D_SetError("CreatePixelShader()", result);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   849
            }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   850
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   851
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   852
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   853
    return renderer;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   854
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   855
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   856
static void
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   857
D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   858
{
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   859
    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   860
5297
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   861
    if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
1800dc39b74c Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   862
        data->updateSize = SDL_TRUE;
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   863
    }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   864
}
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   865
5484
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   866
static D3DTEXTUREFILTERTYPE
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   867
GetScaleQuality(void)
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   868
{
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   869
    const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   870
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   871
    if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   872
        return D3DTEXF_POINT;
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   873
    } else /* if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ {
5484
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   874
        return D3DTEXF_LINEAR;
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   875
    }
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   876
}
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   877
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   878
static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   879
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   880
{
6404
724e1fba7933 Whoops, removed wrong variable.
Ryan C. Gordon <icculus@icculus.org>
parents: 6403
diff changeset
   881
    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   882
    D3D_TextureData *data;
5173
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   883
    D3DPOOL pool;
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   884
    DWORD usage;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   885
    HRESULT result;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   886
1920
8a162bfdc838 Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents: 1918
diff changeset
   887
    data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   888
    if (!data) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   889
        return SDL_OutOfMemory();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   890
    }
5484
e20c93bc9122 Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents: 5299
diff changeset
   891
    data->scaleMode = GetScaleQuality();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   892
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   893
    texture->driverdata = data;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   894
5173
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   895
#ifdef USE_DYNAMIC_TEXTURE
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   896
    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   897
        pool = D3DPOOL_DEFAULT;
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   898
        usage = D3DUSAGE_DYNAMIC;
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   899
    } else
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   900
#endif
6232
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   901
    if (texture->access == SDL_TEXTUREACCESS_TARGET) {
6246
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   902
        /* D3DPOOL_MANAGED does not work with D3DUSAGE_RENDERTARGET */
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   903
        pool = D3DPOOL_DEFAULT;
6232
37e8d0736366 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   904
        usage = D3DUSAGE_RENDERTARGET;
6246
c70ec935a4bb Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents: 6242
diff changeset
   905
    } else {
5173
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   906
        pool = D3DPOOL_MANAGED;
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   907
        usage = 0;
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   908
    }
2973
ab0c00f1b070 Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents: 2972
diff changeset
   909
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   910
    result =
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   911
        IDirect3DDevice9_CreateTexture(renderdata->device, texture->w,
5173
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   912
                                       texture->h, 1, usage,
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   913
                                       PixelFormatToD3DFMT(texture->format),
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   914
                                       pool, &data->texture, NULL);
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   915
    if (FAILED(result)) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6971
diff changeset
   916
        return D3D_SetError("CreateTexture()", result);
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   917
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   918
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   919
    if (texture->format == SDL_PIXELFORMAT_YV12 ||
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   920
        texture->format == SDL_PIXELFORMAT_IYUV) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   921
        data->yuv = SDL_TRUE;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   922
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   923
        result =
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   924
            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w / 2,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   925
                                           texture->h / 2, 1, usage,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   926
                                           PixelFormatToD3DFMT(texture->format),
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   927
                                           pool, &data->utexture, NULL);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   928
        if (FAILED(result)) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   929
            return D3D_SetError("CreateTexture()", result);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   930
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   931
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   932
        result =
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   933
            IDirect3DDevice9_CreateTexture(renderdata->device, texture->w / 2,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   934
                                           texture->h / 2, 1, usage,
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   935
                                           PixelFormatToD3DFMT(texture->format),
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   936
                                           pool, &data->vtexture, NULL);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   937
        if (FAILED(result)) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   938
            return D3D_SetError("CreateTexture()", result);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   939
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   940
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   941
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   942
    return 0;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   943
}
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   944
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   945
static int
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   946
D3D_UpdateTextureInternal(IDirect3DTexture9 *texture, Uint32 format, SDL_bool full_texture, int x, int y, int w, int h, const void *pixels, int pitch)
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   947
{
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   948
    RECT d3drect;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   949
    D3DLOCKED_RECT locked;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   950
    const Uint8 *src;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   951
    Uint8 *dst;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   952
    int row, length;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   953
    HRESULT result;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   954
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   955
    if (full_texture) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   956
        result = IDirect3DTexture9_LockRect(texture, 0, &locked, NULL, D3DLOCK_DISCARD);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   957
    } else {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   958
        d3drect.left = x;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   959
        d3drect.right = x + w;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   960
        d3drect.top = y;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   961
        d3drect.bottom = y + h;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   962
        result = IDirect3DTexture9_LockRect(texture, 0, &locked, &d3drect, 0);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   963
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   964
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   965
    if (FAILED(result)) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   966
        return D3D_SetError("LockRect()", result);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   967
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   968
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   969
    src = (const Uint8 *)pixels;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   970
    dst = locked.pBits;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   971
    length = w * SDL_BYTESPERPIXEL(format);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   972
    if (length == pitch && length == locked.Pitch) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   973
        SDL_memcpy(dst, src, length*h);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   974
    } else {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   975
        for (row = 0; row < h; ++row) {
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   976
            SDL_memcpy(dst, src, length);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   977
            src += pitch;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   978
            dst += locked.Pitch;
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   979
        }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   980
    }
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   981
    IDirect3DTexture9_UnlockRect(texture, 0);
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   982
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   983
    return 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   984
}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   985
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   986
static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   987
D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   988
                  const SDL_Rect * rect, const void *pixels, int pitch)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   989
{
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   990
    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
7505
bc709c9493e7 Added Direct3D shader to hardware accelerate YV12 and IYUV textures.
Sam Lantinga <slouken@libsdl.org>
parents: 7502
diff changeset
   991
    SDL_bool full_texture = SDL_FALSE;
1903
f132024010be More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents: 1901
diff changeset
   992
5173
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   993
#ifdef USE_DYNAMIC_TEXTURE
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
   994
    if (texture->access == SDL_TEXTUREACCESS_STREAMING &&
ebfedf3787b1 Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff