jackinoob
06-08-2006, 06:48 PM
Hi all. I am trying to create a window in MEL, then call a plugin to draw a rectangle in that window using OpenGL. The following plugin loads and runs correctly, no errors, except it does not draw my OpenGL rectangle. I may be doing this completely wrong, any ideas would be appreciated. Thanks in advance!
Here is what I have in MEL:
---------------------------
window mywin;
columnLayout;
api_gl; //calling the plugin
showWindow mywin;
---------------------------
And here is my plugin:
---------------------------
#include <windows.h>
#include <maya/MSimple.h>
#include <maya/MPxCommand.h>
#include <maya/MGlobal.h>
#include <maya/MFnPlugin.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
class mayaAPI_GL : public MPxCommand
{
public:
virtual MStatus doIt ( const MArgList& );
static void *creator() { return new mayaAPI_GL; }
};
MStatus mayaAPI_GL::doIt( const MArgList& args )
{
MStatus stat = MS::kSuccess;
MGlobal::displayInfo( "Hello ");
glColor3f(0.0, 0.0, 1.0);
glRectf(-5.0, 5.0, 5.0, -5.0); //draw the rectangle
setResult( "mayaAPI_GL hello command executed!\n" );
return stat;
}
MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, "first_try", "1.0" );
MStatus stat;
stat = plugin.registerCommand( "api_gl", mayaAPI_GL::creator );
if ( !stat )
stat.perror( "registerCommand failed");
return stat;
}
MStatus uninitializePlugin( MObject obj )
{
MFnPlugin plugin( obj );
MStatus stat;
stat = plugin.deregisterCommand( "api_gl" );
if ( !stat )
stat.perror( "deregisterCommand failed" );
return stat;
}
---------------------------
Here is what I have in MEL:
---------------------------
window mywin;
columnLayout;
api_gl; //calling the plugin
showWindow mywin;
---------------------------
And here is my plugin:
---------------------------
#include <windows.h>
#include <maya/MSimple.h>
#include <maya/MPxCommand.h>
#include <maya/MGlobal.h>
#include <maya/MFnPlugin.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
class mayaAPI_GL : public MPxCommand
{
public:
virtual MStatus doIt ( const MArgList& );
static void *creator() { return new mayaAPI_GL; }
};
MStatus mayaAPI_GL::doIt( const MArgList& args )
{
MStatus stat = MS::kSuccess;
MGlobal::displayInfo( "Hello ");
glColor3f(0.0, 0.0, 1.0);
glRectf(-5.0, 5.0, 5.0, -5.0); //draw the rectangle
setResult( "mayaAPI_GL hello command executed!\n" );
return stat;
}
MStatus initializePlugin( MObject obj )
{
MFnPlugin plugin( obj, "first_try", "1.0" );
MStatus stat;
stat = plugin.registerCommand( "api_gl", mayaAPI_GL::creator );
if ( !stat )
stat.perror( "registerCommand failed");
return stat;
}
MStatus uninitializePlugin( MObject obj )
{
MFnPlugin plugin( obj );
MStatus stat;
stat = plugin.deregisterCommand( "api_gl" );
if ( !stat )
stat.perror( "deregisterCommand failed" );
return stat;
}
---------------------------
