- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Friends

# MGLFunctionTable Class Reference
OpenMayaRender - API module for rendering

Search for all occurrences

## 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
    {
    public:
        MStatus initializeGL();
        void    drawAxis();
    protected:
        MGLFunctionTable *gGLFT; // Function table to use
    private:
    // No private members
    };

    MStatus
    myClass::initializeGL()
    {
        // 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;
    }

    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:

  cgfxEffectDef.cpp, cgfxShaderNode.cpp, hwColorPerVertexShader.cpp, hwPhongShader.cpp, lineManip.cpp, lineManipContainer.cpp, OpenGLViewportRenderer.cpp, squareScaleManip.cpp, and squareScaleManipContext.cpp.

`#include <MGLFunctionTable.h>`

List of all members.

## 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.
unsigned int | numTexUnits () const
| Get information about the maximum number of texture units.
unsigned int | numTexInterpolants () const
| Get information about the maximum number of texture interpolants.
unsigned int | numTexImageUnits () const
| Get information about the maximum number of texture image units available.
unsigned int | maxTextureSize () const
| Get information about the maximum texture size.
unsigned int | maxVertexAttributes () const
| Get information about the maximum number of vertex attributes available.
## Friends
class | MHardwareRenderer Search for all occurrences

## Member Enumeration Documentation

enum MGLversion

Search for all occurrences

OpenGL versions checked.

Enumerator:

  kMGL_Version11 | GL 1.1. Search for all occurrences
  kMGL_Version12 | GL 1.2. Search for all occurrences
  kMGL_Version121 | GL 1.2.1. Search for all occurrences
  kMGL_Version13 | GL 1.3.1. Search for all occurrences
  kMGL_Version14 | GL 1.4.1. Search for all occurrences
  kMGL_Version15 | GL 1.5. Search for all occurrences
  kMGL_Version20 | GL 2.0. Search for all occurrences

## Member Function Documentation

bool extensionExists | ( | MGLExtension | extension | ) |

Search for all occurrences

Provides information as to whether a given OpenGL extension exists.

That is, the extension is reported to be supported.

Parameters:

  [in] | extension | Extension enumeration.

Returns:
  true if the extension exists, false otherwise.

unsigned int numTexUnits | ( |  | ) | const

Search for all occurrences

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

Search for all occurrences

Get information about the maximum number of texture interpolants.

Returns:
  Maximum number of texture interpolants.

unsigned int numTexImageUnits | ( |  | ) | const

Search for all occurrences

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

Returns:
  Maximum number of image units.

unsigned int maxTextureSize | ( |  | ) | const

Search for all occurrences

Get information about the maximum texture size.

Returns:
  Maximum size.

unsigned int maxVertexAttributes | ( |  | ) | const

Search for all occurrences

Get information about the maximum number of vertex attributes available.

Returns:
  Number of attributes available.

MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable
MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable MGLFunctionTable