mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
A few more fixes
This commit is contained in:
parent
d63920086a
commit
cb8e25f859
@ -4053,3 +4053,56 @@ LPDIRECT3DDEVICE8 DXGraphicsStateGuardian8::
|
||||
get_d3d_device() {
|
||||
return _d3d_device;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: dxGraphicsStateGuardian8::calc_fb_properties
|
||||
// Access: Public
|
||||
// Description: Convert DirectX framebuffer format ids into a
|
||||
// FrameBufferProperties structure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FrameBufferProperties DXGraphicsStateGuardian8::
|
||||
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype) {
|
||||
FrameBufferProperties props;
|
||||
int index=0;
|
||||
int alpha=0;
|
||||
int color=0;
|
||||
switch (cformat) {
|
||||
case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break;
|
||||
case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break;
|
||||
case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break;
|
||||
case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break;
|
||||
case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break;
|
||||
case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break;
|
||||
case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break;
|
||||
case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break;
|
||||
case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break;
|
||||
case D3DFMT_A8P8: index=1; color= 8; alpha=8; break;
|
||||
case D3DFMT_P8: index=1; color= 8; alpha=0; break;
|
||||
}
|
||||
props.set_color_bits(color);
|
||||
props.set_alpha_bits(alpha);
|
||||
if (index) {
|
||||
props.set_rgb_color(0);
|
||||
props.set_indexed_color(1);
|
||||
} else if (color) {
|
||||
props.set_rgb_color(1);
|
||||
props.set_indexed_color(0);
|
||||
}
|
||||
int depth=0;
|
||||
int stencil=0;
|
||||
switch (dformat) {
|
||||
case D3DFMT_D32: depth=32; stencil=0; break;
|
||||
case D3DFMT_D15S1: depth=15; stencil=1; break;
|
||||
case D3DFMT_D24S8: depth=24; stencil=8; break;
|
||||
case D3DFMT_D16: depth=16; stencil=0; break;
|
||||
case D3DFMT_D24X8: depth=24; stencil=0; break;
|
||||
case D3DFMT_D24X4S4: depth=24; stencil=4; break;
|
||||
}
|
||||
props.set_depth_bits(depth);
|
||||
props.set_stencil_bits(stencil);
|
||||
props.set_multisamples(multisampletype);
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,9 @@ public:
|
||||
DXGraphicsStateGuardian8(GraphicsPipe *pipe);
|
||||
~DXGraphicsStateGuardian8();
|
||||
|
||||
FrameBufferProperties
|
||||
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype);
|
||||
|
||||
virtual TextureContext *prepare_texture(Texture *tex);
|
||||
void apply_texture(int i, TextureContext *tc);
|
||||
virtual void release_texture(TextureContext *tc);
|
||||
|
@ -137,7 +137,7 @@ end_frame(FrameMode mode, Thread *current_thread) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::save_bitplanes
|
||||
// Function: wdxGraphicsBuffer8::save_bitplanes
|
||||
// Access: Public
|
||||
// Description: After rendering, d3d_device will need to be restored
|
||||
// to its initial state. This function saves the state.
|
||||
@ -151,26 +151,16 @@ save_bitplanes() {
|
||||
dxgsg8_cat.error ( ) << "GetRenderTarget " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_color_buffer -> GetDesc (&_saved_color_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg8_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _dxgsg -> _d3d_device -> GetDepthStencilSurface (&_saved_depth_buffer);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg8_cat.error ( ) << "GetDepthStencilSurface " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_depth_buffer -> GetDesc (&_saved_depth_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg8_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::restore_bitplanes
|
||||
// Function: wdxGraphicsBuffer8::restore_bitplanes
|
||||
// Access: Public
|
||||
// Description: After rendering, d3d_device will need to be restored
|
||||
// to its initial state. This function restores the state.
|
||||
@ -197,7 +187,7 @@ restore_bitplanes() {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::rebuild_bitplanes
|
||||
// Function: wdxGraphicsBuffer8::rebuild_bitplanes
|
||||
// Access: Public
|
||||
// Description: If necessary, reallocates (or allocates) the
|
||||
// bitplanes for the buffer.
|
||||
@ -447,6 +437,23 @@ open_buffer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
hr = _saved_color_buffer -> GetDesc (&_saved_color_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg8_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_depth_buffer -> GetDesc (&_saved_depth_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg8_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
_fb_properties = _dxgsg->
|
||||
calc_fb_properties(_saved_color_desc.Format,
|
||||
_saved_depth_desc.Format,
|
||||
_saved_depth_desc.MultiSampleType);
|
||||
_fb_properties.set_force_hardware(1); // Wild guess.
|
||||
|
||||
if (!rebuild_bitplanes()) {
|
||||
restore_bitplanes();
|
||||
return false;
|
||||
|
@ -5199,3 +5199,61 @@ do_issue_stencil() {
|
||||
stencil_render_states -> set_stencil_render_state (true, StencilRenderStates::SRS_back_enable, 0);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: dxGraphicsStateGuardian9::calc_fb_properties
|
||||
// Access: Public
|
||||
// Description: Convert DirectX framebuffer format ids into a
|
||||
// FrameBufferProperties structure.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FrameBufferProperties DXGraphicsStateGuardian9::
|
||||
calc_fb_properties(DWORD cformat, DWORD dformat,
|
||||
DWORD multisampletype, DWORD multisamplequality) {
|
||||
FrameBufferProperties props;
|
||||
int index=0;
|
||||
int alpha=0;
|
||||
int color=0;
|
||||
switch (cformat) {
|
||||
case D3DFMT_R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_A8R8G8B8: index=0; color=24; alpha=8; break;
|
||||
case D3DFMT_X8R8G8B8: index=0; color=24; alpha=0; break;
|
||||
case D3DFMT_R5G6B5: index=0; color=16; alpha=0; break;
|
||||
case D3DFMT_X1R5G5B5: index=0; color=15; alpha=0; break;
|
||||
case D3DFMT_A1R5G5B5: index=0; color=15; alpha=1; break;
|
||||
case D3DFMT_A4R4G4B4: index=0; color=12; alpha=4; break;
|
||||
case D3DFMT_R3G3B2: index=0; color= 8; alpha=0; break;
|
||||
case D3DFMT_A8R3G3B2: index=0; color= 8; alpha=8; break;
|
||||
case D3DFMT_X4R4G4B4: index=0; color=12; alpha=0; break;
|
||||
case D3DFMT_A2B10G10R10: index=0; color=30; alpha=2; break;
|
||||
case D3DFMT_A8P8: index=1; color= 8; alpha=8; break;
|
||||
case D3DFMT_P8: index=1; color= 8; alpha=0; break;
|
||||
}
|
||||
props.set_color_bits(color);
|
||||
props.set_alpha_bits(alpha);
|
||||
if (index) {
|
||||
props.set_rgb_color(0);
|
||||
props.set_indexed_color(1);
|
||||
} else if (color) {
|
||||
props.set_rgb_color(1);
|
||||
props.set_indexed_color(0);
|
||||
}
|
||||
int depth=0;
|
||||
int stencil=0;
|
||||
switch (dformat) {
|
||||
case D3DFMT_D32: depth=32; stencil=0; break;
|
||||
case D3DFMT_D15S1: depth=15; stencil=1; break;
|
||||
case D3DFMT_D24S8: depth=24; stencil=8; break;
|
||||
case D3DFMT_D16: depth=16; stencil=0; break;
|
||||
case D3DFMT_D24X8: depth=24; stencil=0; break;
|
||||
case D3DFMT_D24X4S4: depth=24; stencil=4; break;
|
||||
}
|
||||
props.set_depth_bits(depth);
|
||||
props.set_stencil_bits(stencil);
|
||||
if (multisampletype == D3DMULTISAMPLE_NONMASKABLE) {
|
||||
props.set_multisamples(2);
|
||||
} else {
|
||||
props.set_multisamples(multisampletype);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,10 @@ public:
|
||||
DXGraphicsStateGuardian9(GraphicsPipe *pipe);
|
||||
~DXGraphicsStateGuardian9();
|
||||
|
||||
FrameBufferProperties
|
||||
calc_fb_properties(DWORD cformat, DWORD dformat,
|
||||
DWORD multisampletype, DWORD multisamplequality);
|
||||
|
||||
virtual TextureContext *prepare_texture(Texture *tex);
|
||||
void apply_texture(int i, TextureContext *tc);
|
||||
virtual void release_texture(TextureContext *tc);
|
||||
|
@ -151,21 +151,11 @@ save_bitplanes() {
|
||||
dxgsg9_cat.error ( ) << "GetRenderTarget " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_color_buffer -> GetDesc (&_saved_color_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg9_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _dxgsg -> _d3d_device -> GetDepthStencilSurface (&_saved_depth_buffer);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg9_cat.error ( ) << "GetDepthStencilSurface " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_depth_buffer -> GetDesc (&_saved_depth_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg9_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -457,6 +447,25 @@ open_buffer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
hr = _saved_color_buffer -> GetDesc (&_saved_color_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg9_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
hr = _saved_depth_buffer -> GetDesc (&_saved_depth_desc);
|
||||
if (!SUCCEEDED (hr)) {
|
||||
dxgsg9_cat.error ( ) << "GetDesc " << D3DERRORSTRING(hr) FL;
|
||||
return false;
|
||||
}
|
||||
_fb_properties = _dxgsg->
|
||||
calc_fb_properties(_saved_color_desc.Format,
|
||||
_saved_depth_desc.Format,
|
||||
_saved_depth_desc.MultiSampleType,
|
||||
_saved_depth_desc.MultiSampleQuality);
|
||||
_fb_properties.set_force_hardware(1); // Wild guess.
|
||||
|
||||
|
||||
if (!rebuild_bitplanes()) {
|
||||
restore_bitplanes();
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user