mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
show_frame shouldnt flip if no valid backbuf
This commit is contained in:
parent
38db3b62d2
commit
c1db2dc152
@ -782,7 +782,8 @@ dx_init(HCURSOR hMouseCursor) {
|
||||
init_lights(DXGSG_MAX_LIGHTS);
|
||||
} else {
|
||||
init_lights(min(DXGSG_MAX_LIGHTS,scrn.d3dcaps.MaxActiveLights));
|
||||
} */
|
||||
}
|
||||
*/
|
||||
|
||||
if(dx_auto_normalize_lighting)
|
||||
scrn.pD3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, true);
|
||||
@ -3998,8 +3999,6 @@ begin_frame() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::
|
||||
end_frame() {
|
||||
GraphicsStateGuardian::end_frame();
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
if(_bShowFPSMeter) {
|
||||
@ -4122,6 +4121,8 @@ end_frame() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GraphicsStateGuardian::end_frame();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -4699,15 +4700,36 @@ HRESULT DXGraphicsStateGuardian::ReleaseAllDeviceObjects(void) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: show_frame
|
||||
// Access:
|
||||
// Description: Repaint primary buffer from back buffer
|
||||
// Description: redraw primary buffer
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void DXGraphicsStateGuardian::show_frame(void) {
|
||||
void DXGraphicsStateGuardian::show_frame(bool bNoNewFrameDrawn) {
|
||||
if(scrn.pD3DDevice==NULL)
|
||||
return;
|
||||
|
||||
DO_PSTATS_STUFF(PStatTimer timer(_win->_swap_pcollector)); // this times just the flip, so it must go here in dxgsg, instead of wdxdisplay, which would time the whole frame
|
||||
HRESULT hr;
|
||||
|
||||
if(bNoNewFrameDrawn) {
|
||||
// a new frame has not been rendered, we just want to display the last thing
|
||||
// that was drawn into backbuf, if backbuf is valid
|
||||
if(scrn.PresParams.SwapEffect==D3DSWAPEFFECT_DISCARD) {
|
||||
// in DISCARD mode, old backbufs are not guaranteed to have valid pixels,
|
||||
// so we cant copy back->front here. just give up.
|
||||
return;
|
||||
} else if(scrn.PresParams.SwapEffect==D3DSWAPEFFECT_FLIP) {
|
||||
/* bugbug: here we should use CopyRects here to copy backbuf to front (except in
|
||||
the case of frames 1 and 2 where we have no valid data in the backbuffer yet,
|
||||
for those cases give up and return).
|
||||
not implemented yet since right now we always do discard mode for fullscrn Present()
|
||||
for speed.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise we have D3DSWAPEFFECT_COPY, so fall-thru to normal Present()
|
||||
// may work ok as long as backbuf hasnt been touched
|
||||
}
|
||||
|
||||
hr = scrn.pD3DDevice->Present((CONST RECT*)NULL,(CONST RECT*)NULL,(HWND)NULL,NULL);
|
||||
if(FAILED(hr)) {
|
||||
if(hr == D3DERR_DEVICELOST) {
|
||||
|
@ -352,7 +352,7 @@ public:
|
||||
#define DO_REACTIVATE_WINDOW true
|
||||
bool CheckCooperativeLevel(bool bDoReactivateWindow = false);
|
||||
|
||||
void show_frame();
|
||||
void show_frame(bool bNoNewFrameDrawn = false);
|
||||
void dx_init(HCURSOR hMouseCursor);
|
||||
|
||||
void support_overlay_window(bool flag);
|
||||
|
@ -318,7 +318,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
|
||||
PAINTSTRUCT ps;
|
||||
BeginPaint(hwnd, &ps);
|
||||
show_frame();
|
||||
if(DX_IS_READY) {
|
||||
_dxgsg->show_frame(true); // 'true' since just want to show the last rendered backbuf, if any
|
||||
}
|
||||
EndPaint(hwnd, &ps);
|
||||
return 0;
|
||||
}
|
||||
@ -1446,7 +1448,29 @@ void wdxGraphicsWindow::config_window(wdxGraphicsWindowGroup *pParentGroup) {
|
||||
// on both OS's. After we verify that truth of the above claim, we
|
||||
// should base this decision on GetVersionEx() or maybe
|
||||
// VerifyVersionInfo().
|
||||
|
||||
_ime_composition_w = ime_composition_w;
|
||||
|
||||
// need to re-evaluate above in light of this, it seems that
|
||||
// ImmGetCompositionStringW should work on both:
|
||||
// The Input Method Editor and Unicode Windows 98/Me, Windows
|
||||
// NT/2000/XP: Windows supports a Unicode interface for the
|
||||
// IME, in addition to the ANSI interface originally supported.
|
||||
// Windows 98/Me supports all the Unicode functions except
|
||||
// ImmIsUIMessage. Also, all the messages in Windows 98/Me are
|
||||
// ANSI based. Since Windows 98/Me does not support Unicode
|
||||
// messages, applications can use ImmGetCompositionString to
|
||||
// receive Unicode characters from a Unicode based IME on
|
||||
// Windows 98/Me. There are two issues involved with Unicode
|
||||
// handling and the IME. One is that the Unicode versions of
|
||||
// IME routines return the size of a buffer in bytes rather
|
||||
// than 16-bit Unicode characters,and the other is the IME
|
||||
// normally returns Unicode characters (rather than DBCS) in
|
||||
// the WM_CHAR and WM_IME_CHAR messages. Use RegisterClassW
|
||||
// to cause the WM_CHAR and WM_IME_CHAR messages to return
|
||||
// Unicode characters in the wParam parameter rather than DBCS
|
||||
// characters. This is only available under Windows NT; it is
|
||||
// stubbed out in Windows 95/98/Me.
|
||||
}
|
||||
|
||||
void wdxGraphicsWindow::finish_window_setup(void) {
|
||||
@ -1464,55 +1488,6 @@ void wdxGraphicsWindow::finish_window_setup(void) {
|
||||
// UpdateWindow( _mwindow );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
HRESULT CALLBACK EnumDevicesCallback(LPSTR pDeviceDescription, LPSTR pDeviceName,
|
||||
LPD3DDEVICEDESC7 pD3DDeviceDesc,LPVOID pContext) {
|
||||
D3DDEVICEDESC7 *pd3ddevs = (D3DDEVICEDESC7 *)pContext;
|
||||
#ifdef _DEBUG
|
||||
wdxdisplay_cat.spam() << "Enumerating Device " << pDeviceName << " : " << pDeviceDescription << endl;
|
||||
#endif
|
||||
|
||||
#define REGHALIDX 0
|
||||
#define TNLHALIDX 1
|
||||
|
||||
// only saves hal and tnl devs, not sw rasts
|
||||
|
||||
if(IsEqualGUID(pD3DDeviceDesc->deviceGUID,IID_IDirect3DHALDevice)) {
|
||||
CopyMemory(&pd3ddevs[REGHALIDX],pD3DDeviceDesc,sizeof(D3DDEVICEDESC7));
|
||||
} else if(IsEqualGUID(pD3DDeviceDesc->deviceGUID,IID_IDirect3DTnLHalDevice)) {
|
||||
CopyMemory(&pd3ddevs[TNLHALIDX],pD3DDeviceDesc,sizeof(D3DDEVICEDESC7));
|
||||
}
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
#define MAX_DISPLAY_MODES 100 // probably dont need this much, since i already screen for width&hgt
|
||||
typedef struct {
|
||||
DWORD maxWidth,maxHeight;
|
||||
DWORD supportedBitDepths; // uses DDBD_* flags
|
||||
LPDDSURFACEDESC2 pDDSD_Arr;
|
||||
DWORD cNumSurfDescs;
|
||||
} DisplayModeInfo;
|
||||
|
||||
HRESULT WINAPI EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
||||
DisplayModeInfo *pDMI = (DisplayModeInfo *) lpContext;
|
||||
|
||||
// ddsd_search should assure this is true
|
||||
assert((lpDDSurfaceDesc->dwWidth == pDMI->maxWidth) && (lpDDSurfaceDesc->dwHeight == pDMI->maxHeight));
|
||||
|
||||
// ignore refresh rates under 60Hz (and special values of 0 & 1)
|
||||
if((lpDDSurfaceDesc->dwRefreshRate>1) && (lpDDSurfaceDesc->dwRefreshRate<60))
|
||||
return DDENUMRET_OK;
|
||||
|
||||
assert(pDMI->cNumSurfDescs < MAX_DISPLAY_MODES);
|
||||
memcpy(&(pDMI->pDDSD_Arr[pDMI->cNumSurfDescs]), lpDDSurfaceDesc, sizeof(DDSURFACEDESC2) );
|
||||
pDMI->cNumSurfDescs++;
|
||||
pDMI->supportedBitDepths |= BitDepth_2_DDBDMask(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
|
||||
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
// this handles external programmatic requests for resizing (usually fullscrn resize)
|
||||
bool wdxGraphicsWindow::resize(unsigned int xsize,unsigned int ysize) {
|
||||
bool bResizeSucceeded=false;
|
||||
@ -2459,6 +2434,8 @@ CreateScreenBuffersAndDevice(DXScreenData &Display) {
|
||||
assert(pPresParams->SwapEffect == D3DSWAPEFFECT_DISCARD); // only valid effect for multisample
|
||||
#endif
|
||||
|
||||
ClearToBlack(GetDesktopWindow(),_props);
|
||||
|
||||
hr = pD3D8->CreateDevice(Display.CardIDNum, D3DDEVTYPE_HAL, _pParentWindowGroup->_hParentWindow,
|
||||
dwBehaviorFlags, pPresParams, &Display.pD3DDevice);
|
||||
|
||||
@ -2705,6 +2682,7 @@ void wdxGraphicsWindow::setup_colormap(void) {
|
||||
RealizePalette(_hdc);
|
||||
}
|
||||
|
||||
/* dont need to override the defaults (which just go to gsg->begin_frame())
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: begin_frame
|
||||
// Access:
|
||||
@ -2713,10 +2691,6 @@ void wdxGraphicsWindow::begin_frame(void) {
|
||||
GraphicsWindow::begin_frame();
|
||||
}
|
||||
|
||||
void wdxGraphicsWindow::show_frame(void) {
|
||||
_dxgsg->show_frame();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: end_frame
|
||||
// Access:
|
||||
@ -2725,6 +2699,7 @@ void wdxGraphicsWindow::show_frame(void) {
|
||||
void wdxGraphicsWindow::end_frame(void) {
|
||||
GraphicsWindow::end_frame();
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: handle_window_move
|
||||
@ -3057,6 +3032,7 @@ void wdxGraphicsWindowGroup::initWindowGroup(void) {
|
||||
UINT num_windows=_windows.size();
|
||||
|
||||
#define D3D8_NAME "d3d8.dll"
|
||||
#define D3DCREATE8 "Direct3DCreate8"
|
||||
|
||||
_hD3D8_DLL = LoadLibrary(D3D8_NAME);
|
||||
if(_hD3D8_DLL == 0) {
|
||||
@ -3080,8 +3056,8 @@ void wdxGraphicsWindowGroup::initWindowGroup(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// Do all DX7 stuff first
|
||||
// find_all_card_memavails();
|
||||
// Do all DX7 stuff first
|
||||
// find_all_card_memavails();
|
||||
|
||||
LPDIRECT3D8 pD3D8;
|
||||
|
||||
@ -3089,10 +3065,10 @@ void wdxGraphicsWindowGroup::initWindowGroup(void) {
|
||||
|
||||
// dont want to statically link to possibly non-existent d3d8 dll, so must call D3DCr8 indirectly
|
||||
Direct3DCreate8_ProcPtr D3DCreate8_Ptr =
|
||||
(Direct3DCreate8_ProcPtr) GetProcAddress(_hD3D8_DLL, "Direct3DCreate8" );
|
||||
(Direct3DCreate8_ProcPtr) GetProcAddress(_hD3D8_DLL, D3DCREATE8);
|
||||
|
||||
if(D3DCreate8_Ptr == NULL) {
|
||||
wdxdisplay_cat.fatal() << "GetProcAddress for D3DCreate8 failed!" << endl;
|
||||
wdxdisplay_cat.fatal() << "GetProcAddress for "<< D3DCREATE8 << "failed!" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -3117,7 +3093,7 @@ void wdxGraphicsWindowGroup::initWindowGroup(void) {
|
||||
}
|
||||
|
||||
if(pD3D8==NULL) {
|
||||
wdxdisplay_cat.fatal() << "Direct3DCreate8 failed!\n";
|
||||
wdxdisplay_cat.fatal() << D3DCREATE8 << " failed!\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,8 @@ class wdxGraphicsWindowGroup;
|
||||
const int WDXWIN_CONFIGURE = 4;
|
||||
const int WDXWIN_EVENT = 8;
|
||||
|
||||
//#define FIND_CARD_MEMAVAILS
|
||||
|
||||
typedef HRESULT (WINAPI * LPDIRECTDRAWCREATEEX)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter);
|
||||
|
||||
typedef struct {
|
||||
@ -54,6 +56,7 @@ class EXPCL_PANDADX wdxGraphicsWindow : public GraphicsWindow {
|
||||
friend class DXGraphicsStateGuardian;
|
||||
friend class DXTextureContext;
|
||||
friend class wdxGraphicsWindowGroup;
|
||||
friend class DInput8Info;
|
||||
|
||||
public:
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe);
|
||||
@ -63,7 +66,6 @@ public:
|
||||
wdxGraphicsWindow(GraphicsPipe* pipe,const GraphicsWindow::Properties& props,wdxGraphicsWindowGroup *pParentGroup);
|
||||
|
||||
virtual ~wdxGraphicsWindow(void);
|
||||
virtual void end_frame( void );
|
||||
|
||||
virtual TypeHandle get_gsg_type() const;
|
||||
static GraphicsWindow* make_wdxGraphicsWindow(const FactoryParams ¶ms);
|
||||
@ -76,11 +78,14 @@ public:
|
||||
void handle_window_move( int x, int y );
|
||||
void handle_mouse_motion( int x, int y );
|
||||
void handle_mouse_exit(void);
|
||||
void handle_keypress( ButtonHandle key, int x, int y );
|
||||
void handle_keyrelease( ButtonHandle key);
|
||||
void handle_keypress(ButtonHandle key, int x, int y );
|
||||
void handle_keyrelease(ButtonHandle key);
|
||||
void dx_setup();
|
||||
virtual void begin_frame( void );
|
||||
void show_frame();
|
||||
|
||||
// dont need to override these now?
|
||||
// virtual void begin_frame( void );
|
||||
// virtual void end_frame( void );
|
||||
|
||||
virtual bool 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);
|
||||
@ -175,6 +180,7 @@ public:
|
||||
DWORD _numMonitors,_numAdapters;
|
||||
LPDIRECT3D8 _pD3D8;
|
||||
HINSTANCE _hD3D8_DLL;
|
||||
DInput8Info *_pDInputInfo;
|
||||
DXDeviceInfoVec _DeviceInfoVec;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user