mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
another non-working save
This commit is contained in:
parent
feaf71a3fc
commit
28029a2e2a
@ -6,7 +6,7 @@
|
||||
|
||||
#if $[BUILD_DX8]
|
||||
#begin lib_target
|
||||
#define TARGET dxgsg
|
||||
#define TARGET dxgsg8
|
||||
#define LOCAL_LIBS \
|
||||
cull gsgmisc gsgbase gobj sgattrib sgraphutil graph display light \
|
||||
putil linmath sgraph mathutil pnmimage event
|
||||
|
@ -16,10 +16,10 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_dxgsg.h"
|
||||
#include "dxGraphicsStateGuardian.h"
|
||||
#include "dxSavedFrameBuffer.h"
|
||||
#include "dxTextureContext.h"
|
||||
#include "config_dxgsg8.h"
|
||||
#include "dxGraphicsStateGuardian8.h"
|
||||
#include "dxSavedFrameBuffer8.h"
|
||||
#include "dxTextureContext8.h"
|
||||
|
||||
#include <dconfig.h>
|
||||
|
||||
@ -40,9 +40,8 @@ bool dx_full_screen = config_dxgsg.GetBool("dx-full-screen", false);
|
||||
// irrespective of the video refresh.
|
||||
bool dx_sync_video = config_dxgsg.GetBool("sync-video", true);
|
||||
|
||||
// enable this to turn on full-screen anti-aliasing, if the HW supports it
|
||||
// this var is also used in wdxGraphicsWindows.cxx
|
||||
bool dx_full_screen_antialiasing = config_dxgsg.GetBool("dx-antialias", false);
|
||||
// Set Level of MultiSampling to be used, if HW supports it. Valid values are 2-16.
|
||||
DWORD dx_multisample_antialiasing_level = (DWORD) config_dxgsg.GetInt("dx-multisample-antialiasing-level", 0);
|
||||
|
||||
// Configure this true to perform a cull traversal over the geometry
|
||||
// by default, false otherwise. The cull traversal provides support
|
||||
@ -52,6 +51,9 @@ bool dx_cull_traversal = config_dxgsg.GetBool("dx-cull-traversal", true);
|
||||
// if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability
|
||||
bool dx_no_vertex_fog = config_dxgsg.GetBool("dx-no-vertex-fog", false);
|
||||
|
||||
// if true, triangle filter will be used to generate mipmap levels instead of default box filter
|
||||
bool dx_use_triangle_mipgen_filter = config_dxgsg.GetBool("dx-use-triangle-mipgen-filter", false);
|
||||
|
||||
// Configure this true to cause all lighting normals to automatically
|
||||
// be normalized by the CPU before rendering. This is
|
||||
// necessary if you intend to render things under scale transforms and
|
||||
@ -138,3 +140,57 @@ init_libdxgsg() {
|
||||
(DXGraphicsStateGuardian::get_class_type(),
|
||||
DXGraphicsStateGuardian::make_DXGraphicsStateGuardian);
|
||||
}
|
||||
|
||||
const char *D3DFormatStr(D3DFORMAT fmt) {
|
||||
|
||||
#define CASESTR(XX) case XX: return #XX;
|
||||
|
||||
switch(fmt) {
|
||||
CASESTR(D3DFMT_UNKNOWN);
|
||||
CASESTR(D3DFMT_R8G8B8);
|
||||
CASESTR(D3DFMT_A8R8G8B8);
|
||||
CASESTR(D3DFMT_X8R8G8B8);
|
||||
CASESTR(D3DFMT_R5G6B5);
|
||||
CASESTR(D3DFMT_X1R5G5B5);
|
||||
CASESTR(D3DFMT_A1R5G5B5);
|
||||
CASESTR(D3DFMT_A4R4G4B4);
|
||||
CASESTR(D3DFMT_R3G3B2);
|
||||
CASESTR(D3DFMT_A8);
|
||||
CASESTR(D3DFMT_A8R3G3B2);
|
||||
CASESTR(D3DFMT_X4R4G4B4);
|
||||
CASESTR(D3DFMT_A2B10G10R10);
|
||||
CASESTR(D3DFMT_G16R16);
|
||||
CASESTR(D3DFMT_A8P8);
|
||||
CASESTR(D3DFMT_P8);
|
||||
CASESTR(D3DFMT_L8);
|
||||
CASESTR(D3DFMT_A8L8);
|
||||
CASESTR(D3DFMT_A4L4);
|
||||
CASESTR(D3DFMT_V8U8);
|
||||
CASESTR(D3DFMT_L6V5U5);
|
||||
CASESTR(D3DFMT_X8L8V8U8);
|
||||
CASESTR(D3DFMT_Q8W8V8U8);
|
||||
CASESTR(D3DFMT_V16U16);
|
||||
CASESTR(D3DFMT_W11V11U10);
|
||||
CASESTR(D3DFMT_A2W10V10U10);
|
||||
CASESTR(D3DFMT_UYVY);
|
||||
CASESTR(D3DFMT_YUY2);
|
||||
CASESTR(D3DFMT_DXT1);
|
||||
CASESTR(D3DFMT_DXT2);
|
||||
CASESTR(D3DFMT_DXT3);
|
||||
CASESTR(D3DFMT_DXT4);
|
||||
CASESTR(D3DFMT_DXT5);
|
||||
CASESTR(D3DFMT_D16_LOCKABLE);
|
||||
CASESTR(D3DFMT_D32);
|
||||
CASESTR(D3DFMT_D15S1);
|
||||
CASESTR(D3DFMT_D24S8);
|
||||
CASESTR(D3DFMT_D16);
|
||||
CASESTR(D3DFMT_D24X8);
|
||||
CASESTR(D3DFMT_D24X4S4);
|
||||
CASESTR(D3DFMT_VERTEXDATA);
|
||||
CASESTR(D3DFMT_INDEX16);
|
||||
CASESTR(D3DFMT_INDEX32);
|
||||
}
|
||||
|
||||
return "Invalid D3DFORMAT";
|
||||
}
|
||||
|
||||
|
@ -16,11 +16,12 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef CONFIG_DXGSG_H
|
||||
#define CONFIG_DXGSG_H
|
||||
#ifndef CONFIG_DXGSG8_H
|
||||
#define CONFIG_DXGSG8_H
|
||||
|
||||
#include <pandabase.h>
|
||||
#include <notifyCategoryProxy.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
NotifyCategoryDecl(dxgsg, EXPCL_PANDADX, EXPTP_PANDADX);
|
||||
|
||||
@ -34,6 +35,9 @@ extern float dx_fps_meter_update_interval;
|
||||
extern bool dx_auto_normalize_lighting;
|
||||
extern bool dx_use_rangebased_fog;
|
||||
extern const bool link_tristrips;
|
||||
extern DWORD dx_multisample_antialiasing_level;
|
||||
extern bool dx_use_triangle_mipgen_filter;
|
||||
extern const char *D3DFormatStr(D3DFORMAT fmt);
|
||||
|
||||
// debug flags we might want to use in full optimized build
|
||||
extern bool dx_ignore_mipmaps;
|
||||
|
@ -26,6 +26,8 @@ INLINE DXGeomNodeContext::
|
||||
DXGeomNodeContext(GeomNode *node) : GeomNodeContext(node)
|
||||
{
|
||||
_num_verts = 0;
|
||||
/*
|
||||
_pVB = NULL;
|
||||
_pXformed_VB = NULL;
|
||||
*/
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ TypeHandle DXGeomNodeContext::_type_handle;
|
||||
|
||||
DXGeomNodeContext::~DXGeomNodeContext()
|
||||
{
|
||||
/*
|
||||
if(_pXformed_VB!=NULL)
|
||||
_pXformed_VB->Release();
|
||||
_pXformed_VB=NULL;
|
||||
@ -29,5 +30,6 @@ DXGeomNodeContext::~DXGeomNodeContext()
|
||||
if(_pVB!=NULL)
|
||||
_pVB->Release();
|
||||
_pVB=NULL;
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,16 @@
|
||||
#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h
|
||||
#include <d3d8.h>
|
||||
|
||||
#if D3D_SDK_VERSION != 220
|
||||
#error you have DX 8.0 headers, not DX 8.1, you need to install newer MS Platform SDK!
|
||||
#endif
|
||||
|
||||
#if DIRECT3D_VERSION != 0x0800
|
||||
#error DX8.1 headers not available, you need to install newer MS Platform SDK!
|
||||
#endif
|
||||
|
||||
#if D3D_SDK_VERSION != 220
|
||||
#error you have DX 8.0 headers, not DX 8.1, you need to install newer MS Platform SDK!
|
||||
#ifndef D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
||||
#error you have pre-release DX8.1 headers, you need to install newer MS Platform SDK!
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@ -48,6 +52,8 @@ typedef struct {
|
||||
D3DPRIMITIVETYPE primtype;
|
||||
} DPInfo;
|
||||
|
||||
// empty shell unimplemented for DX8 right now
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DXGeomNodeContext
|
||||
// Description :
|
||||
@ -66,8 +72,11 @@ public:
|
||||
// but we will want a way to know if VB has already been xformed by ProcessVerts this frame
|
||||
// if multiple geomnodes share VBs
|
||||
|
||||
/* unimplemented right now
|
||||
LPDIRECT3DVERTEXBUFFER7 _pVB;
|
||||
LPDIRECT3DVERTEXBUFFER7 _pXformed_VB;
|
||||
*/
|
||||
|
||||
|
||||
int _start_index; // starting offset of this geom's verts within the VB
|
||||
int _num_verts; // number of verts used by this geomcontext within the VB
|
||||
|
@ -16,7 +16,7 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_dxgsg.h"
|
||||
#include "config_dxgsg8.h"
|
||||
#include <graphicsWindow.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -30,12 +30,12 @@ enable_line_smooth(bool val) {
|
||||
_line_smooth_enabled = val;
|
||||
#ifdef NDEBUG
|
||||
{
|
||||
if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
|
||||
if(val && (scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
|
||||
dxgsg_cat.error() << "no HW support for line smoothing!!\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_EDGEANTIALIAS, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ enable_line_smooth(bool val) {
|
||||
INLINE void DXGraphicsStateGuardian::
|
||||
enable_lighting(bool val) {
|
||||
if (_lighting_enabled != val) {
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_LIGHTING, (DWORD)val);
|
||||
if(_lighting_enabled = val)
|
||||
_lighting_enabled_this_frame = true;
|
||||
}
|
||||
@ -64,14 +64,14 @@ enable_dither(bool val) {
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
|
||||
if(val && !(scrn.d3dcaps.RasterCaps & D3DPRASTERCAPS_DITHER))
|
||||
dxgsg_cat.error() << "no HW support for color dithering!!\n";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_dither_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_DITHERENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_stencil_test(bool val) {
|
||||
if (_stencil_test_enabled != val) {
|
||||
_stencil_test_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_STENCILENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,27 +100,55 @@ enable_color_material(bool val) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::enable_clip_plane
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void DXGraphicsStateGuardian::
|
||||
enable_clip_plane(int clip_plane, bool val)
|
||||
enable_clip_plane(int clip_plane_id, bool val)
|
||||
{
|
||||
if (_clip_plane_enabled[clip_plane] != val)
|
||||
{
|
||||
_clip_plane_enabled[clip_plane] = val;
|
||||
assert(clip_plane_id < D3DMAXUSERCLIPPLANES);
|
||||
|
||||
if (_clip_plane_enabled[clip_plane_id] != val) {
|
||||
DWORD bitflag = 1 << clip_plane_id;
|
||||
|
||||
_clip_plane_enabled[clip_plane_id] = val;
|
||||
DWORD ClipPlaneBits;
|
||||
scrn.pD3DDevice->GetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , &ClipPlaneBits);
|
||||
scrn.pD3DDevice->GetRenderState(D3DRS_CLIPPLANEENABLE , &ClipPlaneBits);
|
||||
if (val)
|
||||
ClipPlaneBits |= 1 << clip_plane;
|
||||
ClipPlaneBits |= bitflag;
|
||||
else
|
||||
ClipPlaneBits &= ~(1 << clip_plane);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , ClipPlaneBits);
|
||||
ClipPlaneBits &= ~bitflag;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE , ClipPlaneBits);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::enable_clip_plane
|
||||
// Access:
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void DXGraphicsStateGuardian::
|
||||
enable_clip_plane(int clip_plane_id, bool val)
|
||||
{
|
||||
assert(clip_plane_id < D3DMAXUSERCLIPPLANES);
|
||||
|
||||
// clip plane stuff needs total rewriting to get rid of these arrays
|
||||
// if (((_clip_planes_enabled & bitflag)!=0) != val)
|
||||
if (_clip_plane_enabled[clip_plane_id] != val) {
|
||||
_clip_plane_enabled[clip_plane_id] = val;
|
||||
if(val)
|
||||
_clip_plane_enabled |= bitflag;
|
||||
else _clip_plane_enabled &= ~bitflag;
|
||||
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE , _clip_planes_enabled);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: DXGraphicsStateGuardian::enable_blend
|
||||
// Access:
|
||||
@ -130,7 +158,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_blend(bool val) {
|
||||
if (_blend_enabled != val) {
|
||||
_blend_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,10 +168,10 @@ enable_blend(bool val) {
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void DXGraphicsStateGuardian::
|
||||
set_shademode(D3DSHADEMODE val) {
|
||||
if (_CurShadeMode != val) {
|
||||
_CurShadeMode = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
|
||||
enable_gouraud_shading(bool val) {
|
||||
if (_bGouraudShadingOn != val) {
|
||||
_bGouraudShadingOn = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_COLORVERTEX, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +179,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_primitive_clipping(bool val) {
|
||||
if (_clipping_enabled != val) {
|
||||
_clipping_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_CLIPPING, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +192,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_fog(bool val) {
|
||||
if ((_fog_enabled != val) && (_doFogType!=None)) {
|
||||
_fog_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_FOGENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +206,7 @@ enable_alpha_test(bool val )
|
||||
{
|
||||
if (_alpha_test_enabled != val) {
|
||||
_alpha_test_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,8 +223,8 @@ call_dxLightModelAmbient( const Colorf& color)
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
|
||||
#endif
|
||||
scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
|
||||
D3DRGBA(color[0], color[1], color[2], color[3]));
|
||||
scrn.pD3DDevice->SetRenderState( D3DRS_AMBIENT,
|
||||
D3DCOLOR_COLORVALUE(color[0], color[1], color[2], color[3]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,8 +270,8 @@ call_dxAlphaFunc(D3DCMPFUNC func, DWORD ref)
|
||||
}
|
||||
dxgsg_cat.debug() << ref << ")" << endl;
|
||||
#endif
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, ref);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_ALPHAFUNC, func);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_ALPHAREF, ref);
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +282,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
|
||||
if (_blend_source_func != sfunc)
|
||||
{
|
||||
_blend_source_func = sfunc;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_SRCBLEND, sfunc);
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxSrcBlendFunc(";
|
||||
switch (sfunc)
|
||||
@ -296,7 +324,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
|
||||
if ( _blend_dest_func != dfunc)
|
||||
{
|
||||
_blend_dest_func = dfunc;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_DESTBLEND, dfunc);
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxDstBlendFunc(";
|
||||
switch (dfunc)
|
||||
@ -338,7 +366,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_zwritemask(bool val) {
|
||||
if (_depth_write_enabled != val) {
|
||||
_depth_write_enabled = val;
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,40 +38,49 @@
|
||||
#include <pointerToArray.h>
|
||||
#include <planeNode.h>
|
||||
|
||||
#include "dxGeomNodeContext.h"
|
||||
#include "dxTextureContext.h"
|
||||
#include "dxGeomNodeContext8.h"
|
||||
#include "dxTextureContext8.h"
|
||||
#include <vector>
|
||||
|
||||
extern char * ConvD3DErrorToString(const HRESULT &error); // defined in wdxGraphicsPipe.cxx
|
||||
#define FLG(NN) (1<<NN)
|
||||
#define MAX_POSSIBLE_TEXFMTS 32
|
||||
typedef enum {
|
||||
R8G8B8_FLAG = FLG(0),
|
||||
A8R8G8B8_FLAG = FLG(1),
|
||||
X8R8G8B8_FLAG = FLG(2),
|
||||
R5G6B5_FLAG = FLG(3),
|
||||
X1R5G5B5_FLAG = FLG(4),
|
||||
A1R5G5B5_FLAG = FLG(5),
|
||||
A4R4G4B4_FLAG = FLG(6),
|
||||
R3G3B2_FLAG = FLG(7),
|
||||
A8_FLAG = FLG(8),
|
||||
A8R3G3B2_FLAG = FLG(9),
|
||||
X4R4G4B4_FLAG = FLG(10),
|
||||
A2B10G10R10_FLAG = FLG(12),
|
||||
// G16R16_FLAG = FLG(13), leaving this 1 out to fit in 32 bits
|
||||
A8P8_FLAG = FLG(13),
|
||||
P8_FLAG = FLG(14),
|
||||
L8_FLAG = FLG(15),
|
||||
A8L8_FLAG = FLG(16),
|
||||
A4L4_FLAG = FLG(17),
|
||||
V8U8_FLAG = FLG(18),
|
||||
L6V5U5_FLAG = FLG(19),
|
||||
X8L8V8U8_FLAG = FLG(20),
|
||||
Q8W8V8U8_FLAG = FLG(21),
|
||||
V16U16_FLAG = FLG(22),
|
||||
W11V11U10_FLAG = FLG(23),
|
||||
A2W10V10U10_FLAG = FLG(24),
|
||||
UYVY_FLAG = FLG(25),
|
||||
YUY2_FLAG = FLG(26),
|
||||
DXT1_FLAG = FLG(27),
|
||||
DXT2_FLAG = FLG(28),
|
||||
DXT3_FLAG = FLG(29),
|
||||
DXT4_FLAG = FLG(30),
|
||||
DXT5_FLAG = FLG(31)
|
||||
} D3DFORMAT_FLAG;
|
||||
|
||||
// for dwSupportedScreenDepthsMask
|
||||
#define X1R5G5B5_FLAG 0x1
|
||||
#define R5G6B5_FLAG 0x2
|
||||
#define X8R8G8B8_FLAG 0x4
|
||||
#define R8G8B8_FLAG 0x8
|
||||
|
||||
typedef struct {
|
||||
LPDIRECT3DDEVICE8 pD3DDevice;
|
||||
LPDIRECT3D8 pD3D8;
|
||||
LPDIRECTDRAWSURFACE7 pddsPrimary,pddsBack,pddsZBuf;
|
||||
HWND hWnd;
|
||||
HMONITOR hMon;
|
||||
RECT view_rect,clip_rect;
|
||||
DWORD MaxAvailVidMem;
|
||||
bool bIsLowVidMemCard;
|
||||
bool bIsTNLDevice;
|
||||
ushort depth_buffer_bitdepth; //GetSurfaceDesc is not reliable so must store this explicitly
|
||||
ushort CardIDNum; // adapter ID
|
||||
DWORD dwSupportedScreenDepthsMask;
|
||||
D3DCAPS8 d3dcaps;
|
||||
D3DDISPLAYMODE DisplayMode;
|
||||
D3DPRESENT_PARAMETERS PresParams; // not redundant with DisplayMode since width/height must be 0 for windowed mode
|
||||
#ifdef USE_TEXFMTVEC
|
||||
DDPixelFormatVec TexPixFmts;
|
||||
#endif
|
||||
D3DADAPTER_IDENTIFIER8 DXDeviceID;
|
||||
} DXScreenData;
|
||||
// typedef vector<DXScreenData> ScreenDataVector;
|
||||
#define IS_16BPP_FORMAT(FMT) (((FMT)>=D3DFMT_R5G6B5)&&((FMT)<=D3DFMT_A1R5G5B5))
|
||||
#define IS_STENCIL_FORMAT(FMT) (((FMT)==D3DFMT_D24S8) || ((FMT)==D3DFMT_D15S1) || ((FMT)==D3DFMT_D24X4S4))
|
||||
|
||||
class PlaneNode;
|
||||
class Light;
|
||||
@ -94,10 +103,14 @@ INLINE ostream &operator << (ostream &out, GLenum v) {
|
||||
ZeroMemory(&var, sizeof(type)); \
|
||||
var.dwSize = sizeof(type);
|
||||
|
||||
// #define DEBUG_RELEASES
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
|
||||
// this is bDoDownToZero argument to RELEASE()
|
||||
#define RELEASE_DOWN_TO_ZERO true
|
||||
#define RELEASE_ONCE false
|
||||
|
||||
// #define DEBUG_RELEASES
|
||||
|
||||
#ifdef DEBUG_RELEASES
|
||||
#define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero) \
|
||||
@ -263,16 +276,9 @@ public:
|
||||
|
||||
public:
|
||||
// recreate_tex_callback needs these to be public
|
||||
LPDIRECT3DDEVICE7 _pCurD3DDevice; //this needs to be set every device iteration
|
||||
LPDIRECTDRAW7 _pDD;
|
||||
// LPDIRECT3DDEVICE7 _pCurD3DDevice; //this needs to be set every device iteration
|
||||
DXScreenData scrn;
|
||||
|
||||
#ifndef USE_TEXFMTVEC
|
||||
LPDDPIXELFORMAT _pTexPixFmts;
|
||||
int _cNumTexPixFmts;
|
||||
#endif
|
||||
// D3DDEVICEDESC7 _D3DDevDesc;
|
||||
|
||||
protected:
|
||||
void free_pointers(); // free local internal buffers
|
||||
void free_dxgsg_objects(void); // free the DirectX objects we create
|
||||
@ -290,24 +296,8 @@ protected:
|
||||
|
||||
bool _dx_ready;
|
||||
HRESULT _last_testcooplevel_result;
|
||||
|
||||
/*
|
||||
moved to per display data
|
||||
bool _bIsTNLDevice;
|
||||
LPDIRECTDRAWSURFACE7 _back;
|
||||
LPDIRECTDRAWSURFACE7 _zbuf;
|
||||
LPDIRECTDRAWSURFACE7 _pri;
|
||||
|
||||
LPDIRECT3D7 _d3d;
|
||||
LPDIRECTDRAW7 _pDD;
|
||||
RECT _view_rect;
|
||||
RECT clip_rect;
|
||||
*/
|
||||
LPDIRECT3D7 _pCurD3D7;
|
||||
LPDIRECTDRAW7 _pCurDD;
|
||||
bool _bShowFPSMeter;
|
||||
|
||||
HDC _front_hdc;
|
||||
// HDC _front_hdc;
|
||||
DXTextureContext *_pCurTexContext;
|
||||
|
||||
bool _bTransformIssued; // decaling needs to tell when a transform has been issued
|
||||
@ -331,10 +321,10 @@ protected:
|
||||
*/
|
||||
|
||||
INLINE void enable_color_material(bool val);
|
||||
INLINE void enable_clip_plane(int clip_plane, bool val);
|
||||
INLINE void enable_clip_plane(int clip_plane_id, bool val);
|
||||
INLINE void enable_fog(bool val);
|
||||
INLINE void enable_zwritemask(bool val);
|
||||
INLINE void set_shademode(D3DSHADEMODE val);
|
||||
INLINE void enable_gouraud_shading(bool val);
|
||||
|
||||
INLINE D3DTEXTUREADDRESS get_texture_wrap_mode(Texture::WrapMode wm) const;
|
||||
INLINE D3DCMPFUNC get_depth_func_type(DepthTestProperty::Mode m) const;
|
||||
@ -375,7 +365,8 @@ protected:
|
||||
Colorf _issued_color; // WBD ADDED
|
||||
D3DCOLOR _issued_color_D3DCOLOR; // WBD ADDED
|
||||
D3DCOLOR _d3dcolor_clear_value;
|
||||
D3DSHADEMODE _CurShadeMode;
|
||||
// D3DSHADEMODE _CurShadeMode;
|
||||
bool _bGouraudShadingOn;
|
||||
|
||||
bool _bDrawPrimDoSetupVertexBuffer; // if true, draw methods just copy vertex data into pCurrentGeomContext
|
||||
DXGeomNodeContext *_pCurrentGeomContext; // used in vertex buffer setup
|
||||
@ -408,8 +399,8 @@ protected:
|
||||
float _material_emission;
|
||||
|
||||
typedef enum {None,
|
||||
PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
|
||||
PerPixelFog=D3DRENDERSTATE_FOGTABLEMODE
|
||||
PerVertexFog=D3DRS_FOGVERTEXMODE,
|
||||
PerPixelFog=D3DRS_FOGTABLEMODE
|
||||
} DxgsgFogType;
|
||||
DxgsgFogType _doFogType;
|
||||
bool _fog_enabled;
|
||||
@ -523,15 +514,13 @@ public:
|
||||
RECT viewrect); */
|
||||
void dx_init(void);
|
||||
|
||||
friend HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param );
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#define ISPOW2(X) (((X) & ((X)-1))==0)
|
||||
|
||||
#include "dxGraphicsStateGuardian.I"
|
||||
#include "dxGraphicsStateGuardian8.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,8 @@
|
||||
|
||||
#include <pandabase.h>
|
||||
|
||||
//#define DO_CUSTOM_CONVERSIONS
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifndef STRICT
|
||||
// enable strict type checking in windows.h, see msdn
|
||||
@ -28,27 +30,41 @@
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ddraw.h>
|
||||
|
||||
#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include <dxerr8.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
|
||||
#ifndef D3DERRORSTRING
|
||||
#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__"), hr=" << DXGetErrorString8(HRESULT) << ": " << DXGetErrorDescription8(HRESULT) << endl
|
||||
#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__ << "), hr=" << DXGetErrorString8(HRESULT) << ": " << DXGetErrorDescription8(HRESULT) << endl
|
||||
#endif
|
||||
|
||||
#include <texture.h>
|
||||
#include <textureContext.h>
|
||||
|
||||
//#define USE_TEXFMTVEC // doesnt work now, crashes in destructor
|
||||
|
||||
#ifdef USE_TEXFMTVEC
|
||||
typedef pvector<DDPIXELFORMAT> DDPixelFormatVec;
|
||||
#else
|
||||
#define MAX_DX_TEXPIXFMTS 20 // should be enough for any card
|
||||
#endif
|
||||
typedef struct {
|
||||
LPDIRECT3DDEVICE8 pD3DDevice;
|
||||
LPDIRECT3D8 pD3D8;
|
||||
HWND hWnd;
|
||||
HMONITOR hMon;
|
||||
RECT view_rect,clip_rect;
|
||||
DWORD MaxAvailVidMem;
|
||||
bool bIsLowVidMemCard;
|
||||
bool bIsTNLDevice;
|
||||
bool bIsDX81;
|
||||
ushort depth_buffer_bitdepth; //GetSurfaceDesc is not reliable so must store this explicitly
|
||||
ushort CardIDNum; // adapter ID
|
||||
DWORD dwSupportedScreenDepthsMask;
|
||||
DWORD SupportedTexFmtsMask;
|
||||
D3DCAPS8 d3dcaps;
|
||||
D3DDISPLAYMODE DisplayMode;
|
||||
D3DPRESENT_PARAMETERS PresParams; // not redundant with DisplayMode since width/height must be 0 for windowed mode
|
||||
D3DADAPTER_IDENTIFIER8 DXDeviceID;
|
||||
} DXScreenData;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DXTextureContext
|
||||
@ -62,23 +78,19 @@ public:
|
||||
DXTextureContext(Texture *tex);
|
||||
~DXTextureContext();
|
||||
|
||||
LPDIRECTDRAWSURFACE7 _surface;
|
||||
IDirect3DTexture8 *_pD3DTexture8;
|
||||
Texture *_tex; // ptr to parent, primarily for access to namestr
|
||||
|
||||
// static is_unused_texpixelformat(DDPIXELFORMAT *)
|
||||
|
||||
#ifdef USE_TEXFMTVEC
|
||||
LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
|
||||
#else
|
||||
LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc);
|
||||
#endif
|
||||
IDirect3DTexture8 *CreateTexture(DXScreenData &scrn);
|
||||
|
||||
bool _bHasMipMaps;
|
||||
|
||||
#ifdef DO_CUSTOM_CONVERSIONS
|
||||
DWORD _PixBufConversionType; // enum ConversionType
|
||||
#endif
|
||||
|
||||
// must be public since called from global callback fns
|
||||
void DeleteTexture(void);
|
||||
HRESULT FillDDSurfTexturePixels(void);
|
||||
HRESULT FillDDSurfTexturePixels(DWORD TargetWidth,DWORD TargetHeight,D3DFORMAT PixBufD3DFmt);
|
||||
|
||||
protected:
|
||||
unsigned int get_bits_per_pixel(PixelBuffer::Format format, int *alphbits);
|
||||
@ -101,6 +113,7 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
extern HRESULT ConvertD3DSurftoPixBuf(IDirect3DSurface8 *pD3DSurf8,PixelBuffer *pixbuf);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#if $[BUILD_DX8]
|
||||
#begin lib_target
|
||||
#define TARGET wdxdisplay
|
||||
#define TARGET wdxdisplay8
|
||||
#define LOCAL_LIBS \
|
||||
dxgsg
|
||||
|
||||
|
@ -20,13 +20,12 @@
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <tchar.h>
|
||||
#include "wdxGraphicsWindow.h"
|
||||
#include "wdxGraphicsPipe.h"
|
||||
#include "config_wdxdisplay.h"
|
||||
#include "wdxGraphicsWindow8.h"
|
||||
#include "wdxGraphicsPipe8.h"
|
||||
#include "config_wdxdisplay8.h"
|
||||
|
||||
#include <keyboardButton.h>
|
||||
#include <mouseButton.h>
|
||||
|
||||
#include <throw_event.h>
|
||||
|
||||
#ifdef DO_PSTATS
|
||||
@ -901,11 +900,10 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
||||
wc.hInstance = hProgramInstance;
|
||||
wc.hCursor = NULL; // for DX8 we handle the cursor messages ourself
|
||||
|
||||
#if 0
|
||||
|
||||
// all this must be moved to dx_init, since we need to create DX surface
|
||||
string windows_icon_filename = get_icon_filename().to_os_specific();
|
||||
string windows_mono_cursor_filename = get_mono_cursor_filename().to_os_specific();
|
||||
string windows_color_cursor_filename = get_color_cursor_filename().to_os_specific();
|
||||
|
||||
|
||||
if(!windows_icon_filename.empty()) {
|
||||
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
|
||||
@ -921,6 +919,8 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
||||
wc.hIcon = NULL; // use default app icon
|
||||
}
|
||||
|
||||
// Note: dx_init() uses the cursor handle to create the dx cursor surface
|
||||
string windows_color_cursor_filename = get_color_cursor_filename().to_os_specific();
|
||||
|
||||
if(!windows_color_cursor_filename.empty()) {
|
||||
// card support for full color non-black/white GDI cursors varies greatly. if the cursor is not supported,
|
||||
@ -931,9 +931,12 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
||||
// (sync issues?). instead we do mono cursor unless card is known to support 256 color cursors
|
||||
bool bSupportsColorCursor=true;
|
||||
|
||||
#if 0
|
||||
// remove this check for now, since dx8 should emulate color cursors
|
||||
/* if any card doesnt support color, dont load it*/
|
||||
for(int w=0;w<_windows.size();w++)
|
||||
bSupportsColorCursor &= supports_color_cursors(_windows[w]->_dxgsg->scrn.DXDeviceID);
|
||||
#endif
|
||||
|
||||
if(bSupportsColorCursor) {
|
||||
DWORD load_flags = LR_LOADFROMFILE;
|
||||
@ -956,20 +959,16 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
||||
|
||||
}
|
||||
|
||||
/* dont need these anymore since we are do mousestuff before window creation
|
||||
SetClassLongPtr(_mwindow, GCLP_HCURSOR, (LONG_PTR) hNewMouseCursor);
|
||||
SetCursor(hNewMouseCursor);
|
||||
|
||||
if(_bLoadedCustomCursor)
|
||||
DestroyCursor(_hMouseCursor);
|
||||
*/
|
||||
_bLoadedCustomCursor=true;
|
||||
}
|
||||
}
|
||||
|
||||
try_mono_cursor:
|
||||
|
||||
if((!_bLoadedCustomCursor) && (!windows_mono_cursor_filename.empty())) {
|
||||
if(!_bLoadedCustomCursor) {
|
||||
string windows_mono_cursor_filename = get_mono_cursor_filename().to_os_specific();
|
||||
|
||||
if(!windows_mono_cursor_filename.empty()) {
|
||||
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
|
||||
// if icon is more than 8bpp
|
||||
|
||||
@ -987,13 +986,11 @@ void wdxGraphicsWindowGroup::CreateWindows(void) {
|
||||
wdxdisplay_cat.warning() << "windows mono cursor filename '" << windows_mono_cursor_filename << "' not found!!\n";
|
||||
} else _bLoadedCustomCursor=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!_bLoadedCustomCursor)
|
||||
_hMouseCursor = LoadCursor(NULL, DEFAULT_CURSOR);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
if (!wc_registered) {
|
||||
// We only need to register the window class once per session.
|
||||
wc.hCursor = _hMouseCursor;
|
||||
@ -1609,6 +1606,10 @@ bool wdxGraphicsWindow::search_for_device(LPDIRECT3D8 pD3D8,DXDeviceInfo *pDevin
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(d3dcaps.MaxStreams==0) {
|
||||
wdxdisplay_cat.info() << "Warning: video driver predates DX8\n";
|
||||
}
|
||||
|
||||
if(bWantStencil & (d3dcaps.StencilCaps==0x0)) {
|
||||
wdxdisplay_cat.fatal() << "Stencil ability requested, but device #" << pDevInfo->cardID << " (" << _dxgsg->scrn.DXDeviceID.szDescription<<"), has no stencil capability!\n";
|
||||
exit(1);
|
||||
@ -1901,7 +1902,7 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
// LPDIRECTDRAW7 pDD=Display.pDD;
|
||||
// D3DDEVICEDESC7 *pD3DDevDesc=&Display.D3DDevDesc;
|
||||
LPD3DCAPS8 pD3Dcaps = &Display.d3dcaps;
|
||||
|
||||
D3DPRESENT_PARAMETERS* pPresParams = &Display.PresParams;
|
||||
LPDIRECTDRAWSURFACE7 pPrimaryDDSurf,pBackDDSurf,pZDDSurf;
|
||||
LPDIRECT3DDEVICE7 pD3DDevice;
|
||||
RECT view_rect;
|
||||
@ -1946,8 +1947,6 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
}
|
||||
*/
|
||||
|
||||
ResourceManagerDiscardBytes(0);
|
||||
|
||||
// DX_DECLARE_CLEAN(DDCAPS,DDCaps);
|
||||
// pDD->GetCaps(&DDCaps,NULL);
|
||||
|
||||
@ -1986,7 +1985,6 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
}
|
||||
}
|
||||
|
||||
D3DPRESENT_PARAMETERS* pPresParams = &Display.PresParams;
|
||||
pPresParams->Windowed = dx_full_screen;
|
||||
DWORD dwBehaviorFlags=0x0;
|
||||
|
||||
@ -2061,8 +2059,6 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
hr = pD3D8->CreateDevice(Display.CardIDNum, D3DDEVTYPE_HAL, _pParentWindowGroup->_hParentWindow,
|
||||
dwBehaviorFlags, pPresParams, &Display.pD3DDevice);
|
||||
|
||||
#define IS_16BPP_FORMAT(FMT) (((FMT)>=D3DFMT_R5G6B5)&&((FMT)<=D3DFMT_A1R5G5B5))
|
||||
|
||||
if(FAILED(hr)) {
|
||||
wdxdisplay_cat.fatal() << "D3D CreateDevice failed for device #" << Display.CardIDnum << ", " << D3DERRORSTRING(hr);
|
||||
|
||||
@ -2131,6 +2127,11 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
}
|
||||
} // end create windowed buffers
|
||||
|
||||
hr = Display.pD3DDevice->ResourceManagerDiscardBytes(0);
|
||||
if(hr != DD_OK) {
|
||||
wdxdisplay_cat.fatal() << "ResourceManagerDiscardBytes failed for device #" << Display.CardIDnum << ", " << D3DERRORSTRING(hr);
|
||||
}
|
||||
|
||||
// clear to transparent black to get rid of visible garbage
|
||||
hr = Display.pD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET,0,0.0,0);
|
||||
if(hr != DD_OK) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user