GLUTINIT(3)

πŸ“¦
version 3.8.0 Β· 2 versions
, in centos-stream 10, centos-stream 9, fedora 43, fedora 44, opensuse-leap 16.0

πŸ’– GLUTINIT(3) πŸ’–

okay so bestie, we're doing the glutInit page from the OpenGLUT - mainloop library section, and honestly? it's the first thing you ever call and also lowkey the most important. let's get into it ✨


🌸 NAME 🌸

glutInit β€” Initialize OpenGLUT data structures. that's it, that's the whole vibe. it sets up the internal stuff so everything else can actually work πŸ’…


πŸŽ€ LIBRARY πŸŽ€

OpenGLUT - mainloop


✨ SYNOPSIS ✨

#include <openglut.h>

void
glutInit(int *pargc, char **argv);

πŸ¦‹ PARAMETERS πŸ¦‹

  • pargc β€” a pointer to something like main()'s argc. yeah. that one. πŸ‘‘
  • argv β€” something like main()'s argv. the sibling. the duo. iconic.

πŸ’œ DESCRIPTION πŸ’œ

so like, you call this function once, near the start of any GLUT, freeglut, or OpenGLUT program. one time. not twice. it's giving "hello world but make it official" 🫢

it serves two vital roles, and when i say vital i mean it:

  • it lets OpenGLUT initialize its internal structures
  • it lets OpenGLUT process command-line arguments to control the initial window position, etc.

now here's the part where you need to pay attention, bestie, because the interaction between glutInit() and its related functions (like glutInitWindowPosition()) is sneaky. OpenGLUT always uses the most recent configuration information. so if you call glutInit() and then glutInitWindowPosition(), you have literally just prevented the user from controlling the initial window position via a command-line parameter. you took that power away from them. no cap. 😭

glutInit() will remove from pargc and argv any parameters that it recognizes in the command line. so like, it eats them. the following command-line parameters are suported:

  • -display display-id β€” this allows connection to an alternate X server.
  • -geometry geometry-spec β€” this takes width, height, and window position. the position is given as a signed value (negative values being distance from the far boundary of the screen). for example, a window geometry of 5x7+11-17 is 5 pixels wide, 7 pixels tall, 11 pixels from the left, and 17 pixels from the bottom edge of the screen. math but make it window 🧚
  • -direct β€” insist on only OpenGL direct rendering. direct rendering is normally requested but indirect is normally accepted. -direct is not always available. see -indirect.
  • -indirect β€” attempt only indirect OpenGL rendering. -indirect is always available. see -direct. (the reliable one fr fr)
  • -iconic β€” open the window in iconized form.
  • -gldebug β€” print any detected OpenGL errors via glutReportErrors(). presently done at the bottom of glutMainLoopEvent().
  • -sync β€” synchronize the window system communications heavily.

additionally, this function checks whether the environment variable GLUT_FPS is defined (only on UNIX_X11); if so, OpenGLUT will periodically print the average number of times per second that your program calls glutSwapBuffers(). free stats, we love to see it ⭐


πŸ’€ CAVEATS πŸ’€

you really should always call this, even if you are a WIN32 user. it provides a way for the user to directly inform OpenGLUT about preferences without the application needing to explicitly deal with those issues. this is also where OpenGLUT retrieves your program's name to help disambiguate error and warning messages it may be forced to emit. so like... it knows your name. and it will use it. πŸ™ˆ

option -sync sets a flag, but is not actually used at this time. flag: set. purpose: unclear. main character energy honestly.

lots of code does XFlush() on the X server, regardless of whether -sync is specified. much of that appears to be required in order to support direct client invocation of glutMainLoopEvent(), regrettably. however, if one calls glutMainLoop(), instead, we might avoid gratuitous XFlush() calls. (that last sentence isn't particularly germain to this function, but there's no better place to make this remark at this time.) even for glutMainLoopEvent(), we may be able to coalesce many XFlush() calls.

so yeah. lots of flushing. it is what it is. πŸ’…


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! ✨ this one's UNDATED and honestly the title block just says UNTITLED(), which is so mysterious of it β€” no version stamp, no date, just vibes. slay πŸ’–πŸŽ€