fltk/glut.h File Reference


Classes

class  fltk::GlutWindow

Namespaces

namespace  fltk

Defines

#define GLUT_BITMAP_8_BY_13
#define GLUT_BITMAP_9_BY_15
#define GLUT_BITMAP_HELVETICA_10
#define GLUT_BITMAP_HELVETICA_12
#define GLUT_BITMAP_HELVETICA_18
#define GLUT_BITMAP_TIMES_ROMAN_10
#define GLUT_BITMAP_TIMES_ROMAN_24
#define GLUT_CURSOR_BOTTOM_LEFT_CORNER
#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER
#define GLUT_CURSOR_BOTTOM_SIDE
#define GLUT_CURSOR_CROSSHAIR
#define GLUT_CURSOR_FULL_CROSSHAIR
#define GLUT_CURSOR_HELP
#define GLUT_CURSOR_INFO
#define GLUT_CURSOR_INHERIT
#define GLUT_CURSOR_LEFT_RIGHT
#define GLUT_CURSOR_LEFT_SIDE
#define GLUT_CURSOR_NONE
#define GLUT_CURSOR_RIGHT_SIDE
#define GLUT_CURSOR_TEXT
#define GLUT_CURSOR_TOP_LEFT_CORNER
#define GLUT_CURSOR_TOP_RIGHT_CORNER
#define GLUT_CURSOR_TOP_SIDE
#define GLUT_CURSOR_UP_DOWN
#define GLUT_CURSOR_WAIT
#define GLUT_NORMAL_DAMAGED
#define GLUT_OVERLAY_DAMAGED
#define GLUT_OVERLAY_POSSIBLE
#define GLUT_STROKE_MONO_ROMAN
#define GLUT_STROKE_ROMAN
#define GLUT_TRANSPARENT_INDEX
#define GLUT_WINDOW_ACCUM_ALPHA_SIZE
#define GLUT_WINDOW_ACCUM_BLUE_SIZE
#define GLUT_WINDOW_ACCUM_GREEN_SIZE
#define GLUT_WINDOW_ACCUM_RED_SIZE
#define GLUT_WINDOW_ALPHA_SIZE
#define GLUT_WINDOW_BLUE_SIZE
#define GLUT_WINDOW_COLORMAP_SIZE
#define GLUT_WINDOW_DEPTH_SIZE
#define GLUT_WINDOW_DOUBLEBUFFER
#define GLUT_WINDOW_GREEN_SIZE
#define GLUT_WINDOW_NUM_SAMPLES
#define GLUT_WINDOW_RED_SIZE
#define GLUT_WINDOW_RGBA
#define GLUT_WINDOW_STENCIL_SIZE
#define GLUT_WINDOW_STEREO

Enumerations

enum  {
  GLUT_RGB, GLUT_RGBA, GLUT_INDEX, GLUT_SINGLE,
  GLUT_DOUBLE, GLUT_ACCUM, GLUT_ALPHA, GLUT_DEPTH,
  GLUT_STENCIL, GLUT_MULTISAMPLE, GLUT_STEREO
}
enum  { GLUT_NORMAL, GLUT_OVERLAY }
enum  {
  GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON, GLUT_DOWN,
  GLUT_UP
}
enum  { GLUT_LEFT, GLUT_ENTERED }
enum  { GLUT_NOT_VISIBLE, GLUT_VISIBLE }
enum  { GLUT_MENU_NOT_IN_USE, GLUT_MENU_IN_USE }
enum  {
  GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4,
  GLUT_KEY_F5, GLUT_KEY_F6, GLUT_KEY_F7, GLUT_KEY_F8,
  GLUT_KEY_F9, GLUT_KEY_F10, GLUT_KEY_F11, GLUT_KEY_F12,
  GLUT_KEY_LEFT, GLUT_KEY_UP, GLUT_KEY_RIGHT, GLUT_KEY_DOWN,
  GLUT_KEY_PAGE_UP, GLUT_KEY_PAGE_DOWN, GLUT_KEY_HOME, GLUT_KEY_END,
  GLUT_KEY_INSERT
}
enum  {
  GLUT_RETURN_ZERO, GLUT_WINDOW_X, GLUT_WINDOW_Y, GLUT_WINDOW_WIDTH,
  GLUT_WINDOW_HEIGHT, GLUT_WINDOW_PARENT, GLUT_SCREEN_WIDTH, GLUT_SCREEN_HEIGHT,
  GLUT_MENU_NUM_ITEMS, GLUT_DISPLAY_MODE_POSSIBLE, GLUT_INIT_WINDOW_X, GLUT_INIT_WINDOW_Y,
  GLUT_INIT_WINDOW_WIDTH, GLUT_INIT_WINDOW_HEIGHT, GLUT_INIT_DISPLAY_MODE, GLUT_WINDOW_BUFFER_SIZE
}
enum  { GLUT_ACTIVE_SHIFT, GLUT_ACTIVE_CTRL, GLUT_ACTIVE_ALT }

Functions

void glutAddMenuEntry (const char *label, int value)
void glutAddSubMenu (const char *label, int submenu)
void glutAttachMenu (int b)
void glutBitmapCharacter (void *font, int character)
int glutBitmapLength (void *font, const unsigned char *string)
int glutBitmapWidth (void *font, int character)
void glutChangeToMenuEntry (int item, const char *label, int value)
void glutChangeToSubMenu (int item, const char *label, int submenu)
int glutCreateMenu (void(*)(int))
int glutCreateSubWindow (int win, int x, int y, int width, int height)
int glutCreateWindow (const char *title)
void glutDestroyMenu (int menu)
void glutDestroyWindow (int win)
void glutDetachMenu (int b)
void glutDisplayFunc (void(*f)())
void glutEntryFunc (void(*f)(int s))
void glutEstablishOverlay ()
int APIENTRY glutExtensionSupported (char *name)
void glutFullScreen ()
int glutGet (GLenum type)
int glutGetMenu ()
int glutGetModifiers ()
int glutGetWindow ()
void glutHideOverlay ()
void glutHideWindow ()
void glutIconifyWindow ()
void glutIdleFunc (void(*f)())
void glutInit (int *argcp, char **argv)
void glutInitDisplayMode (unsigned int mode)
void glutInitWindowPosition (int x, int y)
void glutInitWindowSize (int w, int h)
void glutKeyboardFunc (void(*f)(uchar key, int x, int y))
int glutLayerGet (GLenum)
void glutMainLoop ()
void glutMenuStateFunc (void(*f)(int state))
void glutMenuStatusFunc (void(*f)(int status, int x, int y))
void glutMotionFunc (void(*f)(int x, int y))
void glutMouseFunc (void(*f)(int b, int state, int x, int y))
void glutOverlayDisplayFunc (void(*f)())
void glutPassiveMotionFunc (void(*f)(int x, int y))
void glutPopWindow ()
void glutPositionWindow (int x, int y)
void glutPostOverlayRedisplay ()
void glutPostRedisplay ()
void glutPostWindowRedisplay (int win)
void glutRemoveMenuItem (int item)
void glutRemoveOverlay ()
void glutReshapeFunc (void(*f)(int w, int h))
void glutReshapeWindow (int w, int h)
void glutSetCursor (fltk::Cursor *cursor)
void glutSetIconTitle (const char *t)
void glutSetMenu (int m)
void glutSetWindow (int win)
void glutSetWindowTitle (const char *t)
void glutShowOverlay ()
void glutShowWindow ()
void APIENTRY glutSolidCone (GLdouble base, GLdouble height, GLint slices, GLint stacks)
void APIENTRY glutSolidCube (GLdouble size)
void APIENTRY glutSolidDodecahedron ()
void APIENTRY glutSolidIcosahedron ()
void APIENTRY glutSolidOctahedron ()
void APIENTRY glutSolidSphere (GLdouble radius, GLint slices, GLint stacks)
void APIENTRY glutSolidTeapot (GLdouble size)
void APIENTRY glutSolidTetrahedron ()
void APIENTRY glutSolidTorus (GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings)
void glutSpecialFunc (void(*f)(int key, int x, int y))
void APIENTRY glutStrokeCharacter (void *font, int character)
int APIENTRY glutStrokeWidth (void *font, int character)
void glutSwapBuffers ()
void glutTimerFunc (unsigned int msec, void(*f)(int), int value)
void glutUseLayer (GLenum layer)
void glutVisibilityFunc (void(*f)(int s))
void APIENTRY glutWireCone (GLdouble base, GLdouble height, GLint slices, GLint stacks)
void APIENTRY glutWireCube (GLdouble size)
void APIENTRY glutWireDodecahedron ()
void APIENTRY glutWireIcosahedron ()
void APIENTRY glutWireOctahedron ()
void APIENTRY glutWireSphere (GLdouble radius, GLint slices, GLint stacks)
void APIENTRY glutWireTeapot (GLdouble size)
void APIENTRY glutWireTetrahedron ()
void APIENTRY glutWireTorus (GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings)

