GLUT = Graphics Library Utility Tool-kit (ang.) jest to wysokopoziomowa biblioteka zawierająca niezależny od sprzętu dostęp do okien (ang. window system)Building OpenGL/GLUT Programs by Sugih Jamin Programowanie z użyciem biblioteki Glut są sterowane zdarzeniami GLUT description TUFTS UNIVERSITY Wersje oryginalna (Bardzo stara biblioteka) freeglut FreeGLUT is a completely OpenSourced alternative to the OpenGL Utility Toolkit (GLUT) library openglut
Jak sprawdzić jaką wersję używamy:
locate glut.h
otrzymujemy:
/usr/include/GL/freeglut.h /usr/include/GL/glut.h
Możemy używać:
#ifdef FREEGLUT #include #else #include #endif
Instalacja
opis Building OpenGL/GLUT Programs by Sugih Jamin
freeglut
Download (HTTP): http://downloads.sourceforge.net/freeglut/freeglut-2.8.1.tar.gz Download MD5 sum: 918ffbddcffbac83c218bc52355b6d5a Download size: 984 KB Estimated disk space required: 11 MB Estimated build time: 0.1 SBU Freeglut Dependencies : Required GLU-9.0.0 Test suite : no Installed Library : libglut.so
Instrukcje: ./configure --prefix=/usr --disable-static && make
Teraz jako root:
make install
Interakcja
Program sterowany zdarzeniami:Event-driven interaction with GLUT by Gustav Taxén mysz (ruch, kliknięcie) klawiatura: glutKeyboardFunc menu okno (przesunięcie lub zmiana rozmiaru): glutReshapeFunc system (Idle, timer): glutIdleFunc, glutTimerFunc program (glutDisplayFunc)
Typy zdarzeń związanych z myszą: kliknięcie (glutMouseFunc) ruch (glutMotionFunc, glutPassiveMotionFunc) przekraczanie granic okna (glutEntryFunc) Programy Użycie GLUT do sprawdzenia wersji OpenGL
#include /* printf */ #include /* glut graphics library */ /* Linux c console program gcc f.c -lglut -lGL ./a.out */ main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("red 3D lighted cube"); printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); /* GL_VERSION = 2.1.2 NVIDIA 195.36.24 */ return 0; }
Więcej informacji
Ten program wyświetla informacje o glut.glversion.c
Kompilacja:
gcc v.c -lglut -lGL
Uruchomienie: ./a.out
#include
#if defined(HAVE_FREEGLUT)
#ifdef WIN32 #include "../include/GL/freeglut.h" #else #include #endif
#else
#include
#endif
#define PROGRAM "glversion"
int main(int argc, char **argv) { char *version = NULL; char *vendor = NULL; char *renderer = NULL; char *extensions = NULL; GLuint idWindow = 0; int glutVersion;
glutInit(&argc, argv); glutInitWindowSize(1,1); glutInitDisplayMode(GLUT_RGBA); idWindow = glutCreateWindow(PROGRAM); glutHideWindow();
glutVersion = glutGet(0x01FC); version = (char*)glGetString(GL_VERSION); vendor = (char*)glGetString(GL_VENDOR); renderer = (char*)glGetString(GL_RENDERER); extensions = (char*)glGetString(GL_EXTENSIONS);
printf("GLUT=%d\nVERSION=%s\nVENDOR=%s\nRENDERER=%s\nEXTENSIONS=%s\n", glutVersion,version,vendor,renderer,extensions);
glutDestroyWindow(idWindow); return(0); } GLSL
// http://www.lighthouse3d.com/tutorials/glsl-tutorial/setup/ // #include // use GLEW to access OpenGL 3.3 functionality. #include
void main(int argc, char **argv) {
glutInit(&argc, argv); ... glewInit();
if (glewIsSupported("GL_VERSION_3_3")) printf("Ready for OpenGL 3.3\n"); else { printf("OpenGL 3.3 not supported\n"); exit(1);
setShaders(); initGL();
glutMainLoop(); }
Źródła
en:OpenGL_Programming/Installation/GLUT ko:OpenGL 프로그래밍/설치/GLUT