PDA

View Full Version : OpenGL Overlay in Maya Viewports?


paulwconnor
04-06-2004, 10:19 PM
Hi,

I was wondering if anyone could suggest the best way of overlaying an OpenGL buffer over standard Maya viewports? (probably using API)>

I'm reasonably sure this is possible (I noticed the MPxGlBuffer class in the API Docs), but could do with some tips as to how to use this in the overlay process?

If possible, perhaps someone could write a simple command which creates a GL overlay, and (say) renders a coloured triangle (or something simple) to the viewport overlay?

Thanks in advance for your help!

Paul.
:hmm:

Hugh
04-06-2004, 11:19 PM
I'll have to check some code when I get into work tomorrow, but yeah, it's pretty easy....

I hacked around with someone's code to get it to draw black bars around the frame to frame it properly....

I seem to remember that it was as easy as making GL calls....

I'll check the code and write up some examples...

paulwconnor
04-07-2004, 12:26 AM
Thanks, Hugh!

Hugh
04-07-2004, 11:25 AM
Okay... a brief outline for how to draw to the viewport:

This assumes a member variable: 'bool drawState' that is initialised to false in the constructor....


void myNode::draw(M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status)
{
double width = view.portWidth();
double height = view.portHeight();

view.beginGL();

glPushAttrib(GL_ALL_ATTRIB_BITS);
glClear(GL_CURRENT_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)width, 0.0, (GLdouble)height);
glMatrixMode(GL_MODELVIEW);
glShadeModel(GL_SMOOTH);

// Do any OpenGL drawing here....

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

if(!drawState)
{
#ifndef _WIN32
glXSwapBuffers(view.display(), view.window());
#else
SwapBuffers(view.deviceContext());
#endif

drawState = true;
}

glPopAttrib();
view.endGL();
}

paulwconnor
04-07-2004, 05:44 PM
Thanks, Hugh.

So, is myNode::draw a function which I define? And what's 'myNode'? ... and where do I call this function from?

Paul.

Hugh
04-07-2004, 06:20 PM
Ahh - you will want to look into Maya API programming....

In this case, myNode is derived from MPxLocatorNode

draw() is called automatically when the node needs to be drawn...

paulwconnor
04-07-2004, 06:24 PM
Okay, thanks Hugh!

djwarder
04-10-2004, 04:32 PM
Would this page help at all?

http://www.ewertb.com/maya/api/api.php?howto=07

Dan

CGTalk Moderation
01-18-2006, 12:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.