class MGLFunctionTable

Jump to documentation

Utility class which provides wrappers for the OpenGL API. (OpenMayaRender) (OpenMayaRender.py)

public members:

enum MGLversion
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
bool extensionExists (MGLExtension extension)
unsigned int numTexUnits () const
unsigned int numTexInterpolants () const
unsigned int numTexImageUnits () const
unsigned int maxTextureSize () const
unsigned int maxVertexAttributes () const

Documentation

Utility class which provides wrappers for the OpenGL API. (OpenMayaRender) (OpenMayaRender.py)
Description

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 it's 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.





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 maya.OpenMayaRender as OpenMayaRender


def initializeGL():
  glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
  glFT = glRenderer.glFunctionTable()


def printMaxTextureSize():
  maxTxtSize = glFT.maxTextureSize()
  print maxTxtSize


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)

Functions

bool MGLFunctionTable:: extensionExists (MGLExtension extension)

Description

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

Arguments

  • extension Extension enumeration.

Return Value

  • true : if it exists. Otherwise false.

unsigned int MGLFunctionTable:: numTexUnits () const

Description

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

Arguments

  • None.

Return Value

  • Maximum number of texture units.

unsigned int MGLFunctionTable:: numTexInterpolants () const

Description

Get information about the maximum number of texture interpolants.

Arguments

  • None.

Return Value

  • Maximum number of texture interpolants.

unsigned int MGLFunctionTable:: numTexImageUnits () const

Description

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

Arguments

  • None.

Return Value

  • Maximum number of image units.

unsigned int MGLFunctionTable:: maxTextureSize () const

Description

Get information about the maximum texture size.

Arguments

  • None.

Return Value

  • Maximum size.

unsigned int MGLFunctionTable:: maxVertexAttributes () const

Description

Get information about the maximum number of vertex attributes available.

Arguments

  • None.

Return Value

  • Number of attributes available.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright