/* Automatically generated by
	VMPluginCodeGenerator VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1
   from
	B3DAcceleratorPlugin VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1
 */
static char __buildInfo[] = "B3DAcceleratorPlugin VMMaker.oscog-eem.2480 uuid: bb3ffda7-8241-4dea-b886-d656e474b6c1 " __DATE__ ;



#include "config.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/* Default EXPORT macro that does nothing (see comment in sq.h): */
#define EXPORT(returnType) returnType

/* Do not include the entire sq.h file but just those parts needed. */
#include "sqConfig.h"			/* Configuration options */
#include "sqVirtualMachine.h"	/*  The virtual machine proxy definition */
#include "sqPlatformSpecific.h"	/* Platform specific definitions */

#define true 1
#define false 0
#define null 0  /* using 'null' because nil is predefined in Think C */
#ifdef SQUEAK_BUILTIN_PLUGIN
# undef EXPORT
# define EXPORT(returnType) static returnType
#endif

#include "B3DAcceleratorPlugin.h"
#include "sqMemoryAccess.h"


/*** Function Prototypes ***/
static sqInt checkBoundsRangefacescount(sqInt vertices, unsigned int *facePtr, sqInt faceCount);
static sqInt checkVertexData(sqInt vertices);
static void* fetchLightSourceofObject(sqInt index, sqInt anArray);
EXPORT(const char*) getModuleName(void);
EXPORT(sqInt) initialiseModule(void);
static sqInt loadClientStateverticescolorsnormalstexCoords(sqInt handle, sqInt vertices, sqInt colors, sqInt normals, sqInt texCoords);
EXPORT(sqInt) primitiveAllocateTexture(void);
EXPORT(sqInt) primitiveClearDepthBuffer(void);
EXPORT(sqInt) primitiveClearViewport(void);
EXPORT(sqInt) primitiveCompositeTexture(void);
EXPORT(sqInt) primitiveCreateRenderer(void);
EXPORT(sqInt) primitiveCreateRendererFlags(void);
EXPORT(sqInt) primitiveDestroyRenderer(void);
EXPORT(sqInt) primitiveDestroyTexture(void);
EXPORT(sqInt) primitiveDrawArrays(void);
EXPORT(sqInt) primitiveDrawElements(void);
EXPORT(sqInt) primitiveDrawRangeElements(void);
EXPORT(sqInt) primitiveEnableDrawRangeChecks(void);
EXPORT(sqInt) primitiveFinishRenderer(void);
EXPORT(sqInt) primitiveFlushRenderer(void);
EXPORT(sqInt) primitiveGetIntProperty(void);
EXPORT(sqInt) primitiveGetRendererColorMasks(void);
EXPORT(sqInt) primitiveGetRendererSurfaceDepth(void);
EXPORT(sqInt) primitiveGetRendererSurfaceHandle(void);
EXPORT(sqInt) primitiveGetRendererSurfaceHeight(void);
EXPORT(sqInt) primitiveGetRendererSurfaceWidth(void);
EXPORT(sqInt) primitiveIsOverlayRenderer(void);
EXPORT(sqInt) primitiveRendererVersion(void);
EXPORT(sqInt) primitiveRenderVertexBuffer(void);
EXPORT(sqInt) primitiveSetBufferRect(void);
EXPORT(sqInt) primitiveSetFog(void);
EXPORT(sqInt) primitiveSetIntProperty(void);
EXPORT(sqInt) primitiveSetLights(void);
EXPORT(sqInt) primitiveSetMaterial(void);
EXPORT(sqInt) primitiveSetTransform(void);
EXPORT(sqInt) primitiveSetVerboseLevel(void);
EXPORT(sqInt) primitiveSetViewport(void);
EXPORT(sqInt) primitiveSwapRendererBuffers(void);
EXPORT(sqInt) primitiveTextureByteSex(void);
EXPORT(sqInt) primitiveTextureDepth(void);
EXPORT(sqInt) primitiveTextureGetColorMasks(void);
EXPORT(sqInt) primitiveTextureSurfaceHandle(void);
EXPORT(sqInt) primitiveTextureUpload(void);
EXPORT(sqInt) setInterpreter(struct VirtualMachine *anInterpreter);
EXPORT(sqInt) shutdownModule(void);
static sqInt stackLightArrayValue(sqInt stackIndex);
static void * stackMaterialValue(sqInt stackIndex);
static void* stackMatrix(sqInt index);
static void* stackPrimitiveIndexArrayofSizevalidateforVertexSize(sqInt stackIndex, sqInt nItems, sqInt aBool, sqInt maxIndex);
static void* stackPrimitiveVertexArrayofSize(sqInt index, sqInt nItems);


/*** Variables ***/
static sqInt doRangeChecks;

