/*  $Id: opengl_state.cpp,v 1.6 2004/01/31 19:36:04 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library 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
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include "Display/display_precomp.h"
#include "API/GL/opengl_state.h"
#include "opengl_state_generic.h"

/////////////////////////////////////////////////////////////////////////////
// CL_OpenGLState construction:

CL_OpenGLState::CL_OpenGLState()
{
}

CL_OpenGLState::CL_OpenGLState(CL_GraphicContext *gc)
: impl(new CL_OpenGLState_Generic(gc))
{
}

CL_OpenGLState::CL_OpenGLState(CL_GraphicContext_OpenGL *gc_opengl)
: impl(new CL_OpenGLState_Generic(gc_opengl))
{
}

CL_OpenGLState::CL_OpenGLState(const CL_OpenGLState &copy) : impl(copy.impl)
{
}

CL_OpenGLState::~CL_OpenGLState()
{
}

/////////////////////////////////////////////////////////////////////////////
// CL_OpenGLState attributes:

bool CL_OpenGLState::is_active() const
{
	return impl->is_active();
}

/////////////////////////////////////////////////////////////////////////////
// CL_OpenGLState operations:

void CL_OpenGLState::set_active()
{
	if (impl) impl->set_active();
}

void CL_OpenGLState::attach_data(CL_OpenGLStateData *data, bool delete_data)
{
	if (impl) impl->data_objects.push_back(std::pair<CL_OpenGLStateData *, bool>(data, delete_data));
}

void CL_OpenGLState::detach_data(CL_OpenGLStateData *data)
{
	if (impl == 0) return;

	std::list< std::pair<CL_OpenGLStateData *, bool> >::iterator it;
	for (it = impl->data_objects.begin(); it != impl->data_objects.end(); ++it)
	{
		if ((*it).first == data)
		{
			impl->data_objects.erase(it);
			return;
		}
	}
}

void CL_OpenGLState::setup_2d(bool upside_down)
{
	impl->setup_2d(upside_down);
}

/////////////////////////////////////////////////////////////////////////////
// CL_OpenGLState implementation:
