+
Skip to content

jtsiomb/miniglut

Repository files navigation

MiniGLUT

logo

GNU/Linux build status Windows MinGW build status Windows MSVC6 build status

MiniGLUT is a subset of GLUT (or more precisely a subset of FreeGLUT) implemented in a single C source file, without any non-essential dependencies, not even the C library.

You can use MiniGLUT by simply dropping two files: miniglut.h and miniglut.c into your project source tree, or by building MiniGLUT as a static library and linking with it.

On GNU/Linux x86/x86-64 and 32bit Windows, MiniGLUT can be compiled to never call any C library functions whatsoever (which is the default if you use the included makefile/msvc project to build a static library). This is useful to avoid dependencies on any specific libc or msvc runtime.

Reasons to use MiniGLUT over a more complete implementation like freeglut:

  • ease of project setup: on some systems it's much harder to install freeglut and direct your toolchain on where to find it, than it is to just drop a couple of files in your project.

  • easier portability: instead of having to install a version of GLUT on every new system, just by transferring your source code you already have it.

  • avoiding runtime library conflicts: the option to build miniglut to never call the C library, can be useful in avoiding MSVC runtime conflicts on windows, or dependency to versioned glibc symbols on GNU, that limit compatibility with older systems.

Download

Latest release (v0.5):

Both archives are identical, choose whichever is more convenient.

Source repository (git):

Build

Under X11 MiniGLUT depends only on Xlib and OpenGL. Therefore to build a program using MiniGLUT you'll need to link with -lX11 -lGL.

Under Windows MiniGLUT depends only on OpenGL, GDI and winmm. Therefore to build a program using MiniGLUT you'll need to link with -lopengl32 -lgdi32 -lwinmm. When building with MSVC, linking with the correct libraries is taken care by pragmas in the header file. If you wish to avoid the winmm dependency, define MINIGLUT_NO_WINMM.

To disable calling any C library functions, make sure to have MINIGLUT_NO_LIBC defined when building miniglut.c. Either add that to your build system, or just modify miniglut.c and define it at the top.

Note: in previous versions (including v0.5), building without libc was the default, and you had to define MINIGLUT_USE_LIBC to make it use libc. But it turns out usually when you're building miniglut as part of your project, there's no real downside to using libc in most use cases, so I decided to change the default, and have the extra define go to the static library build files instead of every project which drops miniglut.h/miniglut.c in the source tree.

To avoid calling C library functions, MiniGLUT uses inline assembly code for system calls and trigonometric operations. This is currently implemented only on x86 (32 and 64bit), and only on 32bit when building with MSVC (which doesn't support inline assembly on x86-64). For all other systems you need to link with libc.

License

Copyright (C) 2020-2025 John Tsiombikas nuclear@mutantstargoat.org

MiniGLUT is free software. Feel free to use, modify and/or redistribute it, under the terms of the GNU General Public License v3, or at your option any newer version published by the Free Software Foundation. See COPYING for details.

The intention is not to dictate a specific free software license (GPL) but to shut the door to proprietary programs. If you want to use MiniGLUT in a free software project with an incompatible license, contact me and we will figure out a way to enable that.

To learn more about GPL-incompatible free software licenses where this might be an issue, see: https://www.gnu.org/licenses/license-list.en.html#GPLIncompatibleLicenses

Implementation Notes

On UNIX systems, spaceball callbacks are supported by talking to a 6dof device driver through the Magellan X11 ClientMessage protocol. This works with either the free software spacenavd driver, or the proprietary 3dxsrv. Spacenavd supports all 6dof devices from the first serial ones to current models.

On Windows, spaceball support relies on the 3Dconnexion driver and its old siapp API. This should work on any version of the driver from very old ones running on windows 9x and supporting serial devices, to the latest current driver for USB and bluetooth spacemice.

Known Issues

MiniGLUT being a subset of GLUT, is missing a number of features. Some of them on purpose to keep it minimal, and some of them because I didn't happen to use them in a program I wanted to link with MiniGLUT yet.

Missing GLUT features:

  • The only supported systems are: UNIX with X11 (GLX), and Windows (WGL).
  • Multiple windows.
  • Subwindows.
  • Overlays.
  • Game mode (video mode switching).
  • Menus.
  • Stroke fonts.
  • Bitmap fonts are currently not available on Windows.
  • Some of the primitives.
  • Buttons and Dials callbacks.
  • Tablet callbacks.
  • Timer callback.

Missing FreeGLUT features:

  • Mobile callbacks.
  • Context version and profile selection and other context flags.
  • Window close actions.
  • Multi-touch/multi-pointer callbacks.
  • User-pointer callbacks.
  • Joystick callbacks.
  • More missing primitives.

If youwish to let me know how much you need one of the missing features, or even better if you are volunteering to implement it yourself, send me an email at: nuclear@mutantstargoat.com

Only plain-text emails, hard-wrapped at 72 columns will be accepted.

About

minimal single-file GLUT implementation without unnecessary dependencies

Topics

Resources

License

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载