// ------------------------------------------------------------------------
/*
	author: Jaap Suter

	Copyright (C) Electronic Arts Canada Inc. 2002.  All rights reserved.	
*/
// ------------------------------------------------------------------------

/*! \file */

#ifndef REVEAL_TEST_GDI_RENDERER_H
#define REVEAL_TEST_GDI_RENDERER_H

#include <windows.h>

#include "reveal/renderer.h"
#include "reveal/smart_ptr/scoped_ptr.h"

// -----------------------------------------------------------------------
#if defined _MSC_VER
	namespace Gdiplus
	{
		class Bitmap;
		class Image;
	}
#endif

// -----------------------------------------------------------------------
class GdiRenderer : public Reveal::Renderer
{
public:

	struct UnableToCreateWindow {};
	struct UnableToInitGdiplus {};

	GdiRenderer( HINSTANCE hInstance, int showCmd );
	~GdiRenderer();
	void FlipAndClear();

	virtual int DoGetScreenOriginX() const { return 0; }
	virtual int DoGetScreenOriginY() const { return 0; }
	virtual int DoGetScreenWidth()   const { return mWidth; }
    virtual int DoGetScreenHeight()  const { return mHeight; }

	HWND	GetHwnd() const { return mHwnd; }

private:

	void FixBackBuffer();
	
	virtual void DoLine( int x1, int y1, int x2, int y2, Reveal::uint32_t color ) const;
    virtual void DoBar( int x1, int y1, int width, int height, Reveal::uint32_t color ) const;
    virtual void DoString( int x1, int y1, const char* str, Reveal::uint32_t color ) const;
	virtual void DoTriangle( int x1, int y1, int x2, int y2, int x3, int y3, Reveal::uint32_t color ) const;
	virtual bool DoScreenSpaceToWorldSpace( int screenX, int  screenY, 
											float&  worldspaceX, float&  worldspaceY, float& worldspaceZ,
											float&  rayX, float&  rayY, float& rayZ ) const;

	HWND		mHwnd;
	int			mWidth;
	int			mHeight;

#if defined _MSC_VER
	ULONG_PTR   mGdiplusToken;		
	Reveal::SmartPtr::ScopedPtr< Gdiplus::Bitmap >	mBackbuffer;
	Reveal::SmartPtr::ScopedPtr< Gdiplus::Image  >	mBackgroundImage;
#endif

};

#endif
