[ create a new paste ] login | about

Link: http://codepad.org/7DUQTVs6    [ raw code | output | fork ]

C++, pasted on May 21:
//####################################################################
//  NAME: HGE F1
//  PURPOSE: Add a information window to applications by pressing F1
//				With the least possible dependencies
//  CREDITS: Ian T. Jacobsen aka. Akkernight
//
//	Copyright 2009 Aeres Entertainment™
//####################################################################

#include <windows.h>
#include <d3d9.h>


namespace hgeF1 {

	LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
		switch( msg )
		{
		case WM_CLOSE:


			PostQuitMessage(0);
			break;

		case WM_DESTROY:

			PostQuitMessage(0);
			break;

		default:

			return DefWindowProc( hWnd, msg, wParam, lParam );

			break;
		}

		return 0;
	} // End WindowProc

	class CCreate
	{


	private:

		bool created;
		DWORD bgColor;

		LPDIRECT3D9 m_pD3D;
		HWND		m_hWnd;

		LPDIRECT3DDEVICE9	m_pd3dDevice;

		WNDCLASSEX m_wc;


		void init()
		{

			m_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

			D3DDISPLAYMODE d3ddm;

			m_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

			D3DPRESENT_PARAMETERS d3dpp;
			ZeroMemory( &d3dpp, sizeof(d3dpp) );

			d3dpp.Windowed					= TRUE;
			d3dpp.SwapEffect				= D3DSWAPEFFECT_DISCARD;
			d3dpp.BackBufferFormat			= d3ddm.Format;
			d3dpp.EnableAutoDepthStencil	= TRUE;
			d3dpp.AutoDepthStencilFormat	= D3DFMT_D16;
			d3dpp.PresentationInterval		= D3DPRESENT_INTERVAL_IMMEDIATE;

			m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
				m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
				&d3dpp, &m_pd3dDevice );

		} // End init()


		inline void Render()
		{

			m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, bgColor, 1.0f, 0 );

			m_pd3dDevice->BeginScene();

			//The stuff to render

			m_pd3dDevice->EndScene();

			m_pd3dDevice->Present( NULL, NULL, NULL, NULL );


		} // End Render()


	public:

		CCreate(HINSTANCE& hInstance, HWND parent_, WNDPROC MsgProc, DWORD& bgColor_)
			// Should be created in the Entry Point
			: m_pD3D(NULL), m_hWnd(NULL), m_pd3dDevice(NULL), created(false)
		{

			MSG uMsg;
			bgColor = bgColor_;

			memset(&uMsg, 0, sizeof(uMsg));

			/*m_wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
						GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
			"HGE_F1_CLASS", NULL };*/

			m_wc.lpszClassName = "HGE_F1_CLASS";
			m_wc.cbSize		   = sizeof(WNDCLASSEX);
			m_wc.style		   = CS_CLASSDC;
			m_wc.lpfnWndProc   = MsgProc;
			m_wc.hInstance	   = hInstance;
			m_wc.lpszMenuName  = NULL;
			m_wc.cbClsExtra    = 0;
			m_wc.cbWndExtra    = 0;

			if( !RegisterClassEx(&m_wc) )
				// Do error handling code

			// Create Window

			m_hWnd = CreateWindowEx( NULL, "HGE_F1_CLASS",
									 "Application Information",
									 WS_OVERLAPPED | WS_VISIBLE,
									 100,100, 800, 600, parent_, NULL, hInstance, NULL );

			if( m_hWnd == NULL )
				// Do error handling code

			init();
			Render();

		} // End constructor

	void Destroy()
	{

		if( m_pd3dDevice != NULL )
			m_pd3dDevice->Release();

		if( m_pD3D != NULL)
			m_pD3D->Release();

		UnregisterClass( "HGE_F1_CLASS", m_wc.hInstance );
	} // End Destroy()

	~CCreate(){
		Destroy();
	} // End Destructor

	void Update(bool render = false)
	{

		UpdateWindow( m_hWnd );

		if(render && created == false)
		{
			created = true;

			ShowWindow( m_hWnd, 0);

		}

	} // End Update()


	};	// End CCreate

CCreate* creator;

} // End namespace hgeF1


Output:
1
2
3
4
Line 20: error: windows.h: No such file or directory
Line 17: error: d3d9.h: No such file or directory
Line 16: error: 'LRESULT' does not name a type
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: