#include "StdAfx.h"
#include "ShapeGL.h"
#include "MultiVertex.h"

extern ID3D * d3d;

OpenGL_Library::ShapeGL::ShapeGL(void)
{
	shape = NULL;
}

OpenGL_Library::ShapeGL::~ShapeGL(void)
{
	if (shape != NULL)
	{
		delete shape;
	}
}

void OpenGL_Library::ShapeGL::Set(int n, array<double> ^ x)
{
	IMeshBuilder ** mb = new IMeshBuilder*;
	if (shape != NULL)
	{
		delete shape;
		shape = NULL;
	}
	double * arr = new double[x.Length];
	for (int i = 0; i < x.Length; i++)
	{
		arr[i] = x[i];
	}
	shape = new MultiVertex(n, arr, 100000000);
	delete arr;
	shape->CreatePointerMeshBuilder(d3d, mb);
	delete *mb;
	delete mb;
}

MultiVertex * OpenGL_Library::ShapeGL::GetShape()
{
	return shape;
}

