JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
Dx9.h
Go to the documentation of this file.
1#pragma once
2
8#include "..\stdafx.h"
9
10#include "common++.h"
11
12#include <d3d9.h>
13#include <d3dx9.h>
14#include <dxerr.h>
15
16//
17#ifndef DIRECTINPUT_VERSION
18#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION // 0x0800
19#endif
20#include <dinput.h>
21
22#include "Gdata.h"
23
24
25//
26namespace jbxwl {
27
28
29extern LPDIRECT3D9 GpD3D;
30extern LPDIRECTINPUT8 GpDInput;
31
32extern LPDIRECTINPUTDEVICE8 GpDMouse; // マウスのインターフェイス
33extern LPDIRECTINPUTDEVICE8 GpDKeyBoard; // キーボードのインターフェイス
34
35extern BOOL Dx9DividePrimitiveMode;
36extern BOOL Dx9ReverseZMode;
37
38#define CDXRELEASE(d) if((d)!=NULL){while((d)->Release());(d)=NULL;} // 完全リーリス(つまり削除)
39#define DXRELEASE(d) if((d)!=NULL){(d)->Release();(d)=NULL;}
40
41#define DXMAXPRIMITIVE 32768
42
43
44BOOL Dx9CreateInterface(CWinApp* wapp);
46
47LPDIRECT3DDEVICE9 Dx9CreateGraphic(LPDIRECT3D9, D3DPRESENT_PARAMETERS*, HWND);
48LPDIRECTINPUTDEVICE8 Dx9CreateMouse(LPDIRECTINPUT8, HWND);
49LPDIRECTINPUTDEVICE8 Dx9CreateKeyBoard(LPDIRECTINPUT8, HWND);
50
51POINT Dx9GetBackBuffer(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9*);
52BOOL Dx9SurfaceFromMemory(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9*, CmnHead);
53BOOL Dx9TextureFromMemory(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9*, CmnHead);
54
55BOOL Dx9SurfaceFromByteMemory(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9*, CmnHead);
56BOOL Dx9SurfaceFromMemoryFile(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9*, CmnHead);
57BOOL Dx9TextureFromByteMemory(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9*, CmnHead);
58BOOL Dx9TextureFromMemoryFile(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9*, CmnHead);
59
60HRESULT Dx9DrawPrimitive(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, UINT, UINT);
61POINT Dx9GetSurfaceSize(LPDIRECT3DSURFACE9* lpsf);
62
63
64
65//
66inline D3DCOLOR Dx9Word2RGBA(uWord pp)
67{
68 int r, g, b, a;
69
70 if (isBigEndian) {
71 r = (int)((pp&0xf000)>>12);
72 g = (int)((pp&0x0f00)>>8);
73 b = (int)((pp&0x00f0)>>4);
74 a = (int) (pp&0x000f);
75 }
76 else {
77 b = (int)((pp&0xf000)>>12);
78 a = (int)((pp&0x0f00)>>8);
79 r = (int)((pp&0x00f0)>>4);
80 g = (int) (pp&0x000f);
81 }
82
83 return D3DCOLOR_RGBA(r*17, g*17, b*17, a*17);
84}
85
86
87//
88inline D3DCOLOR Dx9Word2ARGB(uWord pp)
89{
90 int r, g, b, a;
91
92 if (isBigEndian) {
93 a = (int)((pp&0xf000)>>12);
94 r = (int)((pp&0x0f00)>>8);
95 g = (int)((pp&0x00f0)>>4);
96 b = (int) (pp&0x000f);
97 }
98 else {
99 g = (int)((pp&0xf000)>>12);
100 b = (int)((pp&0x0f00)>>8);
101 a = (int)((pp&0x00f0)>>4);
102 r = (int) (pp&0x000f);
103 }
104
105 return D3DCOLOR_ARGB(a*17, r*17, g*17, b*17);
106}
107
108
109//
110inline D3DCOLOR Dx9Word2RGB(uWord pp)
111{
112 int r, g, b;
113
114 if (isLittleEndian) swap_byte(&pp, 2, 2);
115
116 r = (int)((pp&0xf800)>>11);
117 g = (int)((pp&0x07e0)>>5);
118 b = (int) (pp&0x001f);
119
120 return D3DCOLOR_XRGB((int)(r*8.23), (int)(g*4.05), (int)(b*8.23));
121}
122
123
124
134} // namespace
BOOL Dx9ReverseZMode
Definition Dx9.cpp:21
LPDIRECTINPUTDEVICE8 GpDMouse
Definition Dx9.cpp:16
BOOL Dx9SurfaceFromByteMemory(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *, CmnHead)
Definition Dx9.cpp:236
BOOL Dx9TextureFromMemoryFile(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9 *, CmnHead)
Definition Dx9.cpp:281
LPDIRECTINPUTDEVICE8 GpDKeyBoard
Definition Dx9.cpp:17
POINT Dx9GetSurfaceSize(LPDIRECT3DSURFACE9 *lpsf)
Definition Dx9.cpp:361
LPDIRECTINPUTDEVICE8 Dx9CreateKeyBoard(LPDIRECTINPUT8, HWND)
Definition Dx9.cpp:151
D3DCOLOR Dx9Word2RGB(uWord pp)
Definition Dx9.h:110
D3DCOLOR Dx9Word2ARGB(uWord pp)
Definition Dx9.h:88
HRESULT Dx9DrawPrimitive(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, UINT, UINT)
Definition Dx9.cpp:335
BOOL Dx9CreateInterface(CWinApp *wapp)
Definition Dx9.cpp:30
LPDIRECT3DDEVICE9 Dx9CreateGraphic(LPDIRECT3D9, D3DPRESENT_PARAMETERS *, HWND)
Definition Dx9.cpp:93
BOOL Dx9SurfaceFromMemoryFile(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *, CmnHead)
Definition Dx9.cpp:216
POINT Dx9GetBackBuffer(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *)
Definition Dx9.cpp:175
LPDIRECT3D9 GpD3D
Definition Dx9.cpp:13
LPDIRECTINPUT8 GpDInput
Definition Dx9.cpp:14
LPDIRECTINPUTDEVICE8 Dx9CreateMouse(LPDIRECTINPUT8, HWND)
Definition Dx9.cpp:114
BOOL Dx9SurfaceFromMemory(LPDIRECT3DDEVICE9, LPDIRECT3DSURFACE9 *, CmnHead)
Definition Dx9.cpp:198
BOOL Dx9TextureFromMemory(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9 *, CmnHead)
Definition Dx9.cpp:263
D3DCOLOR Dx9Word2RGBA(uWord pp)
Definition Dx9.h:66
void Dx9ReleaseInterface()
Definition Dx9.cpp:75
BOOL Dx9DividePrimitiveMode
Definition Dx9.cpp:20
BOOL Dx9TextureFromByteMemory(LPDIRECT3DDEVICE9, LPDIRECT3DTEXTURE9 *, CmnHead)
Definition Dx9.cpp:296