Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

openmaya stencil buffer question...

0 REPLIES 0
Reply
Message 1 of 1
lihhh
305 Views, 0 Replies

openmaya stencil buffer question...

does anyone have experience with the openmaya opengl.

I am trying to use the openmaya api and the stencilmask but doesn't seem to work properly.

 

the case following you should be able to see a green tringle.

but is the just a square.

 

tried in plugin just a node in the draw function that wasn't the beginXorDrawing same problem.

tried on an normal pyopengl works as what I expected.

did I miss something that needs to be setup in maya??

 

 

import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
import maya.OpenMayaRender as OpenMayaRender
import maya.OpenMayaUI as OpenMayaUI


glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
glFT = glRenderer.glFunctionTable()

activeView = OpenMayaUI.M3dView().active3dView()
activeView.refresh(False,True)
activeView.updateViewingParameters()
activeView.beginXorDrawing(False)

glFT.glClearColor(0.0, 0.0, 0.0, 0.0)
glFT.glClear(OpenMayaRender.MGL_STENCIL_BUFFER_BIT)
glFT.glClear(OpenMayaRender.MGL_DEPTH_BUFFER_BIT)
glFT.glClear(OpenMayaRender.MGL_COLOR_BUFFER_BIT)

glFT.glEnable(OpenMayaRender.MGL_STENCIL_TEST)
glFT.glColorMask(0,0,0,0)
glFT.glDepthMask(0)
glFT.glStencilMask(1)
glFT.glStencilFunc(OpenMayaRender.MGL_NEVER,0,0xFF)
#stencil always fail... running into OpenMayaRender.MGL_REPLACE
#sfail,dpfail,dppass
glFT.glStencilOp(OpenMayaRender.MGL_REPLACE,OpenMayaRender.MGL_KEEP,OpenMayaRender.MGL_KEEP)        
#triangle
glFT.glColor3f(1,0,0)
glFT.glBegin(OpenMayaRender.MGL_POLYGON)
glFT.glVertex3i(-1, -1, 0)
glFT.glVertex3i(1, -1, 0)
glFT.glVertex3i(0, 1, 0)
glFT.glEnd()
#should have a triangle in stencil buffer

glFT.glStencilMask(1)
glFT.glDepthMask(1)
glFT.glColorMask(1,1,1,1)
#check if stencil buffer is one pass
glFT.glStencilFunc(OpenMayaRender.MGL_EQUAL,1,0xFF)
glFT.glStencilOp(OpenMayaRender.MGL_REPLACE,OpenMayaRender.MGL_KEEP,OpenMayaRender.MGL_KEEP)

#square
glFT.glColor3f( 0,1,0)
glFT.glBegin(OpenMayaRender.MGL_POLYGON)
glFT.glVertex3i(3, 3, 0)
glFT.glVertex3i(-3, 3, 0)
glFT.glVertex3i(-3, -3, 0)
glFT.glVertex3i(3, -3, 0)                      
glFT.glEnd()
glFT.glDepthFunc(OpenMayaRender.MGL_LESS)

activeView.endXorDrawing()

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report