Fix rendering of cube map faces.

This commit is contained in:
aignacio_sf 2006-07-12 02:12:37 +00:00
parent 5d709e329a
commit 9bcd40db9b

View File

@ -276,12 +276,14 @@ rebuild_bitplanes() {
} else {
color_cube = color_ctx->_d3d_cube_texture;
nassertr(color_cube != 0, false);
if (_cube_map_index >= 0 && _cube_map_index < 6) {
hr = color_cube -> GetCubeMapSurface ((D3DCUBEMAP_FACES) _cube_map_index, 0, &color_surf);
if (!SUCCEEDED(hr)) {
dxgsg8_cat.error ( ) << "GetCubeMapSurface " << D3DERRORSTRING(hr) FL;
}
}
}
}
if (depth_tex_index < 0) {
// Maintain the backing depth surface.
@ -334,10 +336,12 @@ rebuild_bitplanes() {
// Load up the bitplanes.
if (color_surf && depth_surf) {
hr = _dxgsg -> _d3d_device -> SetRenderTarget (color_surf, depth_surf);
if (!SUCCEEDED (hr)) {
dxgsg8_cat.error ( ) << "SetRenderTarget " << D3DERRORSTRING(hr) FL;
}
}
// Decrement the reference counts on these surfaces. The refcounts
// were incremented earlier when we called GetSurfaceLevel.
@ -363,6 +367,49 @@ rebuild_bitplanes() {
void wdxGraphicsBuffer8::
select_cube_map(int cube_map_index) {
_cube_map_index = cube_map_index;
HRESULT hr;
Texture *color_tex = 0;
DXTextureContext8 *color_ctx = 0;
IDirect3DCubeTexture8 *color_cube = 0;
IDirect3DSurface8 *color_surf = 0;
int color_tex_index = -1;
for (int i=0; i<count_textures(); i++) {
if (get_rtm_mode(i) == RTM_bind_or_copy) {
if ((get_texture(i)->get_format() != Texture::F_depth_component)&&
(get_texture(i)->get_format() != Texture::F_stencil_index)&&
(color_tex_index < 0)) {
color_tex_index = i;
} else {
_textures[i]._rtm_mode = RTM_copy_texture;
}
}
}
color_tex = get_texture(color_tex_index);
if (color_tex) {
color_ctx =
DCAST(DXTextureContext8,
color_tex->prepare_now(_gsg->get_prepared_objects(), _gsg));
color_cube = color_ctx->_d3d_cube_texture;
if (color_cube && _cube_map_index >= 0 && _cube_map_index < 6) {
hr = color_cube -> GetCubeMapSurface ((D3DCUBEMAP_FACES) _cube_map_index, 0, &color_surf);
if (!SUCCEEDED(hr)) {
dxgsg8_cat.error ( ) << "GetCubeMapSurface " << D3DERRORSTRING(hr) FL;
}
hr = _dxgsg -> _d3d_device -> SetRenderTarget (color_surf, 0);
if (!SUCCEEDED (hr)) {
dxgsg8_cat.error ( ) << "SetRenderTarget " << D3DERRORSTRING(hr) FL;
}
else {
color_surf->Release();
}
}
}
}
////////////////////////////////////////////////////////////////////