some changes to support reflection map and fixes a crash bug with windo/fullscreen mode switch

This commit is contained in:
Asad M. Zaman 2004-07-20 22:28:04 +00:00
parent e10c64cdb3
commit d582986396
10 changed files with 317 additions and 224 deletions

View File

@ -278,6 +278,8 @@ set_vertex_format(DWORD NewFvfType) {
if (_CurFVFType != NewFvfType) {
_CurFVFType = NewFvfType;
// dxgsg8_cat.info() << "current fvf " << _CurFVFType << endl;
HRESULT hr = _pD3DDevice->SetVertexShader(NewFvfType);
#ifndef NDEBUG
if(FAILED(hr)) {
@ -527,10 +529,26 @@ compute_distance_to(const LPoint3f &point) const {
////////////////////////////////////////////////////////////////////
INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian8::
get_texture_wrap_mode(Texture::WrapMode wm) const {
#if 0
static D3DTEXTUREADDRESS PandaTexWrapMode_to_D3DTexWrapMode[Texture::WM_invalid] = {
D3DTADDRESS_CLAMP,D3DTADDRESS_WRAP,D3DTADDRESS_MIRROR,D3DTADDRESS_MIRRORONCE,D3DTADDRESS_BORDER};
return PandaTexWrapMode_to_D3DTexWrapMode[wm];
#endif
switch (wm) {
case Texture::WM_clamp:
return D3DTADDRESS_CLAMP;
case Texture::WM_repeat:
return D3DTADDRESS_WRAP;
case Texture::WM_mirror:
return D3DTADDRESS_MIRROR;
case Texture::WM_mirror_once:
return D3DTADDRESS_MIRRORONCE;
case Texture::WM_border_color:
return D3DTADDRESS_BORDER;
}
dxgsg8_cat.error() << "Invalid Texture::Mode value" << endl;
return D3DTADDRESS_WRAP;
}
////////////////////////////////////////////////////////////////////

View File

@ -1264,6 +1264,7 @@ draw_prim_setup(const Geom *geom) {
vi = geom->make_vertex_iterator();
DWORD newFVFflags = D3DFVF_XYZ;
size_t vertex_size = sizeof(float) * 3;
GeomBindType ColorBinding=geom->get_binding(G_COLOR);
@ -1324,7 +1325,9 @@ draw_prim_setup(const Geom *geom) {
//////
ti = geom->make_texcoord_iterator();
newFVFflags |= (D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE2(0));
vertex_size += sizeof(float) * 2;
}
@ -3503,24 +3506,32 @@ issue_tex_gen(const TexGenAttrib *attrib) {
} else if (attrib->get_mode() == TexGenAttrib::M_spherical) {
#if 0
// best reflection on a sphere is achieved by camera space normals in directx
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACENORMAL);
// We have set up the texture matrix to scale and translate the
// texture coordinates to get from camera space (-1, +1) to
// texture space (0,1)
LMatrix4f dm(0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.5f, 0.5f, 0.0f, 0.0f);
_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT2);
#if 0
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACENORMAL);
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.0f, 1.0f);
#else
_pD3DDevice->SetRenderState(D3DRS_LOCALVIEWER, TRUE);
// since this is a reflection map, we want the camera space
// reflection vector. A close approximation of the asin(theta)/pi
// + 0.5 is achieved by the following matrix
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
LMatrix4f dm(0.33f, 0.0f, 0.0f, 0.0f,
0.0f, 0.33f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.0f, 1.0f);
#endif
_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT2);
//_pD3DDevice->SetRenderState(D3DRS_LOCALVIEWER, false);
}
}

View File

