mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
non-working progress save
This commit is contained in:
parent
bf23168c43
commit
212ed03c2b
@ -6,26 +6,25 @@
|
||||
|
||||
#if $[BUILD_DX8]
|
||||
#begin lib_target
|
||||
|
||||
#define TARGET dxgsg8
|
||||
#define TARGET dxgsg
|
||||
#define LOCAL_LIBS \
|
||||
cull gsgmisc gsgbase gobj sgattrib sgraphutil graph display light \
|
||||
putil linmath sgraph mathutil pnmimage event
|
||||
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
|
||||
|
||||
#define SOURCES \
|
||||
config_dxgsg8.h dxGraphicsStateGuardian8.I \
|
||||
dxGraphicsStateGuardian8.cxx dxGraphicsStateGuardian8.h \
|
||||
dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h \
|
||||
// need to install these due to external projects that link directly with libpandadx (bartop)
|
||||
#define INSTALL_HEADERS \
|
||||
config_dxgsg8.h dxGraphicsStateGuardian8.I dxGraphicsStateGuardian8.h \
|
||||
dxTextureContext8.h dxGeomNodeContext8.h dxGeomNodeContext8.I
|
||||
|
||||
// build dxGraphicsStateGuardian separately since its so big
|
||||
|
||||
#define SOURCES \
|
||||
dxGraphicsStateGuardian8.cxx dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h $[INSTALL_HEADERS]
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_dxgsg8.cxx dxSavedFrameBuffer8.cxx dxTextureContext8.cxx dxGeomNodeContext8.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
dxGraphicsStateGuardian8.I dxGraphicsStateGuardian8.h \
|
||||
dxSavedFrameBuffer8.I dxSavedFrameBuffer8.h dxTextureContext8.h
|
||||
|
||||
#end lib_target
|
||||
#endif
|
||||
|
@ -16,10 +16,10 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_dxgsg8.h"
|
||||
#include "dxGraphicsStateGuardian8.h"
|
||||
#include "dxSavedFrameBuffer8.h"
|
||||
#include "dxTextureContext8.h"
|
||||
#include "config_dxgsg.h"
|
||||
#include "dxGraphicsStateGuardian.h"
|
||||
#include "dxSavedFrameBuffer.h"
|
||||
#include "dxTextureContext.h"
|
||||
|
||||
#include <dconfig.h>
|
||||
|
||||
@ -74,11 +74,12 @@ bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
|
||||
|
||||
// if this is set, more accurate but more expensive fog computations are performed
|
||||
bool dx_use_rangebased_fog = config_dxgsg.GetBool("dx-use-rangebased-fog", false);
|
||||
bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
|
||||
bool dx_no_dithering = config_dxgsg.GetBool("dx-no-dithering", false);
|
||||
|
||||
#ifdef _DEBUG
|
||||
float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
|
||||
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_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
|
||||
//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
|
||||
#endif
|
||||
@ -104,7 +105,7 @@ parse_decal_type(const string &type) {
|
||||
}
|
||||
|
||||
ConfigureFn(config_dxgsg) {
|
||||
init_libdxgsg8();
|
||||
init_libdxgsg();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -115,7 +116,8 @@ ConfigureFn(config_dxgsg) {
|
||||
// called by the static initializers and need not be
|
||||
// called explicitly, but special cases exist.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void init_libdxgsg8() {
|
||||
void
|
||||
init_libdxgsg() {
|
||||
static bool initialized = false;
|
||||
if (initialized) {
|
||||
return;
|
||||
|
@ -35,10 +35,12 @@ extern bool dx_auto_normalize_lighting;
|
||||
extern bool dx_use_rangebased_fog;
|
||||
extern const bool link_tristrips;
|
||||
|
||||
// debug flags
|
||||
// debug flags we might want to use in full optimized build
|
||||
extern bool dx_ignore_mipmaps;
|
||||
extern bool dx_mipmap_everything;
|
||||
extern bool dx_show_transforms;
|
||||
extern bool dx_force_16bpptextures;
|
||||
extern bool dx_no_dithering;
|
||||
|
||||
#ifndef NDEBUG
|
||||
extern int dx_force_backface_culling;
|
||||
@ -47,7 +49,6 @@ extern int dx_force_backface_culling;
|
||||
#ifdef _DEBUG
|
||||
extern float dx_global_miplevel_bias;
|
||||
extern bool dx_debug_view_mipmaps;
|
||||
extern bool dx_force_16bpptextures;
|
||||
extern bool dx_force_anisotropic_filtering;
|
||||
#endif
|
||||
|
||||
@ -59,6 +60,6 @@ enum DXDecalType {
|
||||
};
|
||||
extern DXDecalType dx_decal_type;
|
||||
|
||||
extern EXPCL_PANDADX void init_libdxgsg8();
|
||||
extern EXPCL_PANDADX void init_libdxgsg();
|
||||
|
||||
#endif
|
||||
|
@ -33,7 +33,15 @@
|
||||
#include "pvector.h"
|
||||
|
||||
#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h
|
||||
#include <d3d.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#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!
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
DWORD nVerts;
|
||||
|
@ -16,7 +16,7 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "config_dxgsg8.h"
|
||||
#include "config_dxgsg.h"
|
||||
#include <graphicsWindow.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -30,12 +30,12 @@ enable_line_smooth(bool val) {
|
||||
_line_smooth_enabled = val;
|
||||
#ifdef NDEBUG
|
||||
{
|
||||
if(val && (_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
|
||||
if(val && (scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES))
|
||||
dxgsg_cat.error() << "no HW support for line smoothing!!\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_EDGEANTIALIAS, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ enable_line_smooth(bool val) {
|
||||
INLINE void DXGraphicsStateGuardian::
|
||||
enable_lighting(bool val) {
|
||||
if (_lighting_enabled != val) {
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_LIGHTING, (DWORD)val);
|
||||
if(_lighting_enabled = val)
|
||||
_lighting_enabled_this_frame = true;
|
||||
}
|
||||
@ -64,14 +64,14 @@ enable_dither(bool val) {
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
if(val && !(_D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
|
||||
if(val && !(scrn.D3DDevDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_DITHER))
|
||||
dxgsg_cat.error() << "no HW support for color dithering!!\n";
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_dither_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_stencil_test(bool val) {
|
||||
if (_stencil_test_enabled != val) {
|
||||
_stencil_test_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_STENCILENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,12 +112,12 @@ enable_clip_plane(int clip_plane, bool val)
|
||||
{
|
||||
_clip_plane_enabled[clip_plane] = val;
|
||||
DWORD ClipPlaneBits;
|
||||
_d3dDevice->GetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , &ClipPlaneBits);
|
||||
scrn.pD3DDevice->GetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , &ClipPlaneBits);
|
||||
if (val)
|
||||
ClipPlaneBits |= 1 << clip_plane;
|
||||
else
|
||||
ClipPlaneBits &= ~(1 << clip_plane);
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , ClipPlaneBits);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPLANEENABLE , ClipPlaneBits);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_blend(bool val) {
|
||||
if (_blend_enabled != val) {
|
||||
_blend_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
set_shademode(D3DSHADEMODE val) {
|
||||
if (_CurShadeMode != val) {
|
||||
_CurShadeMode = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_primitive_clipping(bool val) {
|
||||
if (_clipping_enabled != val) {
|
||||
_clipping_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_CLIPPING, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_fog(bool val) {
|
||||
if ((_fog_enabled != val) && (_doFogType!=None)) {
|
||||
_fog_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ enable_alpha_test(bool val )
|
||||
{
|
||||
if (_alpha_test_enabled != val) {
|
||||
_alpha_test_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, (DWORD)val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ call_dxLightModelAmbient( const Colorf& color)
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxLightModel(LIGHT_MODEL_AMBIENT, " << color << ")" << endl;
|
||||
#endif
|
||||
_d3dDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
|
||||
scrn.pD3DDevice->SetRenderState( D3DRENDERSTATE_AMBIENT,
|
||||
D3DRGBA(color[0], color[1], color[2], color[3]));
|
||||
}
|
||||
}
|
||||
@ -242,8 +242,8 @@ call_dxAlphaFunc(D3DCMPFUNC func, DWORD ref)
|
||||
}
|
||||
dxgsg_cat.debug() << ref << ")" << endl;
|
||||
#endif
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, ref);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC, func);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF, ref);
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
|
||||
if (_blend_source_func != sfunc)
|
||||
{
|
||||
_blend_source_func = sfunc;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, sfunc);
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxSrcBlendFunc(";
|
||||
switch (sfunc)
|
||||
@ -296,7 +296,7 @@ call_dxBlendFunc(D3DBLEND sfunc, D3DBLEND dfunc )
|
||||
if ( _blend_dest_func != dfunc)
|
||||
{
|
||||
_blend_dest_func = dfunc;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, dfunc);
|
||||
#ifdef GSG_VERBOSE
|
||||
dxgsg_cat.debug() << "dxDstBlendFunc(";
|
||||
switch (dfunc)
|
||||
@ -338,7 +338,7 @@ INLINE void DXGraphicsStateGuardian::
|
||||
enable_zwritemask(bool val) {
|
||||
if (_depth_write_enabled != val) {
|
||||
_depth_write_enabled = val;
|
||||
_d3dDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
|
||||
scrn.pD3DDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,8 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DXGRAPHICSSTATEGUARDIAN8_H
|
||||
#define DXGRAPHICSSTATEGUARDIAN8_H
|
||||
#ifndef DXGRAPHICSSTATEGUARDIAN_H
|
||||
#define DXGRAPHICSSTATEGUARDIAN_H
|
||||
|
||||
//#define GSG_VERBOSE
|
||||
|
||||
@ -38,11 +38,41 @@
|
||||
#include <pointerToArray.h>
|
||||
#include <planeNode.h>
|
||||
|
||||
#include "dxGeomNodeContext8.h"
|
||||
#include "dxTextureContext8.h"
|
||||
#include "dxGeomNodeContext.h"
|
||||
#include "dxTextureContext.h"
|
||||
#include <vector>
|
||||
|
||||
extern char * ConvD3DErrorToString(const HRESULT &error); // defined in wdxGraphicsPipe.cxx
|
||||
|
||||
// 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; // its posn in DisplayArray, for dbgprint purposes
|
||||
DDDEVICEIDENTIFIER2 DXDeviceID;
|
||||
// D3DDEVICEDESC8 D3DDevDesc;
|
||||
DWORD dwSupportedScreenDepthsMask;
|
||||
D3DCAPS8 d3dcaps;
|
||||
D3DDISPLAYMODE DisplayMode;
|
||||
#ifdef USE_TEXFMTVEC
|
||||
DDPixelFormatVec TexPixFmts;
|
||||
#endif
|
||||
} DXScreenData;
|
||||
// typedef vector<DXScreenData> ScreenDataVector;
|
||||
|
||||
class PlaneNode;
|
||||
class Light;
|
||||
|
||||
@ -61,7 +91,7 @@ INLINE ostream &operator << (ostream &out, GLenum v) {
|
||||
|
||||
#define DX_DECLARE_CLEAN(type, var) \
|
||||
type var; \
|
||||
ZeroMemory(&var, sizeof(type)); \
|
||||
ZeroMemory(&var, sizeof(type)); \
|
||||
var.dwSize = sizeof(type);
|
||||
|
||||
// #define DEBUG_RELEASES
|
||||
@ -115,6 +145,10 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
|
||||
#define PRINTVIDMEM(pDD,pCaps,pMsg)
|
||||
#endif
|
||||
|
||||
#ifndef D3DERRORSTRING
|
||||
#define D3DERRORSTRING(HRESULT) " at (" << __FILE__ << ":" << __LINE__"), hr=" << DXGetErrorString8(HRESULT) << ": " << DXGetErrorDescription8(HRESULT) << endl
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DXGraphicsStateGuardian
|
||||
// Description : A GraphicsStateGuardian specialized for rendering
|
||||
@ -123,6 +157,8 @@ extern void dbgPrintVidMem(LPDIRECTDRAW7 pDD, LPDDSCAPS2 lpddsCaps,const char *p
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDADX DXGraphicsStateGuardian : public GraphicsStateGuardian {
|
||||
friend class wdxGraphicsWindow;
|
||||
friend class wdxGraphicsPipe;
|
||||
friend class wdxGraphicsWindowGroup;
|
||||
friend class DXTextureContext;
|
||||
|
||||
public:
|
||||
@ -137,9 +173,9 @@ public:
|
||||
virtual void prepare_display_region();
|
||||
|
||||
virtual void render_frame();
|
||||
virtual void render_scene(Node *root, ProjectionNode *projnode);
|
||||
virtual void render_scene(Node *root, LensNode *projnode);
|
||||
virtual void render_subgraph(RenderTraverser *traverser,
|
||||
Node *subgraph, ProjectionNode *projnode,
|
||||
Node *subgraph, LensNode *projnode,
|
||||
const AllTransitionsWrapper &net_trans);
|
||||
virtual void render_subgraph(RenderTraverser *traverser,
|
||||
Node *subgraph,
|
||||
@ -227,9 +263,15 @@ public:
|
||||
|
||||
public:
|
||||
// recreate_tex_callback needs these to be public
|
||||
LPDIRECT3DDEVICE7 _d3dDevice;
|
||||
LPDIRECT3DDEVICE7 _pCurD3DDevice; //this needs to be set every device iteration
|
||||
LPDIRECTDRAW7 _pDD;
|
||||
DXScreenData scrn;
|
||||
|
||||
#ifndef USE_TEXFMTVEC
|
||||
LPDDPIXELFORMAT _pTexPixFmts;
|
||||
int _cNumTexPixFmts;
|
||||
#endif
|
||||
// D3DDEVICEDESC7 _D3DDevDesc;
|
||||
|
||||
protected:
|
||||
void free_pointers(); // free local internal buffers
|
||||
@ -241,8 +283,6 @@ protected:
|
||||
void set_draw_buffer(const RenderBuffer &rb);
|
||||
void set_read_buffer(const RenderBuffer &rb);
|
||||
|
||||
void bind_texture(TextureContext *tc);
|
||||
|
||||
// for storage of the flexible vertex format
|
||||
char *_pCurFvfBufPtr,*_pFvfBufBasePtr;
|
||||
INLINE void add_to_FVFBuf(void *data, size_t bytes) ;
|
||||
@ -250,15 +290,23 @@ protected:
|
||||
|
||||
bool _dx_ready;
|
||||
HRESULT _last_testcooplevel_result;
|
||||
|
||||
/*
|
||||
moved to per display data
|
||||
bool _bIsTNLDevice;
|
||||
LPDIRECTDRAWSURFACE7 _back;
|
||||
LPDIRECTDRAWSURFACE7 _zbuf;
|
||||
LPDIRECT3D7 _d3d;
|
||||
LPDIRECTDRAWSURFACE7 _pri;
|
||||
LPDIRECTDRAW7 _pDD;
|
||||
|
||||
RECT _view_rect;
|
||||
RECT clip_rect;
|
||||
LPDIRECT3D7 _d3d;
|
||||
LPDIRECTDRAW7 _pDD;
|
||||
RECT _view_rect;
|
||||
RECT clip_rect;
|
||||
*/
|
||||
LPDIRECT3D7 _pCurD3D7;
|
||||
LPDIRECTDRAW7 _pCurDD;
|
||||
bool _bShowFPSMeter;
|
||||
|
||||
HDC _front_hdc;
|
||||
DXTextureContext *_pCurTexContext;
|
||||
|
||||
@ -267,8 +315,6 @@ protected:
|
||||
|
||||
RenderBuffer::Type _cur_read_pixel_buffer; // source for copy_pixel_buffer operation
|
||||
|
||||
D3DDEVICEDESC7 _D3DDevDesc;
|
||||
|
||||
void GenerateSphere(void *pVertexSpace,DWORD dwVertSpaceByteSize,
|
||||
void *pIndexSpace,DWORD dwIndexSpaceByteSize,
|
||||
D3DVECTOR *pCenter, float fRadius,
|
||||
@ -329,7 +375,6 @@ protected:
|
||||
Colorf _issued_color; // WBD ADDED
|
||||
D3DCOLOR _issued_color_D3DCOLOR; // WBD ADDED
|
||||
D3DCOLOR _d3dcolor_clear_value;
|
||||
|
||||
D3DSHADEMODE _CurShadeMode;
|
||||
|
||||
bool _bDrawPrimDoSetupVertexBuffer; // if true, draw methods just copy vertex data into pCurrentGeomContext
|
||||
@ -370,10 +415,7 @@ protected:
|
||||
bool _fog_enabled;
|
||||
/*
|
||||
TODO: cache fog state
|
||||
float _fog_start;
|
||||
float _fog_end;
|
||||
float _fog_density;
|
||||
float _fog_color;
|
||||
float _fog_start,_fog_end,_fog_density,float _fog_color;
|
||||
*/
|
||||
float _alpha_func_ref;
|
||||
D3DCMPFUNC _alpha_func;
|
||||
@ -398,7 +440,6 @@ protected:
|
||||
int _decal_level;
|
||||
|
||||
RenderModeProperty::Mode _current_fill_mode; //poinr/wireframe/solid
|
||||
|
||||
GraphicsChannel *_panda_gfx_channel; // cache the 1 channel dx supports
|
||||
|
||||
// Cur Texture State
|
||||
@ -452,12 +493,13 @@ public:
|
||||
static void init_type(void);
|
||||
virtual TypeHandle get_type(void) const;
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
LPDIRECT3DDEVICE7 GetD3DDevice() { return _d3dDevice; }
|
||||
LPDIRECTDRAW7 GetDDInterface() { return _pDD; }
|
||||
LPDIRECTDRAWSURFACE7 GetBackBuffer() { return _back; }
|
||||
/*
|
||||
LPDIRECT3DDEVICE7 GetD3DDevice() { return scrn.pD3DDevice; }
|
||||
LPDIRECTDRAW7 GetDDInterface() { return scrn.pDD; }
|
||||
LPDIRECTDRAWSURFACE7 GetBackBuffer() { return scrn.pddsBackBuffer; }
|
||||
LPDIRECTDRAWSURFACE7 GetZBuffer() { return _zbuf; }
|
||||
INLINE void Set_HDC(HDC hdc) { _front_hdc = hdc; }
|
||||
*/
|
||||
// INLINE void Set_HDC(HDC hdc) { _front_hdc = hdc; }
|
||||
void adjust_view_rect(int x, int y);
|
||||
INLINE void SetDXReady(bool stat) { _dx_ready = stat; }
|
||||
INLINE bool GetDXReady(void) { return _dx_ready;}
|
||||
@ -472,13 +514,14 @@ public:
|
||||
void show_frame();
|
||||
void show_full_screen_frame();
|
||||
void show_windowed_frame();
|
||||
void dx_init( LPDIRECTDRAW7 context,
|
||||
/* void dx_init( LPDIRECTDRAW7 context,
|
||||
LPDIRECTDRAWSURFACE7 pri,
|
||||
LPDIRECTDRAWSURFACE7 back,
|
||||
LPDIRECTDRAWSURFACE7 zbuf,
|
||||
LPDIRECT3D7 d3d,
|
||||
LPDIRECT3DDEVICE7 d3dDevice,
|
||||
RECT viewrect);
|
||||
RECT viewrect); */
|
||||
void dx_init(void);
|
||||
|
||||
friend HRESULT CALLBACK EnumTexFmtsCallback( LPDDPIXELFORMAT pddpf, VOID* param );
|
||||
|
||||
@ -488,7 +531,7 @@ private:
|
||||
|
||||
#define ISPOW2(X) (((X) & ((X)-1))==0)
|
||||
|
||||
#include "dxGraphicsStateGuardian8.I"
|
||||
#include "dxGraphicsStateGuardian.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -18,9 +18,9 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include "dxTextureContext8.h"
|
||||
#include "config_dxgsg8.h"
|
||||
#include "dxGraphicsStateGuardian8.h"
|
||||
#include "dxTextureContext.h"
|
||||
#include "config_dxgsg.h"
|
||||
#include "dxGraphicsStateGuardian.h"
|
||||
#include "pnmImage.h"
|
||||
|
||||
//#define FORCE_16bpp_1555
|
||||
@ -971,24 +971,38 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
|
||||
// gets the attributes of the texture from the bitmap, creates the
|
||||
// texture, and then copies the bitmap into the texture.
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTDRAWSURFACE7 DXTextureContext::
|
||||
CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts) {
|
||||
LPDIRECTDRAWSURFACE7 DXTextureContext::CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice,
|
||||
#ifdef USE_TEXFMTVEC
|
||||
DDPixelFormatVec &TexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
|
||||
#else
|
||||
int cNumTexPixFmts, DDPIXELFORMAT *pTexFmts,LPD3DDEVICEDESC7 pD3DDevDesc)
|
||||
#endif
|
||||
{
|
||||
HRESULT hr;
|
||||
int i;
|
||||
PixelBuffer *pbuf = _texture->_pbuffer;
|
||||
int cNumAlphaBits; // number of alpha bits in texture pixfmt
|
||||
|
||||
int i,cNumAlphaBits; // number of alpha bits in texture pixfmt
|
||||
DDPIXELFORMAT *pDesiredPixFmt;
|
||||
LPDIRECTDRAWSURFACE7 pddsRender;
|
||||
LPDIRECTDRAW7 pDD = NULL;
|
||||
|
||||
DDPIXELFORMAT TexFmtsArr[MAX_DX_TEXPIXFMTS];
|
||||
|
||||
ConversionType ConvNeeded;
|
||||
|
||||
assert(_texture!=NULL);
|
||||
|
||||
PixelBuffer *pbuf = _texture->_pbuffer;
|
||||
|
||||
#ifdef USE_TEXFMTVEC
|
||||
int cNumTexPixFmts=TexturePixelFormats.size();
|
||||
#endif
|
||||
DDPIXELFORMAT *pTexPixFmts = new DDPIXELFORMAT[cNumTexPixFmts];
|
||||
|
||||
// make local copy of array so I can muck with it during searches for this texture fmt
|
||||
memcpy(TexFmtsArr,pTexPixFmts,cNumTexPixFmts*sizeof(DDPIXELFORMAT));
|
||||
pTexPixFmts=TexFmtsArr;
|
||||
// (such as marking pixfmts that no search will be interested in)
|
||||
// probably should do this faster way
|
||||
|
||||
#ifdef USE_TEXFMTVEC
|
||||
memcpy(pTexPixFmts,&TexturePixelFormats[0],cNumTexPixFmts*sizeof(DDPIXELFORMAT));
|
||||
#else
|
||||
memcpy(pTexPixFmts,pTexFmts,cNumTexPixFmts*sizeof(DDPIXELFORMAT));
|
||||
#endif
|
||||
|
||||
// bpp indicates requested fmt, not pixbuf fmt
|
||||
DWORD bpp = get_bits_per_pixel(pbuf->get_format(), &cNumAlphaBits);
|
||||
@ -1006,12 +1020,10 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
DWORD dwOrigWidth = (DWORD)pbuf->get_xsize();
|
||||
DWORD dwOrigHeight = (DWORD)pbuf->get_ysize();
|
||||
|
||||
// Get the device caps so we can check if the device has any constraints
|
||||
// when using textures
|
||||
D3DDEVICEDESC7 devDesc;
|
||||
if(FAILED( pd3dDevice->GetCaps( &devDesc ) )) {
|
||||
goto error_exit;
|
||||
}
|
||||
// Use the device caps so we can check if the device has any constraints
|
||||
// when using textures.
|
||||
|
||||
assert((pD3DDevDesc->dwMaxTextureWidth>0) && (pD3DDevDesc->dwMaxTextureHeight>0));
|
||||
|
||||
// Setup the new surface desc for the texture. Note how we are using the
|
||||
// texture manage attribute, so Direct3D does alot of dirty work for us
|
||||
@ -1056,31 +1068,31 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
|
||||
if(!ISPOW2(ddsd.dwWidth) || !ISPOW2(ddsd.dwHeight)) {
|
||||
dxgsg_cat.error() << "ERROR: texture dimensions are not a power of 2 for " << _tex->get_name() << "!!!!! \n";
|
||||
#ifdef _DEBUG
|
||||
exit(1); // want to catch badtexsize errors
|
||||
#else
|
||||
goto error_exit;
|
||||
#endif
|
||||
#ifdef _DEBUG
|
||||
exit(1); // want to catch badtexsize errors
|
||||
#else
|
||||
goto error_exit;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool bShrinkOriginal;
|
||||
|
||||
bShrinkOriginal=false;
|
||||
if((dwOrigWidth>devDesc.dwMaxTextureWidth)||(dwOrigHeight>devDesc.dwMaxTextureHeight)) {
|
||||
#ifdef _DEBUG
|
||||
dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << devDesc.dwMaxTextureWidth << "," << devDesc.dwMaxTextureHeight << ") !!\n"
|
||||
<< "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< devDesc.dwMaxTextureWidth << "," << devDesc.dwMaxTextureHeight << ") !\n";
|
||||
#endif
|
||||
|
||||
if(dwOrigWidth>devDesc.dwMaxTextureWidth)
|
||||
ddsd.dwWidth=devDesc.dwMaxTextureWidth;
|
||||
if(dwOrigHeight>devDesc.dwMaxTextureHeight)
|
||||
ddsd.dwHeight=devDesc.dwMaxTextureHeight;
|
||||
if((dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)||(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)) {
|
||||
#ifdef _DEBUG
|
||||
dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
|
||||
<< "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !\n";
|
||||
#endif
|
||||
|
||||
if(dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)
|
||||
ddsd.dwWidth=pD3DDevDesc->dwMaxTextureWidth;
|
||||
if(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)
|
||||
ddsd.dwHeight=pD3DDevDesc->dwMaxTextureHeight;
|
||||
bShrinkOriginal=true;
|
||||
}
|
||||
|
||||
// checks for SQUARE reqmt (nvidia riva128 needs this)
|
||||
if((ddsd.dwWidth != ddsd.dwHeight) && (devDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )) {
|
||||
if((ddsd.dwWidth != ddsd.dwHeight) && (pD3DDevDesc->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )) {
|
||||
|
||||
// assume pow2 textures. sum exponents, divide by 2 rounding down to get sq size
|
||||
int i,width_exp,height_exp;
|
||||
@ -1130,7 +1142,8 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
|
||||
szErrorMsg = "CreateTexture failed: couldn't find compatible Tex DDPIXELFORMAT!\n";
|
||||
|
||||
dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
|
||||
if(dxgsg_cat.is_spam())
|
||||
dxgsg_cat.spam() << "CreateTexture handling bitdepth: " << bpp << " alphabits: " << cNumAlphaBits << "\n";
|
||||
|
||||
// Mark formats I dont want to deal with
|
||||
for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
|
||||
@ -1220,9 +1233,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
|
||||
assert(cNumAlphaBits==0); // dont know how to handle non-zero alpha for 24bit total
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(!dx_force_16bpptextures)
|
||||
#endif
|
||||
for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
|
||||
if((pCurPixFmt->dwFlags & DDPF_RGB)&&(pCurPixFmt->dwRGBBitCount==24)) {
|
||||
ConvNeeded=((cNumColorChannels==3) ? Conv24to24 : Conv32to24);
|
||||
@ -1230,13 +1241,10 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(!dx_force_16bpptextures)
|
||||
#endif
|
||||
|
||||
// no 24-bit fmt. look for 32 bit fmt (note: this is memory-hogging choice
|
||||
// instead I could look for memory-conserving 16-bit fmt).
|
||||
// check mask to ensure ARGB, not RGBA (which I am not handling here)
|
||||
if(!dx_force_16bpptextures) {
|
||||
// no 24-bit fmt. look for 32 bit fmt (note: this is memory-hogging choice
|
||||
// instead I could look for memory-conserving 16-bit fmt).
|
||||
// check mask to ensure ARGB, not RGBA (which I am not handling here)
|
||||
for(i=0,pCurPixFmt=pTexPixFmts;i<cNumTexPixFmts;i++,pCurPixFmt++) {
|
||||
if((pCurPixFmt->dwRGBBitCount==32) && (pCurPixFmt->dwFlags & DDPF_RGB)
|
||||
&& ((pCurPixFmt->dwRBitMask|pCurPixFmt->dwGBitMask|pCurPixFmt->dwBBitMask)==0xFFFFFF)
|
||||
@ -1246,6 +1254,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
goto found_matching_format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no 24-bit or 32 fmt. look for 16 bit fmt
|
||||
for(i=0,pCurPixFmt=&pTexPixFmts[cNumTexPixFmts-1];i<cNumTexPixFmts;i++,pCurPixFmt--) {
|
||||
@ -1271,11 +1280,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
|
||||
if(ddsd.ddpfPixelFormat.dwFlags & DDPF_LUMINANCE) {
|
||||
// look for native lum fmt
|
||||
#ifdef _DEBUG
|
||||
if(!dx_force_16bpptextures)
|
||||
#endif
|
||||
{
|
||||
|
||||
if(!dx_force_16bpptextures) {
|
||||
for(i=0,pCurPixFmt=&pTexPixFmts[cNumTexPixFmts-1];i<cNumTexPixFmts;i++,pCurPixFmt--) {
|
||||
if((pCurPixFmt->dwRGBBitCount==16) && (pCurPixFmt->dwFlags & DDPF_ALPHAPIXELS) &&
|
||||
(pCurPixFmt->dwFlags & DDPF_LUMINANCE)) {
|
||||
@ -1375,9 +1380,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
// look for native lum fmt
|
||||
|
||||
assert(cNumAlphaBits==0); // dont handle those other 8bit lum fmts like 4-4, since 16 8-8 is usually supported too
|
||||
#ifdef _DEBUG
|
||||
if(!dx_force_16bpptextures)
|
||||
#endif
|
||||
{
|
||||
for(i=0,pCurPixFmt=&pTexPixFmts[cNumTexPixFmts-1];i<cNumTexPixFmts;i++,pCurPixFmt--) {
|
||||
if((pCurPixFmt->dwRGBBitCount==8) && (pCurPixFmt->dwFlags & DDPF_LUMINANCE) &&
|
||||
@ -1404,15 +1407,16 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
}
|
||||
}
|
||||
|
||||
// find compatible 16bpp fmt, just look for any 565, then 0555
|
||||
// find compatible 16bpp fmt, just look for any 565, then 0555
|
||||
DWORD dwMasks[2] = {0xF800, 0x7C00};
|
||||
ConversionType ConvType[2] = {ConvLum8to16_0565,ConvLum8to16_0555};
|
||||
|
||||
for(DWORD modenum=0;modenum<2;modenum++)
|
||||
for(i=0,pCurPixFmt=&pTexPixFmts[0];i<cNumTexPixFmts;i++,pCurPixFmt++) {
|
||||
if((pCurPixFmt->dwRGBBitCount==16) && (pCurPixFmt->dwFlags & DDPF_RGB)
|
||||
&& (!(pCurPixFmt->dwFlags & DDPF_ALPHAPIXELS))
|
||||
&& (pCurPixFmt->dwRBitMask==dwMasks[modenum])) {
|
||||
ConvNeeded=ConvLum8to16_0565;
|
||||
ConvNeeded=ConvType[modenum];
|
||||
goto found_matching_format;
|
||||
}
|
||||
}
|
||||
@ -1481,7 +1485,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
else ft=Texture::FT_linear;
|
||||
}
|
||||
|
||||
if((ft==Texture::FT_linear) && !(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
||||
if((ft==Texture::FT_linear) && !(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
||||
ft=Texture::FT_nearest;
|
||||
_tex->set_magfilter(ft);
|
||||
|
||||
@ -1514,26 +1518,26 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
ft=Texture::FT_linear;
|
||||
}
|
||||
|
||||
assert((devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_NEAREST)!=0);
|
||||
assert((pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_NEAREST)!=0);
|
||||
|
||||
switch(ft) {
|
||||
case Texture::FT_nearest_mipmap_linear:
|
||||
if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPNEAREST))
|
||||
if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPNEAREST))
|
||||
ft=Texture::FT_nearest_mipmap_nearest;
|
||||
break;
|
||||
case Texture::FT_linear_mipmap_nearest:
|
||||
if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR))
|
||||
if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR))
|
||||
ft=Texture::FT_nearest_mipmap_nearest;
|
||||
break;
|
||||
case Texture::FT_linear_mipmap_linear:
|
||||
if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPLINEAR)) {
|
||||
if(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR)
|
||||
if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPLINEAR)) {
|
||||
if(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR)
|
||||
ft=Texture::FT_linear_mipmap_nearest;
|
||||
else ft=Texture::FT_nearest_mipmap_nearest; // if you cant do linear in a level, you probably cant do linear b/w levels, so just do nearest-all
|
||||
}
|
||||
break;
|
||||
case Texture::FT_linear:
|
||||
if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
||||
if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
||||
ft=Texture::FT_nearest;
|
||||
break;
|
||||
}
|
||||
@ -1543,14 +1547,14 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
uint aniso_degree;
|
||||
|
||||
aniso_degree=1;
|
||||
if(devDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANISOTROPY) {
|
||||
if(pD3DDevDesc->dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANISOTROPY) {
|
||||
aniso_degree=_tex->get_anisotropic_degree();
|
||||
if((aniso_degree>devDesc.dwMaxAnisotropy)
|
||||
if((aniso_degree>pD3DDevDesc->dwMaxAnisotropy)
|
||||
#ifdef _DEBUG
|
||||
|| dx_force_anisotropic_filtering
|
||||
#endif
|
||||
)
|
||||
aniso_degree=devDesc.dwMaxAnisotropy;
|
||||
aniso_degree=pD3DDevDesc->dwMaxAnisotropy;
|
||||
}
|
||||
_tex->set_anisotropic_degree(aniso_degree);
|
||||
#ifdef _DEBUG
|
||||
@ -1564,7 +1568,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
|
||||
}
|
||||
|
||||
if(devDesc.dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
|
||||
if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
|
||||
// must assign a texture to a specific stage
|
||||
// for now I'm just going to use stage 0 for all
|
||||
ddsd.dwTextureStage=0;
|
||||
@ -1594,6 +1598,8 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
// Done with DDraw
|
||||
pDD->Release();
|
||||
|
||||
delete [] pTexPixFmts;
|
||||
|
||||
// Return the newly created texture
|
||||
return _surface;
|
||||
|
||||
@ -1606,6 +1612,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
||||
_surface = NULL;
|
||||
}
|
||||
|
||||
delete [] pTexPixFmts;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DXTEXTURECONTEXT8_H
|
||||
#define DXTEXTURECONTEXT8_H
|
||||
#ifndef DXTEXTURECONTEXT_H
|
||||
#define DXTEXTURECONTEXT_H
|
||||
|
||||
#include <pandabase.h>
|
||||
|
||||
@ -32,13 +32,23 @@
|
||||
#include <ddraw.h>
|
||||
|
||||
#define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h
|
||||
#include <d3d.h>
|
||||
#include <d3d8.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#ifndef D3DERRORSTRING
|
||||
#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
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DXTextureContext
|
||||
@ -55,7 +65,13 @@ public:
|
||||
LPDIRECTDRAWSURFACE7 _surface;
|
||||
Texture *_tex; // ptr to parent, primarily for access to namestr
|
||||
|
||||
LPDIRECTDRAWSURFACE7 CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts);
|
||||
// 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
|
||||
|
||||
bool _bHasMipMaps;
|
||||
DWORD _PixBufConversionType; // enum ConversionType
|
||||
@ -85,5 +101,6 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,15 +6,24 @@
|
||||
|
||||
#if $[BUILD_DX8]
|
||||
#begin lib_target
|
||||
#define TARGET wdxdisplay8
|
||||
#define LOCAL_LIBS dxgsg8
|
||||
#define TARGET wdxdisplay
|
||||
#define LOCAL_LIBS \
|
||||
dxgsg
|
||||
|
||||
#define COMBINED_SOURCES $[TARGET]_composite1.cxx
|
||||
|
||||
#define SOURCES \
|
||||
config_wdxdisplay8.h wdxGraphicsPipe8.h wdxGraphicsWindow8.cxx wdxGraphicsWindow8.h
|
||||
// need to install these due to external projects that link directly with libpandadx (bartop)
|
||||
#define INSTALL_HEADERS \
|
||||
config_wdxdisplay8.h wdxGraphicsPipe8.h wdxGraphicsWindow8.h
|
||||
|
||||
#define INCLUDED_SOURCES config_wdxdisplay8.cxx wdxGraphicsPipe8.cxx
|
||||
#define INCLUDED_SOURCES \
|
||||
config_wdxdisplay8.cxx wdxGraphicsPipe8.cxx
|
||||
|
||||
// note SOURCES shoult NOT include INCLUDED_SOURCES, that would cause a double build
|
||||
// SOURCES should be headers and separately-built cxx files
|
||||
// build wdxGraphicsWindow.cxx separately since its big
|
||||
|
||||
#define SOURCES wdxGraphicsWindow8.cxx $[INSTALL_HEADERS]
|
||||
|
||||
#end lib_target
|
||||
#endif
|
||||
|
@ -31,6 +31,8 @@ ConfigureFn(config_wdxdisplay) {
|
||||
|
||||
bool dx_force_16bpp_zbuffer = config_wdxdisplay.GetBool("dx-force-16bpp-zbuffer", false);
|
||||
bool bResponsive_minimized_fullscreen_window = config_wdxdisplay.GetBool("responsive-minimized-fullscreen-window",false);
|
||||
bool dx_preserve_fpu_state = config_wdxdisplay.GetBool("dx-preserve-fpu-state", false);
|
||||
int dx_preferred_deviceID = config_wdxdisplay.GetInt("dx-preferred-deviceID", -1);
|
||||
|
||||
extern void AtExitFn(void);
|
||||
|
||||
|
@ -27,6 +27,8 @@ NotifyCategoryDecl(wdxdisplay, EXPCL_PANDADX, EXPTP_PANDADX);
|
||||
|
||||
extern bool bResponsive_minimized_fullscreen_window;
|
||||
extern bool dx_force_16bpp_zbuffer;
|
||||
extern bool dx_preserve_fpu_state;
|
||||
extern int dx_preferred_deviceID;
|
||||
extern Filename get_icon_filename();
|
||||
extern Filename get_mono_cursor_filename();
|
||||
extern Filename get_color_cursor_filename();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,7 +37,6 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Defines
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class Xclass;
|
||||
|
||||
extern char * ConvD3DErrorToString(const HRESULT &error);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,9 @@
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef WDXGRAPHICSWINDOW8_H
|
||||
#define WDXGRAPHICSWINDOW8_H
|
||||
//#define WBD_GL_MODE 1 // if setting this, do it in dxGraphicsStateGuardian.h too
|
||||
#ifndef WDXGRAPHICSWINDOW_H
|
||||
#define WDXGRAPHICSWINDOW_H
|
||||
//#define WBD_GL_MODE 1 // if setting this, do it in wdxGraphicsStateGuardian.h too
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Includes
|
||||
@ -28,15 +28,30 @@
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WINDOWS_LEAN_AND_MEAN
|
||||
#include <d3d.h>
|
||||
#include <d3d8.h>
|
||||
#include <dxerr8.h>
|
||||
|
||||
#include "dxGraphicsStateGuardian8.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Defines
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class wdxGraphicsPipe;
|
||||
class wdxGraphicsWindowGroup;
|
||||
|
||||
const int WDXWIN_CONFIGURE = 4;
|
||||
const int WDXWIN_EVENT = 8;
|
||||
const int WDXWIN_CONFIGURE = 4;
|
||||
const int WDXWIN_EVENT = 8;
|
||||
|
||||
typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter);
|
||||
|
||||
typedef struct {
|
||||
UINT cardID;
|
||||
char szDriver[MAX_DDDEVICEID_STRING];
|
||||
char szDescription[MAX_DDDEVICEID_STRING];
|
||||
GUID guidDeviceIdentifier;
|
||||
HMONITOR hMon;
|
||||
} DXDeviceInfo;
|
||||
typedef vector<DXDeviceInfo> DXDeviceInfoVec;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : wdxGraphicsWindow
|
||||
@ -45,31 +60,29 @@ const int WDXWIN_EVENT = 8;
|
||||
class EXPCL_PANDADX wdxGraphicsWindow : public GraphicsWindow {
|
||||
friend class DXGraphicsStateGuardian;
|
||||
friend class DXTextureContext;
|
||||
friend class wdxGraphicsWindowGroup;
|
||||
|
||||
public:
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe);
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe,
|
||||
const GraphicsWindow::Properties& props);
|
||||
virtual ~wdxGraphicsWindow(void);
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe,const GraphicsWindow::Properties& props);
|
||||
|
||||
// this constructor will not initialize the wdx stuff, only the panda graphicswindow stuff
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe,const GraphicsWindow::Properties& props,wdxGraphicsWindowGroup *pParentGroup);
|
||||
|
||||
virtual ~wdxGraphicsWindow(void);
|
||||
virtual bool supports_update() const;
|
||||
virtual void update(void);
|
||||
virtual void end_frame( void );
|
||||
|
||||
virtual TypeHandle get_gsg_type() const;
|
||||
static GraphicsWindow* make_wdxGraphicsWindow(const FactoryParams ¶ms);
|
||||
void CreateScreenBuffersAndDevice(DWORD dwRenderWidth, DWORD dwRenderHeight,
|
||||
LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI,
|
||||
D3DDEVICEDESC7 *pD3DDevDesc);
|
||||
|
||||
LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
void process_events(void);
|
||||
|
||||
INLINE bool mouse_entry_enabled(void) { return _mouse_entry_enabled; }
|
||||
INLINE bool mouse_motion_enabled(void) { return _mouse_motion_enabled; }
|
||||
INLINE bool mouse_passive_motion_enabled(void) {
|
||||
return _mouse_passive_motion_enabled;
|
||||
}
|
||||
INLINE bool mouse_passive_motion_enabled(void) { return _mouse_passive_motion_enabled; }
|
||||
void handle_window_move( int x, int y );
|
||||
void handle_mouse_motion( int x, int y );
|
||||
void handle_mouse_entry( int state, HCURSOR hMouseCursor );
|
||||
@ -78,8 +91,6 @@ public:
|
||||
void dx_setup();
|
||||
virtual void begin_frame( void );
|
||||
void show_frame();
|
||||
DXGraphicsStateGuardian *_dxgsg;
|
||||
|
||||
virtual void resize(unsigned int xsize,unsigned int ysize);
|
||||
virtual unsigned int verify_window_sizes(unsigned int numsizes,unsigned int *dimen);
|
||||
virtual int get_depth_bitwidth(void);
|
||||
@ -87,30 +98,30 @@ public:
|
||||
protected:
|
||||
void CreateScreenBuffersAndDevice(LPDIRECTDRAW7 pDD,LPDIRECT3D7 pD3DI);
|
||||
ButtonHandle lookup_key(WPARAM wparam) const;
|
||||
virtual void config( void );
|
||||
// virtual void config(void);
|
||||
void config_single_window(void);
|
||||
void config_window(wdxGraphicsWindowGroup *pParentGroup);
|
||||
void finish_window_setup(void);
|
||||
bool search_for_device(LPDIRECT3D8 pD3D8,DXDeviceInfo *pDevinfo);
|
||||
void setup_colormap(void);
|
||||
|
||||
void enable_mouse_input(bool val);
|
||||
void enable_mouse_motion(bool val);
|
||||
void enable_mouse_passive_motion(bool val);
|
||||
void enable_mouse_entry(bool val);
|
||||
void check_for_color_cursor_support(void);
|
||||
DDDEVICEIDENTIFIER2 _DXDeviceID;
|
||||
|
||||
public:
|
||||
HWND _mwindow;
|
||||
HWND _hOldForegroundWindow;
|
||||
UINT_PTR _PandaPausedTimer;
|
||||
UINT_PTR _PandaPausedTimer;
|
||||
DXGraphicsStateGuardian *_dxgsg;
|
||||
void CreateScreenBuffersAndDevice(DXScreenData &Display);
|
||||
|
||||
private:
|
||||
wdxGraphicsWindowGroup *_pParentWindowGroup;
|
||||
HDC _hdc;
|
||||
HPALETTE _colormap;
|
||||
typedef enum { NotAdjusting,MovingOrResizing,Resizing } WindowAdjustType;
|
||||
WindowAdjustType _WindowAdjustingType;
|
||||
bool _bIsLowVidMemCard;
|
||||
bool _bLoadedCustomCursor;
|
||||
HCURSOR _hMouseCursor;
|
||||
bool _bSizeIsMaximized;
|
||||
WindowAdjustType _WindowAdjustingType;
|
||||
bool _bSizeIsMaximized;
|
||||
bool _mouse_input_enabled;
|
||||
bool _mouse_motion_enabled;
|
||||
bool _mouse_passive_motion_enabled;
|
||||
@ -137,6 +148,42 @@ private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
// this class really belongs in panda, not here
|
||||
class EXPCL_PANDADX wdxGraphicsWindowGroup {
|
||||
// group of windows are all created at the same time
|
||||
friend class wdxGraphicsWindow;
|
||||
|
||||
PUBLISHED:
|
||||
wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&);
|
||||
wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&,const GraphicsWindow::Properties&);
|
||||
wdxGraphicsWindowGroup(GraphicsPipe *,const GraphicsWindow::Properties&,const GraphicsWindow::Properties&,
|
||||
const GraphicsWindow::Properties&);
|
||||
public:
|
||||
wdxGraphicsWindowGroup(wdxGraphicsWindow *OneWindow);
|
||||
// dont publish variable length one, since FFI wont support it
|
||||
wdxGraphicsWindowGroup(GraphicsPipe *pipe,int num_windows,GraphicsWindow::Properties *WinPropArray);
|
||||
~wdxGraphicsWindowGroup();
|
||||
void SetCoopLevelsAndDisplayModes(void);
|
||||
public:
|
||||
void CreateWindows(void);
|
||||
void make_windows(GraphicsPipe *,int num_windows,GraphicsWindow::Properties *pWinPropArray);
|
||||
void initWindowGroup(void);
|
||||
|
||||
pvector<wdxGraphicsWindow *> _windows;
|
||||
DXDeviceInfoVec *_pDeviceInfoVec; // only used during init to store valid devices
|
||||
HWND _hParentWindow;
|
||||
HWND _hOldForegroundWindow;
|
||||
HCURSOR _hMouseCursor;
|
||||
bool _bLoadedCustomCursor;
|
||||
bool _bClosingAllWindows;
|
||||
bool _bIsDX81;
|
||||
UINT _numMonitors,_numAdapters;
|
||||
LPDIRECT3D8 _pD3D8;
|
||||
HINSTANCE _hDDrawDLL,_hD3D8_DLL;
|
||||
LPDIRECTDRAWCREATEEX _pDDCreateEx;
|
||||
DXDeviceInfoVec _DeviceInfoVec;
|
||||
};
|
||||
|
||||
extern void set_global_parameters(void);
|
||||
extern void restore_global_parameters(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user