GLMAP2(3G)

๐Ÿ“ฆ version 1.1, in centos-stream 9, fedora 43, fedora 44

โœจ NAME โœจ

okay so bestie, welcome to GLMAP2(3G) ๐Ÿ’– โ€” the page for glMap2d and glMap2f, and what they do is define a two-dimensional evaluator. that's it. that's the whole vibe. ๐Ÿฆ‹


๐Ÿ“ C SPECIFICATION ๐Ÿ“

void glMap2d( GLenum target,
              GLdouble u1,
              GLdouble u2,
              GLint ustride,
              GLint uorder,
              GLdouble v1,
              GLdouble v2,
              GLint vstride,
              GLint vorder,
              const GLdouble *points )
void glMap2f( GLenum target,
              GLfloat u1,
              GLfloat u2,
              GLint ustride,
              GLint uorder,
              GLfloat v1,
              GLfloat v2,
              GLint vstride,
              GLint vorder,
              const GLfloat *points )

๐ŸŒธ PARAMETERS ๐ŸŒธ

  • target โ€” tells the evaluator what kind of values it's gonna spit out. the accepted glow-up constants are GL_MAP2_VERTEX_3, GL_MAP2_VERTEX_4, GL_MAP2_INDEX, GL_MAP2_COLOR_4, GL_MAP2_NORMAL, GL_MAP2_TEXTURE_COORD_1, GL_MAP2_TEXTURE_COORD_2, GL_MAP2_TEXTURE_COORD_3, and GL_MAP2_TEXTURE_COORD_4. all nine, bestie, no skips. ๐Ÿ‘‘
  • u1, u2 โ€” these set up a linear mapping of u, the way it shows up when you hand it to glEvalCoord2, onto u โ€” and u is one of the two variables that get evaluated by the equations this command defines. initial tea: u1 is 0 and u2 is 1. ๐Ÿ“
  • ustride โ€” the number of floats or doubles between the start of control point Rij and the start of control point R(i+1)j, where i and j are the u and v control point indices, respectively. this is the little trick that lets control points live embedded in arbitrary data structures. the only rule? the values for one particular control point have to sit in contiguous memory locations, periodt. ustride starts life at 0. โœจ
  • uorder โ€” the dimension of the control point array along the u axis. must be positive. initial value is 1. ๐Ÿ’…
  • v1, v2 โ€” same energy as u1/u2 but for v: a linear mapping of v, as presented to glEvalCoord2, onto v, one of the two variables evaluated by the equations this command specifies. initially v1 is 0 and v2 is 1. ๐ŸŽ€
  • vstride โ€” the number of floats or doubles between the start of control point Rij and the start of control point Ri(j+1), where i and j are the u and v control point indices, respectively. yes it also lets control points be embedded in arbitrary data structures, and yes the only constraint is that a particular control point's values must occupy contiguous memory locations. initial value is 0. ๐ŸŒˆ
  • vorder โ€” the dimension of the control point array along the v axis. must be positive. initial value is 1. โญ
  • points โ€” a pointer to the array of control points. iconic. ๐Ÿ“

๐ŸŽ€ DESCRIPTION ๐ŸŽ€

Evaluators are the moment where you get to use polynomial or rational polynomial mapping to produce vertices, normals, texture coordinates, and colors. the values an evaluator produces get sent onward through the later stages of GL processing exactly as if you'd handed them over with glVertex, glNormal, glTexCoord, and glColor commands โ€” with one lil caveat: the generated values do not update the current normal, texture coordinates, or color. they just pass through, no commitment. ๐Ÿ˜Œ

Every polynomial or rational polynomial spline of any degree (up to the maximum degree your GL implementation supports) can be described using evaluators. that covers basically almost all surfaces used in computer graphics โ€” B-spline surfaces, NURBS surfaces, Bezier surfaces, and so on. all of them. obsessed. ๐Ÿ”ฅ

Evaluators define surfaces based on bivariate Bernstein polynomials. define p(u,v) as:

p(u,v)=iฮฃ0jฮฃ0Bi(u)Bj(v)Rij

where Rij is a control point, Bi(u) is the ith Bernstein polynomial of degree n (uorder = n+1):

Bi(u)=โŽnโŽ ui(1โˆ’u)nโˆ’i
       i

and Bj(v) is the jth Bernstein polynomial of degree m (vorder = m+1):

Bj(v)=โŽmโŽ vj(1โˆ’v)mโˆ’j
       j

and recall that:

00โ‰ก1 and โŽnโŽ โ‰ก1
          0

glMap2 is what you use to define the basis and to say what kind of values get produced. once a map is defined, you can enable and disable it by calling glEnable and glDisable with the map name โ€” one of the nine predefined values for target, described below. when glEvalCoord2 presents values u and v, the bivariate Bernstein polynomials get evaluated using u and v, where:

u=_____

v=_____

