/* this file has been autogenerated by vtkNodeJsWrap */
/* editing this might proof futile */

#define VTK_WRAPPING_CXX
#define VTK_STREAMS_FWD_ONLY
#include <nan.h>

#include "vtkTextureWrap.h"
#include "vtkOpenGLTextureWrap.h"
#include "vtkObjectBaseWrap.h"
#include "vtkRendererWrap.h"
#include "vtkWindowWrap.h"
#include "../../plus/plus.h"

using namespace v8;

extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap;
Nan::Persistent<v8::FunctionTemplate> VtkOpenGLTextureWrap::ptpl;

VtkOpenGLTextureWrap::VtkOpenGLTextureWrap()
{ }

VtkOpenGLTextureWrap::VtkOpenGLTextureWrap(vtkSmartPointer<vtkOpenGLTexture> _native)
{ native = _native; }

VtkOpenGLTextureWrap::~VtkOpenGLTextureWrap()
{ }

void VtkOpenGLTextureWrap::Init(v8::Local<v8::Object> exports)
{
	Nan::SetAccessor(exports, Nan::New("vtkOpenGLTexture").ToLocalChecked(), ConstructorGetter);
	Nan::SetAccessor(exports, Nan::New("OpenGLTexture").ToLocalChecked(), ConstructorGetter);
}

void VtkOpenGLTextureWrap::ConstructorGetter(
	v8::Local<v8::String> property,
	const Nan::PropertyCallbackInfo<v8::Value>& info)
{
	InitPtpl();
	info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction());
}

void VtkOpenGLTextureWrap::InitPtpl()
{
	if (!ptpl.IsEmpty()) return;
	v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
	VtkTextureWrap::InitPtpl( );
	tpl->Inherit(Nan::New<FunctionTemplate>(VtkTextureWrap::ptpl));
	tpl->SetClassName(Nan::New("VtkOpenGLTextureWrap").ToLocalChecked());
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	Nan::SetPrototypeMethod(tpl, "CopyTexImage", CopyTexImage);
	Nan::SetPrototypeMethod(tpl, "copyTexImage", CopyTexImage);

	Nan::SetPrototypeMethod(tpl, "GetIsDepthTexture", GetIsDepthTexture);
	Nan::SetPrototypeMethod(tpl, "getIsDepthTexture", GetIsDepthTexture);

	Nan::SetPrototypeMethod(tpl, "GetTextureType", GetTextureType);
	Nan::SetPrototypeMethod(tpl, "getTextureType", GetTextureType);

	Nan::SetPrototypeMethod(tpl, "GetTextureUnit", GetTextureUnit);
	Nan::SetPrototypeMethod(tpl, "getTextureUnit", GetTextureUnit);

	Nan::SetPrototypeMethod(tpl, "IsTranslucent", IsTranslucent);
	Nan::SetPrototypeMethod(tpl, "isTranslucent", IsTranslucent);

	Nan::SetPrototypeMethod(tpl, "Load", Load);
	Nan::SetPrototypeMethod(tpl, "load", Load);

	Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance);
	Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance);

	Nan::SetPrototypeMethod(tpl, "PostRender", PostRender);
	Nan::SetPrototypeMethod(tpl, "postRender", PostRender);

	Nan::SetPrototypeMethod(tpl, "ReleaseGraphicsResources", ReleaseGraphicsResources);
	Nan::SetPrototypeMethod(tpl, "releaseGraphicsResources", ReleaseGraphicsResources);

	Nan::SetPrototypeMethod(tpl, "Render", Render);
	Nan::SetPrototypeMethod(tpl, "render", Render);

	Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast);
	Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast);

	Nan::SetPrototypeMethod(tpl, "SetIsDepthTexture", SetIsDepthTexture);
	Nan::SetPrototypeMethod(tpl, "setIsDepthTexture", SetIsDepthTexture);

	Nan::SetPrototypeMethod(tpl, "SetTextureType", SetTextureType);
	Nan::SetPrototypeMethod(tpl, "setTextureType", SetTextureType);

#ifdef VTK_NODE_PLUS_VTKOPENGLTEXTUREWRAP_INITPTPL
	VTK_NODE_PLUS_VTKOPENGLTEXTUREWRAP_INITPTPL
#endif
	ptpl.Reset( tpl );
}

void VtkOpenGLTextureWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	if(!info.IsConstructCall())
	{
		Nan::ThrowError("Constructor not called in a construct call.");
		return;
	}

	if(info.Length() == 0)
	{
		vtkSmartPointer<vtkOpenGLTexture> native = vtkSmartPointer<vtkOpenGLTexture>::New();
		VtkOpenGLTextureWrap* obj = new VtkOpenGLTextureWrap(native);
		obj->Wrap(info.This());
	}
	else
	{
		if(info[0]->ToObject() != vtkNodeJsNoWrap )
		{
			Nan::ThrowError("Parameter Error");
			return;
		}
	}

	info.GetReturnValue().Set(info.This());
}

