<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "DTD/docbook/docbookx.dtd">
<!--
License Applicability. Except to the extent portions of this file are
made subject to an alternative license as permitted in the SGI Free
Software License B, Version 1.1 (the "License"), the contents of this
file are subject only to the provisions of the License. You may not use
this file except in compliance with the License. You may obtain a copy
of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
http://oss.sgi.com/projects/FreeB
Note that, as provided in the License, the Software is distributed on an
"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
Original Code. The Original Code is: OpenGL ES Reference Manual,
Version 1.0, released September 2003, developed by Silicon Graphics,
Inc. The Original Code is Copyright (c) 2003 Silicon Graphics, Inc.
Copyright in any portions created by third parties is as indicated
elsewhere herein. All Rights Reserved.
-->
<refentry id="glMultMatrix">
<refmeta>
<refentrytitle>glMultMatrix</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refdescriptor>glMultMatrix</refdescriptor>
<refname>glMultMatrixf</refname>
<refname>glMultMatrixx</refname>
<refpurpose>multiply the current matrix with the specified
matrix</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glMultMatrixf</function></funcdef>
<paramdef>const GLfloat * <parameter>m</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>glMultMatrixx</function></funcdef>
<paramdef>const GLfixed * <parameter>m</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>
<parameter>m</parameter>
</term>
<listitem>
<para>Points to 16 consecutive values that are used as
the elements of a
<inlineequation><math>
<mn>4</mn><mo>x</mo><mn>4</mn>
</math></inlineequation>
column-major matrix.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para><function>glMultMatrix</function>
multiplies the current matrix with the one specified using
<parameter>m</parameter>,
and replaces the current matrix with the product.</para>
<para>The current matrix is determined by the current matrix mode (see
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>).
It is either the projection matrix, modelview matrix, or the
texture matrix.</para>
</refsect1>
<refsect1>
<title>Examples</title>
<para>If the current matrix is <replaceable>C</replaceable>,
and the coordinates to be transformed are,
<inlineequation><math>
<mi>v</mi><mo>=</mo>
<mfenced>
<mrow><mi>v</mi><mo>[</mo><mn>0</mn><mo>]</mo></mrow>
<mrow><mi>v</mi><mo>[</mo><mn>1</mn><mo>]</mo></mrow>
<mrow><mi>v</mi><mo>[</mo><mn>2</mn><mo>]</mo></mrow>
<mrow><mi>v</mi><mo>[</mo><mn>3</mn><mo>]</mo></mrow>
</mfenced>
</math></inlineequation>,
then the current transformation is
<inlineequation><math>
<mi>C</mi><mo>x</mo><mi>v</mi>
</math></inlineequation>, or
</para>
<informalequation><math><mrow>
<mo>(</mo>
<mtable class="matrix">
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>0</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>4</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>8</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>12</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>1</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>5</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>9</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>13</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>2</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>6</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>10</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>14</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>3</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>7</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>11</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>15</mn><mo>]</mo></mtd>
</mtr>
</mtable>
<mo>)</mo>
<mo>x</mo>
<mo>(</mo>
<mtable class="vector">
<mtr><mtd><mi>v</mi><mo>[</mo><mn>0</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>1</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>2</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>3</mn><mo>]</mo></mtd></mtr>
</mtable>
<mo>)</mo>
</mrow></math></informalequation>
<para>Calling
<function>glMultMatrix</function>
with an argument of
<inlineequation><math>
<mrow>
<mi>m</mi><mo>=</mo>
<mi>m</mi><mo>[</mo><mn>0</mn><mo>]</mo>,
<mi>m</mi><mo>[</mo><mn>1</mn><mo>]</mo>,
<mo>...</mo>
<mi>m</mi><mo>[</mo><mn>15</mn><mo>]</mo>
</mrow>
</math></inlineequation>
replaces the current transformation with
<inlineequation><math>
<mfenced><mrow><mi>C</mi><mo>x</mo><mi>M</mi></mrow></mfenced>
<mo>x</mo><mi>v</mi>
</math></inlineequation>, or</para>
<informalequation><math><mrow>
<mo>(</mo>
<mtable class="matrix">
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>0</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>4</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>8</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>12</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>1</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>5</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>9</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>13</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>2</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>6</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>10</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>14</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>c</mi><mo>[</mo><mn>3</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>7</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>11</mn><mo>]</mo></mtd>
<mtd><mi>c</mi><mo>[</mo><mn>15</mn><mo>]</mo></mtd>
</mtr>
</mtable>
<mo>)</mo>
<mo>x</mo>
<mo>(</mo>
<mtable class="matrix">
<mtr>
<mtd><mi>m</mi><mo>[</mo><mn>0</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>4</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>8</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>12</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>m</mi><mo>[</mo><mn>1</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>5</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>9</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>13</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>m</mi><mo>[</mo><mn>2</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>6</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>10</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>14</mn><mo>]</mo></mtd>
</mtr>
<mtr>
<mtd><mi>m</mi><mo>[</mo><mn>3</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>7</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>11</mn><mo>]</mo></mtd>
<mtd><mi>m</mi><mo>[</mo><mn>15</mn><mo>]</mo></mtd>
</mtr>
</mtable>
<mo>)</mo>
<mo>x</mo>
<mo>(</mo>
<mtable class="vector">
<mtr><mtd><mi>v</mi><mo>[</mo><mn>0</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>1</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>2</mn><mo>]</mo></mtd></mtr>
<mtr><mtd><mi>v</mi><mo>[</mo><mn>3</mn><mo>]</mo></mtd></mtr>
</mtable>
<mo>)</mo>
</mrow></math></informalequation>
<para>Where
``<inlineequation><math><mo>x</mo></math></inlineequation>''
denotes matrix multiplication, and
<replaceable>v</replaceable>
is represented as a
<inlineequation><math>
<mn>4</mn><mo>x</mo><mn>1</mn>
</math></inlineequation>
matrix.</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>While the elements of the matrix may be specified with
single or double precision, the GL may store or operate on
these values in less than single precision.</para>
<para>In many computer languages
<inlineequation><math>
<mn>4</mn><mo>x</mo><mn>4</mn>
</math></inlineequation>
arrays are represented in row-major order. The transformations
just described represent these matrices in column-major order.
The order of the multiplication is important. For example, if
the current transformation is a rotation, and
<function>glMultMatrix</function>
is called with a translation matrix, the translation is done
directly on the coordinates to be transformed, while the
rotation is done on the results of that translation.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>glLoadIdentity</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glLoadMatrix</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPushMatrix</refentrytitle></citerefentry>
</para>
</refsect1>
</refentry>