MGLFunctionTable Class Reference
[OpenMayaRender - API module for rendering]

#include <MGLFunctionTable.h>

List of all members.

Detailed Description

Utility class which provides wrappers for the OpenGL API.

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 <MHardwareRenderer.h>
#include <MGLFunctionTable.h>

class myClass
        MStatus initializeGL();
        void    drawAxis();
        MGLFunctionTable *gGLFT; // Function table to use
// No private members

        // Get a pointer to a GL function table
        MHardwareRenderer *rend = MHardwareRenderer::theRenderer();
        if (rend)
                gGLFT = rend->glFunctionTable();
        if (!gGLFT)
                return MStatus::kFailure;
        return MStatus::kSuccess;

        // Draw a world space axis
        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 );

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.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 )


lineManip.cpp, lineManipContainer.cpp, OpenGLViewportRenderer.cpp, squareScaleManip.cpp, and squareScaleManipContext.cpp.

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)
unsigned int  numTexUnits () const
unsigned int  numTexInterpolants () const
unsigned int  numTexImageUnits () const
unsigned int  maxTextureSize () const
unsigned int  maxVertexAttributes () const


class  MHardwareRenderer

Member Enumeration Documentation

OpenGL versions checked.

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

bool MGLFunctionTable::extensionExists ( MGLExtension  extension  ) 

Provides information as to whether a given OpenGL extension exists. That is, the extension is reported to be supported.

[in]  extension  Extension enumeration.
true if the extension exists, false otherwise.

unsigned int MGLFunctionTable::numTexUnits (  )  const

Get information about the maximum number of texture units. This may not be the same as the number of interpolants available.

Maximum number of texture units.

unsigned int MGLFunctionTable::numTexInterpolants (  )  const

Get information about the maximum number of texture interpolants.

Maximum number of texture interpolants.

unsigned int MGLFunctionTable::numTexImageUnits (  )  const

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

Maximum number of image units.

unsigned int MGLFunctionTable::maxTextureSize (  )  const

Get information about the maximum texture size.

Maximum size.

unsigned int MGLFunctionTable::maxVertexAttributes (  )  const

Get information about the maximum number of vertex attributes available.

Number of attributes available.

Autodesk® Maya® 2011 © 1997-2010 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6