GLSHADEMODEL(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

✨ glShadeModel ✨

okay bestie, welcome to glShadeModel(3G) β€” the lil GL function that decides whether your primitives get their colors blended all cute and smooth, or slapped on flat like a sticker. it's giving very important, very short, and you're gonna slay it. πŸ’…


πŸŽ€ C SPECIFICATION πŸŽ€

void glShadeModel( GLenum mode )

like, that's it. one arg. one job. iconic behavior honestly. πŸ‘‘


🌸 PARAMETERS 🌸

  • mode β€” specifies a symbolic value representing a shading technique. the accepted values are GL_FLAT and GL_SMOOTH. the initial value is GL_SMOOTH.

πŸ¦‹ DESCRIPTION πŸ¦‹

so GL primitives can have either flat or smooth shading, and ngl those two vibes are very different.

Smooth shading is the default, and it causes the computed colors of vertices to be interpolated as the primitive is rasterized β€” typically assigning different colors to each resulting pixel fragment. it's the gradient girlie. the blend. the soft glow. ✨

Flat shading selects the computed color of just one vertex and assigns it to all the pixel fragments generated by rasterizing a single primitive. no blending, just commitment. it's giving monochrome.

and in either case β€” hear me out β€” the computed color of a vertex is the result of lighting if lighting is enabled, or it is the current color at the time the vertex was specified if lighting is disabled. fr fr. that's the rule. 🫢

k so here's the tea: flat and smooth shading are indistinguishable for points. like, literally cannot tell. periodt.

but for the other primitives? buckle up. starting when glBegin is issued and counting vertices and primitives from 1, the GL gives each flat-shaded line segment i the computed color of vertex i+1, its second vertex. so the second vertex is the one running the show. main character energy for real. πŸ‘‘

counting similarly from 1, the GL gives each flat-shaded polygon the computed color of the vertex listed in the following table. this is the last vertex to specify the polygon in all cases except single polygons, where the first vertex specifies the flat-shaded color. (yes bestie, single polygons are the exception, don't come for me.)

Primitive Type of Polygon i   Vertex
Single polygon (i≑1)            1
Triangle strip                 i+2
Triangle fan                   i+2
Independent triangle            3i
Quad strip                     2i+2
Independent quad                4i

flat and smooth shading are specified by glShadeModel with mode set to GL_FLAT and GL_SMOOTH, respectively. that's the whole thing. πŸ’–


😭 ERRORS 😭

  • GL_INVALID_ENUM is generated if mode is any value other than GL_FLAT or GL_SMOOTH. like, don't try it. it will not work. πŸ’€
  • GL_INVALID_OPERATION is generated if glShadeModel is executed between the execution of glBegin and the corresponding execution of glEnd. so do NOT be calling this mid-primitive, bestie, that's not the vibe. πŸ™ˆ

πŸ“ ASSOCIATED GETS πŸ“

  • glGet with argument GL_SHADE_MODEL

πŸ’œ SEE ALSO πŸ’œ

  • glBegin(3G)
  • glColor(3G)
  • glLight(3G)
  • glLightModel(3G)

and that's the whole page, babe β€” GLSHADEMODEL(3G), living in manual section 3G, brought to you by the source/version line and date that live down at the bottom of the original page. mwah. go shade something gorgeous. πŸ’–πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from