#if !defined(SQUEAK_BUILTIN_PLUGIN)
static sqInt (*booleanValueOf)(sqInt obj);
static sqInt (*failed)(void);
static sqInt (*fetchIntegerofObject)(sqInt fieldIndex, sqInt objectPointer);
static sqInt (*fetchPointerofObject)(sqInt index, sqInt oop);
static void * (*firstIndexableField)(sqInt oop);
static double (*floatValueOf)(sqInt oop);
static sqInt (*isArray)(sqInt oop);
static sqInt (*isPointers)(sqInt oop);
static sqInt (*isWords)(sqInt oop);
static sqInt (*methodArgumentCount)(void);
static sqInt (*methodReturnInteger)(sqInt integer);
static sqInt (*nilObject)(void);
static sqInt (*pop)(sqInt nItems);
static sqInt (*popRemappableOop)(void);
static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
static usqInt (*positive32BitValueOf)(sqInt oop);
static sqInt (*primitiveFail)(void);
static sqInt (*pushBool)(sqInt trueOrFalse);
static sqInt (*pushInteger)(sqInt integerValue);
static sqInt (*pushRemappableOop)(sqInt oop);
static sqInt (*slotSizeOf)(sqInt oop);
static sqInt (*stackIntegerValue)(sqInt offset);
static sqInt (*stackObjectValue)(sqInt offset);
static sqInt (*stackValue)(sqInt offset);
static sqInt (*storePointerofObjectwithValue)(sqInt index, sqInt oop, sqInt valuePointer);
static sqInt (*topRemappableOop)(void);
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
extern sqInt booleanValueOf(sqInt obj);
extern sqInt failed(void);
extern sqInt fetchIntegerofObject(sqInt fieldIndex, sqInt objectPointer);
extern sqInt fetchPointerofObject(sqInt index, sqInt oop);
extern void * firstIndexableField(sqInt oop);
extern double floatValueOf(sqInt oop);
extern sqInt isArray(sqInt oop);
extern sqInt isPointers(sqInt oop);
extern sqInt isWords(sqInt oop);
extern sqInt methodArgumentCount(void);
extern sqInt methodReturnInteger(sqInt integer);
extern sqInt nilObject(void);
extern sqInt pop(sqInt nItems);
extern sqInt popRemappableOop(void);
extern sqInt positive32BitIntegerFor(unsigned int integerValue);
extern usqInt positive32BitValueOf(sqInt oop);
extern sqInt primitiveFail(void);
extern sqInt pushBool(sqInt trueOrFalse);
extern sqInt pushInteger(sqInt integerValue);
extern sqInt pushRemappableOop(sqInt oop);
extern sqInt slotSizeOf(sqInt oop);
extern sqInt stackIntegerValue(sqInt offset);
extern sqInt stackObjectValue(sqInt offset);
extern sqInt stackValue(sqInt offset);
extern sqInt storePointerofObjectwithValue(sqInt index, sqInt oop, sqInt valuePointer);
extern sqInt topRemappableOop(void);
extern
#endif
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
	"B3DAcceleratorPlugin VMMaker.oscog-eem.2480 (i)"
#else
	"B3DAcceleratorPlugin VMMaker.oscog-eem.2480 (e)"
#endif
;



/*	Verify the bounds condition on the entire faces array */

	/* B3DAcceleratorPlugin>>#checkBoundsRange:faces:count: */
static sqInt
checkBoundsRangefacescount(sqInt vertices, unsigned int *facePtr, sqInt faceCount)
{
    sqInt i;
    sqInt vtxSize;

	vtxSize = (slotSizeOf(vertices)) / 3;
	for (i = 0; i < faceCount; i += 1) {
		if ((facePtr[i]) > vtxSize) {
			return primitiveFail();
		}
	}
	return 0;
}


/*	Check the entire vertex data to ensure no nan/inf values */

	/* B3DAcceleratorPlugin>>#checkVertexData: */
static sqInt
checkVertexData(sqInt vertices)
{
    float f;
    sqInt i;
    float *vtxPtr;
    sqInt vtxSize;

	vtxSize = slotSizeOf(vertices);
	vtxPtr = firstIndexableField(vertices);
	for (i = 0; i < vtxSize; i += 1) {
		f = vtxPtr[i];
		if (isnan(f - f)) {
			return primitiveFail();
		}
	}
	return 0;
}


/*	Fetch the primitive light source from the given array.
	Note: No checks are done within here - that happened in
	stackLightArrayValue: 
 */

	/* B3DAcceleratorPlugin>>#fetchLightSource:ofObject: */
static void*
fetchLightSourceofObject(sqInt index, sqInt anArray)
{
    sqInt lightOop;

	lightOop = fetchPointerofObject(index, anArray);
	return firstIndexableField(lightOop);
}


/*	Note: This is hardcoded so it can be run from Squeak.
	The module name is used for validating a module *after*
	it is loaded to check if it does really contain the module
	we're thinking it contains. This is important! */

	/* InterpreterPlugin>>#getModuleName */
EXPORT(const char*)
getModuleName(void)
{
	return moduleName;
}

	/* B3DAcceleratorPlugin>>#initialiseModule */
EXPORT(sqInt)
initialiseModule(void)
{
	doRangeChecks = 1;
	return b3dxInitialize();
}


/*	Common method to set up client state for some render ops */

	/* B3DAcceleratorPlugin>>#loadClientState:vertices:colors:normals:texCoords: */
static sqInt
loadClientStateverticescolorsnormalstexCoords(sqInt handle, sqInt vertices, sqInt colors, sqInt normals, sqInt texCoords)
{
    void *colorPtr;
    sqInt nilOop;
    void *normalPtr;
    sqInt ok;
    sqInt sz;
    void *txPtr;
    void *vertexPtr;
    sqInt vtxSize;

	colorPtr = (normalPtr = (txPtr = (vertexPtr = null)));

	/* Verify vertex data */
	sz = 0;
	if (!(isWords(vertices))) {
		return primitiveFail();
	}

	/* Verify assumptions of color, normal, texCoords data */
	vtxSize = (slotSizeOf(vertices)) / 3;
	nilOop = nilObject();
	if (!((colors == nilOop)
		 || ((isWords(colors))
		 && ((slotSizeOf(colors)) == (vtxSize * 4))))) {
		return primitiveFail();
	}
	if (!((normals == nilOop)
		 || ((isWords(normals))
		 && ((slotSizeOf(normals)) == (vtxSize * 3))))) {
		return primitiveFail();
	}
	if (!((texCoords == nilOop)
		 || (isWords(texCoords)))) {
		return primitiveFail();
	}
	if (!(colors == nilOop)) {
		colorPtr = firstIndexableField(colors);
	}
	if (!(normals == nilOop)) {
		normalPtr = firstIndexableField(normals);
	}
	if (!(texCoords == nilOop)) {
		sz = (slotSizeOf(texCoords)) / vtxSize;
		txPtr = firstIndexableField(texCoords);
	}
	vertexPtr = firstIndexableField(vertices);
	if (!(failed())) {
		ok = b3dLoadClientState(handle, vertexPtr, 3, colorPtr, 4, normalPtr, 3, txPtr, sz);
		if (!ok) {
			primitiveFail();
		}
	}
	return null;
}

	/* B3DAcceleratorPlugin>>#primitiveAllocateTexture */
