mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Use sampler states in Direct3D 8
This commit is contained in:
parent
8a5452b0b6
commit
270667ece2
@ -175,7 +175,7 @@ prepare_texture(Texture *tex, int view) {
|
|||||||
// rendering on the ith stage.
|
// rendering on the ith stage.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DXGraphicsStateGuardian8::
|
void DXGraphicsStateGuardian8::
|
||||||
apply_texture(int i, TextureContext *tc) {
|
apply_texture(int i, TextureContext *tc, const SamplerState &sampler) {
|
||||||
if (tc == (TextureContext *)NULL) {
|
if (tc == (TextureContext *)NULL) {
|
||||||
// The texture wasn't bound properly or something, so ensure
|
// The texture wasn't bound properly or something, so ensure
|
||||||
// texturing is disabled and just return.
|
// texturing is disabled and just return.
|
||||||
@ -194,19 +194,19 @@ apply_texture(int i, TextureContext *tc) {
|
|||||||
Texture *tex = tc->get_texture();
|
Texture *tex = tc->get_texture();
|
||||||
|
|
||||||
SamplerState::WrapMode wrap_u, wrap_v, wrap_w;
|
SamplerState::WrapMode wrap_u, wrap_v, wrap_w;
|
||||||
wrap_u = tex->get_wrap_u();
|
wrap_u = sampler.get_wrap_u();
|
||||||
wrap_v = tex->get_wrap_v();
|
wrap_v = sampler.get_wrap_v();
|
||||||
wrap_w = tex->get_wrap_w();
|
wrap_w = sampler.get_wrap_w();
|
||||||
|
|
||||||
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSU, get_texture_wrap_mode(wrap_u));
|
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSU, get_texture_wrap_mode(wrap_u));
|
||||||
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSV, get_texture_wrap_mode(wrap_v));
|
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSV, get_texture_wrap_mode(wrap_v));
|
||||||
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSW, get_texture_wrap_mode(wrap_w));
|
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSW, get_texture_wrap_mode(wrap_w));
|
||||||
|
|
||||||
_d3d_device->SetTextureStageState(i, D3DTSS_BORDERCOLOR,
|
_d3d_device->SetTextureStageState(i, D3DTSS_BORDERCOLOR,
|
||||||
LColor_to_D3DCOLOR(tex->get_border_color()));
|
LColor_to_D3DCOLOR(sampler.get_border_color()));
|
||||||
|
|
||||||
uint aniso_degree = tex->get_effective_anisotropic_degree();
|
uint aniso_degree = sampler.get_effective_anisotropic_degree();
|
||||||
SamplerState::FilterType ft = tex->get_effective_magfilter();
|
SamplerState::FilterType ft = sampler.get_effective_magfilter();
|
||||||
|
|
||||||
if (aniso_degree >= 1) {
|
if (aniso_degree >= 1) {
|
||||||
_d3d_device->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, aniso_degree);
|
_d3d_device->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, aniso_degree);
|
||||||
@ -222,8 +222,8 @@ apply_texture(int i, TextureContext *tc) {
|
|||||||
_d3d_device->SetTextureStageState(i, D3DTSS_MAGFILTER, new_mag_filter);
|
_d3d_device->SetTextureStageState(i, D3DTSS_MAGFILTER, new_mag_filter);
|
||||||
|
|
||||||
// map Panda composite min+mip filter types to d3d's separate min & mip filter types
|
// map Panda composite min+mip filter types to d3d's separate min & mip filter types
|
||||||
D3DTEXTUREFILTERTYPE new_min_filter = get_d3d_min_type(tex->get_effective_minfilter());
|
D3DTEXTUREFILTERTYPE new_min_filter = get_d3d_min_type(sampler.get_effective_minfilter());
|
||||||
D3DTEXTUREFILTERTYPE new_mip_filter = get_d3d_mip_type(tex->get_effective_minfilter());
|
D3DTEXTUREFILTERTYPE new_mip_filter = get_d3d_mip_type(sampler.get_effective_minfilter());
|
||||||
|
|
||||||
if (!tex->might_have_ram_image()) {
|
if (!tex->might_have_ram_image()) {
|
||||||
// If the texture is completely dynamic, don't try to issue
|
// If the texture is completely dynamic, don't try to issue
|
||||||
@ -2859,11 +2859,12 @@ do_issue_texture() {
|
|||||||
|
|
||||||
Texture *texture = _target_texture->get_on_texture(stage);
|
Texture *texture = _target_texture->get_on_texture(stage);
|
||||||
nassertv(texture != (Texture *)NULL);
|
nassertv(texture != (Texture *)NULL);
|
||||||
|
const SamplerState &sampler = _target_texture->get_on_sampler(stage);
|
||||||
|
|
||||||
// We always reissue every stage in DX, just in case the texcoord
|
// We always reissue every stage in DX, just in case the texcoord
|
||||||
// index or texgen mode or some other property has changed.
|
// index or texgen mode or some other property has changed.
|
||||||
TextureContext *tc = texture->prepare_now(0, _prepared_objects, this);
|
TextureContext *tc = texture->prepare_now(0, _prepared_objects, this);
|
||||||
apply_texture(si, tc);
|
apply_texture(si, tc, sampler);
|
||||||
set_texture_blend_mode(si, stage);
|
set_texture_blend_mode(si, stage);
|
||||||
|
|
||||||
int texcoord_dimensions = 2;
|
int texcoord_dimensions = 2;
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype);
|
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype);
|
||||||
|
|
||||||
virtual TextureContext *prepare_texture(Texture *tex, int view);
|
virtual TextureContext *prepare_texture(Texture *tex, int view);
|
||||||
void apply_texture(int i, TextureContext *tc);
|
void apply_texture(int i, TextureContext *tc, const SamplerState &sampler);
|
||||||
virtual bool update_texture(TextureContext *tc, bool force);
|
virtual bool update_texture(TextureContext *tc, bool force);
|
||||||
bool upload_texture(DXTextureContext8 *dtc, bool force);
|
bool upload_texture(DXTextureContext8 *dtc, bool force);
|
||||||
virtual void release_texture(TextureContext *tc);
|
virtual void release_texture(TextureContext *tc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user