#include "environmentprobe.h"

using namespace VRUT;

const wxString EnvironmentProbe::CubeMapNameSuffix = wxT("_cubemap");

#ifndef VRUT_HPC
bool EnvironmentProbe::SetupAttachments()
{
	if (!GetTextureAttachmentOfType(GL_COLOR_ATTACHMENT0_EXT))
	{	
		//Stencil buffer is ommited. I think we will not be doing stencil effects when rendering into cube maps.
		//If the future proves me wrong, just add it like in the RenderGlModule::updateSingleSampledRenderTarget.
		//Multisampled rendering into the cube map is also neglected.
		AddRenderBufferAttachment(RenderTarget::RenderBufferAttachmentParams(textureDimension, textureDimension, GL_DEPTH_COMPONENT, 1, 1, GL_DEPTH_ATTACHMENT_EXT, RenderTarget::NONE));
		//Hey, it is 2010, let's support HDR rendering by default
		AddCubeTextureAttachment(RenderTarget::TextureAttachmentParams(textureDimension, textureDimension, /*GL_RGB8*/GL_RGB16F_ARB, GL_COLOR_ATTACHMENT0_EXT, GL_RGB, /*GL_UNSIGNED_BYTE*/GL_HALF_FLOAT_ARB));
		
		return true;
	}
	return false;
}
#endif

wxString EnvironmentProbe::BuildEnvironmentProbeName(const smart_pointer<SceneNode>& sceneNode)
{
	 return sceneNode->GetName() + wxT("_") + wxString::Format(wxT("%d"), sceneNode->GetID()) + CubeMapNameSuffix;
}
