Skip to content

Commit

Permalink
Add DX related color conversion functions (#649)
Browse files Browse the repository at this point in the history
* Add DX related color conversion functions

* Remove blank lines and move functions to the top
  • Loading branch information
abhijeetbhagat authored and retep998 committed Jul 29, 2018
1 parent 11061cd commit 661685f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/shared/d3d9types.rs
Expand Up @@ -12,6 +12,35 @@ use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT, USHORT, WORD};
use shared::windef::HWND;
use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LONG, SHORT};
pub type D3DCOLOR = DWORD;
#[inline]
pub fn D3DCOLOR_ARGB(a: DWORD, r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR {
(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) as D3DCOLOR
}
#[inline]
pub fn D3DCOLOR_RGBA(r: DWORD, g: DWORD, b: DWORD, a: DWORD) -> D3DCOLOR {
D3DCOLOR_ARGB(a, r, g, b)
}
#[inline]
pub fn D3DCOLOR_XRGB(r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR {
D3DCOLOR_ARGB(0xff, r, g, b)
}
#[inline]
pub fn D3DCOLOR_XYUV(y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR {
D3DCOLOR_ARGB(0xff, y, u, v)
}
#[inline]
pub fn D3DCOLOR_AYUV(a: DWORD, y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR {
D3DCOLOR_ARGB(a, y, u, v)
}
#[inline]
pub fn D3DCOLOR_COLORVALUE(r: f32, g: f32, b: f32, a: f32) -> D3DCOLOR {
D3DCOLOR_ARGB(
(r * 255f32) as DWORD,
(g * 255f32) as DWORD,
(b * 255f32) as DWORD,
(a * 255f32) as DWORD,
)
}
STRUCT!{struct D3DVECTOR {
x: c_float,
y: c_float,
Expand Down

0 comments on commit 661685f

Please sign in to comment.