00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 INLINE DWORD DXGraphicsStateGuardian8::
00023 LColor_to_D3DCOLOR(const LColor &cLColor) {
00024
00025 #if (defined(_M_IX86) || defined(_X86_)) && !defined(STDFLOAT_DOUBLE)
00026 DWORD d3dcolor, tempcolorval=255;
00027
00028
00029
00030
00031 __asm {
00032 push ebx ; want to save this in case this fn is inlined
00033 push ecx
00034 mov ecx, cLColor
00035 fild tempcolorval
00036 fld DWORD PTR [ecx]
00037 fmul ST(0), ST(1)
00038 fistp tempcolorval ; no way to store directly to int register
00039 mov eax, tempcolorval
00040 shl eax, 16
00041
00042 fld DWORD PTR [ecx+4] ;grn
00043 fmul ST(0), ST(1)
00044 fistp tempcolorval
00045 mov ebx, tempcolorval
00046 shl ebx, 8
00047 or eax, ebx
00048
00049 fld DWORD PTR [ecx+8] ;blue
00050 fmul ST(0), ST(1)
00051 fistp tempcolorval
00052 or eax, tempcolorval
00053
00054 fld DWORD PTR [ecx+12] ;alpha
00055 fmul ST(0), ST(1)
00056 fistp tempcolorval
00057 ; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
00058 ffree ST(0)
00059 fincstp
00060 mov ebx, tempcolorval
00061 shl ebx, 24
00062 or eax, ebx
00063 mov d3dcolor, eax
00064 pop ecx
00065 pop ebx
00066 }
00067
00068
00069 return d3dcolor;
00070 #else //!_X86_
00071 return MY_D3DRGBA(cLColor[0], cLColor[1], cLColor[2], cLColor[3]);
00072 #endif //!_X86_
00073 }
00074
00075
00076
00077
00078
00079
00080
00081 INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian8::
00082 get_texture_wrap_mode(Texture::WrapMode wm) {
00083 switch (wm) {
00084 case Texture::WM_clamp:
00085 return D3DTADDRESS_CLAMP;
00086 case Texture::WM_repeat:
00087 return D3DTADDRESS_WRAP;
00088 case Texture::WM_mirror:
00089 return D3DTADDRESS_MIRROR;
00090 case Texture::WM_mirror_once:
00091 return D3DTADDRESS_MIRRORONCE;
00092 case Texture::WM_border_color:
00093 return D3DTADDRESS_BORDER;
00094 }
00095 dxgsg8_cat.error() << "Invalid Texture::Mode value" << endl;
00096 return D3DTADDRESS_WRAP;
00097 }
00098
00099
00100
00101
00102
00103
00104 INLINE D3DFOGMODE DXGraphicsStateGuardian8::
00105 get_fog_mode_type(Fog::Mode m) {
00106 switch (m) {
00107 case Fog::M_linear:
00108 return D3DFOG_LINEAR;
00109 case Fog::M_exponential:
00110 return D3DFOG_EXP;
00111 case Fog::M_exponential_squared:
00112 return D3DFOG_EXP2;
00113 }
00114 dxgsg8_cat.error() << "Invalid Fog::Mode value" << endl;
00115 return D3DFOG_EXP;
00116 }
00117
00118
00119
00120
00121
00122
00123 INLINE D3DTRANSFORMSTATETYPE DXGraphicsStateGuardian8::
00124 get_tex_mat_sym(int stage_index) {
00125 return (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + stage_index);
00126 }
00127
00128
00129
00130
00131
00132
00133
00134 INLINE unsigned char *DXGraphicsStateGuardian8::
00135 get_safe_buffer_start() {
00136 if (_temp_buffer == NULL) {
00137
00138
00139
00140
00141 _temp_buffer = new unsigned char[0x1ffff];
00142 _safe_buffer_start = (unsigned char *)(((long)_temp_buffer + 0xffff) & ~0xffff);
00143 }
00144
00145 return _safe_buffer_start;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 INLINE bool DXGraphicsStateGuardian8::
00157 get_supports_render_texture() const {
00158 return _supports_render_texture;
00159 }