jdk/src/windows/native/sun/java2d/d3d/D3DUtils.h
author ohair
Fri, 08 Aug 2008 08:52:18 -0700
changeset 921 85b4d3bded64
parent 2 90ce3da70b43
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef D3DUTILS_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define D3DUTILS_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "D3DContext.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
// - Types and macros used in SelectDeviceGUID -----------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
// Indexes for the rasterizers:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
// TNL, HAL, REF, RGB
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#define TNL_IDX (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define HAL_IDX (1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define REF_IDX (2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define RGB_IDX (3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define DEV_IDX_MAX (RGB_IDX+1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    const GUID *pGUIDs[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
} DEVICES_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
// - Utility funcions for dealing with pixel formats ----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
const GUID *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
D3DUtils_SelectDeviceGUID(IDirect3D7 *d3dObject);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
D3DUtils_FindDepthBufferFormat(IDirect3D7 *d3dObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                               int preferredDepth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                               DDPIXELFORMAT* pddpf,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
                               const GUID *pDeviceGUID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
D3DUtils_FindMaskTileTextureFormat(IDirect3DDevice7 *d3dDevice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                   DDPIXELFORMAT* pddpf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
D3DUtils_SetupTextureFormats(IDirect3DDevice7 *d3dDevice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                             D3DTextureTable &table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
// - Utility funcions for working with matricies ---------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
D3DUtils_SetIdentityMatrix(D3DMATRIX *m, BOOL adjust = TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
D3DUtils_SetOrthoMatrixOffCenterLH(D3DMATRIX *m,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                   float width, float height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
DDrawSurface *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
D3DUtils_CreatePlainSurface(JNIEnv *env, DDraw *ddObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                            D3DContext *d3dContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                            int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
DDrawSurface *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
D3DUtils_CreateTexture(JNIEnv *env, DDraw *ddObject,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                       D3DContext *d3dContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                       int transparency,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                       int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
D3DUtils_UploadIntImageToXRGBTexture(DDrawSurface *lpTexture,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                                     int *pSrc, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
// - Utility functions for checking various capabilities of the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
D3DUtils_CheckD3DCaps(LPD3DDEVICEDESC7 lpDesc7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
D3DUtils_CheckDepthCaps(LPD3DDEVICEDESC7 lpDesc7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
D3DUtils_CheckTextureCaps(LPD3DDEVICEDESC7 lpDesc7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
HRESULT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
D3DUtils_CheckDeviceCaps(LPD3DDEVICEDESC7 lpDesc7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
// - Utility macros error handling of d3d operations -----------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
/*  #define NO_D3D_CHECKING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#ifdef NO_D3D_CHECKING
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define D3DU_PRIM_LOOP_BEGIN(RES, DST_WSDO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
#define D3DU_PRIM2_LOOP_BEGIN(RES, SRC_WSDO, DST_WSDO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
#define D3DU_PRIM_LOOP_END(ENV, RES, DST_WSDO, PRIM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#define D3DU_PRIM2_LOOP_END(ENV, RES, SRC_WSDO, DST_WSDO, PRIM)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#else /* NO_D3D_CHECKING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#ifndef MAX_BUSY_ATTEMPTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
  #define MAX_BUSY_ATTEMPTS 50  // Arbitrary number of times to attempt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#define D3DU_PRIM_LOOP_BEGIN(RES, DST_WSDO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    int attempts = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    while (attempts++ < MAX_BUSY_ATTEMPTS) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (FAILED((DST_WSDO)->lpSurface->IsLost())) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            RES = DDERR_SURFACELOST; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#define D3DU_PRIM2_LOOP_BEGIN(RES, SRC_WSDO, DST_WSDO) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    int attempts = 0; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    while (attempts++ < MAX_BUSY_ATTEMPTS) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (FAILED((DST_WSDO)->lpSurface->IsLost()) || \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            FAILED((SRC_WSDO)->lpSurface->IsLost())) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            RES = DDERR_SURFACELOST; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
#define D3DU_PRIM_LOOP_END(ENV, RES, DST_WSDO, PRIM) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        if (SUCCEEDED(RES)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } else if (RES == DDERR_SURFACEBUSY || RES == DDERR_WASSTILLDRAWING) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            J2dTraceLn(J2D_TRACE_VERBOSE, #PRIM ## ": surface is busy."); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        } else if (RES == DDERR_SURFACELOST) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            J2dTraceLn(J2D_TRACE_INFO, #PRIM ## ": dest surface lost."); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            DST_WSDO->RestoreSurface(ENV, DST_WSDO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            DebugPrintDirectDrawError(RES, #PRIM); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
#define D3DU_PRIM2_LOOP_END(ENV, RES, SRC_WSDO, DST_WSDO, PRIM) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (SUCCEEDED(RES)) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        } else if (RES == DDERR_SURFACEBUSY || RES == DDERR_WASSTILLDRAWING) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            J2dTraceLn(J2D_TRACE_VERBOSE, #PRIM ## ": surface is busy."); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            continue; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        } else if (RES == DDERR_SURFACELOST) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            if (FAILED((DST_WSDO)->lpSurface->IsLost())) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                J2dTraceLn(J2D_TRACE_INFO, #PRIM ## ": dst surface lost."); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                (DST_WSDO)->RestoreSurface(ENV, (DST_WSDO)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            if (FAILED((SRC_WSDO)->lpSurface->IsLost())) { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                J2dTraceLn(J2D_TRACE_INFO, #PRIM ## ": src surface lost."); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                (SRC_WSDO)->RestoreSurface(ENV, (SRC_WSDO)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            break; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } else { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            DebugPrintDirectDrawError(RES, #PRIM); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     } \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
#endif /* NO_D3D_CHECKING */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
// - Utility macros for initializing vertex structures ---------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
#define D3D_EXEC_PRIM_LOOP(ENV, RES, DST_WSDO, PRIM) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
  D3DU_PRIM_LOOP_BEGIN(RES, DST_WSDO); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  RES = (PRIM); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
  D3DU_PRIM_LOOP_END(ENV, RES, DST_WSDO, PRIM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#define D3DU_INIT_VERTEX_PENT_XY(VQUAD, X1, Y1, X2, Y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    D3DU_INIT_VERTEX_QUAD_XY(VQUAD, X1, Y1, X2, Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    (VQUAD)[4].x = (X1); (VQUAD)[4].y = (Y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
#define D3DU_INIT_VERTEX_PENT_COLOR(VQUAD, VCOLOR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    D3DU_INIT_VERTEX_QUAD_COLOR(VQUAD, VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    (VQUAD)[4].color = (VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
#define D3DU_INIT_VERTEX_QUAD_XY(VQUAD, X1, Y1, X2, Y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    (VQUAD)[0].x = (X1); (VQUAD)[0].y = (Y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    (VQUAD)[1].x = (X2); (VQUAD)[1].y = (Y1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    (VQUAD)[2].x = (X2); (VQUAD)[2].y = (Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    (VQUAD)[3].x = (X1); (VQUAD)[3].y = (Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
#define D3DU_INIT_VERTEX_QUAD_XYZ(VQUAD, X1, Y1, X2, Y2, Z) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    D3DU_INIT_VERTEX_QUAD_XY(VQUAD, X1, Y1, X2, Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    (VQUAD)[0].z = (Z); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    (VQUAD)[1].z = (Z); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    (VQUAD)[2].z = (Z); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    (VQUAD)[3].z = (Z); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
#define D3DU_INIT_VERTEX_QUAD_COLOR(VQUAD, VCOLOR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    (VQUAD)[0].color = (VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    (VQUAD)[1].color = (VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    (VQUAD)[2].color = (VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    (VQUAD)[3].color = (VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
#define D3DU_INIT_VERTEX_QUAD_UV(VQUAD, TU1, TV1, TU2, TV2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    (VQUAD)[0].tu = (TU1);  (VQUAD)[0].tv = (TV1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    (VQUAD)[1].tu = (TU2);  (VQUAD)[1].tv = (TV1); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    (VQUAD)[2].tu = (TU2);  (VQUAD)[2].tv = (TV2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    (VQUAD)[3].tu = (TU1);  (VQUAD)[3].tv = (TV2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
#define D3DU_INIT_VERTEX_QUAD_XYUV(VQUAD, X1, Y1, X2, Y2, TU1, TV1, TU2, TV2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    D3DU_INIT_VERTEX_QUAD_XY(VQUAD, X1, Y1, X2, Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    D3DU_INIT_VERTEX_QUAD_UV(VQUAD, TU1, TV1, TU2, TV2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
#define D3DU_INIT_VERTEX_QUAD(VQUAD, X1, Y1, X2, Y2, VCOLOR, TU1, TV1, TU2, TV2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    D3DU_INIT_VERTEX_QUAD_XYUV(VQUAD, X1, Y1, X2, Y2, TU1, TV1, TU2, TV2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    D3DU_INIT_VERTEX_QUAD_COLOR(VQUAD, VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
#define D3DU_INIT_VERTEX_6(VQUAD, X1, Y1, X2, Y2, VCOLOR, TU1, TV1, TU2, TV2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    D3DU_INIT_VERTEX_XY_6(VHEX, X1, Y1, X2, Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    D3DU_INIT_VERTEX_UV_6(VHEX, TU1, TV1, TU2, TV2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    D3DU_INIT_VERTEX_COLOR_6(VHEX, VCOLOR); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
#define D3DU_INIT_VERTEX_UV_6(VHEX, TU1, TV1, TU2, TV2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    (VHEX)[0].tu = TU1;  (VHEX)[0].tv = TV1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    (VHEX)[1].tu = TU2;  (VHEX)[1].tv = TV1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    (VHEX)[2].tu = TU1;  (VHEX)[2].tv = TV2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    (VHEX)[3].tu = TU1;  (VHEX)[3].tv = TV2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    (VHEX)[4].tu = TU2;  (VHEX)[4].tv = TV1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    (VHEX)[5].tu = TU2;  (VHEX)[5].tv = TV2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
#define D3DU_INIT_VERTEX_COLOR_6(VHEX, VCOLOR) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    (VHEX)[0].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    (VHEX)[1].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    (VHEX)[2].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    (VHEX)[3].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    (VHEX)[4].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    (VHEX)[5].color = VCOLOR; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
#define D3DU_INIT_VERTEX_XY_6(VHEX, X1, Y1, X2, Y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    (VHEX)[0].x = X1;  (VHEX)[0].y = Y1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    (VHEX)[1].x = X2;  (VHEX)[1].y = Y1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    (VHEX)[2].x = X1;  (VHEX)[2].y = Y2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    (VHEX)[3].x = X1;  (VHEX)[3].y = Y2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    (VHEX)[4].x = X2;  (VHEX)[4].y = Y1; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    (VHEX)[5].x = X2;  (VHEX)[5].y = Y2; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
#define D3DU_INIT_VERTEX_XYZ_6(VHEX, X1, Y1, X2, Y2, Z) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    D3DU_INIT_VERTEX_XY_6(VHEX, X1, Y1, X2, Y2); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    (VHEX)[0].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    (VHEX)[1].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    (VHEX)[2].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    (VHEX)[3].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    (VHEX)[4].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    (VHEX)[5].z = (Z);  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
#endif // D3DUTILS_H