Variables

void(* glut_idle_function )()
int glut_menu
void(* glut_menustate_function )(int)
void(* glut_menustatus_function )(int, int, int)
fltk::GlutWindowglut_window
struct Glut_Bitmap_Font glutBitmap8By13
struct Glut_Bitmap_Font glutBitmap9By15
struct Glut_Bitmap_Font glutBitmapHelvetica10
struct Glut_Bitmap_Font glutBitmapHelvetica12
struct Glut_Bitmap_Font glutBitmapHelvetica18
struct Glut_Bitmap_Font glutBitmapTimesRoman10
struct Glut_Bitmap_Font glutBitmapTimesRoman24
void * glutStrokeMonoRoman
void * glutStrokeRoman

Detailed Description

This file provides GLUT compatibility in FLTK 2.0.

GLUT is/was a popular toolkit for making single-window OpenGL applications. GLUT is Copyright© Mark J. Kilgard, 1994, 1995, 1996. FLTK's emulation is not based on any GLUT code and is not subject to any license other than FLTK's.

Most glut emulation is done by the GlutWindow class, and inline functions in this header file that turn GLUT calls into instances and methods on those instances. You should take a look at it (and maybe at test/glpuzzle.cxx in the FLTK source) if you are having trouble porting your GLUT program.

This has been tested with most of the demo programs that come with the GLUT 3.3 distribution.

Using the GLUT Compatibility Header File

You should be able to compile existing GLUT source code by including <fltk/glut.h> instead of <GL/glut.h>. This can be done by editing the source, by changing the -I switches to the compiler, or by providing a symbolic link from GL/glut.h to fltk/glut.h.

All files calling GLUT procedures must be compiled with C++. You may have to alter them slightly to get them to compile without warnings, and you may have to rename them to get make to use the C++ compiler.

You must link with the FLTK library. If you call any GLUT drawing functions that FLTK does not emulate (glutExtensionsSupported(), glutWire*(), glutSolid*(), and glutStroke*()), you will also have to link with the GLUT library (after the FLTK library!)

Known Problems

The following functions and/or arguments to functions are missing, and you will have to replace them or comment them out for your code to compile:

Most of the symbols/enumerations have different values than GLUT uses. This will break code that relies on the actual values. The only symbols guaranteed to have the same values are true/false pairs like GLUT_DOWN and GLUT_UP, mouse buttons GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON, and GLUT_KEY_F1 thru F12.

The strings passed as menu labels are not copied.

glutPostRedisplay() does not work if called from inside a display function. You must use glutIdleFunc() if you want your display to update continuously.

glutSwapBuffers() does not work from inside a display function. This is on purpose, because FLTK swaps the buffers for you.

glutUseLayer() does not work well, and should only be used to initialize transformations inside a resize callback. You should redraw overlays by using glutOverlayDisplayFunc().

Overlays are cleared before the overlay display function is called. glutLayerGet(GLUT_OVERLAY_DAMAGED) always returns true for compatibility with some GLUT overlay programs. You must rewrite your code so that gl_color() is used to choose colors in an overlay, or you will get random overlay colors.

glutSetCursor(GLUT_CURSOR_FULL_CROSSHAIR) just results in a small crosshair.

The fonts used by glutBitmapCharacter() and glutBitmapWidth() may be different.

glutInit(argc,argv) will consume different switches than GLUT does. It accepts the switches recognized by fltk::args(), and will accept any abbreviation of these switches (such as "-di" for "-display").

Mixing GLUT and FLTK Code

You can make your GLUT window a child of a Window with the following scheme. The biggest trick is that GLUT insists on show() 'ing the window at the point it is created, which means the fltk::Window parent window must already be shown.


Wed Jun 17 08:49:29 2009. FLTK ©2007 Bill Spitzak and others.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.