@ -151,7 +151,7 @@ typedef enum {
A8_FLAG = FLG(8),
A8R3G3B2_FLAG = FLG(9),
X4R4G4B4_FLAG = FLG(10),
A2B10G10R10_FLAG = FLG(11),
A2R10G10B10_FLAG = FLG(11),
G16R16_FLAG = FLG(12),
A8P8_FLAG = FLG(13),
P8_FLAG = FLG(14),

View File

@ -527,7 +527,6 @@ search_for_valid_displaymode(DXScreenData &scrn,
// if (_dxgsg->scrn.bIsLowVidMemCard)
// nassertv((RequestedX_Size==640)&&(RequestedY_Size==480));
#endif
*pSuggestedPixFmt = D3DFMT_UNKNOWN;
*pSupportedScreenDepthsMask = 0x0;
*pCouldntFindAnyValidZBuf = false;
@ -570,7 +569,8 @@ search_for_valid_displaymode(DXScreenData &scrn,
(dispmode.Height!=RequestedY_Size)) {
if (bVerboseMode) {
wdxdisplay8_cat.info()
<< "Mode dimension found " << dispmode.Width << "x" << dispmode.Height
<< "Mode dimension " << dispmode.Width << "x" << dispmode.Height
<< " and format " << dispmode.Format
<< ": continuing onto next mode\n";
}
continue;
@ -715,6 +715,11 @@ search_for_valid_displaymode(DXScreenData &scrn,
<< "Validated Mode (" << RequestedX_Size << "x"
<< RequestedY_Size << "," << D3DFormatStr(dispmode.Format) << endl;
/*
// dx8 valid display modes for render targets.
D3DFMT_X1R5G5B5, D3DFMT_R5G6B5, D3DFMT_X8R8G8B8, and D3DFMT_A8R8G8B8
*/
switch (dispmode.Format) {
case D3DFMT_X1R5G5B5:
*pSupportedScreenDepthsMask |= X1R5G5B5_FLAG;
@ -722,15 +727,15 @@ search_for_valid_displaymode(DXScreenData &scrn,
case D3DFMT_X8R8G8B8:
*pSupportedScreenDepthsMask |= X8R8G8B8_FLAG;
break;
case D3DFMT_R8G8B8:
*pSupportedScreenDepthsMask |= R8G8B8_FLAG;
case D3DFMT_A8R8G8B8:
*pSupportedScreenDepthsMask |= A8R8G8B8_FLAG;
break;
case D3DFMT_R5G6B5:
*pSupportedScreenDepthsMask |= R5G6B5_FLAG;
break;
default:
// Render target formats should be only D3DFMT_X1R5G5B5,
// D3DFMT_R5G6B5, D3DFMT_X8R8G8B8 (or R8G8B8?)
// D3DFMT_R5G6B5, D3DFMT_X8R8G8B8 and D3DFMT_A8R8G8B8
wdxdisplay8_cat.error()
<< "unrecognized supported fmt "<< D3DFormatStr(dispmode.Format)
<< " returned by EnumAdapterDisplayModes!\n";
@ -741,8 +746,8 @@ search_for_valid_displaymode(DXScreenData &scrn,
// memory & speed reasons on some older cards in particular
if (*pSupportedScreenDepthsMask & X8R8G8B8_FLAG) {
*pSuggestedPixFmt = D3DFMT_X8R8G8B8;
} else if (*pSupportedScreenDepthsMask & R8G8B8_FLAG) {
*pSuggestedPixFmt = D3DFMT_R8G8B8;
} else if (*pSupportedScreenDepthsMask & A8R8G8B8_FLAG) {
*pSuggestedPixFmt = D3DFMT_A8R8G8B8;
} else if (*pSupportedScreenDepthsMask & R5G6B5_FLAG) {
*pSuggestedPixFmt = D3DFMT_R5G6B5;
} else if (*pSupportedScreenDepthsMask & X1R5G5B5_FLAG) {

View File

@ -16,6 +16,78 @@
//
////////////////////////////////////////////////////////////////////
#if defined(_DEBUG) || defined(COUNT_DRAWPRIMS)
typedef enum {DrawPrim,DrawIndexedPrim} DP_Type;
static const char *DP_Type_Strs[3] = {"DrawPrimitive","DrawIndexedPrimitive"};
void INLINE TestDrawPrimFailure(DP_Type dptype,HRESULT hr,IDirect3DDevice9 *pD3DDevice,DWORD nVerts,DWORD nTris) {
if(FAILED(hr)) {
// loss of exclusive mode is not a real DrawPrim problem, ignore it
HRESULT testcooplvl_hr = pD3DDevice->TestCooperativeLevel();
if((testcooplvl_hr != D3DERR_DEVICELOST)||(testcooplvl_hr != D3DERR_DEVICENOTRESET)) {
dxgsg9_cat.fatal() << DP_Type_Strs[dptype] << "() failed: result = " << D3DERRORSTRING(hr);
exit(1);
}
}
CountDPs(nVerts,nTris);
}
#else
#define TestDrawPrimFailure(a,b,c,nVerts,nTris) CountDPs(nVerts,nTris);
#endif
INLINE DWORD
Colorf_to_D3DCOLOR(const Colorf &cColorf) {
// MS VC defines _M_IX86 for x86. gcc should define _X86_
#if defined(_M_IX86) || defined(_X86_)
DWORD d3dcolor,tempcolorval=255;
// note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
// dont think this makes much difference
__asm {
push ebx ; want to save this in case this fn is inlined
push ecx
mov ecx, cColorf
fild tempcolorval
fld DWORD PTR [ecx]
fmul ST(0),ST(1)
fistp tempcolorval ; no way to store directly to int register
mov eax, tempcolorval
shl eax, 16
fld DWORD PTR [ecx+4] ;grn
fmul ST(0),ST(1)
fistp tempcolorval
mov ebx,tempcolorval
shl ebx, 8
or eax,ebx
fld DWORD PTR [ecx+8] ;blue
fmul ST(0),ST(1)
fistp tempcolorval
or eax,tempcolorval
fld DWORD PTR [ecx+12] ;alpha
fmul ST(0),ST(1)
fistp tempcolorval
; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
ffree ST(0)
fincstp
mov ebx,tempcolorval
shl ebx, 24
or eax,ebx
mov d3dcolor,eax
pop ecx
pop ebx
}
// dxgsg9_cat.debug() << (void*)d3dcolor << endl;
return d3dcolor;
#else //!_X86_
return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
#endif //!_X86_
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_line_smooth
@ -369,6 +441,129 @@ enable_zwritemask(bool val) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::add_to_FVFBuf
// Access: Private
// Description: This adds data to the flexible vertex format
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
add_to_FVFBuf(void *data, size_t bytes) {
memcpy(_pCurFvfBufPtr, data, bytes);
_pCurFvfBufPtr += bytes;
}
INLINE void DXGraphicsStateGuardian9::
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
Colorf transformed
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_texturing
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
enable_texturing(bool val) {
_texturing_enabled = val;
if (!val) {
_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE);
} else {
nassertv(_pCurTexContext!=NULL);
SetTextureBlendMode(_CurTexBlendMode,true);
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::wants_texcoords
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian9::
wants_texcoords() const {
return _texturing_enabled;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::compute_distance_to
// Access: Public, Virtual
// Description: This function may only be called during a render
// traversal; it will compute the distance to the
// indicated point, assumed to be in modelview
// coordinates, from the camera plane.
////////////////////////////////////////////////////////////////////
INLINE float DXGraphicsStateGuardian9::
compute_distance_to(const LPoint3f &point) const {
// In the case of a DXGraphicsStateGuardian9, we know that the
// modelview matrix already includes the relative transform from the
// camera, as well as a to-y-up conversion. Thus, the distance to
// the camera plane is simply the +z distance. (negative of gl compute_distance_to,
// since d3d uses left-hand coords)
return point[2];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::get_texture_wrap_mode
// Access: Protected
// Description: Maps from the Texture's internal wrap mode symbols to
// GL's.
////////////////////////////////////////////////////////////////////
INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian9::
get_texture_wrap_mode(Texture::WrapMode wm) const {
static D3DTEXTUREADDRESS PandaTexWrapMode_to_D3DTexWrapMode[Texture::WM_invalid] = {
D3DTADDRESS_CLAMP,D3DTADDRESS_WRAP,D3DTADDRESS_MIRROR,D3DTADDRESS_MIRRORONCE,D3DTADDRESS_BORDER};
return PandaTexWrapMode_to_D3DTexWrapMode[wm];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::get_fog_mode_type
// Access: Protected
// Description: Maps from the fog types to gl version
////////////////////////////////////////////////////////////////////
INLINE D3DFOGMODE DXGraphicsStateGuardian9::
get_fog_mode_type(Fog::Mode m) const {
switch (m) {
case Fog::M_linear:
return D3DFOG_LINEAR;
case Fog::M_exponential:
return D3DFOG_EXP;
case Fog::M_exponential_squared:
return D3DFOG_EXP2;
}
dxgsg9_cat.error() << "Invalid Fog::Mode value" << endl;
return D3DFOG_EXP;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_clip_plane
// Access: Protected, Virtual
// Description: Intended to be overridden by a derived class to
// enable the indicated clip_plane id. A specific
// PlaneNode will already have been bound to this id via
// bind_clip_plane().
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
enable_clip_plane(int plane_id, bool enable) {
assert(plane_id < D3DMAXUSERCLIPPLANES);
DWORD bitflag = ((DWORD)1 << plane_id);
if (enable) {
_clip_plane_bits |= bitflag;
} else {
_clip_plane_bits &= ~bitflag;
}
_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, _clip_plane_bits);
}
/** unimplemented
////////////////////////////////////////////////////////////////////

View File

@ -129,59 +129,6 @@ static bool bTexStatsRetrievalImpossible=false;
//#define Colorf_to_D3DCOLOR(out_color) (MY_D3DRGBA((out_color)[0], (out_color)[1], (out_color)[2], (out_color)[3]))
INLINE DWORD
Colorf_to_D3DCOLOR(const Colorf &cColorf) {
// MS VC defines _M_IX86 for x86. gcc should define _X86_
#if defined(_M_IX86) || defined(_X86_)
DWORD d3dcolor,tempcolorval=255;
// note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
// dont think this makes much difference
__asm {
push ebx ; want to save this in case this fn is inlined
push ecx
mov ecx, cColorf
fild tempcolorval
fld DWORD PTR [ecx]
fmul ST(0),ST(1)
fistp tempcolorval ; no way to store directly to int register
mov eax, tempcolorval
shl eax, 16
fld DWORD PTR [ecx+4] ;grn
fmul ST(0),ST(1)
fistp tempcolorval
mov ebx,tempcolorval
shl ebx, 8
or eax,ebx
fld DWORD PTR [ecx+8] ;blue
fmul ST(0),ST(1)
fistp tempcolorval
or eax,tempcolorval
fld DWORD PTR [ecx+12] ;alpha
fmul ST(0),ST(1)
fistp tempcolorval
; simulate pop 255.0 off FP stack w/o store, mark top as empty and increment stk ptr
ffree ST(0)
fincstp
mov ebx,tempcolorval
shl ebx, 24
or eax,ebx
mov d3dcolor,eax
pop ecx
pop ebx
}
// dxgsg9_cat.debug() << (void*)d3dcolor << endl;
return d3dcolor;
#else //!_X86_
return MY_D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
#endif //!_X86_
}
void DXGraphicsStateGuardian9::
set_color_clear_value(const Colorf& value) {
_color_clear_value = value;
@ -1118,26 +1065,6 @@ void DXGraphicsStateGuardian9::set_clipper(RECT cliprect) {
}
#endif
#if defined(_DEBUG) || defined(COUNT_DRAWPRIMS)
typedef enum {DrawPrim,DrawIndexedPrim} DP_Type;
static const char *DP_Type_Strs[3] = {"DrawPrimitive","DrawIndexedPrimitive"};
void INLINE TestDrawPrimFailure(DP_Type dptype,HRESULT hr,IDirect3DDevice9 *pD3DDevice,DWORD nVerts,DWORD nTris) {
if(FAILED(hr)) {
// loss of exclusive mode is not a real DrawPrim problem, ignore it
HRESULT testcooplvl_hr = pD3DDevice->TestCooperativeLevel();
if((testcooplvl_hr != D3DERR_DEVICELOST)||(testcooplvl_hr != D3DERR_DEVICENOTRESET)) {
dxgsg9_cat.fatal() << DP_Type_Strs[dptype] << "() failed: result = " << D3DERRORSTRING(hr);
exit(1);
}
}
CountDPs(nVerts,nTris);
}
#else
#define TestDrawPrimFailure(a,b,c,nVerts,nTris) CountDPs(nVerts,nTris);
#endif
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::report_texmgr_stats
// Access: Protected
@ -1283,17 +1210,6 @@ report_texmgr_stats() {
#endif
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::add_to_FVFBuf
// Access: Private
// Description: This adds data to the flexible vertex format
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
add_to_FVFBuf(void *data, size_t bytes) {
memcpy(_pCurFvfBufPtr, data, bytes);
_pCurFvfBufPtr += bytes;
}
// generates slightly fewer instrs
#define add_DWORD_to_FVFBuf(data) { *((DWORD *)_pCurFvfBufPtr) = (DWORD) data; _pCurFvfBufPtr += sizeof(DWORD);}
@ -1302,16 +1218,6 @@ typedef enum {
} GeomVertFormat;
INLINE void DXGraphicsStateGuardian9::
transform_color(Colorf &InColor,D3DCOLOR &OutRGBAColor) {
Colorf transformed
((InColor[0] * _current_color_scale[0]) + _current_color_offset[0],
(InColor[1] * _current_color_scale[1]) + _current_color_offset[1],
(InColor[2] * _current_color_scale[2]) + _current_color_offset[2],
(InColor[3] * _current_color_scale[3]) + _current_color_offset[3]);
OutRGBAColor = Colorf_to_D3DCOLOR(transformed);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::draw_prim_setup
// Access: Private
@ -3526,24 +3432,6 @@ void DXGraphicsStateGuardian9::SetTextureBlendMode(TextureApplyAttrib::Mode TexB
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_texturing
// Access:
// Description:
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
enable_texturing(bool val) {
_texturing_enabled = val;
if (!val) {
_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE);
} else {
nassertv(_pCurTexContext!=NULL);
SetTextureBlendMode(_CurTexBlendMode,true);
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::issue_transform
// Access: Public, Virtual
@ -3599,6 +3487,57 @@ issue_tex_matrix(const TexMatrixAttrib *attrib) {
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian8::issue_tex_gen
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
void DXGraphicsStateGuardian9::
issue_tex_gen(const TexGenAttrib *attrib) {
/*
* Automatically generate texture coordinates for stage 0.
* Use the wrap mode from the texture coordinate set at index 1.
*/
DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1));
if (attrib->is_off()) {
//enable_texturing(false);
// reset the texcoordindex lookup to 0
//_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, 0);
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
} else if (attrib->get_mode() == TexGenAttrib::M_spherical) {
#if 0
// best reflection on a sphere is achieved by camera space normals in directx
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACENORMAL);
// We have set up the texture matrix to scale and translate the
// texture coordinates to get from camera space (-1, +1) to
// texture space (0,1)
LMatrix4f dm(0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.0f, 1.0f);
#else
// since this is a reflection map, we want the camera space
// reflection vector. A close approximation of the asin(theta)/pi
// + 0.5 is achieved by the following matrix
_pD3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
LMatrix4f dm(0.33f, 0.0f, 0.0f, 0.0f,
0.0f, 0.33f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.0f, 1.0f);
#endif
_pD3DDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX *)dm.get_data());
_pD3DDevice->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS,
D3DTTFF_COUNT2);
//_pD3DDevice->SetRenderState(D3DRS_LOCALVIEWER, false);
}
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::issue_texture
// Access: Public, Virtual
@ -4068,17 +4007,6 @@ end_frame() {
GraphicsStateGuardian::end_frame();
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::wants_texcoords
// Access: Public, Virtual
// Description:
////////////////////////////////////////////////////////////////////
INLINE bool DXGraphicsStateGuardian9::
wants_texcoords() const {
return _texturing_enabled;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::depth_offset_decals
// Access: Public, Virtual
@ -4111,25 +4039,6 @@ get_internal_coordinate_system() const {
return CS_yup_left;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::compute_distance_to
// Access: Public, Virtual
// Description: This function may only be called during a render
// traversal; it will compute the distance to the
// indicated point, assumed to be in modelview
// coordinates, from the camera plane.
////////////////////////////////////////////////////////////////////
INLINE float DXGraphicsStateGuardian9::
compute_distance_to(const LPoint3f &point) const {
// In the case of a DXGraphicsStateGuardian9, we know that the
// modelview matrix already includes the relative transform from the
// camera, as well as a to-y-up conversion. Thus, the distance to
// the camera plane is simply the +z distance. (negative of gl compute_distance_to,
// since d3d uses left-hand coords)
return point[2];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::set_draw_buffer
// Access: Protected
@ -4201,39 +4110,6 @@ set_read_buffer(const RenderBuffer &rb) {
return;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::get_texture_wrap_mode
// Access: Protected
// Description: Maps from the Texture's internal wrap mode symbols to
// GL's.
////////////////////////////////////////////////////////////////////
INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian9::
get_texture_wrap_mode(Texture::WrapMode wm) const {
static D3DTEXTUREADDRESS PandaTexWrapMode_to_D3DTexWrapMode[Texture::WM_invalid] = {
D3DTADDRESS_CLAMP,D3DTADDRESS_WRAP,D3DTADDRESS_MIRROR,D3DTADDRESS_MIRRORONCE,D3DTADDRESS_BORDER};
return PandaTexWrapMode_to_D3DTexWrapMode[wm];
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::get_fog_mode_type
// Access: Protected
// Description: Maps from the fog types to gl version
////////////////////////////////////////////////////////////////////
INLINE D3DFOGMODE DXGraphicsStateGuardian9::
get_fog_mode_type(Fog::Mode m) const {
switch (m) {
case Fog::M_linear:
return D3DFOG_LINEAR;
case Fog::M_exponential:
return D3DFOG_EXP;
case Fog::M_exponential_squared:
return D3DFOG_EXP2;
}
dxgsg9_cat.error() << "Invalid Fog::Mode value" << endl;
return D3DFOG_EXP;
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_lighting
// Access: Protected, Virtual
@ -4297,28 +4173,6 @@ slot_new_clip_plane(int plane_id) {
return (plane_id < D3DMAXUSERCLIPPLANES);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::enable_clip_plane
// Access: Protected, Virtual
// Description: Intended to be overridden by a derived class to
// enable the indicated clip_plane id. A specific
// PlaneNode will already have been bound to this id via
// bind_clip_plane().
////////////////////////////////////////////////////////////////////
INLINE void DXGraphicsStateGuardian9::
enable_clip_plane(int plane_id, bool enable) {
assert(plane_id < D3DMAXUSERCLIPPLANES);
DWORD bitflag = ((DWORD)1 << plane_id);
if (enable) {
_clip_plane_bits |= bitflag;
} else {
_clip_plane_bits &= ~bitflag;
}
_pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, _clip_plane_bits);
}
////////////////////////////////////////////////////////////////////
// Function: DXGraphicsStateGuardian9::bind_clip_plane
// Access: Protected, Virtual

View File

@ -29,6 +29,7 @@
#include "graphicsStateGuardian.h"
#include "geomprimitives.h"
#include "texture.h"
#include "texGenAttrib.h"
#include "pixelBuffer.h"
#include "displayRegion.h"
#include "material.h"
@ -113,6 +114,7 @@ public:
virtual void issue_transform(const TransformState *transform);
virtual void issue_tex_matrix(const TexMatrixAttrib *attrib);
virtual void issue_tex_gen(const TexGenAttrib *attrib);
virtual void issue_texture(const TextureAttrib *attrib);
virtual void issue_material(const MaterialAttrib *attrib);
virtual void issue_render_mode(const RenderModeAttrib *attrib);

View File

@ -156,7 +156,7 @@ typedef enum {
A8_FLAG = FLG(8),
A8R3G3B2_FLAG = FLG(9),
X4R4G4B4_FLAG = FLG(10),
A2B10G10R10_FLAG = FLG(11),
A2R10G10B10_FLAG = FLG(11),
G16R16_FLAG = FLG(12),
A8P8_FLAG = FLG(13),
P8_FLAG = FLG(14),

View File

@ -529,9 +529,19 @@ search_for_valid_displaymode(DXScreenData &scrn,
bool bVerboseMode) {
// Use this list of format modes when trying to find a valid graphics
// format for the card. Formats are scanned in the order listed.
/*
Format Back buffer Display
A2R10G10B10 x x (full-screen mode only)
A8R8G8B8 x
X8R8G8B8 x x
A1R5G5B5 x
X1R5G5B5 x x
R5G6B5 x x
*/
static D3DFORMAT valid_formats[] = {
D3DFMT_X8R8G8B8,
D3DFMT_A2B10G10R10,
D3DFMT_A2R10G10B10,
D3DFMT_R5G6B5,
D3DFMT_X1R5G5B5,
};
@ -745,8 +755,8 @@ search_for_valid_displaymode(DXScreenData &scrn,
case D3DFMT_X8R8G8B8:
*pSupportedScreenDepthsMask |= X8R8G8B8_FLAG;
break;
case D3DFMT_A2B10G10R10:
*pSupportedScreenDepthsMask |= A2B10G10R10_FLAG;
case D3DFMT_A2R10G10B10:
*pSupportedScreenDepthsMask |= A2R10G10B10_FLAG;
break;
case D3DFMT_R5G6B5:
*pSupportedScreenDepthsMask |= R5G6B5_FLAG;
@ -883,7 +893,7 @@ void Init_D3DFORMAT_map(void) {
INSERT_ELEM(A8);
INSERT_ELEM(A8R3G3B2);
INSERT_ELEM(X4R4G4B4);
INSERT_ELEM(A2B10G10R10);
INSERT_ELEM(A2R10G10B10);
INSERT_ELEM(G16R16);
INSERT_ELEM(A8P8);
INSERT_ELEM(P8);
@ -924,7 +934,7 @@ const char *D3DFormatStr(D3DFORMAT fmt) {
CASESTR(D3DFMT_A8);
CASESTR(D3DFMT_A8R3G3B2);
CASESTR(D3DFMT_X4R4G4B4);
CASESTR(D3DFMT_A2B10G10R10);
CASESTR(D3DFMT_A2R10G10B10);
CASESTR(D3DFMT_G16R16);
CASESTR(D3DFMT_A8P8);
CASESTR(D3DFMT_P8);

View File

@ -853,8 +853,6 @@ create_screen_buffers_and_device(DXScreenData &Display, bool force_16bpp_zbuffer
wdxdisplay9_cat.warning() << "pPresParams->BackBufferCount : " << pPresParams->BackBufferCount << endl;
wdxdisplay9_cat.warning() << "D3D CreateDevice failed for device #" << Display.CardIDNum << D3DERRORSTRING(hr);
goto Fallback_to_16bpp_buffers;
//exit(1);
return false;
}
} // end create windowed buffers