GLBITMAP(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

πŸ’… GLBITMAP β€” aka glBitmap(3G) bestie edition ✨

okay so welcome to the GLBITMAP(3G) page, this is the OpenGL one (section 3G, iykyk) and we're gonna learn how to draw a bitmap together. grab a snack πŸ“


🌸 NAME 🌸

glBitmap β€” draw a bitmap πŸ’–


✨ C SPECIFICATION ✨

void glBitmap( GLsizei width,
               GLsizei height,
               GLfloat xorig,
               GLfloat yorig,
               GLfloat xmove,
               GLfloat ymove,
               const GLubyte *bitmap )

πŸŽ€ PARAMETERS πŸŽ€

  • width, height β€” the pixel width and pixel height of the bitmap image, literally the size of the lil picture.
  • xorig, yorig β€” where the origin sits inside the bitmap image. and the way it's measured?? from the lower left corner of the bitmap, with right and up being the positive axes. so up-and-right girlies, that's you. πŸ‘‘
  • xmove, ymove β€” the x and y offsets that get added to the current raster position after the bitmap is drawn. it's giving "and then scoot over this much".
  • bitmap β€” the address of the bitmap image. that's the pointer bestie, the actual data.

πŸ¦‹ DESCRIPTION πŸ¦‹

so a bitmap is a binary image, periodt. when it's drawn, the bitmap gets positioned relative to the current raster position, and every frame buffer pixel that lines up with a 1 in the bitmap gets written using the current raster color or index. pixels that line up with a 0?? not modified. untouched. we leave them alone, no notes. πŸ’€

glBitmap takes seven arguments. let's break it down:

  1. the first pair = width and height of the bitmap image.
  2. the second pair = where the bitmap origin is, relative to the lower left corner of the bitmap image.
  3. the third pair = the x and y offsets added to the current raster position after the bitmap has been drawn.
  4. the final argument = a pointer to the bitmap image itself.

the bitmap image is interpreted like image data for the glDrawPixels command, with width and height corresponding to the width and height arguments of that command, and with type set to GL_BITMAP and format set to GL_COLOR_INDEX. modes specified using glPixelStore do affect the interpretation of bitmap image data; modes specified using glPixelTransfer do not. (not me remembering which one does what 😭 it's glPixelStore okay, write it down.)

if the current raster position is invalid, glBitmap is just ignored. nothing happens. the vibes are simply not there. πŸ™ˆ

otherwise, the lower left corner of the bitmap image is positioned at the window coordinates

xw = ⌊xr βˆ’ xoβŒ‹
yw = ⌊yr βˆ’ yoβŒ‹

where (xr, yr) is the raster position and (xo, yo) is the bitmap origin. ✨

fragments are then generated for each pixel corresponding to a 1 in the bitmap image. these fragments are generated using the current raster z coordinate, color or color index, and current raster texture coordinates. and then they're treated exactly as if they had been generated by a point, line, or polygon β€” including texture mapping, fogging, and all per-fragment operations such as alpha and depth testing. full main character treatment, no shortcuts. πŸ’…

after the bitmap has been drawn, the x and y coordinates of the current raster position get offset by xmove and ymove. but heads up: no change is made to the z coordinate of the current raster position, or to the current raster color, texture coordinates, or index. only x and y move, everything else stays exactly where it was. 🫢


🧚 NOTES 🧚

wanna set a valid raster position outside the viewport?? the trick is: first set a valid raster position inside the viewport, then call glBitmap with NULL as the bitmap parameter and with xmove and ymove set to the offsets of the new raster position. this technique is useful when panning an image around the viewport. lowkey iconic behavior honestly 🌈


πŸ”₯ ERRORS πŸ”₯

  • GL_INVALID_VALUE is generated if width or height is negative. (negative size?? absolutely not, bestie 🚫)
  • GL_INVALID_OPERATION is generated if glBitmap is executed between the execution of glBegin and the corresponding execution of glEnd. like, read the room β€” you're inside a glBegin/glEnd block, that's not the moment.

πŸ’œ ASSOCIATED GETS πŸ’œ

glGet with argument:

  • GL_CURRENT_RASTER_POSITION
  • GL_CURRENT_RASTER_COLOR
  • GL_CURRENT_RASTER_DISTANCE
  • GL_CURRENT_RASTER_INDEX
  • GL_CURRENT_RASTER_TEXTURE_COORDS
  • GL_CURRENT_RASTER_POSITION_VALID

⭐ SEE ALSO ⭐

  • glDrawPixels(3G)
  • glPixelStore(3G)
  • glPixelTransfer(3G)
  • glRasterPos(3G)

okay that's the whole page, you ate it, I'm obsessed, go draw some bitmaps πŸŽ€πŸ’–βœ¨

and for the lil sign-off: this whole thing lives under the manual name GLBITMAP(3G) (that's the title and the footer, man pages love a mirror moment), in section 3G, the GL section β€” that's the source/version info baked right into the page name, no separate date stamp on this one. slay. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from