#define WIN32_LEAN_AND_MEAN
#define STRICT

#include <windows.h>
#include <windowsx.h>
#include <winuser.h>
#include <winsock2.h>
#include <commctrl.h>
#include <commdlg.h>
#include <mmsystem.h>
#include <commctrl.h>
#include <shlwapi.h>

#include <io.h>
#include <conio.h>
#include <commctrl.h>
#include <shlwapi.h>

#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <math.h>

#define _USE_BETTLEJUICE_


#if defined(_USE_BETTLEJUICE_)

#include "beetlejuice.h"

__FRiOption FRiOption;
__FRiOptionV FRiOptionV;

__FRiBegin FRiBegin;
__FRiEnd FRiEnd;
__FRiFrameBegin FRiFrameBegin;
__FRiFrameEnd FRiFrameEnd;
__FRiWorldBegin FRiWorldBegin;
__FRiWorldEnd FRiWorldEnd;

__FRiFormat FRiFormat;
__FRiFrameAspectRatio FRiFrameAspectRatio;
__FRiProjection FRiProjection;
__FRiProjectionV FRiProjectionV;
__FRiScreenWindow FRiScreenWindow;
__FRiCropWindow FRiCropWindow;
__FRiClipping FRiClipping;
__FRiClippingPlane FRiClippingPlane;
__FRiDepthOfField FRiDepthOfField;
__FRiShutter FRiShutter;
__FRiDisplay FRiDisplay;
__FRiDisplayV FRiDisplayV;

__FRiExposure FRiExposure;
__FRiAAExposure FRiAAExposure;

__FRiQuantize FRiQuantize;
__FRiDither FRiDither;


__FRiPixelSamples FRiPixelSamples;
__FRiPixelVariance FRiPixelVariance;
__FRiPixelFilter FRiPixelFilter;
__FRiGaussianFilter FRiGaussianFilter;
__FRiBoxFilter FRiBoxFilter;
__FRiAreaFilter FRiAreaFilter;
__FRiTriangleFilter FRiTriangleFilter;
__FRiCatmullRomFilter FRiCatmullRomFilter;
__FRiSincFilter FRiSincFilter;
__FRiDiskFilter FRiDiskFilter;
__FRiBesselFilter FRiBesselFilter;

__FRiGetContext FRiGetContext;
__FRiContext FRiContext;

__FRiIdentity FRiIdentity;
__FRiTransform FRiTransform;
__FRiConcatTransform FRiConcatTransform;
__FRiPerspective FRiPerspective;
__FRiTranslate FRiTranslate;
__FRiRotate FRiRotate;
__FRiRotateQuat FRiRotateQuat;
__FRiScale FRiScale;
__FRiTransformBegin FRiTransformBegin;
__FRiTransformEnd FRiTransformEnd;
__FRiCoordinateSystem FRiCoordinateSystem;
__FRiCoordSysTransform FRiCoordSysTransform;
__FRiTransformPoints FRiTransformPoints;
__FRiOrientation FRiOrientation;
__FRiReverseOrientation FRiReverseOrientation;


__FRiLightSource FRiLightSource;
__FRiLightSourceV FRiLightSourceV;
__FRiIlluminate FRiIlluminate;
__FRiLightSetParams FRiLightSetParams;
__FRiLightSetParamsV FRiLightSetParamsV;


__FRiPolygon FRiPolygon;
__FRiPolygonV FRiPolygonV;
__FRiPointsPolygons FRiPointsPolygons;
__FRiPointsPolygonsV FRiPointsPolygonsV;

__FRiPointsTriangles FRiPointsTriangles;
__FRiPointsTrianglesV FRiPointsTrianglesV;
__FRiReplacePointsTrianglesV FRiReplacePointsTrianglesV;

__FRiSphere FRiSphere;
__FRiSphereV FRiSphereV;


__FRiGeometry FRiGeometry;
__FRiGeometryV FRiGeometryV;

__FRiSides FRiSides;

__FRiMapChannel FRiMapChannel;
__FRiUserVertChannel FRiUserVertChannel;
__FRiUserFaceChannel FRiUserFaceChannel;


