📄 glut.h
字号:
//// "$Id: glut.H 4288 2005-04-16 00:13:17Z mike $"//// GLUT emulation header file for the Fast Light Tool Kit (FLTK).//// Copyright 1998-2005 by Bill Spitzak and others.//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Library General Public// License as published by the Free Software Foundation; either// version 2 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Library General Public License for more details.//// You should have received a copy of the GNU Library General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307// USA.//// Please report all bugs and problems on the following page://// http://www.fltk.org/str.php//// Emulation of GLUT using fltk.// GLUT is Copyright (c) Mark J. Kilgard, 1994, 1995, 1996:// "This program is freely distributable without licensing fees and is// provided without guarantee or warrantee expressed or implied. This// program is -not- in the public domain."// Although I have copied the GLUT API, none of my code is based on// any GLUT implementation details and is therefore covered by the LGPL.// FLTK does not include the GLUT drawing functions (such as// glutWireTeapot()) or the stroke fonts but the declarations for the// drawing functions are included here because otherwise there is no// way to get them along with this. To use them you will have to// link in the original GLUT library, put -lglut *after* -lfltk.// Commented out lines indicate parts of GLUT that are not emulated.#ifndef __glut_h__# define __glut_h__# include "gl.h"//# include <GL/glu.h>////////////////////////////////////////////////////////////////// GLUT is emulated using this window class and these static variables// (plus several more static variables hidden in glut.C):# include "Fl.H"# include "Fl_Gl_Window.H"class FL_EXPORT Fl_Glut_Window : public Fl_Gl_Window { void _init(); int mouse_down;protected: void draw(); void draw_overlay(); int handle(int);public: // so the inline functions work int number; int menu[3]; void make_current(); void (*display)(); void (*overlaydisplay)(); void (*reshape)(int w, int h); void (*keyboard)(uchar, int x, int y); void (*mouse)(int b, int state, int x, int y); void (*motion)(int x, int y); void (*passivemotion)(int x, int y); void (*entry)(int); void (*visibility)(int); void (*special)(int, int x, int y); Fl_Glut_Window(int w, int h, const char *); Fl_Glut_Window(int x, int y, int w, int h, const char *); ~Fl_Glut_Window();};extern FL_EXPORT Fl_Glut_Window *glut_window; // the current windowextern FL_EXPORT int glut_menu; // the current menu// function pointers that are not per-window:extern FL_EXPORT void (*glut_idle_function)();extern FL_EXPORT void (*glut_menustate_function)(int);extern FL_EXPORT void (*glut_menustatus_function)(int,int,int);//////////////////////////////////////////////////////////////////# define GLUT_API_VERSION This does not match any version of GLUT exactly...FL_EXPORT void glutInit(int *argcp, char **argv); // creates first windowFL_EXPORT void glutInitDisplayMode(unsigned int mode);// the FL_ symbols have the same value as the GLUT ones:# define GLUT_RGB FL_RGB# define GLUT_RGBA FL_RGB# define GLUT_INDEX FL_INDEX# define GLUT_SINGLE FL_SINGLE# define GLUT_DOUBLE FL_DOUBLE# define GLUT_ACCUM FL_ACCUM# define GLUT_ALPHA FL_ALPHA# define GLUT_DEPTH FL_DEPTH# define GLUT_STENCIL FL_STENCIL# define GLUT_MULTISAMPLE FL_MULTISAMPLE# define GLUT_STEREO FL_STEREO// # define GLUT_LUMINANCE 512FL_EXPORT void glutInitWindowPosition(int x, int y);FL_EXPORT void glutInitWindowSize(int w, int h);FL_EXPORT void glutMainLoop();FL_EXPORT int glutCreateWindow(char *title);FL_EXPORT int glutCreateSubWindow(int win, int x, int y, int width, int height);FL_EXPORT void glutDestroyWindow(int win);inline void glutPostRedisplay() {glut_window->redraw();}FL_EXPORT void glutSwapBuffers();inline int glutGetWindow() {return glut_window->number;}FL_EXPORT void glutSetWindow(int win);inline void glutSetWindowTitle(char *t) {glut_window->label(t);}inline void glutSetIconTitle(char *t) {glut_window->iconlabel(t);}inline void glutPositionWindow(int x, int y) {glut_window->position(x,y);}inline void glutReshapeWindow(int w, int h) {glut_window->size(w,h);}inline void glutPopWindow() {glut_window->show();}//inline void glutPushWindow();inline void glutIconifyWindow() {glut_window->iconize();}inline void glutShowWindow() {glut_window->show();}inline void glutHideWindow() {glut_window->hide();}inline void glutFullScreen() {glut_window->fullscreen();}inline void glutSetCursor(Fl_Cursor cursor) {glut_window->cursor(cursor);}// notice that the numeric values are different than glut:# define GLUT_CURSOR_RIGHT_ARROW ((Fl_Cursor)2)# define GLUT_CURSOR_LEFT_ARROW ((Fl_Cursor)67)# define GLUT_CURSOR_INFO FL_CURSOR_HAND# define GLUT_CURSOR_DESTROY ((Fl_Cursor)45)# define GLUT_CURSOR_HELP FL_CURSOR_HELP# define GLUT_CURSOR_CYCLE ((Fl_Cursor)26)# define GLUT_CURSOR_SPRAY ((Fl_Cursor)63)# define GLUT_CURSOR_WAIT FL_CURSOR_WAIT# define GLUT_CURSOR_TEXT FL_CURSOR_INSERT# define GLUT_CURSOR_CROSSHAIR FL_CURSOR_CROSS# define GLUT_CURSOR_UP_DOWN FL_CURSOR_NS# define GLUT_CURSOR_LEFT_RIGHT FL_CURSOR_WE# define GLUT_CURSOR_TOP_SIDE FL_CURSOR_N# define GLUT_CURSOR_BOTTOM_SIDE FL_CURSOR_S# define GLUT_CURSOR_LEFT_SIDE FL_CURSOR_W# define GLUT_CURSOR_RIGHT_SIDE FL_CURSOR_E# define GLUT_CURSOR_TOP_LEFT_CORNER FL_CURSOR_NW# define GLUT_CURSOR_TOP_RIGHT_CORNER FL_CURSOR_NE# define GLUT_CURSOR_BOTTOM_RIGHT_CORNER FL_CURSOR_SE# define GLUT_CURSOR_BOTTOM_LEFT_CORNER FL_CURSOR_SW# define GLUT_CURSOR_INHERIT FL_CURSOR_DEFAULT# define GLUT_CURSOR_NONE FL_CURSOR_NONE# define GLUT_CURSOR_FULL_CROSSHAIR FL_CURSOR_CROSS//inline void glutWarpPointer(int x, int y);inline void glutEstablishOverlay() {glut_window->make_overlay_current();}inline void glutRemoveOverlay() {glut_window->hide_overlay();}inline void glutUseLayer(GLenum layer) { layer ? glut_window->make_overlay_current() : glut_window->make_current();}enum {GLUT_NORMAL, GLUT_OVERLAY};inline void glutPostOverlayRedisplay() {glut_window->redraw_overlay();}inline void glutShowOverlay() {glut_window->redraw_overlay();}inline void glutHideOverlay() {glut_window->hide_overlay();}FL_EXPORT int glutCreateMenu(void (*)(int));FL_EXPORT void glutDestroyMenu(int menu);inline int glutGetMenu() {return glut_menu;}inline void glutSetMenu(int m) {glut_menu = m;}FL_EXPORT void glutAddMenuEntry(char *label, int value);FL_EXPORT void glutAddSubMenu(char *label, int submenu);FL_EXPORT void glutChangeToMenuEntry(int item, char *label, int value);FL_EXPORT void glutChangeToSubMenu(int item, char *label, int submenu);FL_EXPORT void glutRemoveMenuItem(int item);inline void glutAttachMenu(int b) {glut_window->menu[b] = glut_menu;}inline void glutDetachMenu(int b) {glut_window->menu[b] = 0;}inline void glutDisplayFunc(void (*f)()) {glut_window->display = f;}inline void glutReshapeFunc(void (*f)(int w, int h)) {glut_window->reshape=f;}inline void glutKeyboardFunc(void (*f)(uchar key, int x, int y)) { glut_window->keyboard = f;}inline void glutMouseFunc(void (*f)(int b, int state, int x, int y)) { glut_window->mouse = f;}# define GLUT_LEFT_BUTTON 0# define GLUT_MIDDLE_BUTTON 1# define GLUT_RIGHT_BUTTON 2# define GLUT_DOWN 0# define GLUT_UP 1inline void glutMotionFunc(void (*f)(int x, int y)) {glut_window->motion= f;}inline void glutPassiveMotionFunc(void (*f)(int x, int y)) { glut_window->passivemotion= f;}inline void glutEntryFunc(void (*f)(int s)) {glut_window->entry = f;}enum {GLUT_LEFT, GLUT_ENTERED};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -