mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
add resize() fullscrn support, more stenciling support
This commit is contained in:
parent
6921f04120
commit
1e37df2ff2
@ -19,43 +19,6 @@
|
|||||||
#include "config_dxgsg.h"
|
#include "config_dxgsg.h"
|
||||||
#include <graphicsWindow.h>
|
#include <graphicsWindow.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::set_pack_alignment
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
set_pack_alignment(int alignment) {
|
|
||||||
#ifdef NDEBUG
|
|
||||||
dxgsg_cat.error() << "set_pack_alignment() unimplemented, has no meaning in DX\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::set_unpack_alignment
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
set_unpack_alignment(int alignment) {
|
|
||||||
#ifdef NDEBUG
|
|
||||||
dxgsg_cat.error() << "set_unpack_alignment() unimplemented, has no meaning in DX\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::enable_multisample
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
enable_multisample(bool val) {
|
|
||||||
_multisample_enabled = val;
|
|
||||||
#ifdef NDEBUG
|
|
||||||
dxgsg_cat.error() << "dx multisample unimplemented!!\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::enable_line_smooth
|
// Function: DXGraphicsStateGuardian::enable_line_smooth
|
||||||
// Access:
|
// Access:
|
||||||
@ -76,20 +39,6 @@ enable_line_smooth(bool val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::enable_point_smooth
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
enable_point_smooth(bool val) {
|
|
||||||
_point_smooth_enabled = val;
|
|
||||||
#ifdef NDEBUG
|
|
||||||
dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::enable_lighting
|
// Function: DXGraphicsStateGuardian::enable_lighting
|
||||||
// Access:
|
// Access:
|
||||||
@ -122,7 +71,6 @@ enable_dither(bool val) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
_dither_enabled = val;
|
_dither_enabled = val;
|
||||||
|
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,32 +121,6 @@ enable_clip_plane(int clip_plane, bool val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
enable_multisample_alpha_one(bool val) {
|
|
||||||
if (_multisample_alpha_one_enabled != val) {
|
|
||||||
_multisample_alpha_one_enabled = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
|
|
||||||
// Access:
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
enable_multisample_alpha_mask(bool val) {
|
|
||||||
if (_multisample_alpha_mask_enabled != val) {
|
|
||||||
_multisample_alpha_mask_enabled = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::enable_blend
|
// Function: DXGraphicsStateGuardian::enable_blend
|
||||||
// Access:
|
// Access:
|
||||||
@ -225,15 +147,6 @@ set_shademode(D3DSHADEMODE val) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INLINE void DXGraphicsStateGuardian::
|
|
||||||
SetDeviceTexture(LPDIRECTDRAWSURFACE7 pTexture) {
|
|
||||||
// this fn is useful because GetTexture() does an AddRef, so faster to cache it ourself
|
|
||||||
if (_pCurDeviceTexture != pTexture) {
|
|
||||||
_pCurDeviceTexture = pTexture;
|
|
||||||
_d3dDevice->SetTexture(0,_pCurDeviceTexture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::enable_fog
|
// Function: DXGraphicsStateGuardian::enable_fog
|
||||||
// Access:
|
// Access:
|
||||||
@ -272,8 +185,7 @@ call_dxLightModelAmbient( const Colorf& color)
|
|||||||
if (_lmodel_ambient != color) {
|
if (_lmodel_ambient != color) {
|
||||||
_lmodel_ambient = color;
|
_lmodel_ambient = color;
|
||||||
#ifdef GSG_VERBOSE
|
#ifdef GSG_VERBOSE
|
||||||
dxgsg_cat.debug()
|
dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
|
||||||
<< "glLightModel(GL_LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
|
|
||||||
#endif
|
#endif
|
||||||
_d3dDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
|
_d3dDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
|
||||||
D3DRGBA(color[0], color[1], color[2], color[3]));
|
D3DRGBA(color[0], color[1], color[2], color[3]));
|
||||||
@ -414,3 +326,58 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** unimplemented
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DXGraphicsStateGuardian::enable_multisample
|
||||||
|
// Access:
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DXGraphicsStateGuardian::
|
||||||
|
enable_multisample(bool val) {
|
||||||
|
_multisample_enabled = val;
|
||||||
|
#ifdef NDEBUG
|
||||||
|
dxgsg_cat.error() << "dx multisample unimplemented!!\n";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_one
|
||||||
|
// Access:
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DXGraphicsStateGuardian::
|
||||||
|
enable_multisample_alpha_one(bool val) {
|
||||||
|
if (_multisample_alpha_one_enabled != val) {
|
||||||
|
_multisample_alpha_one_enabled = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DXGraphicsStateGuardian::enable_multisample_alpha_mask
|
||||||
|
// Access:
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DXGraphicsStateGuardian::
|
||||||
|
enable_multisample_alpha_mask(bool val) {
|
||||||
|
if (_multisample_alpha_mask_enabled != val) {
|
||||||
|
_multisample_alpha_mask_enabled = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: DXGraphicsStateGuardian::enable_point_smooth
|
||||||
|
// Access:
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void DXGraphicsStateGuardian::
|
||||||
|
enable_point_smooth(bool val) {
|
||||||
|
// _point_smooth_enabled = val;
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
dxgsg_cat.error() << "dx point smoothing unimplemented!!\n";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ TypeHandle DXGraphicsStateGuardian::_type_handle;
|
|||||||
static D3DMATRIX matIdentity;
|
static D3DMATRIX matIdentity;
|
||||||
|
|
||||||
#ifdef COUNT_DRAWPRIMS
|
#ifdef COUNT_DRAWPRIMS
|
||||||
|
// you should just use Intel GPT instead of this stuff
|
||||||
|
|
||||||
static DWORD cDPcount=0;
|
static DWORD cDPcount=0;
|
||||||
static DWORD cVertcount=0;
|
static DWORD cVertcount=0;
|
||||||
@ -139,20 +140,17 @@ static bool bTexStatsRetrievalImpossible=false;
|
|||||||
//#define Colorf_to_D3DCOLOR(out_color) (D3DRGBA((out_color)[0], (out_color)[1], (out_color)[2], (out_color)[3]))
|
//#define Colorf_to_D3DCOLOR(out_color) (D3DRGBA((out_color)[0], (out_color)[1], (out_color)[2], (out_color)[3]))
|
||||||
|
|
||||||
INLINE DWORD
|
INLINE DWORD
|
||||||
Colorf_to_D3DCOLOR(Colorf &cColorf) {
|
Colorf_to_D3DCOLOR(const Colorf &cColorf) {
|
||||||
// MS VC defines _M_IX86 for x86. gcc should define _X86_
|
// MS VC defines _M_IX86 for x86. gcc should define _X86_
|
||||||
#if defined(_M_IX86) || defined(_X86_)
|
#if defined(_M_IX86) || defined(_X86_)
|
||||||
DWORD d3dcolor,tempcolorval=255;
|
DWORD d3dcolor,tempcolorval=255;
|
||||||
// DWORD *Colorf_addr=(DWORD*)&cColorf;
|
|
||||||
|
|
||||||
// note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode
|
// 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
|
// dont think this makes much difference
|
||||||
|
|
||||||
__asm {
|
__asm {
|
||||||
; push eax
|
|
||||||
push ebx ; want to save this in case this fn is inlined
|
push ebx ; want to save this in case this fn is inlined
|
||||||
push ecx
|
push ecx
|
||||||
; mov ecx, Colorf_addr ; must be a better way to do this w/o using ecx
|
|
||||||
mov ecx, cColorf
|
mov ecx, cColorf
|
||||||
fild tempcolorval
|
fild tempcolorval
|
||||||
fld [ecx]
|
fld [ecx]
|
||||||
@ -185,16 +183,21 @@ Colorf_to_D3DCOLOR(Colorf &cColorf) {
|
|||||||
mov d3dcolor,eax
|
mov d3dcolor,eax
|
||||||
pop ecx
|
pop ecx
|
||||||
pop ebx
|
pop ebx
|
||||||
; pop eax
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dxgsg_cat.debug() << (void*)d3dcolor << endl;
|
// dxgsg_cat.debug() << (void*)d3dcolor << endl;
|
||||||
return d3dcolor;
|
return d3dcolor;
|
||||||
#else //!_X86_
|
#else //!_X86_
|
||||||
return D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
|
return D3DRGBA(cColorf[0], cColorf[1], cColorf[2], cColorf[3]);
|
||||||
#endif //!_X86_
|
#endif //!_X86_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DXGraphicsStateGuardian::
|
||||||
|
set_color_clear_value(const Colorf& value) {
|
||||||
|
_color_clear_value = value;
|
||||||
|
_d3dcolor_clear_value = Colorf_to_D3DCOLOR(value);
|
||||||
|
}
|
||||||
|
|
||||||
void DXGraphicsStateGuardian::SetFPSMeterPosition(RECT &view_rect) {
|
void DXGraphicsStateGuardian::SetFPSMeterPosition(RECT &view_rect) {
|
||||||
if(_fpsmeter_verts==NULL)
|
if(_fpsmeter_verts==NULL)
|
||||||
return;
|
return;
|
||||||
@ -278,7 +281,7 @@ void DXGraphicsStateGuardian::FillFPSMeterTexture(void) {
|
|||||||
ZeroMemory(ddsd.lpSurface,ddsd.dwWidth*ddsd.dwHeight*2);
|
ZeroMemory(ddsd.lpSurface,ddsd.dwWidth*ddsd.dwHeight*2);
|
||||||
_fpsmeter_font_surf->Unlock(NULL);
|
_fpsmeter_font_surf->Unlock(NULL);
|
||||||
|
|
||||||
// draw text using GDI
|
// draw FPS text using GDI
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
if(FAILED( hr = _fpsmeter_font_surf->GetDC(&hDC))) {
|
if(FAILED( hr = _fpsmeter_font_surf->GetDC(&hDC))) {
|
||||||
dxgsg_cat.error() << "fps meter creation failed, GetDC failed on fps font surface! hr = " << ConvD3DErrorToString(hr) << "\n";
|
dxgsg_cat.error() << "fps meter creation failed, GetDC failed on fps font surface! hr = " << ConvD3DErrorToString(hr) << "\n";
|
||||||
@ -340,33 +343,28 @@ void DXGraphicsStateGuardian::FillFPSMeterTexture(void) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
DXGraphicsStateGuardian::
|
DXGraphicsStateGuardian::
|
||||||
DXGraphicsStateGuardian(GraphicsWindow *win) : GraphicsStateGuardian(win) {
|
DXGraphicsStateGuardian(GraphicsWindow *win) : GraphicsStateGuardian(win) {
|
||||||
_light_enabled = (bool *)NULL;
|
// allocate local buffers used during rendering
|
||||||
_cur_light_enabled = (bool *)NULL;
|
|
||||||
_clip_plane_enabled = (bool *)NULL;
|
GraphicsStateGuardian::reset();
|
||||||
_cur_clip_plane_enabled = (bool *)NULL;
|
|
||||||
_pCurFvfBufPtr = NULL;
|
_pCurFvfBufPtr = NULL;
|
||||||
_pFvfBufBasePtr = new char[VERT_BUFFER_SIZE]; // allocate storage for vertex info.
|
_pFvfBufBasePtr = new char[VERT_BUFFER_SIZE]; // allocate storage for vertex info.
|
||||||
_index_buf = new WORD[D3DMAXNUMVERTICES]; // allocate storage for vertex index info.
|
_index_buf = new WORD[D3DMAXNUMVERTICES]; // allocate storage for vertex index info.
|
||||||
_fpsmeter_verts=NULL;
|
_fpsmeter_verts=NULL;
|
||||||
_fpsmeter_font_surf=NULL;
|
_fpsmeter_font_surf=NULL;
|
||||||
_dx_ready = false;
|
_dx_ready = false;
|
||||||
_pCurDeviceTexture = NULL;
|
|
||||||
|
|
||||||
_CurShadeMode = D3DSHADE_FLAT;
|
|
||||||
|
|
||||||
_pri = _zbuf = _back = NULL;
|
_pri = _zbuf = _back = NULL;
|
||||||
_pDD = NULL;
|
_pDD = NULL;
|
||||||
_d3dDevice = NULL;
|
_d3dDevice = NULL;
|
||||||
|
|
||||||
_cur_read_pixel_buffer=RenderBuffer::T_front;
|
// non-dx obj values inited here should not change if resize is
|
||||||
|
// called and dx objects need to be recreated (otherwise they
|
||||||
|
// belong in dx_init, with other renderstate
|
||||||
|
|
||||||
ZeroMemory(&matIdentity,sizeof(D3DMATRIX));
|
ZeroMemory(&matIdentity,sizeof(D3DMATRIX));
|
||||||
matIdentity._11 = matIdentity._22 = matIdentity._33 = matIdentity._44 = 1.0f;
|
matIdentity._11 = matIdentity._22 = matIdentity._33 = matIdentity._44 = 1.0f;
|
||||||
|
|
||||||
_cNumTexPixFmts = 0;
|
|
||||||
_pTexPixFmts = NULL;
|
|
||||||
_pCurTexContext = NULL;
|
|
||||||
|
|
||||||
// Create a default RenderTraverser.
|
// Create a default RenderTraverser.
|
||||||
if (dx_cull_traversal) {
|
if (dx_cull_traversal) {
|
||||||
_render_traverser = new CullTraverser(this, RenderRelation::get_class_type());
|
_render_traverser = new CullTraverser(this, RenderRelation::get_class_type());
|
||||||
@ -374,14 +372,21 @@ DXGraphicsStateGuardian(GraphicsWindow *win) : GraphicsStateGuardian(win) {
|
|||||||
_render_traverser = new DirectRenderTraverser(this, RenderRelation::get_class_type());
|
_render_traverser = new DirectRenderTraverser(this, RenderRelation::get_class_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Color and alpha transform variables
|
// All implementations have the following buffers.
|
||||||
_color_transform_enabled = false;
|
_buffer_mask = (RenderBuffer::T_color |
|
||||||
_alpha_transform_enabled = false;
|
RenderBuffer::T_depth |
|
||||||
_current_color_mat = LMatrix4f::ident_mat();
|
RenderBuffer::T_back
|
||||||
_current_alpha_offset = 0;
|
// RenderBuffer::T_stencil |
|
||||||
_current_alpha_scale = 1;
|
// RenderBuffer::T_accum
|
||||||
|
);
|
||||||
|
|
||||||
reset();
|
// this is incorrect for general mono displays, need both right and left flags set.
|
||||||
|
// stereo has not been handled yet for dx
|
||||||
|
// _buffer_mask &= ~RenderBuffer::T_right;
|
||||||
|
|
||||||
|
_cur_read_pixel_buffer=RenderBuffer::T_front;
|
||||||
|
|
||||||
|
set_color_clear_value(_color_clear_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -407,71 +412,36 @@ DXGraphicsStateGuardian::
|
|||||||
// created.
|
// created.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DXGraphicsStateGuardian::
|
void DXGraphicsStateGuardian::
|
||||||
reset() {
|
reset(void) {
|
||||||
free_pointers();
|
|
||||||
GraphicsStateGuardian::reset();
|
GraphicsStateGuardian::reset();
|
||||||
_buffer_mask = 0;
|
dxgsg_cat.error() << "DXGSG reset() not implemented properly yet!\n";
|
||||||
|
// delete all the objs too, right?
|
||||||
|
//dx_init();
|
||||||
|
}
|
||||||
|
|
||||||
// All implementations have the following buffers.
|
// recreate dx objects without modifying gsg state, other than clearing state cache
|
||||||
_buffer_mask = (RenderBuffer::T_color |
|
void DXGraphicsStateGuardian::
|
||||||
RenderBuffer::T_depth |
|
free_dxgsg_objects(void) {
|
||||||
RenderBuffer::T_back
|
ULONG refcnt;
|
||||||
// RenderBuffer::T_stencil |
|
|
||||||
// RenderBuffer::T_accum
|
|
||||||
);
|
|
||||||
|
|
||||||
_current_projection_mat = LMatrix4f::ident_mat();
|
free_pointers();
|
||||||
_projection_mat_stack_count = 0;
|
|
||||||
|
|
||||||
_issued_color_enabled = false;
|
// dont want a full reset of gsg, just a state clear
|
||||||
_enable_all_color = true;
|
GraphicsStateGuardian::clear_cached_state(); // want gsg to pass all state settings through
|
||||||
|
|
||||||
// this is incorrect for general mono displays, need both right and left flags set.
|
|
||||||
// stereo has not been handled yet for dx
|
|
||||||
// _buffer_mask &= ~RenderBuffer::T_right;
|
|
||||||
|
|
||||||
// Set up our clear values to invalid values, so the glClear* calls
|
|
||||||
// will be made initially.
|
|
||||||
_clear_color_red = -1.0f;
|
|
||||||
_clear_color_green = -1.0f;
|
|
||||||
_clear_color_blue = -1.0f;
|
|
||||||
_clear_color_alpha = -1.0f;
|
|
||||||
_clear_depth = -1.0f;
|
|
||||||
_clear_stencil = -1;
|
|
||||||
_clear_accum_red = -1.0f;
|
|
||||||
_clear_accum_green = -1.0f;
|
|
||||||
_clear_accum_blue = -1.0f;
|
|
||||||
_clear_accum_alpha = -1.0f;
|
|
||||||
_line_width = 1.0f;
|
|
||||||
_point_size = 1.0f;
|
|
||||||
_depth_mask = false;
|
|
||||||
_fog_mode = D3DFOG_EXP;
|
|
||||||
_alpha_func = D3DCMP_ALWAYS;
|
|
||||||
_alpha_func_ref = 0;
|
|
||||||
// _polygon_mode = GL_FILL;
|
|
||||||
|
|
||||||
// _pack_alignment = 4;
|
|
||||||
// _unpack_alignment = 4;
|
|
||||||
|
|
||||||
// Set up all the enabled/disabled flags to GL's known initial
|
|
||||||
// values: everything off.
|
|
||||||
_multisample_enabled = false;
|
|
||||||
_line_smooth_enabled = false;
|
|
||||||
_point_smooth_enabled = false;
|
|
||||||
_color_material_enabled = false;
|
|
||||||
// _scissor_enabled = false;
|
|
||||||
_lighting_enabled = false;
|
|
||||||
_normals_enabled = false;
|
|
||||||
_texturing_enabled = false;
|
|
||||||
_multisample_alpha_one_enabled = false;
|
|
||||||
_multisample_alpha_mask_enabled = false;
|
|
||||||
_blend_enabled = false;
|
|
||||||
_depth_test_enabled = false;
|
|
||||||
_fog_enabled = false;
|
|
||||||
_alpha_test_enabled = false;
|
|
||||||
_decal_level = 0;
|
|
||||||
|
|
||||||
_dx_ready = false;
|
_dx_ready = false;
|
||||||
|
|
||||||
|
if (_d3dDevice!=NULL) {
|
||||||
|
_d3dDevice->SetTexture(0,NULL); // should release this stuff internally anyway
|
||||||
|
RELEASE(_d3dDevice,dxgsg,"d3dDevice",RELEASE_DOWN_TO_ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteAllVideoSurfaces();
|
||||||
|
|
||||||
|
// Release the DDraw and D3D objects used by the app
|
||||||
|
RELEASE(_zbuf,dxgsg,"zbuffer",false);
|
||||||
|
RELEASE(_back,dxgsg,"backbuffer",false);
|
||||||
|
RELEASE(_pri,dxgsg,"primary surface",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param ) {
|
HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param ) {
|
||||||
@ -490,7 +460,7 @@ HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param ) {
|
|||||||
// set up.
|
// set up.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DXGraphicsStateGuardian::
|
void DXGraphicsStateGuardian::
|
||||||
init_dx( LPDIRECTDRAW7 context,
|
dx_init( LPDIRECTDRAW7 context,
|
||||||
LPDIRECTDRAWSURFACE7 pri,
|
LPDIRECTDRAWSURFACE7 pri,
|
||||||
LPDIRECTDRAWSURFACE7 back,
|
LPDIRECTDRAWSURFACE7 back,
|
||||||
LPDIRECTDRAWSURFACE7 zbuf,
|
LPDIRECTDRAWSURFACE7 zbuf,
|
||||||
@ -505,6 +475,69 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
_d3dDevice = pDevice;
|
_d3dDevice = pDevice;
|
||||||
_view_rect = viewrect;
|
_view_rect = viewrect;
|
||||||
|
|
||||||
|
_depth_write_enabled = true;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, _depth_write_enabled);
|
||||||
|
|
||||||
|
ZeroMemory(&_lmodel_ambient,sizeof(Colorf));
|
||||||
|
_d3dDevice->SetRenderState( D3DRENDERSTATE_AMBIENT, 0x0);
|
||||||
|
|
||||||
|
_light_enabled = (bool *)NULL;
|
||||||
|
_cur_light_enabled = (bool *)NULL;
|
||||||
|
_clip_plane_enabled = (bool *)NULL;
|
||||||
|
_cur_clip_plane_enabled = (bool *)NULL;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , 0x0);
|
||||||
|
|
||||||
|
_CurShadeMode = D3DSHADE_FLAT;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, _CurShadeMode);
|
||||||
|
|
||||||
|
// need to free these properly
|
||||||
|
_cNumTexPixFmts = 0;
|
||||||
|
_pTexPixFmts = NULL;
|
||||||
|
_pCurTexContext = NULL;
|
||||||
|
|
||||||
|
//Color and alpha transform variables
|
||||||
|
_color_transform_enabled = false;
|
||||||
|
_alpha_transform_enabled = false;
|
||||||
|
_current_color_mat = LMatrix4f::ident_mat();
|
||||||
|
_current_alpha_offset = 0;
|
||||||
|
_current_alpha_scale = 1;
|
||||||
|
|
||||||
|
// none of these are implemented
|
||||||
|
//_multisample_enabled = false;
|
||||||
|
//_point_smooth_enabled = false;
|
||||||
|
|
||||||
|
_line_smooth_enabled = false;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, false);
|
||||||
|
|
||||||
|
|
||||||
|
_color_material_enabled = false;
|
||||||
|
_normals_enabled = false;
|
||||||
|
|
||||||
|
_depth_test_enabled = D3DZB_FALSE;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
|
||||||
|
|
||||||
|
_blend_enabled = false;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)_blend_enabled);
|
||||||
|
|
||||||
|
_d3dDevice->GetRenderState(D3DRENDERSTATE_SRCBLEND, (DWORD*)&_blend_source_func);
|
||||||
|
_d3dDevice->GetRenderState(D3DRENDERSTATE_DESTBLEND, (DWORD*)&_blend_dest_func);
|
||||||
|
|
||||||
|
_fog_enabled = false;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, _fog_enabled);
|
||||||
|
|
||||||
|
_decal_level = 0;
|
||||||
|
_current_projection_mat = LMatrix4f::ident_mat();
|
||||||
|
_projection_mat_stack_count = 0;
|
||||||
|
_issued_color_enabled = false;
|
||||||
|
_enable_all_color = true;
|
||||||
|
|
||||||
|
// GL stuff that hasnt been translated to DX
|
||||||
|
// _scissor_enabled = false;
|
||||||
|
// _multisample_alpha_one_enabled = false;
|
||||||
|
// _multisample_alpha_mask_enabled = false;
|
||||||
|
// _line_width = 1.0f;
|
||||||
|
// _point_size = 1.0f;
|
||||||
|
|
||||||
assert(_back!=NULL); // dxgsg is always double-buffered right now
|
assert(_back!=NULL); // dxgsg is always double-buffered right now
|
||||||
|
|
||||||
#ifdef COUNT_DRAWPRIMS
|
#ifdef COUNT_DRAWPRIMS
|
||||||
@ -521,6 +554,8 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
_pTexPixFmts = new DDPIXELFORMAT[MAX_DX_TEXPIXFMTS];
|
_pTexPixFmts = new DDPIXELFORMAT[MAX_DX_TEXPIXFMTS];
|
||||||
|
_cNumTexPixFmts = 0;
|
||||||
|
|
||||||
assert(_pTexPixFmts!=NULL);
|
assert(_pTexPixFmts!=NULL);
|
||||||
|
|
||||||
if (pDevice->EnumTextureFormats(EnumTexFmtsCallback, this) != S_OK) {
|
if (pDevice->EnumTextureFormats(EnumTexFmtsCallback, this) != S_OK) {
|
||||||
@ -542,7 +577,6 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
|
|
||||||
if ((dx_decal_type==GDT_offset) && !(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBIAS)) {
|
if ((dx_decal_type==GDT_offset) && !(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBIAS)) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
// dx7 doesnt support PLANEMASK renderstate
|
// dx7 doesnt support PLANEMASK renderstate
|
||||||
#if(DIRECT3D_VERSION < 0x700)
|
#if(DIRECT3D_VERSION < 0x700)
|
||||||
dxgsg_cat.debug() << "dx-decal-type 'offset' not supported by hardware, switching to decal masking\n";
|
dxgsg_cat.debug() << "dx-decal-type 'offset' not supported by hardware, switching to decal masking\n";
|
||||||
@ -571,13 +605,13 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
|
|
||||||
if ((dx_decal_type==GDT_mask) && !(_D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKPLANES)) {
|
if ((dx_decal_type==GDT_mask) && !(_D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKPLANES)) {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
dxgsg_cat.error() << "No hardware support for colorwrite disabling, switching to dx-decal-type 'mask' to 'blend'\n";
|
dxgsg_cat.debug() << "No hardware support for colorwrite disabling, switching to dx-decal-type 'mask' to 'blend'\n";
|
||||||
#endif
|
#endif
|
||||||
dx_decal_type = GDT_blend;
|
dx_decal_type = GDT_blend;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((dx_decal_type==GDT_blend)||(dx_decal_type==GDT_mask)) && !(_D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKZ)) {
|
if (((dx_decal_type==GDT_blend)||(dx_decal_type==GDT_mask)) && !(_D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKZ)) {
|
||||||
dxgsg_cat.error() << "dx-decal-type mask impossible to implement, no hardware support for Z-masking, decals will not appear correctly\n";
|
dxgsg_cat.error() << "dx-decal-type mask impossible to implement, no hardware support for Z-masking, decals will not appear correctly!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define REQUIRED_BLENDCAPS (D3DPBLENDCAPS_ZERO|D3DPBLENDCAPS_ONE|D3DPBLENDCAPS_SRCCOLOR|D3DPBLENDCAPS_INVSRCCOLOR| \
|
//#define REQUIRED_BLENDCAPS (D3DPBLENDCAPS_ZERO|D3DPBLENDCAPS_ONE|D3DPBLENDCAPS_SRCCOLOR|D3DPBLENDCAPS_INVSRCCOLOR| \
|
||||||
@ -640,8 +674,8 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
SetRect(&clip_rect, 0,0,0,0); // no clip rect set
|
SetRect(&clip_rect, 0,0,0,0); // no clip rect set
|
||||||
|
|
||||||
// Lighting, let's turn it off by default
|
// Lighting, let's turn it off by default
|
||||||
_lighting_enabled = true;
|
_lighting_enabled = false;
|
||||||
enable_lighting(false);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, _lighting_enabled);
|
||||||
|
|
||||||
// turn on dithering if the rendertarget is < 8bits/color channel
|
// turn on dithering if the rendertarget is < 8bits/color channel
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd_back);
|
DX_DECLARE_CLEAN(DDSURFACEDESC2, ddsd_back);
|
||||||
@ -654,8 +688,7 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
|
|
||||||
// Stencil test is off by default
|
// Stencil test is off by default
|
||||||
_stencil_test_enabled = false;
|
_stencil_test_enabled = false;
|
||||||
// _stencil_func = D3DCMP_NOTEQUAL;
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, _stencil_test_enabled);
|
||||||
// _stencil_op = D3DSTENCILOP_REPLACE;
|
|
||||||
|
|
||||||
// Antialiasing.
|
// Antialiasing.
|
||||||
enable_line_smooth(false);
|
enable_line_smooth(false);
|
||||||
@ -700,24 +733,12 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
// initial clip rect
|
// initial clip rect
|
||||||
SetRect(&clip_rect, 0,0,0,0); // no clip rect set
|
SetRect(&clip_rect, 0,0,0,0); // no clip rect set
|
||||||
|
|
||||||
// Make sure the GL state matches all of our initial attribute
|
|
||||||
// states.
|
|
||||||
PT(DepthTestTransition) dta = new DepthTestTransition;
|
|
||||||
PT(DepthWriteTransition) dwa = new DepthWriteTransition;
|
|
||||||
PT(CullFaceTransition) cfa = new CullFaceTransition;
|
|
||||||
PT(LightTransition) la = new LightTransition;
|
|
||||||
PT(TextureTransition) ta = new TextureTransition;
|
|
||||||
|
|
||||||
dta->issue(this);
|
|
||||||
dwa->issue(this);
|
|
||||||
cfa->issue(this);
|
|
||||||
la->issue(this);
|
|
||||||
|
|
||||||
// must do SetTSS here because redundant states are filtered out by our code based on current values above, so
|
// must do SetTSS here because redundant states are filtered out by our code based on current values above, so
|
||||||
// initial conditions must be correct
|
// initial conditions must be correct
|
||||||
|
|
||||||
_CurTexBlendMode = TextureApplyProperty::M_modulate;
|
_CurTexBlendMode = TextureApplyProperty::M_modulate;
|
||||||
SetTextureBlendMode(_CurTexBlendMode,FALSE);
|
SetTextureBlendMode(_CurTexBlendMode,FALSE);
|
||||||
|
_texturing_enabled = false;
|
||||||
_d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); // disables texturing
|
_d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); // disables texturing
|
||||||
|
|
||||||
// Init more Texture State
|
// Init more Texture State
|
||||||
@ -735,8 +756,6 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
_d3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU,get_texture_wrap_mode(_CurTexWrapModeU));
|
_d3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU,get_texture_wrap_mode(_CurTexWrapModeU));
|
||||||
_d3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV,get_texture_wrap_mode(_CurTexWrapModeV));
|
_d3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV,get_texture_wrap_mode(_CurTexWrapModeV));
|
||||||
|
|
||||||
ta->issue(this); // no curtextcontext, this does nothing. dx should already be properly inited above anyway
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if ((_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_MIPMAPLODBIAS) &&
|
if ((_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_MIPMAPLODBIAS) &&
|
||||||
(dx_global_miplevel_bias!=0.0f)) {
|
(dx_global_miplevel_bias!=0.0f)) {
|
||||||
@ -744,8 +763,6 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, _CurShadeMode);
|
|
||||||
|
|
||||||
if(dx_full_screen_antialiasing) {
|
if(dx_full_screen_antialiasing) {
|
||||||
if(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT) {
|
if(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT) {
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ANTIALIAS,D3DANTIALIAS_SORTINDEPENDENT);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ANTIALIAS,D3DANTIALIAS_SORTINDEPENDENT);
|
||||||
@ -770,7 +787,16 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// need to release this better, so init_dx can be called multiple times
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, dx_force_backface_culling);
|
||||||
|
|
||||||
|
_alpha_func = D3DCMP_ALWAYS;
|
||||||
|
_alpha_func_ref = 0;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, _alpha_func);
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, _alpha_func_ref);
|
||||||
|
_alpha_test_enabled = false;
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, _alpha_test_enabled);
|
||||||
|
|
||||||
|
// need to release this better, so dx_init can be called multiple times
|
||||||
|
|
||||||
if(dx_show_fps_meter) {
|
if(dx_show_fps_meter) {
|
||||||
_start_time = timeGetTime();
|
_start_time = timeGetTime();
|
||||||
@ -841,7 +867,10 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
ddsd.dwWidth = texdim_x;
|
ddsd.dwWidth = texdim_x;
|
||||||
ddsd.dwHeight = texdim_y;
|
ddsd.dwHeight = texdim_y;
|
||||||
|
|
||||||
assert(_fpsmeter_font_surf==NULL);
|
if(_fpsmeter_font_surf!=NULL) {
|
||||||
|
ULONG refcnt;
|
||||||
|
RELEASE(_fpsmeter_font_surf,dxgsg,"fpsmeter fontsurf",false);
|
||||||
|
}
|
||||||
|
|
||||||
PRINTREFCNT(_pDD,"pre-fpsmeter-font-create IDirectDraw7");
|
PRINTREFCNT(_pDD,"pre-fpsmeter-font-create IDirectDraw7");
|
||||||
|
|
||||||
@ -863,13 +892,27 @@ init_dx( LPDIRECTDRAW7 context,
|
|||||||
|
|
||||||
int numverts=(NUM_FPSMETER_LETTERS+1)*2*3; // +1 for square to hold suffix
|
int numverts=(NUM_FPSMETER_LETTERS+1)*2*3; // +1 for square to hold suffix
|
||||||
|
|
||||||
_fpsmeter_verts = (DWORD *) new BYTE[_fps_vertexsize*numverts]; //bugbug remember to release this
|
if(_fpsmeter_verts == NULL)
|
||||||
|
_fpsmeter_verts = (DWORD *) new BYTE[_fps_vertexsize*numverts];
|
||||||
|
|
||||||
_fps_u_usedwidth = letterfontareaWidth/(float)texdim_x;
|
_fps_u_usedwidth = letterfontareaWidth/(float)texdim_x;
|
||||||
_fps_v_usedheight = fontareaHeight/(float)texdim_y;
|
_fps_v_usedheight = fontareaHeight/(float)texdim_y;
|
||||||
|
|
||||||
SetFPSMeterPosition(_view_rect);
|
SetFPSMeterPosition(_view_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the DX state matches all of our initial attribute states.
|
||||||
|
PT(DepthTestTransition) dta = new DepthTestTransition;
|
||||||
|
PT(DepthWriteTransition) dwa = new DepthWriteTransition;
|
||||||
|
PT(CullFaceTransition) cfa = new CullFaceTransition;
|
||||||
|
PT(LightTransition) la = new LightTransition;
|
||||||
|
PT(TextureTransition) ta = new TextureTransition;
|
||||||
|
|
||||||
|
dta->issue(this);
|
||||||
|
dwa->issue(this);
|
||||||
|
cfa->issue(this);
|
||||||
|
la->issue(this);
|
||||||
|
ta->issue(this); // no curtextcontext, this does nothing. dx should already be properly inited above anyway
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -894,9 +937,7 @@ clear(const RenderBuffer &buffer) {
|
|||||||
if (buffer_type & RenderBuffer::T_stencil)
|
if (buffer_type & RenderBuffer::T_stencil)
|
||||||
flags |= D3DCLEAR_STENCIL;
|
flags |= D3DCLEAR_STENCIL;
|
||||||
|
|
||||||
D3DCOLOR clear_colr = Colorf_to_D3DCOLOR(_color_clear_value);
|
HRESULT hr = _d3dDevice->Clear(0, NULL, flags, _d3dcolor_clear_value,
|
||||||
|
|
||||||
HRESULT hr = _d3dDevice->Clear(0, NULL, flags, clear_colr,
|
|
||||||
(D3DVALUE) _depth_clear_value, (DWORD)_stencil_clear_value);
|
(D3DVALUE) _depth_clear_value, (DWORD)_stencil_clear_value);
|
||||||
if (hr != DD_OK)
|
if (hr != DD_OK)
|
||||||
dxgsg_cat.error() << "clear_buffer failed: Clear returned " << ConvD3DErrorToString(hr) << endl;
|
dxgsg_cat.error() << "clear_buffer failed: Clear returned " << ConvD3DErrorToString(hr) << endl;
|
||||||
@ -1299,7 +1340,7 @@ render_frame() {
|
|||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_FILLMODE, saved_fill_state);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_FILLMODE, saved_fill_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
_d3dDevice->SetTexture(0, _pCurDeviceTexture);
|
_d3dDevice->SetTexture(0, ((_pCurTexContext != NULL) ? _pCurTexContext->_surface : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = _d3dDevice->EndScene();
|
hr = _d3dDevice->EndScene();
|
||||||
@ -2707,9 +2748,9 @@ draw_tri(GeomTri *geom, GeomContext *gc) {
|
|||||||
DO_PSTATS_STUFF(PStatTimer timer(_draw_primitive_pcollector));
|
DO_PSTATS_STUFF(PStatTimer timer(_draw_primitive_pcollector));
|
||||||
DO_PSTATS_STUFF(_vertices_tri_pcollector.add_level(geom->get_num_vertices()));
|
DO_PSTATS_STUFF(_vertices_tri_pcollector.add_level(geom->get_num_vertices()));
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#if 0
|
||||||
if (_pCurTexContext!=NULL) {
|
if (_pCurTexContext!=NULL) {
|
||||||
// dxgsg_cat.spam() << "Cur active DX texture: " << _pCurTexContext->_tex->get_name() << "\n";
|
dxgsg_cat.spam() << "Cur active DX texture: " << _pCurTexContext->_tex->get_name() << "\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3808,7 +3849,7 @@ apply_texture(TextureContext *tc) {
|
|||||||
// bind_texture(tc);
|
// bind_texture(tc);
|
||||||
|
|
||||||
// specify_texture(tc->_texture);
|
// specify_texture(tc->_texture);
|
||||||
// Note: if this code changes, make sure to change initialization SetTSS code in init_dx as well
|
// Note: if this code changes, make sure to change initialization SetTSS code in dx_init as well
|
||||||
// so DX TSS renderstate matches dxgsg state
|
// so DX TSS renderstate matches dxgsg state
|
||||||
|
|
||||||
DXTextureContext *dtc = DCAST(DXTextureContext, tc);
|
DXTextureContext *dtc = DCAST(DXTextureContext, tc);
|
||||||
@ -3844,13 +3885,7 @@ apply_texture(TextureContext *tc) {
|
|||||||
int aniso_degree=tex->get_anisotropic_degree();
|
int aniso_degree=tex->get_anisotropic_degree();
|
||||||
Texture::FilterType ft=tex->get_magfilter();
|
Texture::FilterType ft=tex->get_magfilter();
|
||||||
|
|
||||||
if (aniso_degree>1) {
|
if (aniso_degree<=1) {
|
||||||
if (aniso_degree!=_CurTexAnisoDegree) {
|
|
||||||
_CurTexAnisoDegree = aniso_degree;
|
|
||||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_ANISOTROPIC );
|
|
||||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY,aniso_degree);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (_CurTexMagFilter!=ft) {
|
if (_CurTexMagFilter!=ft) {
|
||||||
|
|
||||||
_CurTexMagFilter = ft;
|
_CurTexMagFilter = ft;
|
||||||
@ -3861,6 +3896,12 @@ apply_texture(TextureContext *tc) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (aniso_degree!=_CurTexAnisoDegree) {
|
||||||
|
_CurTexAnisoDegree = aniso_degree;
|
||||||
|
_d3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_ANISOTROPIC );
|
||||||
|
_d3dDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY,aniso_degree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -3942,7 +3983,7 @@ apply_texture(TextureContext *tc) {
|
|||||||
// bugbug: does this handle the case of untextured geometry?
|
// bugbug: does this handle the case of untextured geometry?
|
||||||
// we dont see this bug cause we never mix textured/untextured
|
// we dont see this bug cause we never mix textured/untextured
|
||||||
|
|
||||||
SetDeviceTexture(dtc->_surface);
|
_d3dDevice->SetTexture(0,dtc->_surface);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (dtc!=NULL) {
|
if (dtc!=NULL) {
|
||||||
@ -4400,6 +4441,7 @@ apply_fog(Fog *fog) {
|
|||||||
Fog::Mode panda_fogmode = fog->get_mode();
|
Fog::Mode panda_fogmode = fog->get_mode();
|
||||||
D3DFOGMODE d3dfogmode = get_fog_mode_type(panda_fogmode);
|
D3DFOGMODE d3dfogmode = get_fog_mode_type(panda_fogmode);
|
||||||
|
|
||||||
|
|
||||||
// should probably avoid doing redundant SetRenderStates, but whatever
|
// should probably avoid doing redundant SetRenderStates, but whatever
|
||||||
_d3dDevice->SetRenderState((D3DRENDERSTATETYPE)_doFogType, d3dfogmode);
|
_d3dDevice->SetRenderState((D3DRENDERSTATETYPE)_doFogType, d3dfogmode);
|
||||||
|
|
||||||
@ -5068,8 +5110,7 @@ void DXGraphicsStateGuardian::issue_light(const LightTransition *attrib ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::reset_ambient
|
// Function: DXGraphicsStateGuardian::reset_ambient
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -5079,7 +5120,7 @@ void DXGraphicsStateGuardian::
|
|||||||
reset_ambient() {
|
reset_ambient() {
|
||||||
_lmodel_ambient += 2.0f;
|
_lmodel_ambient += 2.0f;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::issue_color_blend //
|
// Function: DXGraphicsStateGuardian::issue_color_blend //
|
||||||
@ -5300,26 +5341,19 @@ issue_stencil(const StencilTransition *attrib) {
|
|||||||
|
|
||||||
StencilProperty::Mode mode = attrib->get_mode();
|
StencilProperty::Mode mode = attrib->get_mode();
|
||||||
|
|
||||||
#if 1
|
|
||||||
if (mode != StencilProperty::M_none) {
|
|
||||||
dxgsg_cat.error() << "stencil buffering unimplemented for DX GSG renderer!!!\n";
|
|
||||||
// to implement stenciling, need to change wdxGraphicsWindow to create a stencil
|
|
||||||
// z-buffer or maybe do a SetRenderTarget on a new zbuffer
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
if (mode == StencilProperty::M_none) {
|
if (mode == StencilProperty::M_none) {
|
||||||
enable_stencil_test(false);
|
enable_stencil_test(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
enable_stencil_test(true);
|
enable_stencil_test(true);
|
||||||
|
// TODO: need to cache all these
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFUNC, get_stencil_func_type(mode));
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFUNC, get_stencil_func_type(mode));
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILPASS, get_stencil_action_type(attrib->get_action()));
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILPASS, get_stencil_action_type(attrib->get_pass_action()));
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFAIL, get_stencil_action_type(attrib->get_action()));
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILFAIL, get_stencil_action_type(attrib->get_fail_action()));
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILZFAIL, get_stencil_action_type(attrib->get_action()));
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILZFAIL, get_stencil_action_type(attrib->get_zfail_action()));
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILREF, attrib->get_reference_value());
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILMASK, attrib->get_func_mask());
|
||||||
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILWRITEMASK, attrib->get_write_mask());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -5818,9 +5852,6 @@ get_depth_func_type(DepthTestProperty::Mode m) const {
|
|||||||
return D3DCMP_LESS;
|
return D3DCMP_LESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// ifdef out until stencil zbuf creation works in wdxGraphicsWindow.c
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::get_stencil_func_type
|
// Function: DXGraphicsStateGuardian::get_stencil_func_type
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
@ -5838,8 +5869,7 @@ get_stencil_func_type(StencilProperty::Mode m) const {
|
|||||||
case StencilProperty::M_greater_equal: return D3DCMP_GREATEREQUAL;
|
case StencilProperty::M_greater_equal: return D3DCMP_GREATEREQUAL;
|
||||||
case StencilProperty::M_always: return D3DCMP_ALWAYS;
|
case StencilProperty::M_always: return D3DCMP_ALWAYS;
|
||||||
}
|
}
|
||||||
dxgsg_cat.error()
|
dxgsg_cat.error() << "Invalid StencilProperty::Mode value" << endl;
|
||||||
<< "Invalid StencilProperty::Mode value" << endl;
|
|
||||||
return D3DCMP_LESS;
|
return D3DCMP_LESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5859,13 +5889,10 @@ get_stencil_action_type(StencilProperty::Action a) const {
|
|||||||
case StencilProperty::A_decrement: return D3DSTENCILOP_DECR;
|
case StencilProperty::A_decrement: return D3DSTENCILOP_DECR;
|
||||||
case StencilProperty::A_invert: return D3DSTENCILOP_INVERT;
|
case StencilProperty::A_invert: return D3DSTENCILOP_INVERT;
|
||||||
}
|
}
|
||||||
dxgsg_cat.error()
|
dxgsg_cat.error() << "Invalid StencilProperty::Action value" << endl;
|
||||||
<< "Invalid StencilProperty::Action value" << endl;
|
|
||||||
return D3DSTENCILOP_KEEP;
|
return D3DSTENCILOP_KEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DXGraphicsStateGuardian::get_fog_mode_type
|
// Function: DXGraphicsStateGuardian::get_fog_mode_type
|
||||||
// Access: Protected
|
// Access: Protected
|
||||||
@ -6228,6 +6255,55 @@ bool refill_tex_callback(TextureContext *tc,void *void_dxgsg_ptr) {
|
|||||||
return hr==S_OK;
|
return hr==S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool delete_tex_callback(TextureContext *tc,void *void_dxgsg_ptr) {
|
||||||
|
DXTextureContext *dtc = DCAST(DXTextureContext, tc);
|
||||||
|
|
||||||
|
// release DDSurf (but not the texture context)
|
||||||
|
dtc->DeleteTexture();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool recreate_tex_callback(TextureContext *tc,void *void_dxgsg_ptr) {
|
||||||
|
DXTextureContext *dtc = DCAST(DXTextureContext, tc);
|
||||||
|
DXGraphicsStateGuardian *dxgsg = (DXGraphicsStateGuardian *)void_dxgsg_ptr;
|
||||||
|
|
||||||
|
// Re-fill the contents of textures and vertex buffers
|
||||||
|
// which just got restored now.
|
||||||
|
|
||||||
|
LPDIRECTDRAWSURFACE7 ddtex = dtc->CreateTexture(dxgsg->_d3dDevice,
|
||||||
|
dxgsg->_cNumTexPixFmts,dxgsg->_pTexPixFmts);
|
||||||
|
return ddtex!=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// release all textures and vertex/index buffers
|
||||||
|
HRESULT DXGraphicsStateGuardian::DeleteAllVideoSurfaces(void) {
|
||||||
|
// BUGBUG: need to handle vertexbuffer handling here
|
||||||
|
|
||||||
|
// cant access template in libpanda.dll directly due to vc++ limitations, use traverser to get around it
|
||||||
|
traverse_prepared_textures(delete_tex_callback,this);
|
||||||
|
|
||||||
|
ULONG refcnt;
|
||||||
|
|
||||||
|
if(dx_show_fps_meter)
|
||||||
|
RELEASE(_fpsmeter_font_surf,dxgsg,"fpsmeter fontsurf",false);
|
||||||
|
|
||||||
|
if(dxgsg_cat.is_debug())
|
||||||
|
dxgsg_cat.debug() << "release of all textures complete\n";
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// recreate all textures and vertex/index buffers
|
||||||
|
HRESULT DXGraphicsStateGuardian::RecreateAllVideoSurfaces(void) {
|
||||||
|
// BUGBUG: need to handle vertexbuffer handling here
|
||||||
|
|
||||||
|
// cant access template in libpanda.dll directly due to vc++ limitations, use traverser to get around it
|
||||||
|
traverse_prepared_textures(recreate_tex_callback,this);
|
||||||
|
|
||||||
|
if(dxgsg_cat.is_debug())
|
||||||
|
dxgsg_cat.debug() << "recreation of all textures complete\n";
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT DXGraphicsStateGuardian::RestoreAllVideoSurfaces(void) {
|
HRESULT DXGraphicsStateGuardian::RestoreAllVideoSurfaces(void) {
|
||||||
// BUGBUG: this should also restore vertex buffer contents when they are implemented
|
// BUGBUG: this should also restore vertex buffer contents when they are implemented
|
||||||
// You will need to destroy and recreate
|
// You will need to destroy and recreate
|
||||||
|
@ -122,6 +122,9 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
|
|||||||
// outside of this object.
|
// outside of this object.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
|
class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
|
||||||
|
friend class wdxGraphicsWindow;
|
||||||
|
friend class DXTextureContext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DXGraphicsStateGuardian(GraphicsWindow *win);
|
DXGraphicsStateGuardian(GraphicsWindow *win);
|
||||||
~DXGraphicsStateGuardian();
|
~DXGraphicsStateGuardian();
|
||||||
@ -220,11 +223,17 @@ public:
|
|||||||
virtual void end_decal(GeomNode *base_geom);
|
virtual void end_decal(GeomNode *base_geom);
|
||||||
|
|
||||||
INLINE float compute_distance_to(const LPoint3f &point) const;
|
INLINE float compute_distance_to(const LPoint3f &point) const;
|
||||||
|
virtual void set_color_clear_value(const Colorf& value);
|
||||||
|
|
||||||
void reset_ambient();
|
public:
|
||||||
|
// recreate_tex_callback needs these to be public
|
||||||
|
LPDIRECT3DDEVICE7 _d3dDevice;
|
||||||
|
LPDDPIXELFORMAT _pTexPixFmts;
|
||||||
|
int _cNumTexPixFmts;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void free_pointers();
|
void free_pointers(); // free local internal buffers
|
||||||
|
void free_dxgsg_objects(void); // free the DirectX objects we create
|
||||||
virtual PT(SavedFrameBuffer) save_frame_buffer(const RenderBuffer &buffer,
|
virtual PT(SavedFrameBuffer) save_frame_buffer(const RenderBuffer &buffer,
|
||||||
CPT(DisplayRegion) dr);
|
CPT(DisplayRegion) dr);
|
||||||
virtual void restore_frame_buffer(SavedFrameBuffer *frame_buffer);
|
virtual void restore_frame_buffer(SavedFrameBuffer *frame_buffer);
|
||||||
@ -245,15 +254,12 @@ protected:
|
|||||||
LPDIRECTDRAWSURFACE7 _back;
|
LPDIRECTDRAWSURFACE7 _back;
|
||||||
LPDIRECTDRAWSURFACE7 _zbuf;
|
LPDIRECTDRAWSURFACE7 _zbuf;
|
||||||
LPDIRECT3D7 _d3d;
|
LPDIRECT3D7 _d3d;
|
||||||
LPDIRECT3DDEVICE7 _d3dDevice;
|
|
||||||
LPDIRECTDRAWSURFACE7 _pri;
|
LPDIRECTDRAWSURFACE7 _pri;
|
||||||
LPDIRECTDRAW7 _pDD;
|
LPDIRECTDRAW7 _pDD;
|
||||||
|
|
||||||
RECT _view_rect;
|
RECT _view_rect;
|
||||||
RECT clip_rect;
|
RECT clip_rect;
|
||||||
HDC _front_hdc;
|
HDC _front_hdc;
|
||||||
int _cNumTexPixFmts;
|
|
||||||
LPDDPIXELFORMAT _pTexPixFmts;
|
|
||||||
DXTextureContext *_pCurTexContext;
|
DXTextureContext *_pCurTexContext;
|
||||||
|
|
||||||
bool _bTransformIssued; // decaling needs to tell when a transform has been issued
|
bool _bTransformIssued; // decaling needs to tell when a transform has been issued
|
||||||
@ -268,14 +274,16 @@ protected:
|
|||||||
D3DVECTOR *pCenter, float fRadius,
|
D3DVECTOR *pCenter, float fRadius,
|
||||||
DWORD wNumRings, DWORD wNumSections, float sx, float sy, float sz,
|
DWORD wNumRings, DWORD wNumSections, float sx, float sy, float sz,
|
||||||
DWORD *pNumVertices,DWORD *pNumIndices,DWORD fvfFlags,DWORD dwVertSize);
|
DWORD *pNumVertices,DWORD *pNumIndices,DWORD fvfFlags,DWORD dwVertSize);
|
||||||
HRESULT DXGraphicsStateGuardian::RestoreAllVideoSurfaces(void);
|
HRESULT RestoreAllVideoSurfaces(void);
|
||||||
|
HRESULT RecreateAllVideoSurfaces(void);
|
||||||
INLINE void set_pack_alignment(int alignment);
|
HRESULT DeleteAllVideoSurfaces(void);
|
||||||
INLINE void set_unpack_alignment(int alignment);
|
|
||||||
|
|
||||||
|
/*
|
||||||
INLINE void enable_multisample_alpha_one(bool val);
|
INLINE void enable_multisample_alpha_one(bool val);
|
||||||
INLINE void enable_multisample_alpha_mask(bool val);
|
INLINE void enable_multisample_alpha_mask(bool val);
|
||||||
INLINE void enable_multisample(bool val);
|
INLINE void enable_multisample(bool val);
|
||||||
|
*/
|
||||||
|
|
||||||
INLINE void enable_color_material(bool val);
|
INLINE void enable_color_material(bool val);
|
||||||
INLINE void enable_clip_plane(int clip_plane, bool val);
|
INLINE void enable_clip_plane(int clip_plane, bool val);
|
||||||
INLINE void enable_fog(bool val);
|
INLINE void enable_fog(bool val);
|
||||||
@ -285,15 +293,9 @@ protected:
|
|||||||
INLINE D3DCMPFUNC get_depth_func_type(DepthTestProperty::Mode m) const;
|
INLINE D3DCMPFUNC get_depth_func_type(DepthTestProperty::Mode m) const;
|
||||||
INLINE D3DFOGMODE get_fog_mode_type(Fog::Mode m) const;
|
INLINE D3DFOGMODE get_fog_mode_type(Fog::Mode m) const;
|
||||||
|
|
||||||
#if 0
|
|
||||||
INLINE D3DCMPFUNC get_stencil_func_type(StencilProperty::Mode m) const;
|
INLINE D3DCMPFUNC get_stencil_func_type(StencilProperty::Mode m) const;
|
||||||
INLINE D3DSTENCILOP get_stencil_action_type(StencilProperty::Action a) const;
|
INLINE D3DSTENCILOP get_stencil_action_type(StencilProperty::Action a) const;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* INLINE void enable_multisample_alpha_one(bool val);
|
|
||||||
INLINE void enable_multisample_alpha_mask(bool val);
|
|
||||||
INLINE void enable_multisample(bool val, LPDIRECT3DDEVICE7 d3dDevice);
|
|
||||||
*/
|
|
||||||
INLINE void enable_alpha_test(bool val);
|
INLINE void enable_alpha_test(bool val);
|
||||||
INLINE void enable_line_smooth(bool val);
|
INLINE void enable_line_smooth(bool val);
|
||||||
INLINE void enable_blend(bool val);
|
INLINE void enable_blend(bool val);
|
||||||
@ -328,6 +330,7 @@ protected:
|
|||||||
bool _enable_all_color;
|
bool _enable_all_color;
|
||||||
Colorf _issued_color; // WBD ADDED
|
Colorf _issued_color; // WBD ADDED
|
||||||
D3DCOLOR _issued_color_D3DCOLOR; // WBD ADDED
|
D3DCOLOR _issued_color_D3DCOLOR; // WBD ADDED
|
||||||
|
D3DCOLOR _d3dcolor_clear_value;
|
||||||
|
|
||||||
D3DSHADEMODE _CurShadeMode;
|
D3DSHADEMODE _CurShadeMode;
|
||||||
|
|
||||||
@ -340,27 +343,12 @@ protected:
|
|||||||
Geom::TexCoordIterator ti;
|
Geom::TexCoordIterator ti;
|
||||||
Geom::ColorIterator ci;
|
Geom::ColorIterator ci;
|
||||||
|
|
||||||
float _clear_color_red, _clear_color_green, _clear_color_blue,_clear_color_alpha;
|
|
||||||
double _clear_depth;
|
|
||||||
int _clear_stencil;
|
|
||||||
float _clear_accum_red, _clear_accum_green, _clear_accum_blue,_clear_accum_alpha;
|
|
||||||
int _scissor_x;
|
|
||||||
int _scissor_y;
|
|
||||||
int _scissor_width;
|
|
||||||
int _scissor_height;
|
|
||||||
int _viewport_x;
|
|
||||||
int _viewport_y;
|
|
||||||
int _viewport_width;
|
|
||||||
int _viewport_height;
|
|
||||||
Colorf _lmodel_ambient;
|
Colorf _lmodel_ambient;
|
||||||
float _material_ambient;
|
float _material_ambient;
|
||||||
float _material_diffuse;
|
float _material_diffuse;
|
||||||
float _material_specular;
|
float _material_specular;
|
||||||
float _material_shininess;
|
float _material_shininess;
|
||||||
float _material_emission;
|
float _material_emission;
|
||||||
float _line_width;
|
|
||||||
float _point_size;
|
|
||||||
bool _depth_mask;
|
|
||||||
|
|
||||||
typedef enum {None,
|
typedef enum {None,
|
||||||
PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
|
PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
|
||||||
@ -368,19 +356,20 @@ protected:
|
|||||||
} DxgsgFogType;
|
} DxgsgFogType;
|
||||||
DxgsgFogType _doFogType;
|
DxgsgFogType _doFogType;
|
||||||
bool _fog_enabled;
|
bool _fog_enabled;
|
||||||
int _fog_mode;
|
/*
|
||||||
|
TODO: cache fog state
|
||||||
float _fog_start;
|
float _fog_start;
|
||||||
float _fog_end;
|
float _fog_end;
|
||||||
float _fog_density;
|
float _fog_density;
|
||||||
float _fog_color;
|
float _fog_color;
|
||||||
|
*/
|
||||||
float _alpha_func_ref;
|
float _alpha_func_ref;
|
||||||
D3DCMPFUNC _alpha_func;
|
D3DCMPFUNC _alpha_func;
|
||||||
|
|
||||||
D3DBLEND _blend_source_func;
|
D3DBLEND _blend_source_func;
|
||||||
D3DBLEND _blend_dest_func;
|
D3DBLEND _blend_dest_func;
|
||||||
|
|
||||||
bool _multisample_enabled;
|
|
||||||
bool _line_smooth_enabled;
|
bool _line_smooth_enabled;
|
||||||
bool _point_smooth_enabled;
|
|
||||||
bool* _light_enabled; // bool[_max_lights]
|
bool* _light_enabled; // bool[_max_lights]
|
||||||
bool _color_material_enabled;
|
bool _color_material_enabled;
|
||||||
bool _lighting_enabled;
|
bool _lighting_enabled;
|
||||||
@ -389,16 +378,11 @@ protected:
|
|||||||
bool _dither_enabled;
|
bool _dither_enabled;
|
||||||
bool _stencil_test_enabled;
|
bool _stencil_test_enabled;
|
||||||
bool* _clip_plane_enabled; // bool[_max_clip_planes]
|
bool* _clip_plane_enabled; // bool[_max_clip_planes]
|
||||||
bool _multisample_alpha_one_enabled;
|
|
||||||
bool _multisample_alpha_mask_enabled;
|
|
||||||
bool _blend_enabled;
|
bool _blend_enabled;
|
||||||
bool _depth_test_enabled;
|
bool _depth_test_enabled;
|
||||||
bool _depth_write_enabled;
|
bool _depth_write_enabled;
|
||||||
DWORD _old_colormaskval;
|
|
||||||
bool _alpha_test_enabled;
|
bool _alpha_test_enabled;
|
||||||
int _decal_level;
|
int _decal_level;
|
||||||
LPDIRECTDRAWSURFACE7 _pCurDeviceTexture;
|
|
||||||
INLINE void SetDeviceTexture(LPDIRECTDRAWSURFACE7 pTexture);
|
|
||||||
|
|
||||||
RenderModeProperty::Mode _current_fill_mode; //poinr/wireframe/solid
|
RenderModeProperty::Mode _current_fill_mode; //poinr/wireframe/solid
|
||||||
|
|
||||||
@ -433,8 +417,6 @@ protected:
|
|||||||
float _current_alpha_offset;
|
float _current_alpha_offset;
|
||||||
float _current_alpha_scale;
|
float _current_alpha_scale;
|
||||||
|
|
||||||
int _pass_number;
|
|
||||||
|
|
||||||
// vars for frames/sec meter
|
// vars for frames/sec meter
|
||||||
DWORD _start_time;
|
DWORD _start_time;
|
||||||
DWORD _start_frame_count;
|
DWORD _start_frame_count;
|
||||||
@ -476,7 +458,7 @@ public:
|
|||||||
void show_frame();
|
void show_frame();
|
||||||
void show_full_screen_frame();
|
void show_full_screen_frame();
|
||||||
void show_windowed_frame();
|
void show_windowed_frame();
|
||||||
void init_dx( LPDIRECTDRAW7 context,
|
void dx_init( LPDIRECTDRAW7 context,
|
||||||
LPDIRECTDRAWSURFACE7 pri,
|
LPDIRECTDRAWSURFACE7 pri,
|
||||||
LPDIRECTDRAWSURFACE7 back,
|
LPDIRECTDRAWSURFACE7 back,
|
||||||
LPDIRECTDRAWSURFACE7 zbuf,
|
LPDIRECTDRAWSURFACE7 zbuf,
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
// Description :
|
// Description :
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDADX DXTextureContext : public TextureContext {
|
class EXPCL_PANDADX DXTextureContext : public TextureContext {
|
||||||
|
friend class DXGraphicsStateGuardian;
|
||||||
|
friend class wdxGraphicsWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DXTextureContext(Texture *tex);
|
DXTextureContext(Texture *tex);
|
||||||
~DXTextureContext();
|
~DXTextureContext();
|
||||||
@ -54,10 +57,11 @@ public:
|
|||||||
|
|
||||||
LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts);
|
LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts);
|
||||||
|
|
||||||
void DeleteTexture();
|
|
||||||
|
|
||||||
bool _bHasMipMaps;
|
bool _bHasMipMaps;
|
||||||
DWORD _PixBufConversionType; // enum ConversionType
|
DWORD _PixBufConversionType; // enum ConversionType
|
||||||
|
|
||||||
|
// must be public since called from global callback fns
|
||||||
|
void DeleteTexture(void);
|
||||||
HRESULT FillDDSurfTexturePixels(void);
|
HRESULT FillDDSurfTexturePixels(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -79,8 +83,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
|
|
||||||
friend class DXGraphicsStateGuardian;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ init_libwdxdisplay() {
|
|||||||
GraphicsWindow::get_factory().register_factory(
|
GraphicsWindow::get_factory().register_factory(
|
||||||
wdxGraphicsWindow::get_class_type(),
|
wdxGraphicsWindow::get_class_type(),
|
||||||
wdxGraphicsWindow::make_wdxGraphicsWindow);
|
wdxGraphicsWindow::make_wdxGraphicsWindow);
|
||||||
|
|
||||||
|
set_global_parameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cant use global var cleanly because global var static init executed after init_libwdxdisplay(), incorrectly reiniting var
|
// cant use global var cleanly because global var static init executed after init_libwdxdisplay(), incorrectly reiniting var
|
||||||
|
@ -62,9 +62,11 @@ TypeHandle wdxGraphicsPipe::get_class_type(void) {
|
|||||||
return _type_handle;
|
return _type_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *pipe_type_name="wdxGraphicsPipe";
|
||||||
|
|
||||||
void wdxGraphicsPipe::init_type(void) {
|
void wdxGraphicsPipe::init_type(void) {
|
||||||
InteractiveGraphicsPipe::init_type();
|
InteractiveGraphicsPipe::init_type();
|
||||||
register_type(_type_handle, "wdxGraphicsPipe",
|
register_type(_type_handle, pipe_type_name,
|
||||||
InteractiveGraphicsPipe::get_class_type());
|
InteractiveGraphicsPipe::get_class_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,18 +76,17 @@ TypeHandle wdxGraphicsPipe::get_type(void) const {
|
|||||||
|
|
||||||
wdxGraphicsPipe::wdxGraphicsPipe(void) {
|
wdxGraphicsPipe::wdxGraphicsPipe(void) {
|
||||||
wdxdisplay_cat.error()
|
wdxdisplay_cat.error()
|
||||||
<< "wdxGraphicsPipes should not be created with the default constructor"
|
<< pipe_type_name <<"s should not be created with the default constructor" << endl;
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wdxGraphicsPipe::wdxGraphicsPipe(const wdxGraphicsPipe&) {
|
wdxGraphicsPipe::wdxGraphicsPipe(const wdxGraphicsPipe&) {
|
||||||
wdxdisplay_cat.error()
|
wdxdisplay_cat.error()
|
||||||
<< "wdxGraphicsPipes should not be copied" << endl;
|
<< pipe_type_name << "s should not be copied" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
wdxGraphicsPipe& wdxGraphicsPipe::operator=(const wdxGraphicsPipe&) {
|
wdxGraphicsPipe& wdxGraphicsPipe::operator=(const wdxGraphicsPipe&) {
|
||||||
wdxdisplay_cat.error()
|
wdxdisplay_cat.error()
|
||||||
<< "wdxGraphicsPipes should not be assigned" << endl;
|
<< pipe_type_name << "s should not be assigned" << endl;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,20 @@ static DWORD BitDepth_2_DDBDMask(DWORD iBitDepth) {
|
|||||||
}
|
}
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
typedef enum {DBGLEV_FATAL,DBGLEV_ERROR,DBGLEV_WARNING,DBGLEV_INFO,DBGLEV_DEBUG,DBGLEV_SPAM
|
||||||
|
} DebugLevels;
|
||||||
|
|
||||||
|
void PrintDBGStr(DebugLevels level,HRESULT hr,const char *msgstr) {
|
||||||
|
ostream *pstrm;
|
||||||
|
static ostream dbg_strms[DBGLEV_SPAM+1]={wdxdisplay_cat.fatal,wdxdisplay_cat.error,
|
||||||
|
wdxdisplay_cat.warning,wdxdisplay_cat.info,wdxdisplay_cat.debug,wdxdisplay_cat.spam};
|
||||||
|
assert(level<=DBGLEV_SPAM);
|
||||||
|
|
||||||
|
pstrm=dbg_strms[level];
|
||||||
|
(*pstrm)->fatal() << "GetDisplayMode failed, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
}
|
||||||
|
*/
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static void DebugPrintPixFmt(DDPIXELFORMAT* pddpf) {
|
static void DebugPrintPixFmt(DDPIXELFORMAT* pddpf) {
|
||||||
static int iddpfnum=0;
|
static int iddpfnum=0;
|
||||||
@ -224,6 +237,8 @@ void AtExitFn() {
|
|||||||
wdxdisplay_cat.spam() << "AtExitFn called\n";
|
wdxdisplay_cat.spam() << "AtExitFn called\n";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
restore_global_parameters();
|
||||||
|
|
||||||
DestroyAllWindows(true);
|
DestroyAllWindows(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,35 +274,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
case WM_CREATE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_CLOSE:
|
|
||||||
close_window();
|
|
||||||
|
|
||||||
// BUGBUG: right now there is no way to tell the panda app the graphics window is invalid or
|
|
||||||
// has been closed by the user, to prevent further methods from being called on the window.
|
|
||||||
// this needs to be added to panda for multiple windows to work. in the meantime, just
|
|
||||||
// trigger an exit here if # windows==0, since that is the expected behavior when all
|
|
||||||
// windows are closed (should be done by the app though, and it assumes you only make this
|
|
||||||
// type of panda gfx window)
|
|
||||||
|
|
||||||
if(hwnd_pandawin_map.size()==0) {
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_ACTIVATEAPP: {
|
|
||||||
#ifdef _DEBUG
|
|
||||||
wdxdisplay_cat.spam() << "WM_ACTIVATEAPP(" << (bool)(wparam!=0) <<") received\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if((!wparam) && _props._fullscreen) {
|
|
||||||
deactivate_window();
|
|
||||||
return 0;
|
|
||||||
} // dont want to reactivate until window is actually un-minimized (see WM_SIZE)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
@ -299,9 +285,27 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
if(!DXREADY)
|
||||||
|
break;
|
||||||
|
|
||||||
|
x = LOWORD(lparam);
|
||||||
|
y = HIWORD(lparam);
|
||||||
|
if(x & 1 << 15) x -= (1 << 16);
|
||||||
|
if(y & 1 << 15) y -= (1 << 16);
|
||||||
|
if(mouse_motion_enabled()
|
||||||
|
&& wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
|
||||||
|
handle_mouse_motion(x, y);
|
||||||
|
} else if(mouse_passive_motion_enabled() &&
|
||||||
|
((wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)) {
|
||||||
|
handle_mouse_motion(x, y);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#if 0
|
||||||
case WM_SYSCHAR:
|
case WM_SYSCHAR:
|
||||||
case WM_CHAR: // shouldnt receive WM_CHAR unless WM_KEYDOWN stops returning 0 and passes on to DefWindProc
|
case WM_CHAR: // shouldnt receive WM_CHAR unless WM_KEYDOWN stops returning 0 and passes on to DefWindProc
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
case WM_KEYDOWN: {
|
case WM_KEYDOWN: {
|
||||||
@ -397,23 +401,6 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
handle_keyrelease(MouseButton::button(button));
|
handle_keyrelease(MouseButton::button(button));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
if(!DXREADY)
|
|
||||||
break;
|
|
||||||
|
|
||||||
x = LOWORD(lparam);
|
|
||||||
y = HIWORD(lparam);
|
|
||||||
if(x & 1 << 15) x -= (1 << 16);
|
|
||||||
if(y & 1 << 15) y -= (1 << 16);
|
|
||||||
if(mouse_motion_enabled()
|
|
||||||
&& wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) {
|
|
||||||
handle_mouse_motion(x, y);
|
|
||||||
} else if(mouse_passive_motion_enabled() &&
|
|
||||||
((wparam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) == 0)) {
|
|
||||||
handle_mouse_motion(x, y);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
if(!DXREADY)
|
if(!DXREADY)
|
||||||
break;
|
break;
|
||||||
@ -426,73 +413,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(_WindowAdjustingType==Resizing) {
|
if(_WindowAdjustingType==Resizing) {
|
||||||
|
|
||||||
GdiFlush();
|
|
||||||
|
|
||||||
if(_dxgsg!=NULL) {
|
|
||||||
_dxgsg->SetDXReady(false); // disable rendering whilst we mess with surfs
|
|
||||||
|
|
||||||
// Want to change rendertarget size without destroying d3d device. To save vid memory
|
|
||||||
// (and make resizing work on memory-starved 4MB cards), we need to construct
|
|
||||||
// a temporary mini-sized render target for the d3d device (it cannot point to a
|
|
||||||
// NULL rendertarget) before creating the fully resized buffers. The old
|
|
||||||
// rendertargets will be freed when these temp targets are set, and that will give
|
|
||||||
// us the memory to create the resized target
|
|
||||||
|
|
||||||
LPDIRECTDRAWSURFACE7 pddsDummy = NULL, pddsDummyZ = NULL;
|
|
||||||
HRESULT hr;
|
|
||||||
ULONG refcnt;
|
|
||||||
|
|
||||||
DX_DECLARE_CLEAN( DDSURFACEDESC2, ddsd );
|
|
||||||
|
|
||||||
if(_dxgsg->GetBackBuffer()==NULL) // bugbug why is this ever true??
|
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
|
||||||
|
|
||||||
_dxgsg->GetBackBuffer()->GetSurfaceDesc(&ddsd);
|
|
||||||
LPDIRECTDRAW7 pDD = _dxgsg->GetDDInterface();
|
|
||||||
|
|
||||||
ddsd.dwFlags &= ~DDSD_PITCH;
|
|
||||||
ddsd.dwWidth = 1; ddsd.dwHeight = 1;
|
|
||||||
ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER);
|
|
||||||
|
|
||||||
PRINTVIDMEM(pDD,&ddsd.ddsCaps,"dummy backbuf");
|
|
||||||
|
|
||||||
if(FAILED( hr = pDD->CreateSurface( &ddsd, &pddsDummy, NULL ) )) {
|
|
||||||
wdxdisplay_cat.fatal() << "Resize CreateSurface for temp backbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
DX_DECLARE_CLEAN( DDSURFACEDESC2, ddsdZ );
|
|
||||||
_dxgsg->GetZBuffer()->GetSurfaceDesc(&ddsdZ);
|
|
||||||
ddsdZ.dwFlags &= ~DDSD_PITCH;
|
|
||||||
ddsdZ.dwWidth = 1; ddsdZ.dwHeight = 1;
|
|
||||||
|
|
||||||
PRINTVIDMEM(pDD,&ddsdZ.ddsCaps,"dummy zbuf");
|
|
||||||
|
|
||||||
if(FAILED( hr = pDD->CreateSurface( &ddsdZ, &pddsDummyZ, NULL ) )) {
|
|
||||||
wdxdisplay_cat.fatal() << "Resize CreateSurface for temp zbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FAILED( hr = pddsDummy->AddAttachedSurface( pddsDummyZ ) )) {
|
|
||||||
wdxdisplay_cat.fatal() << "Resize AddAttachedSurf for temp zbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(FAILED( hr = _dxgsg->GetD3DDevice()->SetRenderTarget( pddsDummy, 0x0 ))) {
|
|
||||||
wdxdisplay_cat.fatal()
|
|
||||||
<< "Resize failed to set render target to temporary surface, result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
RELEASE(pddsDummyZ,wdxdisplay,"dummy resize zbuffer",false);
|
|
||||||
RELEASE(pddsDummy,wdxdisplay,"dummy resize rendertarget buffer",false);
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_reshape(true);
|
handle_reshape(true);
|
||||||
|
|
||||||
if(_dxgsg!=NULL) {
|
|
||||||
_dxgsg->SetDXReady(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_WindowAdjustingType = NotAdjusting;
|
_WindowAdjustingType = NotAdjusting;
|
||||||
@ -523,6 +444,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
// _dxgsg->CheckCooperativeLevel(DO_REACTIVATE_WINDOW);
|
// _dxgsg->CheckCooperativeLevel(DO_REACTIVATE_WINDOW);
|
||||||
// else reactivate_window();
|
// else reactivate_window();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// does the windowed case handle displaychange properly? no. need to recreate all devices
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -538,7 +461,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// old comment -- added SIZE_RESTORED to handle 3dfx case
|
// old comment -- added SIZE_RESTORED to handle 3dfx case
|
||||||
if((_mwindow==NULL) || ((wparam != SIZE_RESTORED) && (wparam != SIZE_MAXIMIZED)))
|
if((_mwindow==NULL) || dx_full_screen || ((wparam != SIZE_RESTORED) && (wparam != SIZE_MAXIMIZED)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
width = LOWORD(lparam); height = HIWORD(lparam);
|
width = LOWORD(lparam); height = HIWORD(lparam);
|
||||||
@ -547,7 +470,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
_WindowAdjustingType = Resizing;
|
_WindowAdjustingType = Resizing;
|
||||||
|
|
||||||
// for maximized,unmaximize, need to call resize code artificially
|
// for maximized,unmaximize, need to call resize code artificially
|
||||||
// since no WM_EXITSIZEMOVE is generated
|
// since no WM_EXITSIZEMOVE is generated.
|
||||||
if(wparam==SIZE_MAXIMIZED) {
|
if(wparam==SIZE_MAXIMIZED) {
|
||||||
_bSizeIsMaximized=TRUE;
|
_bSizeIsMaximized=TRUE;
|
||||||
window_proc(hwnd, WM_EXITSIZEMOVE, 0x0,0x0);
|
window_proc(hwnd, WM_EXITSIZEMOVE, 0x0,0x0);
|
||||||
@ -617,6 +540,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
|
// WM_ERASEBKGND will be ignored during resizing, because
|
||||||
|
// we dont want to redraw as user is manually resizing window
|
||||||
if(_WindowAdjustingType)
|
if(_WindowAdjustingType)
|
||||||
break;
|
break;
|
||||||
return 0; // dont let GDI waste time redrawing the deflt background
|
return 0; // dont let GDI waste time redrawing the deflt background
|
||||||
@ -652,6 +577,36 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
// does app need to know to avoid major computation?
|
// does app need to know to avoid major computation?
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
close_window();
|
||||||
|
|
||||||
|
// BUGBUG: right now there is no way to tell the panda app the graphics window is invalid or
|
||||||
|
// has been closed by the user, to prevent further methods from being called on the window.
|
||||||
|
// this needs to be added to panda for multiple windows to work. in the meantime, just
|
||||||
|
// trigger an exit here if # windows==0, since that is the expected behavior when all
|
||||||
|
// windows are closed (should be done by the app though, and it assumes you only make this
|
||||||
|
// type of panda gfx window)
|
||||||
|
|
||||||
|
if(hwnd_pandawin_map.size()==0) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
//case WM_CREATE:
|
||||||
|
// break;
|
||||||
|
|
||||||
|
case WM_ACTIVATEAPP: {
|
||||||
|
#ifdef _DEBUG
|
||||||
|
wdxdisplay_cat.spam() << "WM_ACTIVATEAPP(" << (bool)(wparam!=0) <<") received\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if((!wparam) && _props._fullscreen) {
|
||||||
|
deactivate_window();
|
||||||
|
return 0;
|
||||||
|
} // dont want to reactivate until window is actually un-minimized (see WM_SIZE)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||||
@ -664,6 +619,78 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void wdxGraphicsWindow::handle_reshape(bool bDoDxReset) {
|
void wdxGraphicsWindow::handle_reshape(bool bDoDxReset) {
|
||||||
|
|
||||||
|
GdiFlush();
|
||||||
|
|
||||||
|
if(bDoDxReset && _dxgsg!=NULL) {
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if(_dxgsg->GetBackBuffer()==NULL) {
|
||||||
|
//assume this is initial creation reshape and ignore this call
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAILED(hr = _dxgsg->_pDD->TestCooperativeLevel())) {
|
||||||
|
wdxdisplay_cat.error() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dxgsg->SetDXReady(false); // disable rendering whilst we mess with surfs
|
||||||
|
|
||||||
|
_dxgsg->RestoreAllVideoSurfaces();
|
||||||
|
|
||||||
|
// Want to change rendertarget size without destroying d3d device. To save vid memory
|
||||||
|
// (and make resizing work on memory-starved 4MB cards), we need to construct
|
||||||
|
// a temporary mini-sized render target for the d3d device (it cannot point to a
|
||||||
|
// NULL rendertarget) before creating the fully resized buffers. The old
|
||||||
|
// rendertargets will be freed when these temp targets are set, and that will give
|
||||||
|
// us the memory to create the resized target
|
||||||
|
|
||||||
|
LPDIRECTDRAWSURFACE7 pddsDummy = NULL, pddsDummyZ = NULL;
|
||||||
|
ULONG refcnt;
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN( DDSURFACEDESC2, ddsd );
|
||||||
|
|
||||||
|
_dxgsg->GetBackBuffer()->GetSurfaceDesc(&ddsd);
|
||||||
|
LPDIRECTDRAW7 pDD = _dxgsg->GetDDInterface();
|
||||||
|
|
||||||
|
ddsd.dwFlags &= ~DDSD_PITCH;
|
||||||
|
ddsd.dwWidth = 1; ddsd.dwHeight = 1;
|
||||||
|
ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER);
|
||||||
|
|
||||||
|
PRINTVIDMEM(pDD,&ddsd.ddsCaps,"dummy backbuf");
|
||||||
|
|
||||||
|
if(FAILED( hr = pDD->CreateSurface( &ddsd, &pddsDummy, NULL ) )) {
|
||||||
|
wdxdisplay_cat.fatal() << "Resize CreateSurface for temp backbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN( DDSURFACEDESC2, ddsdZ );
|
||||||
|
_dxgsg->GetZBuffer()->GetSurfaceDesc(&ddsdZ);
|
||||||
|
ddsdZ.dwFlags &= ~DDSD_PITCH;
|
||||||
|
ddsdZ.dwWidth = 1; ddsdZ.dwHeight = 1;
|
||||||
|
|
||||||
|
PRINTVIDMEM(pDD,&ddsdZ.ddsCaps,"dummy zbuf");
|
||||||
|
|
||||||
|
if(FAILED( hr = pDD->CreateSurface( &ddsdZ, &pddsDummyZ, NULL ) )) {
|
||||||
|
wdxdisplay_cat.fatal() << "Resize CreateSurface for temp zbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAILED( hr = pddsDummy->AddAttachedSurface( pddsDummyZ ) )) {
|
||||||
|
wdxdisplay_cat.fatal() << "Resize AddAttachedSurf for temp zbuf failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAILED( hr = _dxgsg->GetD3DDevice()->SetRenderTarget( pddsDummy, 0x0 ))) {
|
||||||
|
wdxdisplay_cat.fatal()
|
||||||
|
<< "Resize failed to set render target to temporary surface, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
RELEASE(pddsDummyZ,wdxdisplay,"dummy resize zbuffer",false);
|
||||||
|
RELEASE(pddsDummy,wdxdisplay,"dummy resize rendertarget buffer",false);
|
||||||
|
}
|
||||||
|
|
||||||
RECT view_rect;
|
RECT view_rect;
|
||||||
GetClientRect( _mwindow, &view_rect );
|
GetClientRect( _mwindow, &view_rect );
|
||||||
ClientToScreen( _mwindow, (POINT*)&view_rect.left ); // translates top,left pnt
|
ClientToScreen( _mwindow, (POINT*)&view_rect.left ); // translates top,left pnt
|
||||||
@ -679,8 +706,10 @@ void wdxGraphicsWindow::handle_reshape(bool bDoDxReset) {
|
|||||||
wdxdisplay_cat.spam() << "reshape to origin: (" << _props._xorg << "," << _props._yorg << "), size: (" << _props._xsize << "," << _props._ysize << ")\n";
|
wdxdisplay_cat.spam() << "reshape to origin: (" << _props._xorg << "," << _props._yorg << "), size: (" << _props._xsize << "," << _props._ysize << ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if((_dxgsg!=NULL) && bDoDxReset) {
|
if(_dxgsg!=NULL) {
|
||||||
|
if(bDoDxReset)
|
||||||
_dxgsg->dx_setup_after_resize(view_rect,_mwindow); // create the new resized rendertargets
|
_dxgsg->dx_setup_after_resize(view_rect,_mwindow); // create the new resized rendertargets
|
||||||
|
_dxgsg->SetDXReady(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,7 +1003,7 @@ HRESULT CALLBACK EnumDevicesCallback(LPSTR pDeviceDescription, LPSTR pDeviceName
|
|||||||
return DDENUMRET_OK;
|
return DDENUMRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_DISPLAY_MODES 100
|
#define MAX_DISPLAY_MODES 100 // probably dont need this much, since i already screen for width&hgt
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DWORD maxWidth,maxHeight;
|
DWORD maxWidth,maxHeight;
|
||||||
DWORD supportedBitDepths; // uses DDBD_* flags
|
DWORD supportedBitDepths; // uses DDBD_* flags
|
||||||
@ -985,10 +1014,8 @@ typedef struct {
|
|||||||
HRESULT WINAPI EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
HRESULT WINAPI EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
||||||
DisplayModeInfo *pDMI = (DisplayModeInfo *) lpContext;
|
DisplayModeInfo *pDMI = (DisplayModeInfo *) lpContext;
|
||||||
|
|
||||||
// ignore everything over specified dimensions
|
// ddsd_search should assure this is true
|
||||||
if((lpDDSurfaceDesc->dwWidth > pDMI->maxWidth) ||
|
assert((lpDDSurfaceDesc->dwWidth == pDMI->maxWidth) && (lpDDSurfaceDesc->dwHeight == pDMI->maxHeight));
|
||||||
(lpDDSurfaceDesc->dwHeight > pDMI->maxHeight))
|
|
||||||
return DDENUMRET_OK;
|
|
||||||
|
|
||||||
// ignore refresh rates under 60Hz (and special values of 0 & 1)
|
// ignore refresh rates under 60Hz (and special values of 0 & 1)
|
||||||
if((lpDDSurfaceDesc->dwRefreshRate>1) && (lpDDSurfaceDesc->dwRefreshRate<60))
|
if((lpDDSurfaceDesc->dwRefreshRate>1) && (lpDDSurfaceDesc->dwRefreshRate<60))
|
||||||
@ -1017,8 +1044,145 @@ BOOL WINAPI DriverEnumCallback( GUID* pGUID, TCHAR* strDesc,TCHAR* strName,
|
|||||||
return DDENUMRET_OK;
|
return DDENUMRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
|
void wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
|
||||||
//}
|
if(wdxdisplay_cat.is_debug())
|
||||||
|
wdxdisplay_cat.debug() << "resize("<<xsize<<","<<ysize<<") called\n";
|
||||||
|
|
||||||
|
if (!_props._fullscreen) {
|
||||||
|
// is this enough?
|
||||||
|
SetWindowPos(_mwindow, NULL, 0,0, xsize, ysize, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSENDCHANGING);
|
||||||
|
// WM_ERASEBKGND will be ignored, because _WindowAdjustingType!=NotAdjusting because
|
||||||
|
// we dont want to redraw as user is manually resizing window, so need to force explicit
|
||||||
|
// background clear for the programmatic resize fn call
|
||||||
|
_WindowAdjustingType=NotAdjusting;
|
||||||
|
window_proc(_mwindow, WM_ERASEBKGND,(WPARAM)_hdc,0x0);
|
||||||
|
handle_reshape(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dxgsg->SetDXReady(false);
|
||||||
|
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_curmode);
|
||||||
|
|
||||||
|
if(FAILED(hr = _dxgsg->_pDD->GetDisplayMode(&ddsd_curmode))) {
|
||||||
|
wdxdisplay_cat.fatal() << "resize() - GetDisplayMode failed, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_search);
|
||||||
|
|
||||||
|
ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
||||||
|
ddsd_search.dwWidth=xsize; ddsd_search.dwHeight=ysize;
|
||||||
|
|
||||||
|
// not requesting same refresh rate since changing res might not support same refresh rate
|
||||||
|
|
||||||
|
DDSURFACEDESC2 DDSD_Arr[MAX_DISPLAY_MODES];
|
||||||
|
DisplayModeInfo DMI;
|
||||||
|
ZeroMemory(&DDSD_Arr,sizeof(DDSD_Arr));
|
||||||
|
ZeroMemory(&DMI,sizeof(DMI));
|
||||||
|
DMI.maxWidth=xsize; DMI.maxHeight=ysize;
|
||||||
|
DMI.pDDSD_Arr=DDSD_Arr;
|
||||||
|
|
||||||
|
if(FAILED(hr = _dxgsg->_pDD->EnumDisplayModes(DDEDM_REFRESHRATES,&ddsd_search,&DMI,EnumDisplayModesCallBack))) {
|
||||||
|
wdxdisplay_cat.fatal() << "resize() - EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DMI.supportedBitDepths &= _dxgsg->_D3DDevDesc.dwDeviceRenderBitDepth;
|
||||||
|
|
||||||
|
DWORD dwFullScreenBitDepth;
|
||||||
|
DWORD requested_bpp=ddsd_curmode.ddpfPixelFormat.dwRGBBitCount;
|
||||||
|
|
||||||
|
// would like to match current bpp first. if that is not possible, try 16bpp, then 32
|
||||||
|
DWORD requested_bpp_DDBD = BitDepth_2_DDBDMask(requested_bpp);
|
||||||
|
|
||||||
|
if(DMI.supportedBitDepths & requested_bpp_DDBD) {
|
||||||
|
dwFullScreenBitDepth=requested_bpp;
|
||||||
|
} else if(DMI.supportedBitDepths & DDBD_16) {
|
||||||
|
dwFullScreenBitDepth=16;
|
||||||
|
} else if(DMI.supportedBitDepths & DDBD_32) {
|
||||||
|
dwFullScreenBitDepth=32;
|
||||||
|
} else {
|
||||||
|
wdxdisplay_cat.error()
|
||||||
|
<< "resize failed, no fullScreen resolutions at " << xsize << "x" << ysize << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FAILED(hr = _dxgsg->_pDD->TestCooperativeLevel())) {
|
||||||
|
wdxdisplay_cat.error() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
wdxdisplay_cat.error() << "Full screen app failed to get exclusive mode on resize, exiting..\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dxgsg->free_dxgsg_objects();
|
||||||
|
|
||||||
|
// let driver choose default refresh rate (hopefully its >=60Hz)
|
||||||
|
if(FAILED( hr = _dxgsg->_pDD->SetDisplayMode( xsize,ysize,dwFullScreenBitDepth, 0L, 0L ))) {
|
||||||
|
wdxdisplay_cat.error() << "resize failed to reset display mode to (" << xsize <<"x"<<ysize<<"x"<<dwFullScreenBitDepth<<"): result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wdxdisplay_cat.is_debug()) {
|
||||||
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd34);
|
||||||
|
_dxgsg->_pDD->GetDisplayMode(&ddsd34);
|
||||||
|
wdxdisplay_cat.debug() << "set displaymode to " << ddsd34.dwWidth << "x" << ddsd34.dwHeight << " at "<< ddsd34.ddpfPixelFormat.dwRGBBitCount << "bpp, " << ddsd34.dwRefreshRate<< "Hz\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateScreenBuffersAndDevice(xsize,ysize,_dxgsg->_pDD,_dxgsg->_d3d,NULL);
|
||||||
|
_dxgsg->RecreateAllVideoSurfaces();
|
||||||
|
_dxgsg->SetDXReady(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int wdxGraphicsWindow::
|
||||||
|
verify_window_sizes(unsigned int numsizes,unsigned int *dimen) {
|
||||||
|
DWORD num_valid_modes=0;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
// not requesting same refresh rate since changing res might not support same refresh rate at new size
|
||||||
|
|
||||||
|
DDSURFACEDESC2 DDSD_Arr[MAX_DISPLAY_MODES];
|
||||||
|
DisplayModeInfo DMI;
|
||||||
|
DWORD i,*pCurDim=(DWORD *)dimen;
|
||||||
|
|
||||||
|
|
||||||
|
for(i=0;i<numsizes;i++,pCurDim+=2) {
|
||||||
|
DWORD xsize=pCurDim[0];
|
||||||
|
DWORD ysize=pCurDim[1];
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_search);
|
||||||
|
ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH; //| DDSD_PIXELFORMAT;
|
||||||
|
ddsd_search.dwWidth=xsize; ddsd_search.dwHeight=ysize;
|
||||||
|
|
||||||
|
ZeroMemory(&DDSD_Arr,sizeof(DDSD_Arr));
|
||||||
|
ZeroMemory(&DMI,sizeof(DMI));
|
||||||
|
DMI.maxWidth=xsize; DMI.maxHeight=ysize;
|
||||||
|
DMI.pDDSD_Arr=DDSD_Arr;
|
||||||
|
|
||||||
|
if(FAILED(hr = _dxgsg->_pDD->EnumDisplayModes(DDEDM_REFRESHRATES,&ddsd_search,&DMI,EnumDisplayModesCallBack))) {
|
||||||
|
wdxdisplay_cat.fatal() << "resize() - EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rid of bpp's we cant render at
|
||||||
|
DMI.supportedBitDepths &= _dxgsg->_D3DDevDesc.dwDeviceRenderBitDepth;
|
||||||
|
|
||||||
|
bool bIsGoodMode=false;
|
||||||
|
|
||||||
|
if(_bIsLowVidMemCard)
|
||||||
|
bIsGoodMode=(((float)xsize*(float)ysize)<=(float)(640*480));
|
||||||
|
else bIsGoodMode=((DMI.supportedBitDepths & (DDBD_16 | DDBD_24 | DDBD_32))!=0);
|
||||||
|
|
||||||
|
if(bIsGoodMode)
|
||||||
|
num_valid_modes++;
|
||||||
|
else {
|
||||||
|
pCurDim[0] = 0;
|
||||||
|
pCurDim[1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_valid_modes;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: dx_setup
|
// Function: dx_setup
|
||||||
@ -1029,14 +1193,8 @@ BOOL WINAPI DriverEnumCallback( GUID* pGUID, TCHAR* strDesc,TCHAR* strName,
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void wdxGraphicsWindow::
|
void wdxGraphicsWindow::
|
||||||
dx_setup() {
|
dx_setup() {
|
||||||
LPDIRECTDRAWSURFACE7 pBackDDSurf;
|
|
||||||
LPDIRECTDRAWSURFACE7 pZDDSurf;
|
|
||||||
LPDIRECT3D7 pD3DI;
|
LPDIRECT3D7 pD3DI;
|
||||||
LPDIRECT3DDEVICE7 pD3DDevice;
|
|
||||||
LPDIRECTDRAWSURFACE7 pPrimaryDDSurf;
|
|
||||||
LPDIRECTDRAW7 pDD;
|
LPDIRECTDRAW7 pDD;
|
||||||
RECT view_rect;
|
|
||||||
int i;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DX_DECLARE_CLEAN( DDSURFACEDESC2, SurfaceDesc );
|
DX_DECLARE_CLEAN( DDSURFACEDESC2, SurfaceDesc );
|
||||||
|
|
||||||
@ -1044,7 +1202,7 @@ dx_setup() {
|
|||||||
|
|
||||||
HINSTANCE DDHinst = LoadLibrary( "ddraw.dll" );
|
HINSTANCE DDHinst = LoadLibrary( "ddraw.dll" );
|
||||||
if(DDHinst == 0) {
|
if(DDHinst == 0) {
|
||||||
wdxdisplay_cat.fatal() << "error: DDRAW.DLL doesn't exist!" << endl;
|
wdxdisplay_cat.fatal() << "can't locate DDRAW.DLL!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1079,15 +1237,14 @@ dx_setup() {
|
|||||||
|
|
||||||
FreeLibrary(DDHinst); //undo LoadLib above, decrement ddrawl.dll refcnt (after DDrawCreate, since dont want to unload/reload)
|
FreeLibrary(DDHinst); //undo LoadLib above, decrement ddrawl.dll refcnt (after DDrawCreate, since dont want to unload/reload)
|
||||||
|
|
||||||
DDDEVICEIDENTIFIER2 dddi;
|
pDD->GetDeviceIdentifier(&_DXDeviceID,0x0);
|
||||||
pDD->GetDeviceIdentifier(&dddi,0x0);
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
wdxdisplay_cat.debug() << " GfxCard: " << dddi.szDescription << "; DriverFile: '" << dddi.szDriver << "'; VendorID: " <<dddi.dwVendorId <<"; DriverVer: " << HIWORD(dddi.liDriverVersion.HighPart) << "." << LOWORD(dddi.liDriverVersion.HighPart) << "." << HIWORD(dddi.liDriverVersion.LowPart) << "." << LOWORD(dddi.liDriverVersion.LowPart) << endl;
|
wdxdisplay_cat.debug() << " GfxCard: " << _DXDeviceID.szDescription << "; DriverFile: '" << _DXDeviceID.szDriver << "'; VendorID: " <<_DXDeviceID.dwVendorId <<"; DriverVer: " << HIWORD(_DXDeviceID.liDriverVersion.HighPart) << "." << LOWORD(_DXDeviceID.liDriverVersion.HighPart) << "." << HIWORD(_DXDeviceID.liDriverVersion.LowPart) << "." << LOWORD(_DXDeviceID.liDriverVersion.LowPart) << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// imperfect method to ID NVid, could also scan desc str, but that isnt fullproof either
|
// imperfect method to ID NVid, could also scan desc str, but that isnt fullproof either
|
||||||
BOOL bIsNvidia = (dddi.dwVendorId==0x10DE) || (dddi.dwVendorId==0x12D2);
|
#define ISNVIDIA(DDDEVICEID) ((DDDEVICEID.dwVendorId==0x10DE) || (DDDEVICEID.dwVendorId==0x12D2))
|
||||||
|
|
||||||
// Query DirectDraw for access to Direct3D
|
// Query DirectDraw for access to Direct3D
|
||||||
|
|
||||||
@ -1097,16 +1254,17 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3DDEVICEDESC7 d3ddevs[2]; // put HAL in 0, TnLHAL in 1
|
||||||
|
|
||||||
|
|
||||||
// just look for HAL and TnL devices right now. I dont think
|
// just look for HAL and TnL devices right now. I dont think
|
||||||
// we have any interest in the sw rasts at this point
|
// we have any interest in the sw rasts at this point
|
||||||
|
|
||||||
D3DDEVICEDESC7 d3ddevs[2]; // put HAL in 0, TnLHAL in 1
|
|
||||||
ZeroMemory(d3ddevs,2*sizeof(D3DDEVICEDESC7));
|
ZeroMemory(d3ddevs,2*sizeof(D3DDEVICEDESC7));
|
||||||
|
|
||||||
hr = pD3DI->EnumDevices(EnumDevicesCallback,d3ddevs);
|
hr = pD3DI->EnumDevices(EnumDevicesCallback,d3ddevs);
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,10 +1280,9 @@ dx_setup() {
|
|||||||
DeviceIdx=TNLHALIDX;
|
DeviceIdx=TNLHALIDX;
|
||||||
}
|
}
|
||||||
|
|
||||||
DX_DECLARE_CLEAN(DDCAPS,DDCaps);
|
D3DDEVICEDESC7 *pD3DDevDesc=&d3ddevs[DeviceIdx];
|
||||||
pDD->GetCaps(&DDCaps,NULL);
|
|
||||||
|
|
||||||
DWORD dwRenderWidth,dwRenderHeight;
|
DWORD dwRenderWidth=0, dwRenderHeight=0;
|
||||||
|
|
||||||
if(dx_full_screen) {
|
if(dx_full_screen) {
|
||||||
dwRenderWidth = _props._xsize;
|
dwRenderWidth = _props._xsize;
|
||||||
@ -1170,16 +1327,18 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
wdxdisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
wdxdisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DMI.supportedBitDepths &= pD3DDevDesc->dwDeviceRenderBitDepth;
|
||||||
|
|
||||||
// note: this chooses 32bpp, which may not be preferred over 16 for memory & speed reasons
|
// note: this chooses 32bpp, which may not be preferred over 16 for memory & speed reasons
|
||||||
if((DMI.supportedBitDepths & DDBD_32) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_32)) {
|
if(DMI.supportedBitDepths & DDBD_32) {
|
||||||
dwFullScreenBitDepth=32; // go for 32bpp if its avail
|
dwFullScreenBitDepth=32; // go for 32bpp if its avail
|
||||||
} else if((DMI.supportedBitDepths & DDBD_24) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_24)) {
|
} else if(DMI.supportedBitDepths & DDBD_24) {
|
||||||
dwFullScreenBitDepth=24; // go for 24bpp if its avail
|
dwFullScreenBitDepth=24; // go for 24bpp if its avail
|
||||||
} else if((DMI.supportedBitDepths & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)) {
|
} else if(DMI.supportedBitDepths & DDBD_16) {
|
||||||
dwFullScreenBitDepth=16; // do 16bpp
|
dwFullScreenBitDepth=16; // do 16bpp
|
||||||
} else {
|
} else {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal()
|
||||||
@ -1198,6 +1357,7 @@ dx_setup() {
|
|||||||
dwFullScreenBitDepth=16; // do 16bpp
|
dwFullScreenBitDepth=16; // do 16bpp
|
||||||
dwRenderWidth=640;
|
dwRenderWidth=640;
|
||||||
dwRenderHeight=480;
|
dwRenderHeight=480;
|
||||||
|
_bIsLowVidMemCard = true;
|
||||||
wdxdisplay_cat.debug() << " "<<dwFree <<" Available VidMem is under "<< LOWVIDMEMTHRESHOLD <<", using 640x480 16bpp rendertargets to save tex vidmem.\n";
|
wdxdisplay_cat.debug() << " "<<dwFree <<" Available VidMem is under "<< LOWVIDMEMTHRESHOLD <<", using 640x480 16bpp rendertargets to save tex vidmem.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,7 +1376,7 @@ dx_setup() {
|
|||||||
if(memleft < RESERVEDTEXVIDMEM) {
|
if(memleft < RESERVEDTEXVIDMEM) {
|
||||||
dwFullScreenBitDepth=16;
|
dwFullScreenBitDepth=16;
|
||||||
wdxdisplay_cat.debug() << "using 16bpp rendertargets to save tex vidmem\n";
|
wdxdisplay_cat.debug() << "using 16bpp rendertargets to save tex vidmem\n";
|
||||||
assert((DMI.supportedBitDepths & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)); // probably a safe assumption
|
assert((DMI.supportedBitDepths & DDBD_16) && (pD3DDevDesc->dwDeviceRenderBitDepth & DDBD_16)); // probably a safe assumption
|
||||||
rendertargetmem=dwRenderWidth*dwRenderHeight*(dwFullScreenBitDepth>>3);
|
rendertargetmem=dwRenderWidth*dwRenderHeight*(dwFullScreenBitDepth>>3);
|
||||||
memleft = dwFree-rendertargetmem*2;
|
memleft = dwFree-rendertargetmem*2;
|
||||||
|
|
||||||
@ -1227,11 +1387,11 @@ dx_setup() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// extern bool dx_preserve_fpu_state;
|
// extern bool dx_preserve_fpu_state;
|
||||||
DWORD SCL_FPUFlag = DDSCL_FPUSETUP;
|
DWORD SCL_FPUFlag = DDSCL_FPUSETUP;
|
||||||
|
|
||||||
// if(dx_preserve_fpu_state)
|
// if(dx_preserve_fpu_state)
|
||||||
// SCL_FPUFlag = DDSCL_FPUPRESERVE; // tell d3d to preserve the fpu state across calls. this hurts perf, but is good for dbgging
|
// SCL_FPUFlag = DDSCL_FPUPRESERVE; // tell d3d to preserve the fpu state across calls. this hurts perf, but is good for dbgging
|
||||||
|
|
||||||
DWORD SCL_FLAGS = SCL_FPUFlag | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT;
|
DWORD SCL_FLAGS = SCL_FPUFlag | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT;
|
||||||
|
|
||||||
@ -1254,6 +1414,7 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let driver choose default refresh rate (hopefully its >=60Hz)
|
||||||
if(FAILED( hr = pDD->SetDisplayMode( dwRenderWidth, dwRenderHeight,
|
if(FAILED( hr = pDD->SetDisplayMode( dwRenderWidth, dwRenderHeight,
|
||||||
dwFullScreenBitDepth, 0L, 0L ))) {
|
dwFullScreenBitDepth, 0L, 0L ))) {
|
||||||
wdxdisplay_cat.fatal() << "failed to reset display mode to ("<<dwRenderWidth<<"x"<<dwRenderHeight<<"x"<<dwFullScreenBitDepth<<"): result = " << ConvD3DErrorToString(hr) << endl;
|
wdxdisplay_cat.fatal() << "failed to reset display mode to ("<<dwRenderWidth<<"x"<<dwRenderHeight<<"x"<<dwFullScreenBitDepth<<"): result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
@ -1273,7 +1434,61 @@ dx_setup() {
|
|||||||
wdxdisplay_cat.debug() << "after FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
wdxdisplay_cat.debug() << "after FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateScreenBuffersAndDevice(dwRenderWidth,dwRenderHeight,pDD,pD3DI,pD3DDevDesc);
|
||||||
|
|
||||||
|
_dxgsg->SetDXReady(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wdxGraphicsWindow::
|
||||||
|
CreateScreenBuffersAndDevice(DWORD dwRenderWidth, DWORD dwRenderHeight,LPDIRECTDRAW7 pDD,
|
||||||
|
LPDIRECT3D7 pD3DI,D3DDEVICEDESC7 *pD3DDevDesc) {
|
||||||
|
LPDIRECTDRAWSURFACE7 pPrimaryDDSurf,pBackDDSurf,pZDDSurf;
|
||||||
|
LPDIRECT3DDEVICE7 pD3DDevice;
|
||||||
|
RECT view_rect;
|
||||||
|
int i;
|
||||||
|
HRESULT hr;
|
||||||
|
DX_DECLARE_CLEAN( DDSURFACEDESC2, SurfaceDesc );
|
||||||
|
D3DDEVICEDESC7 d3ddevs[2]; // put HAL in 0, TnLHAL in 1
|
||||||
|
|
||||||
|
assert(pDD!=NULL);
|
||||||
|
assert(pD3DI!=NULL);
|
||||||
|
|
||||||
|
// select the best device if the caller does not provide one
|
||||||
|
if(pD3DDevDesc==NULL) {
|
||||||
|
|
||||||
|
// just look for HAL and TnL devices right now. I dont think
|
||||||
|
// we have any interest in the sw rasts at this point
|
||||||
|
|
||||||
|
ZeroMemory(d3ddevs,2*sizeof(D3DDEVICEDESC7));
|
||||||
|
|
||||||
|
hr = pD3DI->EnumDevices(EnumDevicesCallback,d3ddevs);
|
||||||
|
if(hr != DD_OK) {
|
||||||
|
wdxdisplay_cat.fatal() << "EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
WORD DeviceIdx=REGHALIDX;
|
||||||
|
|
||||||
|
if(!(d3ddevs[DeviceIdx].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION )) {
|
||||||
|
wdxdisplay_cat.fatal() << "No 3D HW present, exiting..." << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// select TNL if present
|
||||||
|
if(d3ddevs[TNLHALIDX].dwDevCaps & D3DDEVCAPS_HWRASTERIZATION) {
|
||||||
|
DeviceIdx=TNLHALIDX;
|
||||||
|
}
|
||||||
|
|
||||||
|
pD3DDevDesc=&d3ddevs[DeviceIdx];
|
||||||
|
}
|
||||||
|
|
||||||
|
DX_DECLARE_CLEAN(DDCAPS,DDCaps);
|
||||||
|
pDD->GetCaps(&DDCaps,NULL);
|
||||||
|
|
||||||
|
if(dx_full_screen) {
|
||||||
// Setup to create the primary surface w/backbuffer
|
// Setup to create the primary surface w/backbuffer
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd)
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd)
|
||||||
ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
|
ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
|
||||||
@ -1322,6 +1537,7 @@ dx_setup() {
|
|||||||
} // end create full screen buffers
|
} // end create full screen buffers
|
||||||
|
|
||||||
else { // CREATE WINDOWED BUFFERS
|
else { // CREATE WINDOWED BUFFERS
|
||||||
|
assert(dwRenderWidth==0 && dwRenderHeight==0); // these params are ignored for windowed mode
|
||||||
|
|
||||||
if(!(DDCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED)) {
|
if(!(DDCaps.dwCaps2 & DDCAPS2_CANRENDERWINDOWED)) {
|
||||||
wdxdisplay_cat.fatal() << "the 3D HW cannot render windowed, exiting..." << endl;
|
wdxdisplay_cat.fatal() << "the 3D HW cannot render windowed, exiting..." << endl;
|
||||||
@ -1338,7 +1554,7 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(BitDepth_2_DDBDMask(SurfaceDesc.ddpfPixelFormat.dwRGBBitCount) & d3ddevs[DeviceIdx].dwDeviceRenderBitDepth)) {
|
if(!(BitDepth_2_DDBDMask(SurfaceDesc.ddpfPixelFormat.dwRGBBitCount) & pD3DDevDesc->dwDeviceRenderBitDepth)) {
|
||||||
wdxdisplay_cat.fatal() << "3D Device doesnt support rendering at " << SurfaceDesc.ddpfPixelFormat.dwRGBBitCount << "bpp (current desktop bitdepth)" << endl;
|
wdxdisplay_cat.fatal() << "3D Device doesnt support rendering at " << SurfaceDesc.ddpfPixelFormat.dwRGBBitCount << "bpp (current desktop bitdepth)" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -1453,7 +1669,7 @@ dx_setup() {
|
|||||||
|
|
||||||
// Check if the device supports z-bufferless hidden surface removal. If so,
|
// Check if the device supports z-bufferless hidden surface removal. If so,
|
||||||
// we don't really need a z-buffer
|
// we don't really need a z-buffer
|
||||||
if((!(d3ddevs[DeviceIdx].dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )) &&
|
if((!(pD3DDevDesc->dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )) &&
|
||||||
(_props._mask & W_DEPTH)) {
|
(_props._mask & W_DEPTH)) {
|
||||||
|
|
||||||
// Get z-buffer dimensions from the render target
|
// Get z-buffer dimensions from the render target
|
||||||
@ -1514,7 +1730,7 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bIsNvidia) {
|
if(ISNVIDIA(_DXDeviceID)) {
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_pri)
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_pri)
|
||||||
pPrimaryDDSurf->GetSurfaceDesc(&ddsd_pri);
|
pPrimaryDDSurf->GetSurfaceDesc(&ddsd_pri);
|
||||||
|
|
||||||
@ -1583,7 +1799,7 @@ dx_setup() {
|
|||||||
|
|
||||||
// Create the device. The device is created off of our back buffer, which
|
// Create the device. The device is created off of our back buffer, which
|
||||||
// becomes the render target for the newly created device.
|
// becomes the render target for the newly created device.
|
||||||
hr = pD3DI->CreateDevice(d3ddevs[DeviceIdx].deviceGUID, pBackDDSurf, &pD3DDevice );
|
hr = pD3DI->CreateDevice(pD3DDevDesc->deviceGUID, pBackDDSurf, &pD3DDevice );
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal() << "CreateDevice failed : result = " << ConvD3DErrorToString(hr) << endl;
|
wdxdisplay_cat.fatal() << "CreateDevice failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -1598,9 +1814,8 @@ dx_setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_dxgsg->Set_HDC(_hdc);
|
_dxgsg->Set_HDC(_hdc);
|
||||||
_dxgsg->init_dx(pDD, pPrimaryDDSurf, pBackDDSurf, pZDDSurf, pD3DI, pD3DDevice, view_rect);
|
_dxgsg->dx_init(pDD, pPrimaryDDSurf, pBackDDSurf, pZDDSurf, pD3DI, pD3DDevice, view_rect);
|
||||||
|
// do not SetDXReady() yet since caller may want to do more work before letting rendering proceed
|
||||||
_dxgsg->SetDXReady(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -2012,3 +2227,39 @@ lookup_key(WPARAM wparam) const {
|
|||||||
}
|
}
|
||||||
return ButtonHandle::none();
|
return ButtonHandle::none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Global system parameters we want to modify during our run
|
||||||
|
static int iMouseTrails;
|
||||||
|
static bool bCursorShadowOn,bMouseVanish;
|
||||||
|
|
||||||
|
#ifndef SPI_GETMOUSEVANISH
|
||||||
|
// get of this when we upgrade to winxp winuser.h
|
||||||
|
#define SPI_GETMOUSEVANISH 0x1020
|
||||||
|
#define SPI_SETMOUSEVANISH 0x1021
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void set_global_parameters(void) {
|
||||||
|
// turn off mousetrails and cursor shadow and mouse cursor vanish
|
||||||
|
// cursor shadow causes cursor blink and reduced frame rate due to lack of driver support for
|
||||||
|
// cursor alpha blending
|
||||||
|
|
||||||
|
// this is a win2k/xp only param, could use GetVersionEx to do it just for win2k,
|
||||||
|
// but since it is just a param it will just cause a silent error on other OS's
|
||||||
|
// that should be ok
|
||||||
|
SystemParametersInfo(SPI_GETCURSORSHADOW,NULL,&bCursorShadowOn,NULL);
|
||||||
|
SystemParametersInfo(SPI_SETCURSORSHADOW,NULL,(PVOID)false,NULL);
|
||||||
|
|
||||||
|
SystemParametersInfo(SPI_GETMOUSETRAILS,NULL,&iMouseTrails,NULL);
|
||||||
|
SystemParametersInfo(SPI_SETMOUSETRAILS,NULL,(PVOID)0,NULL);
|
||||||
|
|
||||||
|
// this is ME/XP only feature
|
||||||
|
SystemParametersInfo(SPI_GETMOUSEVANISH,NULL,&bMouseVanish,NULL);
|
||||||
|
SystemParametersInfo(SPI_SETMOUSEVANISH,NULL,(PVOID)false,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_global_parameters(void) {
|
||||||
|
SystemParametersInfo(SPI_SETCURSORSHADOW,NULL,(PVOID)bCursorShadowOn,NULL);
|
||||||
|
SystemParametersInfo(SPI_SETMOUSETRAILS,NULL,(PVOID)iMouseTrails,NULL);
|
||||||
|
SystemParametersInfo(SPI_SETMOUSEVANISH,NULL,(PVOID)bMouseVanish,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ const int WDXWIN_EVENT = 8;
|
|||||||
// Description :
|
// Description :
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
class EXPCL_PANDADX wdxGraphicsWindow : public GraphicsWindow {
|
class EXPCL_PANDADX wdxGraphicsWindow : public GraphicsWindow {
|
||||||
|
friend class DXGraphicsStateGuardian;
|
||||||
friend class DXGraphicsStateGuardian;
|
friend class DXTextureContext;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wdxGraphicsWindow(GraphicsPipe* pipe);
|
wdxGraphicsWindow(GraphicsPipe* pipe);
|
||||||
@ -59,6 +59,9 @@ public:
|
|||||||
|
|
||||||
virtual TypeHandle get_gsg_type() const;
|
virtual TypeHandle get_gsg_type() const;
|
||||||
static GraphicsWindow* make_wdxGraphicsWindow(const FactoryParams ¶ms);
|
static GraphicsWindow* make_wdxGraphicsWindow(const FactoryParams ¶ms);
|
||||||
|
void CreateScreenBuffersAndDevice(DWORD dwRenderWidth, DWORD dwRenderHeight,
|
||||||
|
LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI,
|
||||||
|
D3DDEVICEDESC7 *pD3DDevDesc);
|
||||||
|
|
||||||
LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
void process_events(void);
|
void process_events(void);
|
||||||
@ -78,10 +81,11 @@ public:
|
|||||||
void show_frame();
|
void show_frame();
|
||||||
DXGraphicsStateGuardian *_dxgsg;
|
DXGraphicsStateGuardian *_dxgsg;
|
||||||
|
|
||||||
// virtual void resize(unsigned int xsize,unsigned int ysize);
|
virtual void resize(unsigned int xsize,unsigned int ysize);
|
||||||
// virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
|
virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void CreateScreenBuffersAndDevice(LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI);
|
||||||
ButtonHandle lookup_key(WPARAM wparam) const;
|
ButtonHandle lookup_key(WPARAM wparam) const;
|
||||||
virtual void config( void );
|
virtual void config( void );
|
||||||
void setup_colormap(void);
|
void setup_colormap(void);
|
||||||
@ -90,6 +94,7 @@ protected:
|
|||||||
void enable_mouse_motion(bool val);
|
void enable_mouse_motion(bool val);
|
||||||
void enable_mouse_passive_motion(bool val);
|
void enable_mouse_passive_motion(bool val);
|
||||||
void enable_mouse_entry(bool val);
|
void enable_mouse_entry(bool val);
|
||||||
|
DDDEVICEIDENTIFIER2 _DXDeviceID;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HWND _mwindow;
|
HWND _mwindow;
|
||||||
@ -131,4 +136,8 @@ private:
|
|||||||
static TypeHandle _type_handle;
|
static TypeHandle _type_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern void set_global_parameters(void);
|
||||||
|
extern void restore_global_parameters(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user