void VtkOpenGLTextureWrap::CopyTexImage(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
		if(info.Length() > 1 && info[1]->IsInt32())
		{
			if(info.Length() > 2 && info[2]->IsInt32())
			{
				if(info.Length() > 3 && info[3]->IsInt32())
				{
										if(info.Length() != 4)
					{
						Nan::ThrowError("Too many parameters.");
						return;
					}
					native->CopyTexImage(
						info[0]->Int32Value(),
						info[1]->Int32Value(),
						info[2]->Int32Value(),
						info[3]->Int32Value()
					);
					return;
				}
			}
		}
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::GetIsDepthTexture(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	int r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetIsDepthTexture();
	info.GetReturnValue().Set(Nan::New(r));
}

void VtkOpenGLTextureWrap::GetTextureType(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	int r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetTextureType();
	info.GetReturnValue().Set(Nan::New(r));
}

void VtkOpenGLTextureWrap::GetTextureUnit(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	int r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->GetTextureUnit();
	info.GetReturnValue().Set(Nan::New(r));
}

void VtkOpenGLTextureWrap::IsTranslucent(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	int r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->IsTranslucent();
	info.GetReturnValue().Set(Nan::New(r));
}

void VtkOpenGLTextureWrap::Load(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkRendererWrap::ptpl))->HasInstance(info[0]))
	{
		VtkRendererWrap *a0 = ObjectWrap::Unwrap<VtkRendererWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->Load(
			(vtkRenderer *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	vtkOpenGLTexture * r;
	if(info.Length() != 0)
	{
		Nan::ThrowError("Too many parameters.");
		return;
	}
	r = native->NewInstance();
	VtkOpenGLTextureWrap::InitPtpl();
	v8::Local<v8::Value> argv[1] =
		{ Nan::New(vtkNodeJsNoWrap) };
	v8::Local<v8::Function> cons =
		Nan::New<v8::FunctionTemplate>(VtkOpenGLTextureWrap::ptpl)->GetFunction();
	v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
	VtkOpenGLTextureWrap *w = new VtkOpenGLTextureWrap();
	w->native = r;
	w->Wrap(wo);
	info.GetReturnValue().Set(wo);
}

void VtkOpenGLTextureWrap::PostRender(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkRendererWrap::ptpl))->HasInstance(info[0]))
	{
		VtkRendererWrap *a0 = ObjectWrap::Unwrap<VtkRendererWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->PostRender(
			(vtkRenderer *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::ReleaseGraphicsResources(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkWindowWrap::ptpl))->HasInstance(info[0]))
	{
		VtkWindowWrap *a0 = ObjectWrap::Unwrap<VtkWindowWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->ReleaseGraphicsResources(
			(vtkWindow *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::Render(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkRendererWrap::ptpl))->HasInstance(info[0]))
	{
		VtkRendererWrap *a0 = ObjectWrap::Unwrap<VtkRendererWrap>(info[0]->ToObject());
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->Render(
			(vtkRenderer *) a0->native.GetPointer()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0]))
	{
		VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject());
		vtkOpenGLTexture * r;
		if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		r = native->SafeDownCast(
			(vtkObjectBase *) a0->native.GetPointer()
		);
		VtkOpenGLTextureWrap::InitPtpl();
		v8::Local<v8::Value> argv[1] =
			{ Nan::New(vtkNodeJsNoWrap) };
		v8::Local<v8::Function> cons =
			Nan::New<v8::FunctionTemplate>(VtkOpenGLTextureWrap::ptpl)->GetFunction();
		v8::Local<v8::Object> wo = cons->NewInstance(1, argv);
		VtkOpenGLTextureWrap *w = new VtkOpenGLTextureWrap();
		w->native = r;
		w->Wrap(wo);
		info.GetReturnValue().Set(wo);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::SetIsDepthTexture(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetIsDepthTexture(
			info[0]->Int32Value()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

void VtkOpenGLTextureWrap::SetTextureType(const Nan::FunctionCallbackInfo<v8::Value>& info)
{
	VtkOpenGLTextureWrap *wrapper = ObjectWrap::Unwrap<VtkOpenGLTextureWrap>(info.Holder());
	vtkOpenGLTexture *native = (vtkOpenGLTexture *)wrapper->native.GetPointer();
	if(info.Length() > 0 && info[0]->IsInt32())
	{
				if(info.Length() != 1)
		{
			Nan::ThrowError("Too many parameters.");
			return;
		}
		native->SetTextureType(
			info[0]->Int32Value()
		);
		return;
	}
	Nan::ThrowError("Parameter mismatch");
}