__FRiAttributeBegin FRiAttributeBegin;
__FRiAttributeEnd FRiAttributeEnd;
__FRiAttribute FRiAttribute;
__FRiAttributeV FRiAttributeV;
__FRiSelectForBaking FRiSelectForBaking;

__FRiObjectBegin FRiObjectBegin;
__FRiObjectEnd FRiObjectEnd;
__FRiObjectInstance FRiObjectInstance;
__FRiObjectDelete FRiObjectDelete;

__FRiMotionBegin  FRiMotionBegin;
__FRiMotionBeginV FRiMotionBeginV;
__FRiMotionEnd FRiMotionEnd;
__FRiSetMotionSample FRiSetMotionSample;
__FRiSetMotionSampleV FRiSetMotionSampleV;

__FRiObjectUserData FRiObjectUserData;

__FRiColor FRiColor;
__FRiOpacity FRiOpacity;

__FRiSurface FRiSurface;
__FRiSurfaceV FRiSurfaceV;
__FRiSurfaceBegin FRiSurfaceBegin;
__FRiSurfaceEnd FRiSurfaceEnd;
__FRiSurfaceInstance FRiSurfaceInstance;
__FRiShader FRiShader;
__FRiShaderV FRiShaderV;
__FRiShaderInstance FRiShaderInstance;
__FRiShaderSet FRiShaderSet;
__FRiShaderSetV FRiShaderSetV;
__FRiShaderDelete FRiShaderDelete;
__FRiShaderOutputIdx FRiShaderOutputIdx;
__FRiAssignSurfaceShader FRiAssignSurfaceShader;
__FRiGetSurfaceShader FRiGetSurfaceShader;


__FRiDisplacement FRiDisplacement;
__FRiDisplacementV FRiDisplacementV;

__FRiAtmosphere FRiAtmosphere;
__FRiAtmosphereV FRiAtmosphereV;
__FRiInterior FRiInterior;
__FRiInteriorV FRiInteriorV;
__FRiExterior FRiExterior;
__FRiExteriorV FRiExteriorV;

__FRiEffect FRiEffect;
__FRiEffectV FRiEffectV;

__FRiRenderElement FRiRenderElement;
__FRiRenderElementV FRiRenderElementV;

__FRiSetPluginPath FRiSetPluginPath;
__FRiUnloadPlugins FRiUnloadPlugins;


HINSTANCE hinstLib = NULL;

