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| \
|
||||||
@ -637,25 +671,24 @@ 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);
|
||||||
_back->GetSurfaceDesc(&ddsd_back);
|
_back->GetSurfaceDesc(&ddsd_back);
|
||||||
_dither_enabled = ((ddsd_back.ddpfPixelFormat.dwRGBBitCount < 24) &&
|
_dither_enabled = ((ddsd_back.ddpfPixelFormat.dwRGBBitCount < 24) &&
|
||||||
(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER));
|
(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER));
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, _dither_enabled);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, _dither_enabled);
|
||||||
|
|
||||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPING,true);
|
_d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPING,true);
|
||||||
|
|
||||||
// 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;
|
*/
|
||||||
D3DCMPFUNC _alpha_func;
|
float _alpha_func_ref;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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