src/render/SDL_d3dmath.h
author Ryan C. Gordon <icculus@icculus.org>
Thu, 09 Apr 2015 22:33:39 -0400
branchiOS-improvements
changeset 9542 618662dc9e82
parent 8764 3d5ef7548688
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Closing the iOS-improvements branch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8599
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
  arising from the use of this software.
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
     appreciated but is not required.
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "../SDL_internal.h"
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
8764
3d5ef7548688 Fixes #2529, guard SDL_d3math.* with the proper defines
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8599
diff changeset
    23
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
8599
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
/* Direct3D matrix math functions */
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
typedef struct
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
{
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
    float x;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
    float y;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
} Float2;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
typedef struct
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
{
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    float x;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    float y;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    float z;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
} Float3;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
typedef struct
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
{
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    float x;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    float y;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    float z;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
    float w;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
} Float4;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
typedef struct
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
{
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
    union {
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
        struct {
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
            float _11, _12, _13, _14;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
            float _21, _22, _23, _24;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
            float _31, _32, _33, _34;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
            float _41, _42, _43, _44;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
        };
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
        float m[4][4];
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    };
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
} Float4X4;
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
Float4X4 MatrixIdentity();
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
Float4X4 MatrixScaling(float x, float y, float z);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
Float4X4 MatrixTranslation(float x, float y, float z);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
Float4X4 MatrixRotationX(float r);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
Float4X4 MatrixRotationY(float r);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
Float4X4 MatrixRotationZ(float r);
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
8764
3d5ef7548688 Fixes #2529, guard SDL_d3math.* with the proper defines
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8599
diff changeset
    70
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
3d5ef7548688 Fixes #2529, guard SDL_d3math.* with the proper defines
Gabriel Jacobo <gabomdq@gmail.com>
parents: 8599
diff changeset
    71
8599
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
/* vi: set ts=4 sw=4 expandtab: */