target is a symbolic constant that says what kind of control points you're handing over in points, and what output gets generated when the map is evaluated. it can be one of nine predefined values, and here's the whole lineup, no gatekeeping:

  • GL_MAP2_VERTEX_3 โ€” each control point is three floating-point values representing x, y, and z. internal glVertex3 commands are generated when the map is evaluated. ๐Ÿ‘‘
  • GL_MAP2_VERTEX_4 โ€” each control point is four floating-point values representing x, y, z, and w. internal glVertex4 commands are generated when the map is evaluated. ๐Ÿ’œ
  • GL_MAP2_INDEX โ€” each control point is a single floating-point value representing a color index. internal glIndex commands are generated when the map is evaluated, but the current index is not updated with the value of those glIndex commands. ๐Ÿ™ˆ
  • GL_MAP2_COLOR_4 โ€” each control point is four floating-point values representing red, green, blue, and alpha. internal glColor4 commands are generated when the map is evaluated, but the current color is not updated with the value of those glColor4 commands. ๐ŸŽจ
  • GL_MAP2_NORMAL โ€” each control point is three floating-point values representing the x, y, and z components of a normal vector. internal glNormal commands are generated when the map is evaluated, but the current normal is not updated with the value of those glNormal commands. โญ
  • GL_MAP2_TEXTURE_COORD_1 โ€” each control point is a single floating-point value representing the s texture coordinate. internal glTexCoord1 commands are generated when the map is evaluated, but the current texture coordinates are not updated with the value of those glTexCoord commands. ๐Ÿงต
  • GL_MAP2_TEXTURE_COORD_2 โ€” each control point is two floating-point values representing the s and t texture coordinates. internal glTexCoord2 commands are generated when the map is evaluated, but the current texture coordinates are not updated with the value of those glTexCoord commands. ๐Ÿงš
  • GL_MAP2_TEXTURE_COORD_3 โ€” each control point is three floating-point values representing the s, t, and r texture coordinates. internal glTexCoord3 commands are generated when the map is evaluated, but the current texture coordinates are not updated with the value of those glTexCoord commands. โœจ
  • GL_MAP2_TEXTURE_COORD_4 โ€” each control point is four floating-point values representing the s, t, r, and q texture coordinates. internal glTexCoord4 commands are generated when the map is evaluated, but the current texture coordinates are not updated with the value of those glTexCoord commands. ๐ŸŒธ

ustride, uorder, vstride, vorder, and points are what define the array addressing for accessing the control points. points is the location of the first control point, which occupies one, two, three, or four contiguous memory locations โ€” depending on which map you're defining. there are uorderร—vorder control points in the array. ustride says how many float or double locations get skipped to advance the internal memory pointer from control point Rij to control point R(i+1)j. vstride says how many float or double locations get skipped to advance the internal memory pointer from control point Rij to control point Ri(j+1). math is math, bestie. ๐Ÿงฎ


๐Ÿ’€ NOTES ๐Ÿ’€

like with all GL commands that take pointers to data, it's as if the contents of points were copied by glMap2 before glMap2 returns. changes to the contents of points have no effect after glMap2 is called. so don't be out here editing that array afterwards expecting the map to care. it won't. ๐Ÿ’€

initially, GL_AUTO_NORMAL is enabled. if GL_AUTO_NORMAL is enabled, normal vectors get generated when either GL_MAP2_VERTEX_3 or GL_MAP2_VERTEX_4 is used to generate vertices. automatic. main character behavior. ๐Ÿ‘‘


๐Ÿšจ ERRORS ๐Ÿšจ

  • GL_INVALID_ENUM is generated if target is not an accepted value. ๐Ÿšซ
  • GL_INVALID_VALUE is generated if u1 is equal to u2, or if v1 is equal to v2. ๐Ÿ˜ญ
  • GL_INVALID_VALUE is generated if either ustride or vstride is less than the number of values in a control point. ๐Ÿ™ƒ
  • GL_INVALID_VALUE is generated if either uorder or vorder is less than 1 or greater than the return value of GL_MAX_EVAL_ORDER. ๐Ÿ“
  • GL_INVALID_OPERATION is generated if glMap2 is executed between the execution of glBegin and the corresponding execution of glEnd. ๐Ÿšท
  • when the GL_ARB_multitexture extension is supported, GL_INVALID_OPERATION is generated if glMap2 is called and the value of GL_ACTIVE_TEXTURE_ARB is not GL_TEXTURE0_ARB. ๐ŸŽฏ

๐Ÿ” ASSOCIATED GETS ๐Ÿ”

the stuff you can peek at to check on all this:

  • glGetMap
  • glGet with argument GL_MAX_EVAL_ORDER
  • glIsEnabled with argument GL_MAP2_VERTEX_3
  • glIsEnabled with argument GL_MAP2_VERTEX_4
  • glIsEnabled with argument GL_MAP2_INDEX
  • glIsEnabled with argument GL_MAP2_COLOR_4
  • glIsEnabled with argument GL_MAP2_NORMAL
  • glIsEnabled with argument GL_MAP2_TEXTURE_COORD_1
  • glIsEnabled with argument GL_MAP2_TEXTURE_COORD_2
  • glIsEnabled with argument GL_MAP2_TEXTURE_COORD_3
  • glIsEnabled with argument GL_MAP2_TEXTURE_COORD_4

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

go read these next, bestie, they're all in the group chat:

glBegin(3G), glColor(3G), glEnable(3G), glEvalCoord(3G), glEvalMesh(3G), glEvalPoint(3G), glMap1(3G), glMapGrid(3G), glNormal(3G), glTexCoord(3G), glVertex(3G)


and that's the whole page, you made it to the end ๐Ÿซถ this was GLMAP2(3G) from the 3G manual section โ€” same name up at the top, same name down at the bottom, as is tradition. slay ๐Ÿ’…๐ŸŽ€

๐Ÿ“ฆ where this page comes from