summaryrefslogtreecommitdiffstats
path: root/src/old/d3dframe.h
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-22 15:54:16 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-22 15:54:16 +0200
commit4531ac88d3c022866d564be40c20593de4c70bfc (patch)
tree63bd1feff134c95001a1b10495882debfcdf54e3 /src/old/d3dframe.h
parent11df0ebf94e0842566bdc8d627ab50cc5309605d (diff)
downloadcolobot-4531ac88d3c022866d564be40c20593de4c70bfc.tar.gz
colobot-4531ac88d3c022866d564be40c20593de4c70bfc.tar.bz2
colobot-4531ac88d3c022866d564be40c20593de4c70bfc.zip
Moved old implementations to src/old
Diffstat (limited to 'src/old/d3dframe.h')
-rw-r--r--src/old/d3dframe.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/src/old/d3dframe.h b/src/old/d3dframe.h
new file mode 100644
index 0000000..1c02e04
--- /dev/null
+++ b/src/old/d3dframe.h
@@ -0,0 +1,141 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+//-----------------------------------------------------------------------------
+// File: D3DFrame.h
+//
+// Desc: Class to manage the Direct3D environment objects such as buffers,
+// viewports, and 3D devices.
+//
+// The class is initialized with the Initialize() function, after which
+// the Get????() functions can be used to access the objects needed for
+// rendering. If the device or display needs to be changed, the
+// ChangeDevice() function can be called. If the display window is moved
+// the changes need to be reported with the Move() function.
+//
+// After rendering a frame, the ShowFrame() function filps or blits the
+// backbuffer contents to the primary. If surfaces are lost, they can be
+// restored with the RestoreSurfaces() function. Finally, if normal
+// Windows output is needed, the FlipToGDISurface() provides a GDI
+// surface to draw on.
+//
+// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
+//-----------------------------------------------------------------------------
+
+#pragma once
+
+#include <ddraw.h>
+#include <d3d.h>
+
+
+
+
+//-----------------------------------------------------------------------------
+// Name: CD3DFramework7
+// Desc: The Direct3D sample framework class for DX7. Maintains the D3D
+// surfaces and device used for 3D rendering.
+//-----------------------------------------------------------------------------
+class CD3DFramework7
+{
+ // Internal variables for the framework class
+ HWND m_hWnd; // The window object
+ bool m_bIsFullscreen; // Fullscreen vs. windowed
+ bool m_bIsStereo; // Stereo view mode
+ DWORD m_dwRenderWidth; // Dimensions of the render target
+ DWORD m_dwRenderHeight;
+ RECT m_rcScreenRect; // Screen rect for window
+ LPDIRECTDRAW7 m_pDD; // The DirectDraw object
+ LPDIRECT3D7 m_pD3D; // The Direct3D object
+ LPDIRECT3DDEVICE7 m_pd3dDevice; // The D3D device
+ LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer; // The primary surface
+ LPDIRECTDRAWSURFACE7 m_pddsBackBuffer; // The backbuffer surface
+ LPDIRECTDRAWSURFACE7 m_pddsBackBufferLeft; // For stereo modes
+ LPDIRECTDRAWSURFACE7 m_pddsZBuffer; // The zbuffer surface
+ DWORD m_dwDeviceMemType;
+
+ // Internal functions for the framework class
+ HRESULT CreateZBuffer( GUID* );
+ HRESULT CreateFullscreenBuffers( DDSURFACEDESC2* );
+ HRESULT CreateWindowedBuffers();
+ HRESULT CreateDirectDraw( GUID*, DWORD );
+ HRESULT CreateDirect3D( GUID* );
+ HRESULT CreateEnvironment( GUID*, GUID*, DDSURFACEDESC2*, DWORD );
+
+public:
+ // Access functions for DirectX objects
+ LPDIRECTDRAW7 GetDirectDraw() { return m_pDD; }
+ LPDIRECT3D7 GetDirect3D() { return m_pD3D; }
+ LPDIRECT3DDEVICE7 GetD3DDevice() { return m_pd3dDevice; }
+ LPDIRECTDRAWSURFACE7 GetFrontBuffer() { return m_pddsFrontBuffer; }
+ LPDIRECTDRAWSURFACE7 GetBackBuffer() { return m_pddsBackBuffer; }
+ LPDIRECTDRAWSURFACE7 GetRenderSurface() { return m_pddsBackBuffer; }
+ LPDIRECTDRAWSURFACE7 GetRenderSurfaceLeft() { return m_pddsBackBufferLeft; }
+
+ // Functions to aid rendering
+ HRESULT RestoreSurfaces();
+ HRESULT ShowFrame();
+ HRESULT FlipToGDISurface( bool bDrawFrame = false );
+
+ // Functions for managing screen and viewport bounds
+ bool IsFullscreen() { return m_bIsFullscreen; }
+ bool IsStereo() { return m_bIsStereo; }
+ VOID Move( INT x, INT y );
+
+ // Creates the Framework
+ HRESULT Initialize( HWND hWnd, GUID* pDriverGUID, GUID* pDeviceGUID,
+ DDSURFACEDESC2* pddsd, DWORD dwFlags );
+ HRESULT DestroyObjects();
+
+ CD3DFramework7();
+ ~CD3DFramework7();
+};
+
+
+
+
+//-----------------------------------------------------------------------------
+// Flags used for the Initialize() method of a CD3DFramework object
+//-----------------------------------------------------------------------------
+#define D3DFW_FULLSCREEN 0x00000001 // Use fullscreen mode
+#define D3DFW_STEREO 0x00000002 // Use stereo-scopic viewing
+#define D3DFW_ZBUFFER 0x00000004 // Create and use a zbuffer
+#define D3DFW_NO_FPUSETUP 0x00000008 // Don't use default DDSCL_FPUSETUP flag
+
+
+
+
+//-----------------------------------------------------------------------------
+// Errors that the Initialize() and ChangeDriver() calls may return
+//-----------------------------------------------------------------------------
+#define D3DFWERR_INITIALIZATIONFAILED 0x82000000
+#define D3DFWERR_NODIRECTDRAW 0x82000001
+#define D3DFWERR_COULDNTSETCOOPLEVEL 0x82000002
+#define D3DFWERR_NODIRECT3D 0x82000003
+#define D3DFWERR_NO3DDEVICE 0x82000004
+#define D3DFWERR_NOZBUFFER 0x82000005
+#define D3DFWERR_INVALIDZBUFFERDEPTH 0x82000006
+#define D3DFWERR_NOVIEWPORT 0x82000007
+#define D3DFWERR_NOPRIMARY 0x82000008
+#define D3DFWERR_NOCLIPPER 0x82000009
+#define D3DFWERR_BADDISPLAYMODE 0x8200000a
+#define D3DFWERR_NOBACKBUFFER 0x8200000b
+#define D3DFWERR_NONZEROREFCOUNT 0x8200000c
+#define D3DFWERR_NORENDERTARGET 0x8200000d
+#define D3DFWERR_INVALIDMODE 0x8200000e
+#define D3DFWERR_NOTINITIALIZED 0x8200000f
+
+
+