mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Clear render to texture textures to black when they are first created.
This commit is contained in:
parent
bba7914821
commit
b481bcac00
@ -925,7 +925,7 @@ create_texture(DXScreenData &scrn) {
|
||||
<< " => " << D3DFormatStr(target_pixel_format) << endl;
|
||||
}
|
||||
|
||||
hr = fill_d3d_texture_pixels(scrn._supports_automatic_mipmap_generation);
|
||||
hr = fill_d3d_texture_pixels(scrn._supports_automatic_mipmap_generation, scrn._d3d_device);
|
||||
if (FAILED(hr)) {
|
||||
|
||||
dxgsg9_cat.debug ()
|
||||
@ -1410,7 +1410,7 @@ exit_FillMipmapSurf:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
HRESULT DXTextureContext9::
|
||||
fill_d3d_texture_pixels(bool supports_automatic_mipmap_generation) {
|
||||
fill_d3d_texture_pixels(bool supports_automatic_mipmap_generation, IDirect3DDevice9 *device) {
|
||||
if (get_texture()->get_texture_type() == Texture::TT_3d_texture) {
|
||||
return fill_d3d_volume_texture_pixels();
|
||||
}
|
||||
@ -1424,7 +1424,38 @@ fill_d3d_texture_pixels(bool supports_automatic_mipmap_generation) {
|
||||
// The texture doesn't have an image to load. That's ok; it
|
||||
// might be a texture we've rendered to by frame buffer
|
||||
// operations or something.
|
||||
if (get_texture()->get_render_to_texture()) {
|
||||
if (get_texture()->get_render_to_texture()) {
|
||||
HRESULT result;
|
||||
|
||||
// clear render to texture
|
||||
IDirect3DSurface9 *surface;
|
||||
|
||||
result = _d3d_2d_texture -> GetSurfaceLevel (0, &surface);
|
||||
if (result == D3D_OK) {
|
||||
D3DSURFACE_DESC surface_description;
|
||||
|
||||
if (surface -> GetDesc (&surface_description) == D3D_OK) {
|
||||
IDirect3DSurface9 *current_render_target;
|
||||
|
||||
if (device -> GetRenderTarget (0, ¤t_render_target) == D3D_OK) {
|
||||
if (device -> SetRenderTarget (0, surface) == D3D_OK) {
|
||||
DWORD flags;
|
||||
D3DCOLOR color;
|
||||
|
||||
color = 0xFF000000;
|
||||
flags = D3DCLEAR_TARGET;
|
||||
if (device -> Clear (NULL, NULL, flags, color, 0.0f, 0) == D3D_OK) {
|
||||
}
|
||||
}
|
||||
|
||||
device -> SetRenderTarget (0, current_render_target);
|
||||
current_render_target -> Release();
|
||||
}
|
||||
}
|
||||
|
||||
surface -> Release();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
return E_FAIL;
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
|
||||
private:
|
||||
HRESULT fill_d3d_texture_mipmap_pixels(int mip_level, int depth_index, D3DFORMAT source_format);
|
||||
HRESULT fill_d3d_texture_pixels(bool supports_automatic_mipmap_generation);
|
||||
HRESULT fill_d3d_texture_pixels(bool supports_automatic_mipmap_generation, IDirect3DDevice9 *device);
|
||||
HRESULT fill_d3d_volume_texture_pixels();
|
||||
static int down_to_power_2(int value);
|
||||
unsigned int get_bits_per_pixel(Texture::Format format, int *alphbits);
|
||||
|
Loading…
x
Reference in New Issue
Block a user