diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.I b/panda/src/dxgsg/dxGraphicsStateGuardian.I index c53c1803c5..62674100f9 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.I +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.I @@ -620,57 +620,6 @@ enable_color_material(bool val) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian::enable_texturing -// Access: -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void DXGraphicsStateGuardian:: -enable_texturing(bool val) { - if (_texturing_enabled != val) { - _texturing_enabled = val; - } - -// assert(_pCurTexContext!=NULL); we're definitely called with it NULL for both true and false - -/* -old way to disable texturing - if(val == FALSE) { - _d3dDevice->SetTexture(0,NULL); - } else { - if(_pCurTexContext!=NULL) { - _d3dDevice->SetTexture(0,_pCurTexContext->_surface); - } - } -*/ - - if(val == FALSE) { - if(_pCurTexContext!=NULL) { - _d3dDevice->GetTextureStageState(0,D3DTSS_COLOROP,(DWORD*)&(_pCurTexContext->_SavedStage0_ColorOp)); - } - _d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); - } else { - // note: if we set D3DTSS_COLOROP to something other than disable and then - // call "enable_texturing(), conflict will occur - #if 0 - // we need to set D3DTSS_COLOROP,D3DTOP_MODULATE if pCurTextContext is null and tex enabled true, - // so this test is impossible now - DWORD dwColOpVal=0; - _d3dDevice->GetTextureStageState(0,D3DTSS_COLOROP,&dwColOpVal); - if(dwColOpVal!=D3DTOP_DISABLE) { - dxgsg_cat.error() << "Error in enable_texturing(true), someone set D3DTSS_COLOROP to non-disabled value\n"; - } - #endif - if(_pCurTexContext!=NULL) { - _d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,_pCurTexContext->_SavedStage0_ColorOp); - } else { - // not sure this is the right thing to do - _d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE); - } - } -} - - //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian::enable_clip_plane // Access: diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index 49b3faa696..88151ff655 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -480,9 +480,9 @@ init_dx( LPDIRECTDRAW7 context, cfa->issue(this); la->issue(this); + _CurTexBlendMode = TextureApplyProperty::M_modulate; _d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); // disables texturing ta->issue(this); // no curtextcontext, this does nothing. dx should already be properly inited above anyway - } //////////////////////////////////////////////////////////////////// @@ -3283,16 +3283,9 @@ issue_color_blend(const ColorBlendAttribute *attrib) { break; } } - -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian::issue_texture_apply -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -void DXGraphicsStateGuardian:: -issue_texture_apply(const TextureApplyAttribute *attrib) { - - switch(attrib->get_mode()) { + +void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyProperty::Mode TexBlendMode) { + switch(TexBlendMode) { case TextureApplyProperty::M_modulate: // emulates GL_MODULATE glTexEnv mode // want to multiply tex-color*pixel color to emulate GL modulate blend (see glTexEnv) @@ -3335,7 +3328,7 @@ issue_texture_apply(const TextureApplyAttribute *attrib) { break; case TextureApplyProperty::M_blend: dxgsg_cat.error() - << "Impossible to emulate GL_BLEND in DX exactly " << (int) attrib->get_mode() << endl; + << "Impossible to emulate GL_BLEND in DX exactly " << (int) TexBlendMode << endl; /* // emulate GL_BLEND glTexEnv @@ -3362,11 +3355,49 @@ issue_texture_apply(const TextureApplyAttribute *attrib) { break; default: - dxgsg_cat.error() << "Unknown texture blend mode " << (int) attrib->get_mode() << endl; + dxgsg_cat.error() << "Unknown texture blend mode " << (int) TexBlendMode << endl; break; } } + +//////////////////////////////////////////////////////////////////// +// Function: DXGraphicsStateGuardian::enable_texturing +// Access: +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void DXGraphicsStateGuardian:: +enable_texturing(bool val) { + if (_texturing_enabled != val) { + _texturing_enabled = val; + } + +// assert(_pCurTexContext!=NULL); we're definitely called with it NULL for both true and false + + if((val == FALSE) || (_pCurTexContext==NULL)) { + _d3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE); + } else { + SetTextureBlendMode(_CurTexBlendMode); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: DXGraphicsStateGuardian::issue_texture_apply +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void DXGraphicsStateGuardian:: +issue_texture_apply(const TextureApplyAttribute *attrib) { + + _CurTexBlendMode = attrib->get_mode(); + + if(!_texturing_enabled) { + return; + } + + SetTextureBlendMode(_CurTexBlendMode); +} + //////////////////////////////////////////////////////////////////// // Function: DXGraphicsStateGuardian::issue_color_mask // Access: Public, Virtual diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.h b/panda/src/dxgsg/dxGraphicsStateGuardian.h index 0bf54afd81..4b3daab3a1 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.h +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.h @@ -221,60 +221,6 @@ protected: INLINE void enable_clip_plane(int clip_plane, bool val); INLINE void enable_fog(bool val); -#ifdef WBD_GL_MODE - void print_gfx_visual(); - INLINE void call_glClearColor(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - INLINE void call_glClearDepth(GLclampd depth); - INLINE void call_glClearStencil(GLint s); - INLINE void call_glClearAccum(GLclampf red, GLclampf green, GLclampf blue, - GLclampf alpha); - INLINE void call_glDrawBuffer(GLenum mode); - INLINE void call_glReadBuffer(GLenum mode); - INLINE void call_glShadeModel(GLenum mode); - INLINE void call_glCullFace(GLenum mode); - INLINE void call_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); - INLINE void call_glLightModelAmbient(const Colorf& color); - INLINE void call_glLightModelLocal(GLboolean local); - INLINE void call_glLightModelTwoSide(GLboolean twoside); - INLINE void call_glMaterialAmbient(bool twoside, const Colorf& color); - INLINE void call_glMaterialDiffuse(bool twoside, const Colorf& color); - INLINE void call_glMaterialAmbientDiffuse(bool twoside, const Colorf& color); - INLINE void call_glMaterialSpecular(bool twoside, const Colorf& color); - INLINE void call_glMaterialShininess(bool twoside, float shininess); - INLINE void call_glMaterialEmission(bool twoside, const Colorf& color); - INLINE void call_glStencilFunc(GLenum func); - INLINE void call_glStencilOp(GLenum op); - INLINE void call_glClipPlane(GLenum plane, const double equation[4]); - INLINE void call_glLineWidth(GLfloat width); - INLINE void call_glPointSize(GLfloat size); - INLINE void call_glDepthMask(GLboolean mask); - INLINE void call_glFogMode(GLint mode); - INLINE void call_glFogStart(GLfloat start); - INLINE void call_glFogEnd(GLfloat end); - INLINE void call_glFogDensity(GLfloat density); - INLINE void call_glFogColor(const Colorf &color); - INLINE void call_glPolygonMode(GLenum mode); - - INLINE GLenum get_light_id(int index) const; - INLINE GLenum get_clip_plane_id(int index) const; - - GLenum get_image_type(PixelBuffer::Type type); - GLenum get_external_image_format(PixelBuffer::Format format); - GLenum get_internal_image_format(PixelBuffer::Format format); - GLint get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const; - - GLenum _draw_buffer_mode; - GLenum _read_buffer_mode; - GLenum _shade_model_mode; - GLboolean _lmodel_local; - GLboolean _lmodel_twoside; - GLenum _polygon_mode; - GLenum _stencil_func; - GLenum _stencil_op; - - -#else /* INLINE void enable_multisample_alpha_one(bool val); INLINE void enable_multisample_alpha_mask(bool val); INLINE void enable_multisample(bool val, LPDIRECT3DDEVICE7 d3dDevice); @@ -321,9 +267,6 @@ protected: Geom::TexCoordIterator ti; Geom::ColorIterator ci; - -#endif // WBD_GL_MODE - float _clear_color_red, _clear_color_green, _clear_color_blue,_clear_color_alpha; double _clear_depth; int _clear_stencil; @@ -355,6 +298,8 @@ protected: D3DBLEND _blend_source_func; D3DBLEND _blend_dest_func; + TextureApplyProperty::Mode _CurTexBlendMode; + int _pack_alignment; int _unpack_alignment; @@ -418,6 +363,7 @@ public: INLINE void Set_HDC(HDC hdc) { _hdc = hdc; } void adjust_view_rect(int x, int y); INLINE void SetDXStatus(bool stat) { _dx_ready = stat; } + void DXGraphicsStateGuardian::SetTextureBlendMode(TextureApplyProperty::Mode TexBlendMode); void dx_cleanup(); void dx_setup_after_resize(RECT viewrect,HWND mwindow) ; diff --git a/panda/src/dxgsg/dxTextureContext.cxx b/panda/src/dxgsg/dxTextureContext.cxx index 5e2e01b6f5..ea79a9fd5a 100644 --- a/panda/src/dxgsg/dxTextureContext.cxx +++ b/panda/src/dxgsg/dxTextureContext.cxx @@ -852,7 +852,6 @@ DXTextureContext(Texture *tex) : #endif _surface = NULL; _tex = tex; - _SavedStage0_ColorOp=D3DTOP_MODULATE; // this is default when texturing is enabled } DXTextureContext:: diff --git a/panda/src/dxgsg/dxTextureContext.h b/panda/src/dxgsg/dxTextureContext.h index 0d22ef5ae4..12067bed59 100644 --- a/panda/src/dxgsg/dxTextureContext.h +++ b/panda/src/dxgsg/dxTextureContext.h @@ -31,7 +31,6 @@ public: LPDIRECTDRAWSURFACE7 _surface; Texture *_tex; // ptr to parent, primarily for access to namestr - D3DTEXTUREOP _SavedStage0_ColorOp; LPDIRECTDRAWSURFACE7 CreateTexture( HDC hdc, LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts); void DeleteTexture();