BOOL fnLoadFinalRender()
{
// = (__)GetProcAddress(hinstLib, "");

 hinstLib = LoadLibrary("fri.dll");

	if(hinstLib == NULL)
	return FALSE;

FRiOption = (__FRiOption)GetProcAddress(hinstLib, "FRiOption");
FRiOptionV = (__FRiOptionV)GetProcAddress(hinstLib, "FRiOptionV");


FRiBegin = (__FRiBegin)GetProcAddress(hinstLib, "FRiBegin");
FRiEnd = (__FRiEnd)GetProcAddress(hinstLib, "FRiEnd");
FRiFrameBegin = (__FRiFrameBegin)GetProcAddress(hinstLib, "FRiFrameBegin");
FRiFrameEnd = (__FRiFrameEnd)GetProcAddress(hinstLib, "FRiFrameEnd");
FRiWorldBegin = (__FRiWorldBegin)GetProcAddress(hinstLib, "FRiWorldBegin");
FRiWorldEnd = (__FRiWorldEnd)GetProcAddress(hinstLib, "FRiWorldEnd");

FRiFormat  = (__FRiFormat)GetProcAddress(hinstLib, "FRiFormat");
FRiFrameAspectRatio= (__FRiFrameAspectRatio)GetProcAddress(hinstLib, "FRiFrameAspectRatio");
FRiProjection = (__FRiProjection)GetProcAddress(hinstLib, "FRiProjection");
FRiProjectionV = (__FRiProjectionV)GetProcAddress(hinstLib, "FRiProjectionV");
FRiScreenWindow = (__FRiScreenWindow)GetProcAddress(hinstLib, "FRiScreenWindow");
FRiCropWindow = (__FRiCropWindow)GetProcAddress(hinstLib, "FRiCropWindow");
FRiClipping = (__FRiClipping)GetProcAddress(hinstLib, "FRiClipping");
FRiClippingPlane = (__FRiClippingPlane)GetProcAddress(hinstLib, "FRiClippingPlane");
FRiDepthOfField = (__FRiDepthOfField)GetProcAddress(hinstLib, "FRiDepthOfField");
FRiShutter = (__FRiShutter)GetProcAddress(hinstLib, "FRiShutter");
FRiDisplay = (__FRiDisplay)GetProcAddress(hinstLib, "FRiDisplay");
FRiDisplayV = (__FRiDisplayV)GetProcAddress(hinstLib, "FRiDisplayV");

FRiExposure = (__FRiExposure)GetProcAddress(hinstLib, "FRiExposure");
FRiAAExposure = (__FRiAAExposure)GetProcAddress(hinstLib, "FRiAAExposure");


FRiQuantize = (__FRiQuantize)GetProcAddress(hinstLib, "FRiQuantize");
FRiDither = (__FRiDither)GetProcAddress(hinstLib, "FRiDither");

FRiPixelSamples = (__FRiPixelSamples)GetProcAddress(hinstLib, "FRiPixelSamples");
FRiPixelVariance = (__FRiPixelVariance)GetProcAddress(hinstLib, "FRiPixelVariance");
FRiPixelFilter = (__FRiPixelFilter)GetProcAddress(hinstLib, "FRiPixelFilter");
FRiGaussianFilter = (__FRiGaussianFilter)GetProcAddress(hinstLib, "FRiGaussianFilter");
FRiBoxFilter = (__FRiBoxFilter)GetProcAddress(hinstLib, "FRiBoxFilter");
FRiAreaFilter = (__FRiAreaFilter)GetProcAddress(hinstLib, "FRiAreaFilter");
FRiTriangleFilter = (__FRiTriangleFilter)GetProcAddress(hinstLib, "FRiTriangleFilter");
FRiCatmullRomFilter = (__FRiCatmullRomFilter)GetProcAddress(hinstLib, "FRiCatmullRomFilter");
FRiSincFilter = (__FRiSincFilter)GetProcAddress(hinstLib, "FRiSincFilter");
FRiDiskFilter = (__FRiDiskFilter)GetProcAddress(hinstLib, "FRiDiskFilter");
FRiBesselFilter = (__FRiBesselFilter)GetProcAddress(hinstLib, "FRiBesselFilter");

FRiGetContext = (__FRiGetContext)GetProcAddress(hinstLib, "FRiGetContext");
FRiContext = (__FRiContext)GetProcAddress(hinstLib, "FRiContext");

FRiIdentity = (__FRiIdentity)GetProcAddress(hinstLib, "FRiIdentity");
FRiTransform = (__FRiTransform)GetProcAddress(hinstLib, "FRiTransform");
FRiConcatTransform = (__FRiConcatTransform)GetProcAddress(hinstLib, "FRiConcatTransform");
FRiPerspective = (__FRiPerspective)GetProcAddress(hinstLib, "FRiPerspective");
FRiTranslate = (__FRiTranslate)GetProcAddress(hinstLib, "FRiTranslate");
FRiRotate = (__FRiRotate)GetProcAddress(hinstLib, "FRiRotate");
FRiRotateQuat = (__FRiRotateQuat)GetProcAddress(hinstLib, "FRiRotateQuat");
FRiScale = (__FRiScale)GetProcAddress(hinstLib, "FRiScale");
FRiTransformBegin = (__FRiTransformBegin)GetProcAddress(hinstLib, "FRiTransformBegin");
FRiTransformEnd = (__FRiTransformEnd)GetProcAddress(hinstLib, "FRiTransformEnd");
FRiCoordinateSystem = (__FRiCoordinateSystem)GetProcAddress(hinstLib, "FRiCoordinateSystem");
FRiCoordSysTransform = (__FRiCoordSysTransform)GetProcAddress(hinstLib, "FRiCoordSysTransform");
FRiTransformPoints = (__FRiTransformPoints)GetProcAddress(hinstLib, "FRiTransformPoints");
FRiOrientation = (__FRiOrientation)GetProcAddress(hinstLib, "FRiOrientation");
FRiReverseOrientation = (__FRiReverseOrientation)GetProcAddress(hinstLib, "FRiReverseOrientation");

// Lights
FRiLightSource = (__FRiLightSource)GetProcAddress(hinstLib, "FRiLightSource");
FRiLightSourceV = (__FRiLightSourceV)GetProcAddress(hinstLib, "FRiLightSourceV");
FRiIlluminate = (__FRiIlluminate)GetProcAddress(hinstLib, "FRiIlluminate");
FRiLightSetParams = (__FRiLightSetParams)GetProcAddress(hinstLib, "FRiLightSetParams");
FRiLightSetParamsV = (__FRiLightSetParamsV)GetProcAddress(hinstLib, "FRiLightSetParamsV");

// Geometry
FRiPolygon = (__FRiPolygon)GetProcAddress(hinstLib, "FRiPolygon");
FRiPolygonV = (__FRiPolygonV)GetProcAddress(hinstLib, "FRiPolygonV");
FRiPointsPolygons = (__FRiPointsPolygons)GetProcAddress(hinstLib, "FRiPointsPolygons");
FRiPointsPolygonsV = (__FRiPointsPolygonsV)GetProcAddress(hinstLib, "FRiPointsPolygonsV");
// special FAST methods


FRiPointsTriangles = (__FRiPointsTriangles)GetProcAddress(hinstLib, "FRiPointsTriangles");
FRiPointsTrianglesV = (__FRiPointsTrianglesV)GetProcAddress(hinstLib, "FRiPointsTrianglesV");
FRiReplacePointsTrianglesV = (__FRiReplacePointsTrianglesV)GetProcAddress(hinstLib, "FRiReplacePointsTrianglesV");

// primitives

FRiSphere = (__FRiSphere)GetProcAddress(hinstLib, "FRiSphere");
FRiSphereV = (__FRiSphereV)GetProcAddress(hinstLib, "FRiSphereV");

// geometry shader support
FRiGeometry = (__FRiGeometry)GetProcAddress(hinstLib, "FRiGeometry");
FRiGeometryV = (__FRiGeometryV)GetProcAddress(hinstLib, "FRiGeometryV");

// 1-side, 2-side or flip options
FRiSides = (__FRiSides)GetProcAddress(hinstLib, "FRiSides");

// mapping channels extension

FRiMapChannel = (__FRiMapChannel)GetProcAddress(hinstLib, "FRiMapChannel");
FRiUserVertChannel = (__FRiUserVertChannel)GetProcAddress(hinstLib, "FRiUserVertChannel");
FRiUserFaceChannel = (__FRiUserFaceChannel)GetProcAddress(hinstLib, "FRiUserFaceChannel");

// Attributes
FRiAttributeBegin = (__FRiAttributeBegin)GetProcAddress(hinstLib, "FRiAttributeBegin");
FRiAttributeEnd = (__FRiAttributeEnd)GetProcAddress(hinstLib, "FRiAttributeEnd");
FRiAttribute = (__FRiAttribute)GetProcAddress(hinstLib, "FRiAttribute");
FRiAttributeV = (__FRiAttributeV)GetProcAddress(hinstLib, "FRiAttributeV");
FRiSelectForBaking = (__FRiSelectForBaking)GetProcAddress(hinstLib, "FRiSelectForBaking");

// Instancing
FRiObjectBegin = (__FRiObjectBegin)GetProcAddress(hinstLib, "FRiObjectBegin");
FRiObjectEnd = (__FRiObjectEnd)GetProcAddress(hinstLib, "FRiObjectEnd");
FRiObjectInstance = (__FRiObjectInstance)GetProcAddress(hinstLib, "FRiObjectInstance");
FRiObjectDelete = (__FRiObjectDelete)GetProcAddress(hinstLib, "FRiObjectDelete");

// Motion Blur
FRiMotionBegin = (__FRiMotionBegin)GetProcAddress(hinstLib, "FRiMotionBegin");
FRiMotionBeginV = (__FRiMotionBeginV)GetProcAddress(hinstLib, "FRiMotionBeginV");
FRiMotionEnd = (__FRiMotionEnd)GetProcAddress(hinstLib, "FRiMotionEnd");
FRiSetMotionSample = (__FRiSetMotionSample)GetProcAddress(hinstLib, "FRiSetMotionSample");
FRiSetMotionSampleV = (__FRiSetMotionSampleV)GetProcAddress(hinstLib, "FRiSetMotionSampleV");

// User Data
FRiObjectUserData = (__FRiObjectUserData)GetProcAddress(hinstLib, "FRiObjectUserData");

// Color 
FRiColor = (__FRiColor)GetProcAddress(hinstLib, "FRiColor");
FRiOpacity = (__FRiOpacity)GetProcAddress(hinstLib, "FRiOpacity");
// surface and shaders

FRiSurface = (__FRiSurface)GetProcAddress(hinstLib, "FRiSurface");
FRiSurfaceV = (__FRiSurfaceV)GetProcAddress(hinstLib, "FRiSurfaceV");
FRiSurfaceBegin = (__FRiSurfaceBegin)GetProcAddress(hinstLib, "FRiSurfaceBegin");
FRiSurfaceEnd = (__FRiSurfaceEnd)GetProcAddress(hinstLib, "FRiSurfaceEnd");
FRiSurfaceInstance = (__FRiSurfaceInstance)GetProcAddress(hinstLib, "FRiSurfaceInstance");
FRiShader = (__FRiShader)GetProcAddress(hinstLib, "FRiShader");
FRiShaderV = (__FRiShaderV)GetProcAddress(hinstLib, "FRiShaderV");
FRiShaderInstance = (__FRiShaderInstance)GetProcAddress(hinstLib, "FRiShaderInstance");
FRiShaderSet = (__FRiShaderSet)GetProcAddress(hinstLib, "FRiShaderSet");
FRiShaderSetV = (__FRiShaderSetV)GetProcAddress(hinstLib, "FRiShaderSetV");
FRiShaderDelete = (__FRiShaderDelete)GetProcAddress(hinstLib, "FRiShaderDelete");
FRiShaderOutputIdx = (__FRiShaderOutputIdx)GetProcAddress(hinstLib, "FRiShaderOutputIdx");
FRiAssignSurfaceShader = (__FRiAssignSurfaceShader)GetProcAddress(hinstLib, "FRiAssignSurfaceShader");
FRiGetSurfaceShader = (__FRiGetSurfaceShader)GetProcAddress(hinstLib, "FRiGetSurfaceShader");

// displacement shader

FRiDisplacement = (__FRiDisplacement)GetProcAddress(hinstLib, "FRiDisplacement");
FRiDisplacementV = (__FRiDisplacementV)GetProcAddress(hinstLib, "FRiDisplacementV");
// volume shader (atmospherics)


FRiAtmosphere = (__FRiAtmosphere)GetProcAddress(hinstLib, "FRiAtmosphere");
FRiAtmosphereV = (__FRiAtmosphereV)GetProcAddress(hinstLib, "FRiAtmosphereV");
FRiInterior = (__FRiInterior)GetProcAddress(hinstLib, "FRiInterior");
FRiInteriorV = (__FRiInteriorV)GetProcAddress(hinstLib, "FRiInteriorV");
FRiExterior = (__FRiExterior)GetProcAddress(hinstLib, "FRiExterior");
FRiExteriorV = (__FRiExteriorV)GetProcAddress(hinstLib, "FRiExteriorV");

// effects

FRiEffect = (__FRiEffect)GetProcAddress(hinstLib, "FRiEffect");
FRiEffectV = (__FRiEffectV)GetProcAddress(hinstLib, "FRiEffectV");

// render elements
FRiRenderElement = (__FRiRenderElement)GetProcAddress(hinstLib, "FRiRenderElement");
FRiRenderElementV = (__FRiRenderElementV)GetProcAddress(hinstLib, "FRiRenderElementV");

// plugins
FRiSetPluginPath = (__FRiSetPluginPath)GetProcAddress(hinstLib, "FRiSetPluginPath");
FRiUnloadPlugins = (__FRiUnloadPlugins)GetProcAddress(hinstLib, "FRiUnloadPlugins");


return TRUE;
}


#endif


// EOF