GLBITMAP(3G)
π
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:
- the first pair = width and height of the bitmap image.
- the second pair = where the bitmap origin is, relative to the lower left corner of the bitmap image.
- the third pair = the x and y offsets added to the current raster position after the bitmap has been drawn.
- 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_VALUEis generated ifwidthorheightis negative. (negative size?? absolutely not, bestie π«)GL_INVALID_OPERATIONis generated ifglBitmapis executed between the execution ofglBeginand the corresponding execution ofglEnd. like, read the room β you're inside aglBegin/glEndblock, that's not the moment.
π ASSOCIATED GETS π
glGet with argument:
GL_CURRENT_RASTER_POSITIONGL_CURRENT_RASTER_COLORGL_CURRENT_RASTER_DISTANCEGL_CURRENT_RASTER_INDEXGL_CURRENT_RASTER_TEXTURE_COORDSGL_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
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms