//- // ========================================================================== // Copyright (C) 2005 ATI Technologies Inc. All rights reserved. // // Copyright (C) 1995 - 2005 Alias Systems Corp. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files are provided by Alias // Systems Corp. ("Alias") and/or its licensors for the exclusive use of the // Customer (as defined in the Alias Software License Agreement that // accompanies this Alias software). Such Customer has the right to use, // modify, and incorporate the Data into other products and to distribute such // products for use by end-users. // // THE DATA IS PROVIDED "AS IS". ALIAS HEREBY DISCLAIMS ALL WARRANTIES // RELATING TO THE DATA, INCLUDING, WITHOUT LIMITATION, ANY AND ALL EXPRESS OR // IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. IN NO EVENT SHALL ALIAS BE LIABLE FOR ANY DAMAGES // WHATSOEVER, WHETHER DIRECT, INDIRECT, SPECIAL, OR PUNITIVE, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, OR IN EQUITY, // ARISING OUT OF ACCESS TO, USE OF, OR RELIANCE UPON THE DATA. // ========================================================================== //+ #include #include #include #include #include "GLSLShaderNode.h" #include "fxManagerCmd.h" #include #if MAYA_API_VERSION >= 700 #define _HARDWARE_RENDERER_AVAILABLE_ #include #include #include #include #endif // // static variables for holding the callback IDs // MCallbackId openCallback; MCallbackId importCallback; MStatus initializePlugin( MObject obj ) // // Description: // this method is called when the plug-in is loaded into Maya. It // registers all of the services that this plug-in provides with // Maya. // // Arguments: // obj - a handle to the plug-in object (use MFnPlugin to access it) // { MStatus status; #ifdef _HARDWARE_RENDERER_AVAILABLE_ // The following code is only used on Maya versions 7.0 and // later. It is used to query for proper extension support at // start up, so that the plug-in will fail to load rather than // fail to render. MHardwareRenderer *pRenderer = MHardwareRenderer::theRenderer(); if (pRenderer) { const MString & backEndStr = pRenderer->backEndString(); unsigned int width = 64, height = 64; MStatus status = pRenderer->makeSwatchContextCurrent( backEndStr, width, height ); if (status != MStatus::kSuccess) { MGlobal::displayError(MString("Unqualified video card : Offscreen contexts not supported. Ashli Shader plugin will not be loaded.")); return MStatus::kFailure; } else { if (!InitializeExtensions()) { MGlobal::displayError(MString("Unqualified video card : Required OpenGL extensions not present. Ashli Shader plugin will not be loaded.")); return MStatus::kFailure; } } } else { MGlobal::displayError(MString("Unqualified video card. Ashli Shader plugin will not be loaded.")); return MStatus::kFailure; } const MString& swatchName = MHWShaderSwatchGenerator::initialize(); MString swatchClassification; // Allow an environment variable to override usage of swatch // rendering. const char *ashliEnvVar = getenv("ASHLI_SWATCH_RENDERING"); #ifdef WIN32 if (!ashliEnvVar) swatchClassification = ":swatch/" + swatchName; else { if (ashliEnvVar != "0") swatchClassification = ":swatch/" + swatchName; } #else if (ashliEnvVar == "1") { swatchClassification = ":swatch/" + swatchName; } #endif const MString UserClassify( "shader/surface/utility/" + swatchClassification ); #else const MString UserClassify( "shader/surface/utility"); #endif MFnPlugin plugin( obj, "ATI", "6.5", "Any"); //handle info banner // Add plug-in feature registration here // //register the shader node CHECK_MSTATUS( plugin.registerNode("AshliShader", glslShaderNode::sId, glslShaderNode::creator, glslShaderNode::initialize, MPxNode::kHwShaderNode, &UserClassify)); //register a helper command for querying shader information plugin.registerCommand( "effectManager", fxManagerCmd::creator, fxManagerCmd::mySyntax); //handle scene callback registration (on load, on save, etc) openCallback = MSceneMessage::addCallback(MSceneMessage::kAfterOpen, glslShaderNode::rejigShaders); importCallback = MSceneMessage::addCallback(MSceneMessage::kAfterImport, glslShaderNode::rejigShaders); return status; } MStatus uninitializePlugin( MObject obj ) // // Description: // this method is called when the plug-in is unloaded from Maya. It // deregisters all of the services that it was providing. // // Arguments: // obj - a handle to the plug-in object (use MFnPlugin to access it) // { MStatus status; MFnPlugin plugin( obj ); //disconnect callbacks // Add plug-in feature deregistration here // MSceneMessage::removeCallback( openCallback); MSceneMessage::removeCallback( importCallback); //deregister the shader node CHECK_MSTATUS(plugin.deregisterNode(glslShaderNode::sId)); //deregister any additional commands return status; }