EXPORT(sqInt)
primitiveAllocateTexture(void)
{
    sqInt d;
    sqInt h;
    sqInt renderer;
    sqInt result;
    sqInt w;

	if (!((methodArgumentCount()) == 4)) {
		return primitiveFail();
	}
	h = stackIntegerValue(0);
	w = stackIntegerValue(1);
	d = stackIntegerValue(2);
	renderer = stackIntegerValue(3);
	if (failed()) {
		return null;
	}
	result = b3dxAllocateTexture(renderer, w, h, d);
	if (result == -1) {
		return primitiveFail();
	}
	pop(5);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveClearDepthBuffer */
EXPORT(sqInt)
primitiveClearDepthBuffer(void)
{
    sqInt handle;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (!(failed())) {
		if (b3dxClearDepthBuffer(handle)) {
			pop(1);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveClearViewport */
EXPORT(sqInt)
primitiveClearViewport(void)
{
    sqInt handle;
    sqInt pv;
    sqInt rgba;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	pv = positive32BitValueOf(stackValue(0));
	rgba = positive32BitValueOf(stackValue(1));
	handle = stackIntegerValue(2);
	if (failed()) {
		return null;
	}
	if (b3dxClearViewport(handle, rgba, pv)) {
		pop(3);
	}
	else {
		primitiveFail();
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveCompositeTexture */
EXPORT(sqInt)
primitiveCompositeTexture(void)
{
    sqInt h;
    sqInt rendererHandle;
    sqInt result;
    sqInt texHandle;
    sqInt translucent;
    sqInt w;
    sqInt x;
    sqInt y;

	if (!((methodArgumentCount()) == 7)) {
		return primitiveFail();
	}
	translucent = booleanValueOf(stackValue(0));
	h = stackIntegerValue(1);
	w = stackIntegerValue(2);
	y = stackIntegerValue(3);
	x = stackIntegerValue(4);
	texHandle = stackIntegerValue(5);
	rendererHandle = stackIntegerValue(6);
	if (failed()) {
		return null;
	}
	result = b3dxCompositeTexture(rendererHandle, texHandle, x, y, w, h, translucent);
	if (!result) {
		return primitiveFail();
	}
	return pop(7);
}


/*	NOTE: This primitive is obsolete but should be supported for older images */

	/* B3DAcceleratorPlugin>>#primitiveCreateRenderer */
EXPORT(sqInt)
primitiveCreateRenderer(void)
{
    sqInt allowHardware;
    sqInt allowSoftware;
    sqInt h;
    sqInt result;
    sqInt w;
    sqInt x;
    sqInt y;

	result = 0;
	if (!((methodArgumentCount()) == 6)) {
		return primitiveFail();
	}
	h = stackIntegerValue(0);
	w = stackIntegerValue(1);
	y = stackIntegerValue(2);
	x = stackIntegerValue(3);
	allowHardware = booleanValueOf(stackValue(4));
	allowSoftware = booleanValueOf(stackValue(5));
	if (!(failed())) {
		if ((b3dxCreateRenderer(allowSoftware, allowHardware, x, y, w, h)) >= 0) {
			methodReturnInteger(result);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveCreateRendererFlags */
EXPORT(sqInt)
primitiveCreateRendererFlags(void)
{
    sqInt flags;
    sqInt h;
    sqInt result;
    sqInt w;
    sqInt x;
    sqInt y;

	result = 0;
	if (!((methodArgumentCount()) == 5)) {
		return primitiveFail();
	}
	h = stackIntegerValue(0);
	w = stackIntegerValue(1);
	y = stackIntegerValue(2);
	x = stackIntegerValue(3);
	flags = stackIntegerValue(4);
	if (!(failed())) {
		if ((b3dxCreateRendererFlags(x, y, w, h, flags)) >= 0) {
			methodReturnInteger(result);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveDestroyRenderer */
EXPORT(sqInt)
primitiveDestroyRenderer(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxDestroyRenderer(handle);
	if (!result) {
		return primitiveFail();
	}
	return pop(1);
}

	/* B3DAcceleratorPlugin>>#primitiveDestroyTexture */
EXPORT(sqInt)
primitiveDestroyTexture(void)
{
    sqInt handle;
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	renderer = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	result = b3dxDestroyTexture(renderer, handle);
	if (!result) {
		return primitiveFail();
	}
	return pop(2);
}


/*	Primitive. Setup non-VBO client state and call drawRangeElements in one go
	to avoid
	garbage collection to move the buffers underneith.
 */

	/* B3DAcceleratorPlugin>>#primitiveDrawArrays */
EXPORT(sqInt)
primitiveDrawArrays(void)
{
    sqInt colors;
    float f;
    sqInt handle;
    sqInt i;
    sqInt maxIdx;
    sqInt minIdx;
    sqInt mode;
    sqInt normals;
    sqInt ok;
    sqInt texCoords;
    sqInt vertices;
    float *vtxPtr;
    sqInt vtxSize;
    sqInt vtxSize1;

	if (!((methodArgumentCount()) == 8)) {
		return primitiveFail();
	}
	maxIdx = stackIntegerValue(0);
	minIdx = stackIntegerValue(1);
	mode = stackIntegerValue(2);
	texCoords = stackValue(3);
	normals = stackValue(4);
	colors = stackValue(5);
	vertices = stackValue(6);
	handle = stackIntegerValue(7);
	loadClientStateverticescolorsnormalstexCoords(handle, vertices, colors, normals, texCoords);
	if (failed()) {
		return null;
	}
	if (doRangeChecks) {

		/* Verify the vertex data itself */
		/* begin checkVertexData: */
		vtxSize1 = slotSizeOf(vertices);
		vtxPtr = firstIndexableField(vertices);
		for (i = 0; i < vtxSize1; i += 1) {
			f = vtxPtr[i];
			if (isnan(f - f)) {
				primitiveFail();
				goto l1;
			}
		}
	l1:	/* end checkVertexData: */;
		vtxSize = (slotSizeOf(vertices)) / 3;
		if ((minIdx < 0)
		 || ((minIdx > maxIdx)
		 || (maxIdx > vtxSize))) {
			primitiveFail();
		}
	}
	if (!(failed())) {
		ok = b3dDrawArrays(handle, mode, minIdx, maxIdx);
		if (ok) {
			pop(methodArgumentCount());
		}
	}
	return null;
}


/*	Primitive. Setup non-VBO client state and call drawElements in one go to
	avoid garbage collection to move the buffers underneith. */

	/* B3DAcceleratorPlugin>>#primitiveDrawElements */
EXPORT(sqInt)
primitiveDrawElements(void)
{
    sqInt colors;
    float f;
    unsigned int *facePtr;
    sqInt faceSize;
    sqInt faces;
    sqInt handle;
    sqInt i;
    sqInt i1;
    sqInt mode;
    sqInt normals;
    sqInt ok;
    sqInt texCoords;
    sqInt vertices;
    float *vtxPtr;
    sqInt vtxSize;
    sqInt vtxSize1;

	if (!((methodArgumentCount()) == 7)) {
		return primitiveFail();
	}
	faces = stackValue(0);
	if (!(isWords(faces))) {
		return primitiveFail();
	}
	faceSize = slotSizeOf(faces);
	facePtr = firstIndexableField(faces);
	mode = stackIntegerValue(1);
	texCoords = stackValue(2);
	normals = stackValue(3);
	colors = stackValue(4);
	vertices = stackValue(5);
	handle = stackIntegerValue(6);
	loadClientStateverticescolorsnormalstexCoords(handle, vertices, colors, normals, texCoords);
	if (failed()) {
		return null;
	}
	if (doRangeChecks) {

		/* Verify the vertex data itself */
		/* begin checkVertexData: */
		vtxSize = slotSizeOf(vertices);
		vtxPtr = firstIndexableField(vertices);
		for (i = 0; i < vtxSize; i += 1) {
			f = vtxPtr[i];
			if (isnan(f - f)) {
				primitiveFail();
				goto l1;
			}
		}
	l1:	/* end checkVertexData: */;
		/* begin checkBoundsRange:faces:count: */
		vtxSize1 = (slotSizeOf(vertices)) / 3;
		for (i1 = 0; i1 < faceSize; i1 += 1) {
			if ((facePtr[i1]) > vtxSize1) {
				primitiveFail();
				goto l2;
			}
		}
	l2:	/* end checkBoundsRange:faces:count: */;
	}
	if (!(failed())) {
		ok = b3dDrawElements(handle, mode, faceSize, facePtr);
		if (ok) {
			pop(methodArgumentCount());
		}
	}
	return null;
}


/*	Primitive. Setup non-VBO client state and call drawRangeElements in one go
	to avoid
	garbage collection to move the buffers underneith.
 */

	/* B3DAcceleratorPlugin>>#primitiveDrawRangeElements */
EXPORT(sqInt)
primitiveDrawRangeElements(void)
{
    sqInt colors;
    float f;
    unsigned int *facePtr;
    sqInt faceSize;
    sqInt faces;
    sqInt handle;
    sqInt i;
    sqInt i1;
    sqInt maxIdx;
    sqInt minIdx;
    sqInt mode;
    sqInt normals;
    sqInt ok;
    sqInt texCoords;
    sqInt vertices;
    float *vtxPtr;
    sqInt vtxSize;
    sqInt vtxSize1;
    sqInt vtxSize2;

	if (!((methodArgumentCount()) == 9)) {
		return primitiveFail();
	}
	faces = stackValue(0);
	if (!(isWords(faces))) {
		return primitiveFail();
	}
	faceSize = slotSizeOf(faces);
	facePtr = firstIndexableField(faces);
	maxIdx = stackIntegerValue(1);
	minIdx = stackIntegerValue(2);
	mode = stackIntegerValue(3);
	texCoords = stackValue(4);
	normals = stackValue(5);
	colors = stackValue(6);
	vertices = stackValue(7);
	handle = stackIntegerValue(8);
	loadClientStateverticescolorsnormalstexCoords(handle, vertices, colors, normals, texCoords);
	if (failed()) {
		return null;
	}
	if (doRangeChecks) {

		/* Verify the vertex data itself */
		/* begin checkVertexData: */
		vtxSize1 = slotSizeOf(vertices);
		vtxPtr = firstIndexableField(vertices);
		for (i = 0; i < vtxSize1; i += 1) {
			f = vtxPtr[i];
			if (isnan(f - f)) {
				primitiveFail();
				goto l1;
			}
		}
	l1:	/* end checkVertexData: */;
		/* begin checkBoundsRange:faces:count: */
		vtxSize2 = (slotSizeOf(vertices)) / 3;
		for (i1 = 0; i1 < faceSize; i1 += 1) {
			if ((facePtr[i1]) > vtxSize2) {
				primitiveFail();
				goto l2;
			}
		}
	l2:	/* end checkBoundsRange:faces:count: */;
		vtxSize = (slotSizeOf(vertices)) / 3;
		if ((minIdx < 0)
		 || ((minIdx > maxIdx)
		 || (maxIdx > vtxSize))) {
			primitiveFail();
		}
	}
	if (!(failed())) {
		ok = b3dDrawRangeElements(handle, mode, minIdx, maxIdx, faceSize, facePtr);
		if (ok) {
			pop(methodArgumentCount());
		}
	}
	return null;
}


/*	Primitive. Enable/disable draw (range) checks */

	/* B3DAcceleratorPlugin>>#primitiveEnableDrawRangeChecks */
EXPORT(sqInt)
primitiveEnableDrawRangeChecks(void)
{
    sqInt enabled;

	if ((methodArgumentCount()) == 0) {
		pop(1);
		return pushBool(doRangeChecks);
	}
	if ((methodArgumentCount()) == 1) {
		enabled = booleanValueOf(stackValue(0));
		if (!(failed())) {
			doRangeChecks = enabled;
			return pop(1);
		}
	}
	return null;
}

	/* B3DAcceleratorPlugin>>#primitiveFinishRenderer */
EXPORT(sqInt)
primitiveFinishRenderer(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxFinishRenderer(handle);
	if (!result) {
		return primitiveFail();
	}
	return pop(1);
}

	/* B3DAcceleratorPlugin>>#primitiveFlushRenderer */
EXPORT(sqInt)
primitiveFlushRenderer(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxFlushRenderer(handle);
	if (!result) {
		return primitiveFail();
	}
	return pop(1);
}

	/* B3DAcceleratorPlugin>>#primitiveGetIntProperty */
EXPORT(sqInt)
primitiveGetIntProperty(void)
{
    sqInt handle;
    sqInt prop;
    sqInt result;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	prop = stackIntegerValue(0);
	handle = stackIntegerValue(1);
	result = b3dxGetIntProperty(handle, prop);
	methodReturnInteger(result);
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveGetRendererColorMasks */
EXPORT(sqInt)
primitiveGetRendererColorMasks(void)
{
    sqInt array;
    sqInt handle;
    sqInt i;
    unsigned int masks[4];

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	array = stackObjectValue(0);
	handle = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	if (!((isArray(array))
		 && (((slotSizeOf(array)) == 4)
		 && (b3dxGetRendererColorMasks(handle, masks))))) {
		return primitiveFail();
	}
	pushRemappableOop(array);
	for (i = 0; i <= 3; i += 1) {
		storePointerofObjectwithValue(i, topRemappableOop(), positive32BitIntegerFor(masks[i]));
	}
	popRemappableOop();
	return pop(2);
}

	/* B3DAcceleratorPlugin>>#primitiveGetRendererSurfaceDepth */
EXPORT(sqInt)
primitiveGetRendererSurfaceDepth(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxGetRendererSurfaceDepth(handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(2);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveGetRendererSurfaceHandle */
EXPORT(sqInt)
primitiveGetRendererSurfaceHandle(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxGetRendererSurfaceHandle(handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(2);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveGetRendererSurfaceHeight */
EXPORT(sqInt)
primitiveGetRendererSurfaceHeight(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxGetRendererSurfaceHeight(handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(2);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveGetRendererSurfaceWidth */
EXPORT(sqInt)
primitiveGetRendererSurfaceWidth(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxGetRendererSurfaceWidth(handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(2);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveIsOverlayRenderer */
EXPORT(sqInt)
primitiveIsOverlayRenderer(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxIsOverlayRenderer(handle);
	pop(2);
	return pushBool(result);
}

	/* B3DAcceleratorPlugin>>#primitiveRendererVersion */
EXPORT(sqInt)
primitiveRendererVersion(void)
{
	if (!((methodArgumentCount()) == 0)) {
		return primitiveFail();
	}
	pop(1);
	return pushInteger(1);
}

	/* B3DAcceleratorPlugin>>#primitiveRenderVertexBuffer */
EXPORT(sqInt)
primitiveRenderVertexBuffer(void)
{
    sqInt flags;
    sqInt handle;
    int *idxArray;
    sqInt idxCount;
    sqInt primType;
    sqInt result;
    sqInt texHandle;
    float *vtxArray;
    sqInt vtxCount;

	if (!((methodArgumentCount()) == 8)) {
		return primitiveFail();
	}
	idxCount = stackIntegerValue(0);
	vtxCount = stackIntegerValue(2);
	texHandle = stackIntegerValue(4);
	flags = stackIntegerValue(5);
	primType = stackIntegerValue(6);
	handle = stackIntegerValue(7);
	if (failed()) {
		return null;
	}
	vtxArray = stackPrimitiveVertexArrayofSize(3, vtxCount);
	idxArray = stackPrimitiveIndexArrayofSizevalidateforVertexSize(1, idxCount, 1, vtxCount);
	if ((vtxArray == null)
	 || ((idxArray == null)
	 || ((primType < 1)
	 || ((primType > 6)
	 || (failed()))))) {
		return primitiveFail();
	}
	result = b3dxRenderVertexBuffer(handle, primType, flags, texHandle, vtxArray, vtxCount, idxArray, idxCount);
	if (!result) {
		return primitiveFail();
	}
	return pop(8);
}


/*	Primitive. Set the buffer rectangle (e.g., the pixel area on screen) to
	use for this renderer.
	The viewport is positioned within the buffer rectangle.
 */

	/* B3DAcceleratorPlugin>>#primitiveSetBufferRect */
EXPORT(sqInt)
primitiveSetBufferRect(void)
{
    sqInt h;
    sqInt handle;
    sqInt w;
    sqInt x;
    sqInt y;

	if (!((methodArgumentCount()) == 5)) {
		return primitiveFail();
	}
	h = stackIntegerValue(0);
	w = stackIntegerValue(1);
	y = stackIntegerValue(2);
	x = stackIntegerValue(3);
	handle = stackIntegerValue(4);
	if (!(failed())) {
		if (b3dxSetBufferRect(handle, x, y, w, h)) {
			pop(5);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSetFog */
EXPORT(sqInt)
primitiveSetFog(void)
{
    double density;
    sqInt fogType;
    sqInt handle;
    sqInt rgba;
    double start;
    double stop;

	if (!((methodArgumentCount()) == 6)) {
		return primitiveFail();
	}
	rgba = positive32BitValueOf(stackValue(0));
	stop = floatValueOf(stackValue(1));
	start = floatValueOf(stackValue(2));
	density = floatValueOf(stackValue(3));
	fogType = stackIntegerValue(4);
	handle = stackIntegerValue(5);
	if (!(failed())) {
		if (b3dxSetFog(handle, fogType, density, start, stop, rgba)) {
			pop(6);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSetIntProperty */
EXPORT(sqInt)
primitiveSetIntProperty(void)
{
    sqInt handle;
    sqInt prop;
    sqInt value;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	value = stackIntegerValue(0);
	prop = stackIntegerValue(1);
	handle = stackIntegerValue(2);
	if (b3dxSetIntProperty(handle, prop, value)) {
		pop(3);
	}
	else {
		primitiveFail();
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSetLights */
EXPORT(sqInt)
primitiveSetLights(void)
{
    sqInt handle;
    sqInt i;
    void *light;
    sqInt lightArray;
    sqInt lightCount;
    sqInt lightOop;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	lightArray = stackLightArrayValue(0);
	handle = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	if (!(b3dxDisableLights(handle))) {
		return primitiveFail();
	}
	if (!(lightArray)) {
		return null;
	}

	/* For each enabled light source */
	lightCount = slotSizeOf(lightArray);
	for (i = 0; i < lightCount; i += 1) {
		/* begin fetchLightSource:ofObject: */
		lightOop = fetchPointerofObject(i, lightArray);
		light = ((void *) (firstIndexableField(lightOop)));
		if (!(b3dxLoadLight(handle, i, light))) {
			return primitiveFail();
		}
	}
	return pop(2);
}

	/* B3DAcceleratorPlugin>>#primitiveSetMaterial */
EXPORT(sqInt)
primitiveSetMaterial(void)
{
    sqInt handle;
    void *material;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	material = stackMaterialValue(0);
	handle = stackIntegerValue(1);
	if (!(b3dxLoadMaterial(handle, material))) {
		return primitiveFail();
	}
	return pop(2);
}


/*	Transform an entire vertex buffer using the supplied modelview and
	projection matrix.
 */

	/* B3DAcceleratorPlugin>>#primitiveSetTransform */
EXPORT(sqInt)
primitiveSetTransform(void)
{
    sqInt handle;
    float *modelViewMatrix;
    float *projectionMatrix;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	projectionMatrix = stackMatrix(0);
	modelViewMatrix = stackMatrix(1);
	handle = stackIntegerValue(2);
	if (!(failed())) {
		b3dxSetTransform(handle, modelViewMatrix, projectionMatrix);
		pop(3);
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSetVerboseLevel */
EXPORT(sqInt)
primitiveSetVerboseLevel(void)
{
    sqInt level;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	level = stackIntegerValue(0);
	result = b3dxSetVerboseLevel(level);
	methodReturnInteger(result);
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSetViewport */
EXPORT(sqInt)
primitiveSetViewport(void)
{
    sqInt h;
    sqInt handle;
    sqInt w;
    sqInt x;
    sqInt y;

	if (!((methodArgumentCount()) == 5)) {
		return primitiveFail();
	}
	h = stackIntegerValue(0);
	w = stackIntegerValue(1);
	y = stackIntegerValue(2);
	x = stackIntegerValue(3);
	handle = stackIntegerValue(4);
	if (!(failed())) {
		if (b3dxSetViewport(handle, x, y, w, h)) {
			pop(5);
		}
		else {
			primitiveFail();
		}
	}
	return 0;
}

	/* B3DAcceleratorPlugin>>#primitiveSwapRendererBuffers */
EXPORT(sqInt)
primitiveSwapRendererBuffers(void)
{
    sqInt handle;
    sqInt result;

	if (!((methodArgumentCount()) == 1)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	if (failed()) {
		return null;
	}
	result = b3dxSwapRendererBuffers(handle);
	if (!result) {
		return primitiveFail();
	}
	return pop(1);
}

	/* B3DAcceleratorPlugin>>#primitiveTextureByteSex */
EXPORT(sqInt)
primitiveTextureByteSex(void)
{
    sqInt handle;
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	renderer = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	result = b3dxTextureByteSex(renderer, handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(3);
	return pushBool(result);
}

	/* B3DAcceleratorPlugin>>#primitiveTextureDepth */
EXPORT(sqInt)
primitiveTextureDepth(void)
{
    sqInt handle;
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	renderer = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	result = b3dxActualTextureDepth(renderer, handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(3);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveTextureGetColorMasks */
EXPORT(sqInt)
primitiveTextureGetColorMasks(void)
{
    sqInt array;
    sqInt handle;
    sqInt i;
    unsigned int masks[4];
    sqInt renderer;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	array = stackObjectValue(0);
	handle = stackIntegerValue(1);
	renderer = stackIntegerValue(2);
	if (failed()) {
		return null;
	}
	if (!((isArray(array))
		 && (((slotSizeOf(array)) == 4)
		 && (b3dxTextureColorMasks(renderer, handle, masks))))) {
		return primitiveFail();
	}
	pushRemappableOop(array);
	for (i = 0; i <= 3; i += 1) {
		storePointerofObjectwithValue(i, topRemappableOop(), positive32BitIntegerFor(masks[i]));
	}
	popRemappableOop();
	return pop(3);
}

	/* B3DAcceleratorPlugin>>#primitiveTextureSurfaceHandle */
EXPORT(sqInt)
primitiveTextureSurfaceHandle(void)
{
    sqInt handle;
    sqInt renderer;
    sqInt result;

	if (!((methodArgumentCount()) == 2)) {
		return primitiveFail();
	}
	handle = stackIntegerValue(0);
	renderer = stackIntegerValue(1);
	if (failed()) {
		return null;
	}
	result = b3dxTextureSurfaceHandle(renderer, handle);
	if (result < 0) {
		return primitiveFail();
	}
	pop(3);
	return pushInteger(result);
}

	/* B3DAcceleratorPlugin>>#primitiveTextureUpload */
EXPORT(sqInt)
primitiveTextureUpload(void)
{
    sqInt bits;
    void *bitsPtr;
    sqInt d;
    sqInt form;
    sqInt h;
    sqInt handle;
    sqInt ppw;
    sqInt renderer;
    sqInt result;
    sqInt w;

	if (!((methodArgumentCount()) == 3)) {
		return primitiveFail();
	}
	form = stackValue(0);
	if (!((isPointers(form))
		 && ((slotSizeOf(form)) >= 4))) {
		return primitiveFail();
	}
	bits = fetchPointerofObject(0, form);
	w = fetchIntegerofObject(1, form);
	h = fetchIntegerofObject(2, form);
	d = fetchIntegerofObject(3, form);
	ppw = 32 / d;
	if (!(isWords(bits))) {
		return primitiveFail();
	}
	if (!((slotSizeOf(bits)) == ((((w + ppw) - 1) / ppw) * h))) {
		return primitiveFail();
	}
	bitsPtr = firstIndexableField(bits);
	handle = stackIntegerValue(1);
	renderer = stackIntegerValue(2);
	if (failed()) {
		return null;
	}
	result = b3dxUploadTexture(renderer, handle, w, h, d, bitsPtr);
	if (!result) {
		return primitiveFail();
	}
	return pop(3);
}


/*	Note: This is coded so that it can be run in Squeak. */

	/* InterpreterPlugin>>#setInterpreter: */
EXPORT(sqInt)
setInterpreter(struct VirtualMachine *anInterpreter)
{
    sqInt ok;

	interpreterProxy = anInterpreter;
	ok = ((interpreterProxy->majorVersion()) == (VM_PROXY_MAJOR))
	 && ((interpreterProxy->minorVersion()) >= (VM_PROXY_MINOR));
	if (ok) {
		
#if !defined(SQUEAK_BUILTIN_PLUGIN)
		booleanValueOf = interpreterProxy->booleanValueOf;
		failed = interpreterProxy->failed;
		fetchIntegerofObject = interpreterProxy->fetchIntegerofObject;
		fetchPointerofObject = interpreterProxy->fetchPointerofObject;
		firstIndexableField = interpreterProxy->firstIndexableField;
		floatValueOf = interpreterProxy->floatValueOf;
		isArray = interpreterProxy->isArray;
		isPointers = interpreterProxy->isPointers;
		isWords = interpreterProxy->isWords;
		methodArgumentCount = interpreterProxy->methodArgumentCount;
		methodReturnInteger = interpreterProxy->methodReturnInteger;
		nilObject = interpreterProxy->nilObject;
		pop = interpreterProxy->pop;
		popRemappableOop = interpreterProxy->popRemappableOop;
		positive32BitIntegerFor = interpreterProxy->positive32BitIntegerFor;
		positive32BitValueOf = interpreterProxy->positive32BitValueOf;
		primitiveFail = interpreterProxy->primitiveFail;
		pushBool = interpreterProxy->pushBool;
		pushInteger = interpreterProxy->pushInteger;
		pushRemappableOop = interpreterProxy->pushRemappableOop;
		slotSizeOf = interpreterProxy->slotSizeOf;
		stackIntegerValue = interpreterProxy->stackIntegerValue;
		stackObjectValue = interpreterProxy->stackObjectValue;
		stackValue = interpreterProxy->stackValue;
		storePointerofObjectwithValue = interpreterProxy->storePointerofObjectwithValue;
		topRemappableOop = interpreterProxy->topRemappableOop;
#endif /* !defined(SQUEAK_BUILTIN_PLUGIN) */
	}
	return ok;
}

	/* B3DAcceleratorPlugin>>#shutdownModule */
EXPORT(sqInt)
shutdownModule(void)
{
	return b3dxShutdown();
}


/*	Load an Array of B3DPrimitiveLights from the given stack index */

	/* B3DAcceleratorPlugin>>#stackLightArrayValue: */
static sqInt
stackLightArrayValue(sqInt stackIndex)
{
    sqInt array;
    sqInt arraySize;
    sqInt i;
    sqInt oop;

	array = stackValue(stackIndex);
	if (array == (nilObject())) {
		return null;
	}
	if (!(isArray(array))) {
		return primitiveFail();
	}
	arraySize = slotSizeOf(array);
	for (i = 0; i < arraySize; i += 1) {
		oop = fetchPointerofObject(i, array);
		if (!((isWords(oop))
			 && ((slotSizeOf(oop)) == 32))) {
			return primitiveFail();
		}
	}
	return array;
}


/*	Load a B3DMaterial from the given stack index */

	/* B3DAcceleratorPlugin>>#stackMaterialValue: */
static void *
stackMaterialValue(sqInt stackIndex)
{
    sqInt oop;

	oop = stackObjectValue(stackIndex);
	if (oop == null) {
		return null;
	}
	if (oop == (nilObject())) {
		return null;
	}
	if ((isWords(oop))
	 && ((slotSizeOf(oop)) == 17)) {
		return firstIndexableField(oop);
	}
	return null;
}


/*	Load a 4x4 transformation matrix from the interpreter stack.
	Return a pointer to the matrix data if successful, nil otherwise. */

	/* B3DAcceleratorPlugin>>#stackMatrix: */
static void*
stackMatrix(sqInt index)
{
    sqInt oop;

	oop = stackObjectValue(index);
	if (oop == null) {
		return null;
	}
	if ((isWords(oop))
	 && ((slotSizeOf(oop)) == 16)) {
		return firstIndexableField(oop);
	}
	return null;
}


/*	Load a primitive index array from the interpreter stack.
	If aBool is true then check that all the indexes are in the range
	(1,maxIndex). Return a pointer to the index data if successful, nil
	otherwise. 
 */

	/* B3DAcceleratorPlugin>>#stackPrimitiveIndexArray:ofSize:validate:forVertexSize: */
static void*
stackPrimitiveIndexArrayofSizevalidateforVertexSize(sqInt stackIndex, sqInt nItems, sqInt aBool, sqInt maxIndex)
{
    sqInt i;
    int *idxPtr;
    int index;
    sqInt oop;
    sqInt oopSize;

	oop = stackObjectValue(stackIndex);
	if (oop == null) {
		return null;
	}
	if (!(isWords(oop))) {
		return null;
	}
	oopSize = slotSizeOf(oop);
	if (oopSize < nItems) {
		return null;
	}
	idxPtr = ((int *) (firstIndexableField(oop)));
	if (aBool) {
		for (i = 0; i < nItems; i += 1) {
			index = idxPtr[i];
			if ((index < 0)
			 || (index > maxIndex)) {
				return null;
			}
		}
	}
	return idxPtr;
}


/*	Load a primitive vertex array from the interpreter stack.
	Return a pointer to the vertex data if successful, nil otherwise. */

	/* B3DAcceleratorPlugin>>#stackPrimitiveVertexArray:ofSize: */
static void*
stackPrimitiveVertexArrayofSize(sqInt index, sqInt nItems)
{
    sqInt oop;
    sqInt oopSize;

	oop = stackObjectValue(index);
	if (oop == null) {
		return null;
	}
	if (isWords(oop)) {
		oopSize = slotSizeOf(oop);
		if (((oopSize >= nItems) * 16)
		 && ((oopSize % 16) == 0)) {
			return firstIndexableField(oop);
		}
	}
	return null;
}


#ifdef SQUEAK_BUILTIN_PLUGIN

static char _m[] = "B3DAcceleratorPlugin";
void* B3DAcceleratorPlugin_exports[][3] = {
	{(void*)_m, "getModuleName", (void*)getModuleName},
	{(void*)_m, "initialiseModule", (void*)initialiseModule},
	{(void*)_m, "primitiveAllocateTexture\000\000", (void*)primitiveAllocateTexture},
	{(void*)_m, "primitiveClearDepthBuffer\000\000", (void*)primitiveClearDepthBuffer},
	{(void*)_m, "primitiveClearViewport\000\000", (void*)primitiveClearViewport},
	{(void*)_m, "primitiveCompositeTexture\000\000", (void*)primitiveCompositeTexture},
	{(void*)_m, "primitiveCreateRenderer\000\000", (void*)primitiveCreateRenderer},
	{(void*)_m, "primitiveCreateRendererFlags\000\000", (void*)primitiveCreateRendererFlags},
	{(void*)_m, "primitiveDestroyRenderer\000\000", (void*)primitiveDestroyRenderer},
	{(void*)_m, "primitiveDestroyTexture\000\000", (void*)primitiveDestroyTexture},
	{(void*)_m, "primitiveDrawArrays\000\001", (void*)primitiveDrawArrays},
	{(void*)_m, "primitiveDrawElements\000\001", (void*)primitiveDrawElements},
	{(void*)_m, "primitiveDrawRangeElements\000\001", (void*)primitiveDrawRangeElements},
	{(void*)_m, "primitiveEnableDrawRangeChecks\000\377", (void*)primitiveEnableDrawRangeChecks},
	{(void*)_m, "primitiveFinishRenderer\000\000", (void*)primitiveFinishRenderer},
	{(void*)_m, "primitiveFlushRenderer\000\000", (void*)primitiveFlushRenderer},
	{(void*)_m, "primitiveGetIntProperty\000\000", (void*)primitiveGetIntProperty},
	{(void*)_m, "primitiveGetRendererColorMasks\000\000", (void*)primitiveGetRendererColorMasks},
	{(void*)_m, "primitiveGetRendererSurfaceDepth\000\000", (void*)primitiveGetRendererSurfaceDepth},
	{(void*)_m, "primitiveGetRendererSurfaceHandle\000\000", (void*)primitiveGetRendererSurfaceHandle},
	{(void*)_m, "primitiveGetRendererSurfaceHeight\000\000", (void*)primitiveGetRendererSurfaceHeight},
	{(void*)_m, "primitiveGetRendererSurfaceWidth\000\000", (void*)primitiveGetRendererSurfaceWidth},
	{(void*)_m, "primitiveIsOverlayRenderer\000\000", (void*)primitiveIsOverlayRenderer},
	{(void*)_m, "primitiveRendererVersion\000\377", (void*)primitiveRendererVersion},
	{(void*)_m, "primitiveRenderVertexBuffer\000\001", (void*)primitiveRenderVertexBuffer},
	{(void*)_m, "primitiveSetBufferRect\000\000", (void*)primitiveSetBufferRect},
	{(void*)_m, "primitiveSetFog\000\000", (void*)primitiveSetFog},
	{(void*)_m, "primitiveSetIntProperty\000\000", (void*)primitiveSetIntProperty},
	{(void*)_m, "primitiveSetLights\000\001", (void*)primitiveSetLights},
	{(void*)_m, "primitiveSetMaterial\000\000", (void*)primitiveSetMaterial},
	{(void*)_m, "primitiveSetTransform\000\000", (void*)primitiveSetTransform},
	{(void*)_m, "primitiveSetVerboseLevel\000\000", (void*)primitiveSetVerboseLevel},
	{(void*)_m, "primitiveSetViewport\000\000", (void*)primitiveSetViewport},
	{(void*)_m, "primitiveSwapRendererBuffers\000\000", (void*)primitiveSwapRendererBuffers},
	{(void*)_m, "primitiveTextureByteSex\000\000", (void*)primitiveTextureByteSex},
	{(void*)_m, "primitiveTextureDepth\000\000", (void*)primitiveTextureDepth},
	{(void*)_m, "primitiveTextureGetColorMasks\000\000", (void*)primitiveTextureGetColorMasks},
	{(void*)_m, "primitiveTextureSurfaceHandle\000\000", (void*)primitiveTextureSurfaceHandle},
	{(void*)_m, "primitiveTextureUpload\000\002", (void*)primitiveTextureUpload},
	{(void*)_m, "setInterpreter", (void*)setInterpreter},
	{(void*)_m, "shutdownModule\000\377", (void*)shutdownModule},
	{NULL, NULL, NULL}
};

#else /* ifdef SQ_BUILTIN_PLUGIN */

signed char primitiveAllocateTextureAccessorDepth = 0;
signed char primitiveClearDepthBufferAccessorDepth = 0;
signed char primitiveClearViewportAccessorDepth = 0;
signed char primitiveCompositeTextureAccessorDepth = 0;
signed char primitiveCreateRendererAccessorDepth = 0;
signed char primitiveCreateRendererFlagsAccessorDepth = 0;
signed char primitiveDestroyRendererAccessorDepth = 0;
signed char primitiveDestroyTextureAccessorDepth = 0;
signed char primitiveDrawArraysAccessorDepth = 1;
signed char primitiveDrawElementsAccessorDepth = 1;
signed char primitiveDrawRangeElementsAccessorDepth = 1;
signed char primitiveFinishRendererAccessorDepth = 0;
signed char primitiveFlushRendererAccessorDepth = 0;
signed char primitiveGetIntPropertyAccessorDepth = 0;
signed char primitiveGetRendererColorMasksAccessorDepth = 0;
signed char primitiveGetRendererSurfaceDepthAccessorDepth = 0;
signed char primitiveGetRendererSurfaceHandleAccessorDepth = 0;
signed char primitiveGetRendererSurfaceHeightAccessorDepth = 0;
signed char primitiveGetRendererSurfaceWidthAccessorDepth = 0;
signed char primitiveIsOverlayRendererAccessorDepth = 0;
signed char primitiveRenderVertexBufferAccessorDepth = 1;
signed char primitiveSetBufferRectAccessorDepth = 0;
signed char primitiveSetFogAccessorDepth = 0;
signed char primitiveSetIntPropertyAccessorDepth = 0;
signed char primitiveSetLightsAccessorDepth = 1;
signed char primitiveSetMaterialAccessorDepth = 0;
signed char primitiveSetTransformAccessorDepth = 0;
signed char primitiveSetVerboseLevelAccessorDepth = 0;
signed char primitiveSetViewportAccessorDepth = 0;
signed char primitiveSwapRendererBuffersAccessorDepth = 0;
signed char primitiveTextureByteSexAccessorDepth = 0;
signed char primitiveTextureDepthAccessorDepth = 0;
signed char primitiveTextureGetColorMasksAccessorDepth = 0;
signed char primitiveTextureSurfaceHandleAccessorDepth = 0;
signed char primitiveTextureUploadAccessorDepth = 2;

#endif /* ifdef SQ_BUILTIN_PLUGIN */
