Skip to content

Instantly share code, notes, and snippets.

@SEVEZ
Created August 29, 2015 11:31
Show Gist options
  • Save SEVEZ/a1d70ebf545896aec9aa to your computer and use it in GitHub Desktop.
Save SEVEZ/a1d70ebf545896aec9aa to your computer and use it in GitHub Desktop.
get openGL screen size
def getScreenRes(panel):
m3v = OpenMayaUI.M3dView.active3dView()
OpenMayaUI.M3dView.getM3dViewFromModelPanel(panel, m3v)
xPtr = OpenMaya.MScriptUtil().asUintPtr()
yPtr = OpenMaya.MScriptUtil().asUintPtr()
widthPtr = OpenMaya.MScriptUtil().asUintPtr()
heightPtr = OpenMaya.MScriptUtil().asUintPtr()
m3v.viewport(xPtr, yPtr, widthPtr, heightPtr)
viewWidth = OpenMaya.MScriptUtil().getUint( widthPtr )
viewHeight = OpenMaya.MScriptUtil().getUint( heightPtr )
return (float(viewWidth), float(viewHeight))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment