C++ API Reference
MGLFunctionTable Class Reference

This method is obsolete. More...

#include <MGLFunctionTable.h>

Public Types

enum  MGLversion {
  kMGL_Version11, kMGL_Version12, kMGL_Version121, kMGL_Version13,
  kMGL_Version14, kMGL_Version15, kMGL_Version20
}
 OpenGL versions checked. More...
 

Public Member Functions

bool extensionExists (MGLExtension extension)
 Provides information as to whether a given OpenGL extension exists. More...
 
unsigned int numTexUnits () const
 Get information about the maximum number of texture units. More...
 
unsigned int numTexInterpolants () const
 Get information about the maximum number of texture interpolants. More...
 
unsigned int numTexImageUnits () const
 Get information about the maximum number of texture image units available. More...
 
unsigned int maxTextureSize () const
 Get information about the maximum texture size. More...
 
unsigned int maxVertexAttributes () const
 Get information about the maximum number of vertex attributes available. More...
 

Friends

class MHardwareRenderer
 

Detailed Description

This method is obsolete.

Deprecated:
Please use the Viewport 2.0 device independent MHWRender interfaces instead.

The best cross platform alternative for drawing in Viewport 2.0 is via MHWRender::MVertexBuffer, MHWRender::MPxGeometryOverride, and other classes providing an abstraction from the underlying hardware API. The MHWRender::MUIDrawManager offers handy options for very simple drawing commands.

Drawing in raw OpenGL mode will still be allowed, but we recommend you use the core profile subset of the OpenGL API to ensure compatibility with future versions of Maya.

MGLFunctionTable is a utility class which provides wrappers for the basic functions in the OpenGL API.

Core functions up to OpenGL 2.0 are provided here, as well as a number of ARB/EXT and vendor specific extensions. Refer to the MGLExtension enumeration for extensions which are checked.

Please refer to an OpenGL reference for usage of the OpenGL functions provided in this wrapper class.

When using the functions provided, the standard GL* type and constant definitions to be used can be found in MGLDefinitions.h.

MGLDefinitions.h basically provides a wrapper for what would normally be found in gl.h and glext.h files.

The naming convention used in this file is to take the regular GL* definitions and add a "M" prefix. This is to avoid conflicts with existing type and constant declarations which may be found in files such as gl.h and glext.h. It is recommended that externally provided files which have GL definitions not be included in the same C++ file to avoid conflicts. Mixing GL code wusing MGLFunctionTable and external code is possible, just not recommended.

MGLFunctionTable cannot be created on its own, and must be retrieved via a method on the MHardwareRenderer class. It is possible that this class will not be available, if the hardware renderer class cannot be instantiated. This would be due to insufficient graphics hardware support.

Below is an example of initializing and using the function table to draw a simple 3-line axis. Note the usage of the definitions from MGLDefinitions such as MGL_LIGHTING versus GL_LIGHTING, and MGL_LINES and MGL_DEPTH_TEST.

#include <maya/MHardwareRenderer.h>
#include <maya/MGLFunctionTable.h>
class myClass
{
public:
MStatus initializeGL();
void drawAxis();
protected:
MGLFunctionTable *gGLFT; // Function table to use
private:
// No private members
};
myClass::initializeGL()
{
// Get a pointer to a GL function table
if (rend)
gGLFT = rend->glFunctionTable();
if (!gGLFT)
}
void
myClass::drawAxis()
{
// Draw a world space axis
//
gGLFT->glDisable(MGL_LIGHTING);
gGLFT->glBegin(MGL_LINES);
gGLFT->glColor3f( 1.0f, 0.0f, 0.0f );
gGLFT->glVertex3f( 0.0f, 0.0f, 0.0f );
gGLFT->glVertex3f( 3.0f, 0.0f, 0.0f );
gGLFT->glColor3f( 0.0f, 1.0f, 0.0f );
gGLFT->glVertex3f( 0.0f, 0.0f, 0.0f );
gGLFT->glVertex3f( 0.0f, 3.0f, 0.0f );
gGLFT->glColor3f( 0.0f, 0.0f, 1.0f );
gGLFT->glVertex3f( 0.0f, 0.0f, 0.0f );
gGLFT->glVertex3f( 0.0f, 0.0f, 3.0f );
gGLFT->glEnd();
gGLFT->glEnable(MGL_LIGHTING);
}

Here is a similar example of using the function table in Python.

# Import the module
import maya.OpenMayaRender as OpenMayaRender
# Get a renderer, then a function table
def initializeGL():
glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
glFT = glRenderer.glFunctionTable()
# Query the maximum texture size
def printMaxTextureSize():
maxTxtSize = glFT.maxTextureSize()
print maxTxtSize
# Draw an axis
def drawAxis():
glFT.glDisable(OpenMayaRender.MGL_LIGHTING)
glFT.glBegin(OpenMayaRender.MGL_LINES)
glFT.glColor3f( 1.0, 0.0, 0.0 )
glFT.glVertex3f( 0.0, 0.0, 0.0 )
glFT.glVertex3f( 3.0, 0.0, 0.0 )
glFT.glColor3f( 0.0, 1.0, 0.0 )
glFT.glVertex3f( 0.0, 0.0, 0.0 )
glFT.glVertex3f( 0.0, 3.0, 0.0 )
glFT.glColor3f( 0.0, 0.0, 1.0 )
glFT.glVertex3f( 0.0, 0.0, 0.0 )
glFT.glVertex3f( 0.0, 0.0, 3.0 )
glFT.glEnd()
glFT.glEnable(OpenMayaRender.MGL_LIGHTING)
Examples:
apiMeshShape/apiMeshSubSceneOverride.cpp, cgFx/cgfxEffectDef.cpp, cgFx/cgfxShaderNode.cpp, cgFx/cgfxTextureCache.cpp, dx11Shader/dx11Shader.cpp, gpuCache/gpuCacheGLFT.cpp, gpuCache/gpuCacheGLFT.h, hwApiTextureTest/hwRendererHelperGL.cpp, tessellatedQuad/TessellatedQuadNode.cpp, viewDX11DeviceAccess/viewDX11DeviceAccess.cpp, and viewRenderOverride/viewRenderOverrideUserOperation.cpp.

Member Enumeration Documentation

enum MGLversion

OpenGL versions checked.

Enumerator
kMGL_Version11 

GL 1.1.

kMGL_Version12 

GL 1.2.

kMGL_Version121 

GL 1.2.1.

kMGL_Version13 

GL 1.3.1.

kMGL_Version14 

GL 1.4.1.

kMGL_Version15 

GL 1.5.

kMGL_Version20 

GL 2.0.

Member Function Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN bool extensionExists ( MGLExtension  extension)

Provides information as to whether a given OpenGL extension exists.

That is, the extension is reported to be supported.

Parameters
[in]extensionExtension enumeration.
Returns
true if the extension exists, false otherwise.
Examples:
dx11Shader/dx11Shader.cpp.
unsigned int numTexUnits ( ) const

Get information about the maximum number of texture units.

This may not be the same as the number of interpolants available.

Returns
Maximum number of texture units.
unsigned int numTexInterpolants ( ) const

Get information about the maximum number of texture interpolants.

Returns
Maximum number of texture interpolants.
unsigned int numTexImageUnits ( ) const

Get information about the maximum number of texture image units available.

Returns
Maximum number of image units.
unsigned int maxTextureSize ( ) const

Get information about the maximum texture size.

Returns
Maximum size.
unsigned int maxVertexAttributes ( ) const

Get information about the maximum number of vertex attributes available.

Returns
Number of attributes available.

The documentation for this class was generated from the following files: