mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
add mipmapping & greyscale support
This commit is contained in:
parent
8da0ae3359
commit
f3f4f877e8
@ -21,7 +21,7 @@ bool dx_show_transforms = config_dxgsg.GetBool("dx-show-transforms", false);
|
||||
bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
|
||||
|
||||
// Configure this true to glHint the textures into the cheapest
|
||||
// possible mode.
|
||||
// possible mode. (this does nothing in dx currently)
|
||||
bool dx_cheap_textures = config_dxgsg.GetBool("dx-cheap-textures", false);
|
||||
|
||||
// Configure this true to perform a cull traversal over the geometry
|
||||
@ -29,6 +29,18 @@ bool dx_cheap_textures = config_dxgsg.GetBool("dx-cheap-textures", false);
|
||||
// for state-sorting, z-sorting, and binning.
|
||||
bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
|
||||
|
||||
bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
|
||||
float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
|
||||
bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
|
||||
bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
|
||||
bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
|
||||
|
||||
#endif
|
||||
|
||||
// note: offset currently disabled since it wasnt working properly
|
||||
DXDecalType dx_decal_type = GDT_offset;
|
||||
|
||||
static DXDecalType
|
||||
|
@ -15,11 +15,20 @@ extern bool dx_show_transforms;
|
||||
extern bool dx_full_screen;
|
||||
extern bool dx_cheap_textures;
|
||||
extern bool dx_cull_traversal;
|
||||
extern bool dx_ignore_mipmaps;
|
||||
|
||||
#ifdef _DEBUG
|
||||
extern float dx_global_miplevel_bias;
|
||||
extern bool dx_debug_view_mipmaps;
|
||||
extern bool dx_mipmap_everything;
|
||||
extern bool dx_force_16bpptextures;
|
||||
extern bool dx_force_anisotropic_filtering;
|
||||
#endif
|
||||
|
||||
// Ways to implement decals.
|
||||
enum DXDecalType {
|
||||
GDT_mask, // GL 1.0 style, involving three steps
|
||||
GDT_blend, // As above, but slower; a hack for broken nVidia driver
|
||||
GDT_mask, // GL 1.0 style, involving three steps and double-draw of polygon
|
||||
GDT_blend, // As above, but slower; use blending to disable colorbuffer writes
|
||||
GDT_offset // The fastest, using GL 1.1 style glPolygonOffset
|
||||
};
|
||||
extern DXDecalType dx_decal_type;
|
||||
|
@ -375,14 +375,18 @@ init_dx( LPDIRECTDRAW7 context,
|
||||
dxgsg_cat.error() << "EnumTextureFormats failed!!\n";
|
||||
}
|
||||
|
||||
D3DDEVICEDESC7 D3DDevDesc;
|
||||
|
||||
if(FAILED(hr = pDevice->GetCaps(&D3DDevDesc))) {
|
||||
dxgsg_cat.fatal() << "GetCaps failed on Device\n";
|
||||
if(FAILED(hr = pDevice->GetCaps(&_D3DDevDesc))) {
|
||||
dxgsg_cat.fatal() << "GetCaps failed on D3D Device\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if((dx_decal_type==GDT_offset) && !(D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBIAS)) {
|
||||
DX_DECLARE_CLEAN(DDCAPS,ddCaps);
|
||||
if(FAILED(hr = _pDD->GetCaps(&ddCaps,NULL))) {
|
||||
dxgsg_cat.fatal() << "GetCaps failed on DDraw\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if((dx_decal_type==GDT_offset) && !(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBIAS)) {
|
||||
#ifdef _DEBUG
|
||||
// dx7 doesnt support PLANEMASK renderstate
|
||||
#if(DIRECT3D_VERSION < 0x700)
|
||||
@ -410,14 +414,14 @@ init_dx( LPDIRECTDRAW7 context,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if((dx_decal_type==GDT_mask) && !(D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKPLANES)) {
|
||||
if((dx_decal_type==GDT_mask) && !(_D3DDevDesc.dpcTriCaps.dwMiscCaps & D3DPMISCCAPS_MASKPLANES)) {
|
||||
#ifdef _DEBUG
|
||||
dxgsg_cat.error() << "No hardware support for colorwrite disabling, switching to dx-decal-type 'mask' to 'blend'\n";
|
||||
#endif
|
||||
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";
|
||||
}
|
||||
|
||||
@ -428,29 +432,32 @@ init_dx( LPDIRECTDRAW7 context,
|
||||
#define REQUIRED_BLENDCAPS (D3DPBLENDCAPS_ZERO|D3DPBLENDCAPS_ONE| /*D3DPBLENDCAPS_SRCCOLOR|D3DPBLENDCAPS_INVSRCCOLOR| */ \
|
||||
D3DPBLENDCAPS_SRCALPHA|D3DPBLENDCAPS_INVSRCALPHA /* | D3DPBLENDCAPS_DESTALPHA|D3DPBLENDCAPS_INVDESTALPHA|D3DPBLENDCAPS_DESTCOLOR|D3DPBLENDCAPS_INVDESTCOLOR*/)
|
||||
|
||||
if(((D3DDevDesc.dpcTriCaps.dwSrcBlendCaps & REQUIRED_BLENDCAPS)!=REQUIRED_BLENDCAPS) ||
|
||||
((D3DDevDesc.dpcTriCaps.dwDestBlendCaps & REQUIRED_BLENDCAPS)!=REQUIRED_BLENDCAPS)) {
|
||||
dxgsg_cat.error() << "device is missing alpha blending capabilities, blending may not work correctly: SrcBlendCaps: 0x"<< (void*) D3DDevDesc.dpcTriCaps.dwSrcBlendCaps << " DestBlendCaps: "<< (void*) D3DDevDesc.dpcTriCaps.dwDestBlendCaps << endl;
|
||||
if(((_D3DDevDesc.dpcTriCaps.dwSrcBlendCaps & REQUIRED_BLENDCAPS)!=REQUIRED_BLENDCAPS) ||
|
||||
((_D3DDevDesc.dpcTriCaps.dwDestBlendCaps & REQUIRED_BLENDCAPS)!=REQUIRED_BLENDCAPS)) {
|
||||
dxgsg_cat.error() << "device is missing alpha blending capabilities, blending may not work correctly: SrcBlendCaps: 0x"<< (void*) _D3DDevDesc.dpcTriCaps.dwSrcBlendCaps << " DestBlendCaps: "<< (void*) _D3DDevDesc.dpcTriCaps.dwDestBlendCaps << endl;
|
||||
}
|
||||
|
||||
if(!(D3DDevDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_TRANSPARENCY)) {
|
||||
dxgsg_cat.error() << "device is missing texture transparency capability, transparency may not work correctly! TextureCaps: 0x"<< (void*) D3DDevDesc.dpcTriCaps.dwTextureCaps << endl;
|
||||
if(!(_D3DDevDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_TRANSPARENCY)) {
|
||||
dxgsg_cat.error() << "device is missing texture transparency capability, transparency may not work correctly! TextureCaps: 0x"<< (void*) _D3DDevDesc.dpcTriCaps.dwTextureCaps << endl;
|
||||
}
|
||||
|
||||
// just require trilinear. if it can do that, it can probably do all the lesser point-sampling variations too
|
||||
#define REQUIRED_TEXFILTERCAPS (D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MINFLINEAR | D3DPTFILTERCAPS_LINEAR)
|
||||
if((D3DDevDesc.dpcTriCaps.dwTextureFilterCaps & REQUIRED_TEXFILTERCAPS)!=REQUIRED_TEXFILTERCAPS) {
|
||||
dxgsg_cat.error() << "device is missing texture bilinear filtering capability, textures may appear blocky! TextureFilterCaps: 0x"<< (void*) D3DDevDesc.dpcTriCaps.dwTextureFilterCaps << endl;
|
||||
if((_D3DDevDesc.dpcTriCaps.dwTextureFilterCaps & REQUIRED_TEXFILTERCAPS)!=REQUIRED_TEXFILTERCAPS) {
|
||||
dxgsg_cat.error() << "device is missing texture bilinear filtering capability, textures may appear blocky! TextureFilterCaps: 0x"<< (void*) _D3DDevDesc.dpcTriCaps.dwTextureFilterCaps << endl;
|
||||
}
|
||||
|
||||
#define REQUIRED_MIPMAP_TEXFILTERCAPS (D3DPTFILTERCAPS_MIPFLINEAR | D3DPTFILTERCAPS_LINEARMIPLINEAR)
|
||||
if((D3DDevDesc.dpcTriCaps.dwTextureFilterCaps & REQUIRED_MIPMAP_TEXFILTERCAPS)!=REQUIRED_MIPMAP_TEXFILTERCAPS) {
|
||||
dxgsg_cat.error() << "device is missing tri-linear mipmap filtering capability, texture mipmaps may not supported! TextureFilterCaps: 0x"<< (void*) D3DDevDesc.dpcTriCaps.dwTextureFilterCaps << endl;
|
||||
|
||||
if(!(ddCaps.ddsCaps.dwCaps & DDSCAPS_MIPMAP)) {
|
||||
dxgsg_cat.debug() << "device does not have mipmap texturing filtering capability! TextureFilterCaps: 0x"<< (void*) _D3DDevDesc.dpcTriCaps.dwTextureFilterCaps << endl;
|
||||
dx_ignore_mipmaps = TRUE;
|
||||
} else if((_D3DDevDesc.dpcTriCaps.dwTextureFilterCaps & REQUIRED_MIPMAP_TEXFILTERCAPS)!=REQUIRED_MIPMAP_TEXFILTERCAPS) {
|
||||
dxgsg_cat.debug() << "device is missing tri-linear mipmap filtering capability, texture mipmaps may not supported! TextureFilterCaps: 0x"<< (void*) _D3DDevDesc.dpcTriCaps.dwTextureFilterCaps << endl;
|
||||
}
|
||||
|
||||
#define REQUIRED_TEXBLENDCAPS (D3DTEXOPCAPS_MODULATE | D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2)
|
||||
if((D3DDevDesc.dwTextureOpCaps & REQUIRED_TEXBLENDCAPS)!=REQUIRED_TEXBLENDCAPS) {
|
||||
dxgsg_cat.error() << "device is missing some required texture blending capabilities, texture blending may not work properly! TextureOpCaps: 0x"<< (void*) D3DDevDesc.dwTextureOpCaps << endl;
|
||||
if((_D3DDevDesc.dwTextureOpCaps & REQUIRED_TEXBLENDCAPS)!=REQUIRED_TEXBLENDCAPS) {
|
||||
dxgsg_cat.error() << "device is missing some required texture blending capabilities, texture blending may not work properly! TextureOpCaps: 0x"<< (void*) _D3DDevDesc.dwTextureOpCaps << endl;
|
||||
}
|
||||
|
||||
SetRect(&clip_rect, 0,0,0,0); // no clip rect set
|
||||
@ -513,6 +520,13 @@ init_dx( LPDIRECTDRAW7 context,
|
||||
_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
|
||||
|
||||
#ifdef _DEBUG
|
||||
if((_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_MIPMAPLODBIAS) &&
|
||||
(dx_global_miplevel_bias!=0.0)) {
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPMAPLODBIAS, *((LPDWORD) (&dx_global_miplevel_bias)) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -840,15 +854,14 @@ render_subgraph(RenderTraverser *traverser,
|
||||
_current_projection_node = projnode;
|
||||
LMatrix4f old_projection_mat = _current_projection_mat;
|
||||
|
||||
// The projection matrix must always be right-handed Y-up, even if
|
||||
// our coordinate system of choice is otherwise, because certain GL
|
||||
// calls (specifically glTexGen(GL_SPHERE_MAP)) assume this kind of
|
||||
// a coordinate system. Sigh. In order to implement a Z-up
|
||||
// coordinate system, we'll store the Z-up conversion in the
|
||||
// modelview matrix.
|
||||
// d3d is left-handed coord system
|
||||
LMatrix4f projection_mat =
|
||||
projnode->get_projection()->get_projection_mat(CS_yup_left);
|
||||
|
||||
#if 0
|
||||
dxgsg_cat.spam() << "cur projection matrix: " << projection_mat <<"\n";
|
||||
#endif
|
||||
|
||||
_current_projection_mat = projection_mat;
|
||||
_projection_mat_stack_count++;
|
||||
|
||||
@ -1555,7 +1568,7 @@ draw_tri(const GeomTri *geom) {
|
||||
|
||||
#ifdef _DEBUG
|
||||
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
|
||||
|
||||
@ -3998,8 +4011,14 @@ specify_texture(Texture *tex) {
|
||||
_d3dDevice->SetTextureStageState(0,D3DTSS_ADDRESSV,
|
||||
get_texture_wrap_mode(tex->get_wrapv()));
|
||||
|
||||
int aniso_degree=tex->get_anisotropic_degree();
|
||||
|
||||
Texture::FilterType ft=tex->get_magfilter();
|
||||
|
||||
if(aniso_degree>1) {
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_ANISOTROPIC );
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MAXANISOTROPY,aniso_degree);
|
||||
} else
|
||||
switch(ft) {
|
||||
case Texture::FT_nearest:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_POINT);
|
||||
@ -4014,32 +4033,44 @@ specify_texture(Texture *tex) {
|
||||
|
||||
ft=tex->get_minfilter();
|
||||
|
||||
D3DTEXTUREMIPFILTER mipfilter = D3DTFP_LINEAR;
|
||||
D3DTEXTUREMINFILTER minfilter = D3DTFN_LINEAR;
|
||||
|
||||
switch(ft) {
|
||||
case Texture::FT_nearest:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_POINT);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_NONE);
|
||||
minfilter = D3DTFN_POINT;
|
||||
mipfilter = D3DTFP_NONE;
|
||||
break;
|
||||
case Texture::FT_linear:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_NONE);
|
||||
minfilter = D3DTFN_LINEAR;
|
||||
mipfilter = D3DTFP_NONE;
|
||||
break;
|
||||
case Texture::FT_nearest_mipmap_nearest:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_POINT);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_POINT);
|
||||
minfilter = D3DTFN_POINT;
|
||||
mipfilter = D3DTFP_POINT;
|
||||
break;
|
||||
case Texture::FT_linear_mipmap_nearest:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_POINT);
|
||||
minfilter = D3DTFN_LINEAR;
|
||||
mipfilter = D3DTFP_POINT;
|
||||
break;
|
||||
case Texture::FT_nearest_mipmap_linear:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_POINT);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
|
||||
minfilter = D3DTFN_POINT;
|
||||
mipfilter = D3DTFP_LINEAR;
|
||||
break;
|
||||
case Texture::FT_linear_mipmap_linear:
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_LINEAR);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_LINEAR);
|
||||
minfilter = D3DTFN_LINEAR;
|
||||
mipfilter = D3DTFP_LINEAR;
|
||||
break;
|
||||
default:
|
||||
dxgsg_cat.error() << "Unknown tex filter type for tex: " << tex->get_name() << " filter: "<<(DWORD)ft<<"\n";
|
||||
}
|
||||
|
||||
if(aniso_degree>1) {
|
||||
minfilter=D3DTFN_ANISOTROPIC;
|
||||
}
|
||||
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, minfilter);
|
||||
_d3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, mipfilter);
|
||||
}
|
||||
|
||||
|
||||
@ -4054,6 +4085,8 @@ apply_texture_immediate(DXTextureContext *tc) {
|
||||
// bugbug: does this handle the case of untextured geometry?
|
||||
// we dont see this bug cause we never mix textured/untextured
|
||||
|
||||
// if(tc->_surface->IsLost(
|
||||
|
||||
_d3dDevice->SetTexture(0, tc->_surface );
|
||||
#if 0
|
||||
if(tc!=NULL) {
|
||||
@ -4318,161 +4351,6 @@ void DXGraphicsStateGuardian::init_type(void) {
|
||||
GraphicsStateGuardian::get_class_type());
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef WBD_GL_MODE
|
||||
|
||||
|
||||
/* All of the following routines return GL-specific constants based
|
||||
on Panda defined constants. For DX, just use
|
||||
the Panda defined constants to decide what to do.
|
||||
|
||||
get_image_type(PixelBuffer::Type type) {
|
||||
get_external_image_format(PixelBuffer::Format format) {
|
||||
get_internal_image_format(PixelBuffer::Format format) {
|
||||
get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::get_image_type
|
||||
// Access: Protected
|
||||
// Description: Maps from the PixelBuffer's internal Type symbols
|
||||
// to GL's.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GLenum DXGraphicsStateGuardian::
|
||||
get_image_type(PixelBuffer::Type type) {
|
||||
switch (type) {
|
||||
case PixelBuffer::T_unsigned_byte:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case PixelBuffer::T_unsigned_short:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
#ifdef GL_UNSIGNED_BYTE_3_3_2_EXT
|
||||
case PixelBuffer::T_unsigned_byte_332:
|
||||
return GL_UNSIGNED_BYTE_3_3_2_EXT;
|
||||
#endif
|
||||
case PixelBuffer::T_float:
|
||||
return GL_FLOAT;
|
||||
}
|
||||
dxgsg_cat.error() << "Invalid PixelBuffer::Type value!\n";
|
||||
return GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::get_external_image_format
|
||||
// Access: Protected
|
||||
// Description: Maps from the PixelBuffer's Format symbols
|
||||
// to GL's.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GLenum DXGraphicsStateGuardian::
|
||||
get_external_image_format(PixelBuffer::Format format) {
|
||||
switch (format) {
|
||||
case PixelBuffer::F_color_index:
|
||||
return GL_COLOR_INDEX;
|
||||
case PixelBuffer::F_stencil_index:
|
||||
return GL_STENCIL_INDEX;
|
||||
case PixelBuffer::F_depth_component:
|
||||
return GL_DEPTH_COMPONENT;
|
||||
case PixelBuffer::F_red:
|
||||
return GL_RED;
|
||||
case PixelBuffer::F_green:
|
||||
return GL_GREEN;
|
||||
case PixelBuffer::F_blue:
|
||||
return GL_BLUE;
|
||||
case PixelBuffer::F_alpha:
|
||||
return GL_ALPHA;
|
||||
case PixelBuffer::F_rgb:
|
||||
case PixelBuffer::F_rgb5:
|
||||
case PixelBuffer::F_rgb8:
|
||||
case PixelBuffer::F_rgb12:
|
||||
case PixelBuffer::F_rgb332:
|
||||
return GL_RGB;
|
||||
case PixelBuffer::F_rgba:
|
||||
case PixelBuffer::F_rgba4:
|
||||
case PixelBuffer::F_rgba8:
|
||||
case PixelBuffer::F_rgba12:
|
||||
return GL_RGBA;
|
||||
case PixelBuffer::F_luminance:
|
||||
return GL_LUMINANCE;
|
||||
case PixelBuffer::F_luminance_alpha:
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
}
|
||||
dxgsg_cat.error()
|
||||
<< "Invalid PixelBuffer::Format value in get_external_image_format(): "
|
||||
<< (int)format << "\n";
|
||||
return GL_RGB;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::get_internal_image_format
|
||||
// Access: Protected
|
||||
// Description: Maps from the PixelBuffer's Format symbols to a
|
||||
// suitable internal format for GL textures.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GLenum DXGraphicsStateGuardian::
|
||||
get_internal_image_format(PixelBuffer::Format format) {
|
||||
switch (format) {
|
||||
case PixelBuffer::F_rgba:
|
||||
return GL_RGBA;
|
||||
case PixelBuffer::F_rgba4:
|
||||
return GL_RGBA4;
|
||||
case PixelBuffer::F_rgba8:
|
||||
return GL_RGBA8;
|
||||
case PixelBuffer::F_rgba12:
|
||||
return GL_RGBA12;
|
||||
|
||||
case PixelBuffer::F_rgb:
|
||||
return GL_RGB;
|
||||
case PixelBuffer::F_rgb5:
|
||||
case PixelBuffer::F_rgb8:
|
||||
return GL_RGB8;
|
||||
case PixelBuffer::F_rgb12:
|
||||
return GL_RGB12;
|
||||
case PixelBuffer::F_rgb332:
|
||||
return GL_R3_G3_B2;
|
||||
|
||||
case PixelBuffer::F_luminance_alpha:
|
||||
return GL_LUMINANCE_ALPHA;
|
||||
|
||||
case PixelBuffer::F_alpha:
|
||||
return GL_ALPHA;
|
||||
|
||||
case PixelBuffer::F_red:
|
||||
case PixelBuffer::F_green:
|
||||
case PixelBuffer::F_blue:
|
||||
case PixelBuffer::F_luminance:
|
||||
return GL_LUMINANCE;
|
||||
}
|
||||
|
||||
dxgsg_cat.error()
|
||||
<< "Invalid image format in get_internal_image_format(): "
|
||||
<< (int)format << "\n";
|
||||
return GL_RGB;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::get_texture_apply_mode_type
|
||||
// Access: Protected
|
||||
// Description: Maps from the texture environment's mode types
|
||||
// to the corresponding OpenGL ids
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GLint DXGraphicsStateGuardian::
|
||||
get_texture_apply_mode_type( TextureApplyProperty::Mode am ) const
|
||||
{
|
||||
switch( am )
|
||||
{
|
||||
case TextureApplyProperty::M_modulate: return GL_MODULATE;
|
||||
case TextureApplyProperty::M_decal: return GL_DECAL;
|
||||
case TextureApplyProperty::M_blend: return GL_BLEND;
|
||||
case TextureApplyProperty::M_replace: return GL_REPLACE;
|
||||
case TextureApplyProperty::M_add: return GL_ADD;
|
||||
}
|
||||
dxgsg_cat.error()
|
||||
<< "Invalid TextureApplyProperty::Mode value" << endl;
|
||||
return GL_MODULATE;
|
||||
}
|
||||
#endif // WBD_GL_MODE
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: dx_cleanup
|
||||
// Description: Clean up the DirectX environment.
|
||||
@ -4622,6 +4500,7 @@ dx_setup_after_resize(RECT viewrect, HWND mwindow)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: show_frame
|
||||
// Access:
|
||||
@ -4675,9 +4554,9 @@ void DXGraphicsStateGuardian::show_frame(void) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// right now, we want sync to v-blank (time from now up to vblank is wasted)
|
||||
// worry about triple-buffering l8r
|
||||
// right now, we force sync to v-blank (time from now up to vblank is wasted)
|
||||
// this keeps calling processes from trying to render more frames than the refresh
|
||||
// rate since (as implemented right now) they expect this call to block
|
||||
hr = _pDD->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
|
||||
if (hr != DD_OK) {
|
||||
dxgsg_cat.error() << "DXGraphicsStateGuardian::WaitForVerticalBlank() failed : " << ConvD3DErrorToString(hr) << endl;
|
||||
|
@ -209,6 +209,8 @@ protected:
|
||||
bool _color_transform_enabled;
|
||||
bool _alpha_transform_enabled;
|
||||
|
||||
D3DDEVICEDESC7 _D3DDevDesc;
|
||||
|
||||
void set_clipper(RECT cliprect);
|
||||
|
||||
INLINE void set_pack_alignment(int alignment);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,8 @@ public:
|
||||
LPDIRECTDRAWSURFACE7 _surface;
|
||||
Texture *_tex; // ptr to parent, primarily for access to namestr
|
||||
|
||||
LPDIRECTDRAWSURFACE7 CreateTexture( HDC hdc, LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts);
|
||||
LPDIRECTDRAWSURFACE7 CreateTexture( HDC PrimaryDC, LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts);
|
||||
|
||||
void DeleteTexture();
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user