/// Copyright (c) 2010 Ruben Penalva. All rights reserved.
/// Redistribution and use in source and binary forms, with or without modification, 
/// are permitted provided that the following conditions are met:
///    1. Redistributions of source code must retain the above copyright notice, this 
///    list of conditions and the following disclaimer.
///    2. Redistributions in binary form must reproduce the above copyright notice,
///    this list of conditions and the following disclaimer in the documentation and/or
///    other materials provided with the distribution.
///    3. The name of the author may not be used to endorse or promote products derived
///    from this software without specific prior written permission.
///
/// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
/// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
/// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 
/// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
/// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
/// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
/// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef _TEST_RENDER_H_
#define _TEST_RENDER_H_

/// TODO
/// - Create flock geometry (instanced)
/// - Render scene

#include "IRenderCallable.h"
#include "TestScene.h"
#include <windows.h>
#include "OpenglDriver.h"

#include <boost\shared_ptr.hpp>
#include "OpenglProgram.h"

namespace TaskBasedFlockSim
{

class TestRender :
	public TestFrameWork::IRenderCallable
{
public:
	TestRender(TestFrameWork::ScenePtr scene, HDC canvasContext, size_t width, size_t height);

	~TestRender(void);

	void Initialize(void);

	void Setup(void);

	void Run(float elapsedTime);

private:
	TestScenePtr m_scene;

	HDC m_canvasContext;
	size_t m_width;
	size_t m_height;

	TestFrameWork::OpenglDriverPtr m_driver;

	size_t m_teapotVertexBuffer;
	size_t m_teapotIndexBuffer;

	TestFrameWork::OpenglProgramWeakPtr m_program;

	TestFrameWork::OpenglTextureWeakPtr m_flockDataTexture;

	size_t m_maximumTexture2DSize;

	TestFrameWork::TextureData m_textureData;
	size_t m_textureDataSize;

	void CreateTeapotBuffers(void);

	void CreateProgram(void);

	void SetProgramParameters(void);
 
	void CreateFlockTextureData(void);

	void ModifyFlockTextureData(void);

	void SetMaxFlockSize(void);

	void RenderMetrics(float renderElapsedTime, float logicElapsedTime);
};

}

#endif