/** * Main entry point for GLUT based programs */ int main(int argc, char* argv[]) { gltSetWorkingDirectory(argv[0]); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowSize(800, 600); glutCreateWindow("Triangle"); gltShowVersionInfo(); // Create the menu glutCreateMenu(ProcessMenu); glutAddMenuEntry("Btn1",1); glutAddMenuEntry("Btn2",2); glutAttachMenu(GLUT_RIGHT_BUTTON); glutReshapeFunc(ChangeSize); glutDisplayFunc(RenderScene); glutSpecialFunc(SpecialKeys); glutKeyboardFunc(KeyPressFunc); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return 1; } SetupRC(); glutMainLoop(); OnExit(); return 0; }
/******************************************************************************* GLUT initialization. *******************************************************************************/ void initGlut(int argc, char* argv[]) { glutInit(&argc, argv); /* Initialize GLUT. */ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(500, 500); glutCreateWindow("Sphere-sphere Contact Example"); glutDisplayFunc(displayFunction); /* Setup GLUT callbacks. */ glutMouseFunc(handleMouse); glutIdleFunc(handleIdle); glutCreateMenu(handleMenu); glutAddMenuEntry("Quit", 0); glutAttachMenu(GLUT_RIGHT_BUTTON); }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(height, width); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMotionFunc(MotionCallback); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); glutSpecialFunc(processSpecialKeys); glutCreateMenu(mainMenu); glutAddMenuEntry("UP ARROW: Zoom In", 1); glutAddMenuEntry("DOWN ARROW: Zoom Out", 2); glutAddMenuEntry("RIGHT ARROW: Move To The Right", 3); glutAddMenuEntry("LEFT ARROW: Move To The Left", 4); glutAddMenuEntry("Esc: Exit", 27); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(250, 250); glutInitWindowPosition(100, 100); glutCreateWindow("Hello Haptics"); glutCreateMenu(glutMenu); glutAddMenuEntry("Quit", 0); glutAttachMenu(GLUT_RIGHT_BUTTON); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }
int main() { glutInit( &argc, const_cast<char**>( argv ) ); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL | GLUT_ALPHA ); glutInitWindowSize( 640, 480 ); uintptr_t win1 = glutCreateWindow("Test"); glutSetWindow( win1 ); uintptr_t menu1 = glutCreateMenu( menuFunc ); glutSetMenu( menu1 ); glutAddMenuEntry( "Test 1", 1 ); glutAddMenuEntry( "Test 2", 2 ); glutAttachMenu( GLUT_RIGHT_BUTTON ); glutDisplayFunc( displayFunc ); glutMotionFunc( motionFunc ); glutKeyboardFunc( keyboardFunc ); glutMouseFunc( mouseFunc ); glutTimerFunc( 100, timerFunc, 0 ); glutMainLoop(); return 0; }
void setMenuEntries(bool init) { int i, sub1, sub2; if ( init ) { sub1 = glutCreateMenu(selectMaterials); for (i = 0; i < materialsMenuEntries; i++) glutAddMenuEntry(materialsMenu[i].label, i); sub2 = glutCreateMenu(selectLighting); for (i = 0; i < lightingMenuEntries; i++) glutAddMenuEntry(lightingMenu[i].label, i); glutCreateMenu(selectMain); for(i = 0; i < mainMenuEntries; i++) glutAddMenuEntry(mainMenu[i].label, i); glutAddSubMenu("materials", sub1); glutAddSubMenu("lighting", sub2); glutAttachMenu(GLUT_RIGHT_BUTTON); } }
static void init() { glDisable(GL_DITHER); std::string ver((const char*)glGetString(GL_VERSION)); assert(!ver.empty()); std::istringstream verStream(ver); int major, minor; char dummySep; verStream >> major >> dummySep >> minor; const bool useVertexArrays = ((major>=1) && (minor>=1)); const GLfloat data[] = { -1.f, -1.f, 0.f, 1.f, -1.f, 0.f, 0.f, 1.f, 0.f}; if (useVertexArrays) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, data); } listID = glGenLists(1); glNewList(listID, GL_COMPILE); if (useVertexArrays) glDrawArrays(GL_TRIANGLES, 0, 3); else { glBegin(GL_TRIANGLES); glVertex3fv(&data[0]); glVertex3fv(&data[3]); glVertex3fv(&data[6]); glEnd(); } glEndList(); assert(glGetError()==GL_NO_ERROR); glutDisplayFunc(display); glutReshapeFunc(reshape); glutCreateMenu(mainMenuCB); glutAddMenuEntry("Quit", QUIT_VALUE); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void createMenu(void) { int submenuID = glutCreateMenu( myMenu ); glutAddMenuEntry("Task 1", 1); glutAddMenuEntry("Task 2", 2); glutAddMenuEntry("Task 3", 3); glutAddMenuEntry("Task 4", 4); glutAddMenuEntry("Bonus", 5); /* Create main menu. */ glutCreateMenu(myMenu); glutAddSubMenu("Task Selection", submenuID ); glutAddMenuEntry("Rotation on/off", 10); glutAddMenuEntry("BackFace Culling on/off", 11); glutAddMenuEntry("Polygon Fill mode line/fill", 12 ); glutAddMenuEntry("Quit", 99); /* Menu will be invoked by the right mouse button */ glutAttachMenu(GLUT_RIGHT_BUTTON); }
void time6(int value) { if (value != 6) { printf("FAIL: time6 expected 6\n"); exit(1); } glutMenuStateFunc(mstatus); glutMenuStatusFunc(mstatus2); glutCreateMenu(menu2); glutAddMenuEntry("name", 46); glutAttachMenu(GLUT_LEFT_BUTTON); glutAttachMenu(GLUT_MIDDLE_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); printf("Pop up menu with any mouse button and select the item\n"); }
int main(int argc, char** argv) { /* * initialize GLUT and open a window */ glutInit(&argc, argv); glutInitWindowSize(512, 512); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("Sunlight"); glutDisplayFunc(redrawCB); glutReshapeFunc(reshapeCB); glutMouseFunc(mouseCB); glutMotionFunc(motionCB); glutKeyboardFunc(keyCB); /* * make the menu */ glutCreateMenu(handleMenu); glutAddMenuEntry("SUNLIGHT", 0); glutAddMenuEntry("Show Globe *", MENU_SHOW_GLOBE); glutAddMenuEntry("Show Map", MENU_SHOW_MAP); glutAddMenuEntry("Adjust Globe *", MENU_ADJUST_GLOBE); glutAddMenuEntry("Adjust Day", MENU_ADJUST_DAY); glutAddMenuEntry("Adjust Time", MENU_ADJUST_TIME); glutAddMenuEntry("Quit", MENU_QUIT); glutAttachMenu(GLUT_RIGHT_BUTTON); /* * initialize GL */ initProjection(); gluLookAt(0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); initSunlight(); glEnable(GL_LIGHTING); glEnable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); /* * initialize data structures */ initSphere(); initMap(); initTexture("globe.raw"); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
void createMenu(){ int subMenu_id=glutCreateMenu(subMenu); glutAddMenuEntry("Left",1); glutAddMenuEntry("Right",2); glutAddMenuEntry("Up",3); glutAddMenuEntry("Down",4); glutCreateMenu(menu); if(screenWidth>800 && screenHeight>500) //nema smisla prikazivati ako vec nemamo FULL SCREEN! glutAddMenuEntry("Exit Full Screen",2); glutAddMenuEntry("Zoom in",3); glutAddMenuEntry("Zoom out",4); glutAddSubMenu("Move to",subMenu_id); glutAttachMenu(GLUT_RIGHT_BUTTON); }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutCreateMenu(Select); glutAddMenuEntry("save image",0); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; }
// Initialize GL //***************************************************************************** bool InitGL(int* argc, char **argv ) { // init GLUT and GLUT window glutInit(argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowPosition (glutGet(GLUT_SCREEN_WIDTH)/2 - iGraphicsWinWidth/2, glutGet(GLUT_SCREEN_HEIGHT)/2 - iGraphicsWinHeight/2); glutInitWindowSize(iGraphicsWinWidth, iGraphicsWinHeight); iGLUTWindowHandle = glutCreateWindow("OpenCL/OpenGL post-processing"); #if !(defined (__APPLE__) || defined(MACOSX)) glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif // register GLUT callbacks glutDisplayFunc(DisplayGL); glutKeyboardFunc(KeyboardGL); glutReshapeFunc(Reshape); glutTimerFunc(REFRESH_DELAY, timerEvent, 0); // create GLUT menu iGLUTMenuHandle = glutCreateMenu(mainMenu); glutAddMenuEntry("Toggle Post-processing (Blur filter) ON/OFF <spacebar>", ' '); glutAddMenuEntry("Toggle Processor between GPU and CPU [p]", 'p'); glutAddMenuEntry("Toggle GL animation (rotation) ON/OFF [a]", 'a'); glutAddMenuEntry("Increment blur radius [+ or =]", '='); glutAddMenuEntry("Decrement blur radius [- or _]", '-'); glutAddMenuEntry("Quit <esc>", '\033'); glutAttachMenu(GLUT_RIGHT_BUTTON); // init GLEW glewInit(); GLboolean bGLEW = glewIsSupported("GL_VERSION_2_0 GL_ARB_pixel_buffer_object"); oclCheckErrorEX(bGLEW, shrTRUE, pCleanup); // default initialization glClearColor(0.5, 0.5, 0.5, 1.0); glDisable(GL_DEPTH_TEST); // viewport glViewport(0, 0, iGraphicsWinWidth, iGraphicsWinHeight); // projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)iGraphicsWinWidth / (GLfloat) iGraphicsWinHeight, 0.1, 10.0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_LIGHT0); float red[] = { 1.0, 0.1, 0.1, 1.0 }; float white[] = { 1.0, 1.0, 1.0, 1.0 }; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, red); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0); return true; }
int main(int argc, char** argv) { int scale, translate, rotate, menu; glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); scale = glutCreateMenu(menu_choice); glutAddMenuEntry("2", TWO); glutAddMenuEntry("0.5", HALF); translate = glutCreateMenu(menu_choice); glutAddMenuEntry("Up", UP); glutAddMenuEntry("Down", DOWN); glutAddMenuEntry("Left", LEFT); glutAddMenuEntry("Right", RIGHT); rotate = glutCreateMenu(menu_choice); glutAddMenuEntry("X", X); glutAddMenuEntry("Y", Y); glutAddMenuEntry("Z", Z); menu = glutCreateMenu(menu_choice); glutAddSubMenu("Scale", scale); glutAddSubMenu("Translate", translate); glutAddSubMenu("Rotate", rotate); glutAttachMenu(GLUT_RIGHT_BUTTON); glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(idle); glutMainLoop(); return 0; }
int main(int argc, char* argv[]) { GLint i; glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(windowWidth, windowHeight); glutCreateWindow("Procedural Texture Mapping Demo"); glutReshapeFunc(ChangeSize); glutKeyboardFunc(KeyPressFunc); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); SetupRC(); // Create the menus shaderMenu = glutCreateMenu(ProcessMenu); for (i = 0; i < TOTAL_SHADER_SETS; i++) { char menuEntry[128]; sprintf(menuEntry, "\"%s\"", shaderNames[i]); glutAddMenuEntry(menuEntry, 1+i); } mainMenu = glutCreateMenu(ProcessMenu); { char menuEntry[128]; sprintf(menuEntry, "Choose fragment shader (currently \"%s\")", shaderNames[0]); glutAddSubMenu(menuEntry, shaderMenu); } glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); if (glDeleteProgram && glDeleteShader) { for (i = 0; i < TOTAL_SHADER_SETS; i++) { glDeleteProgram(progObj[i]); glDeleteShader(vShader[i]); glDeleteShader(fShader[i]); } } return 0; }
static void menuInit() { menuId = glutCreateMenu(menuSelected); glutAddMenuEntry("Gaussian blur", GAUSSIAN_BLUR); glutAddMenuEntry("Sharpen", SHARPEN); glutAddMenuEntry("Mean removal", MEAN_REMOVAL); glutAddMenuEntry("Emboss", EMBOSS); glutAddMenuEntry("Edge detect", EDGE_DETECT); glutAddMenuEntry("None", NO_FILTER); glutAddMenuEntry("Quit", QUIT); glutAttachMenu(GLUT_RIGHT_BUTTON); }
////////////////////////////////////////////////////// // Program entry point int main(int argc, char *argv[]) { gltSetWorkingDirectory(argv[0]); // Standard initialization stuff glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(800, 600); glutCreateWindow("Anisotropic Tunnel"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); #ifdef ANGLE glutKeyboardFunc(KeyPressFunc); #else // Add menu entries to change filter glutCreateMenu(ProcessMenu); glutAddMenuEntry("GL_NEAREST",0); glutAddMenuEntry("GL_LINEAR",1); glutAddMenuEntry("GL_NEAREST_MIPMAP_NEAREST",2); glutAddMenuEntry("GL_NEAREST_MIPMAP_LINEAR", 3); glutAddMenuEntry("GL_LINEAR_MIPMAP_NEAREST", 4); glutAddMenuEntry("GL_LINEAR_MIPMAP_LINEAR", 5); glutAddMenuEntry("Anisotropic Filter", 6); glutAddMenuEntry("Anisotropic Off", 7); glutAttachMenu(GLUT_RIGHT_BUTTON); GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return 1; } #endif // Startup, loop, shutdown SetupRC(); glutMainLoop(); ShutdownRC(); return 0; }
//create the right click menu void InitMenu(void) { //main menu glutCreateMenu(OnMainMenu); glutAddMenuEntry("------------------------", -1); glutAddMenuEntry("Toggle fullscreen [f]", 'f'); glutAddMenuEntry("Toggle animation [s]" , 's'); glutAddMenuEntry("Step animation [ ]", ' '); glutAddMenuEntry("------------------------", -1); glutAddMenuEntry("Quit [ESC]", '\033'); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void glut_current_PSF_select() { int i; int id_current; char title[LENGTHBUF]; char psf_name[LENGTHBUF]; id_current = send_current_PSF(); for (i=0; i< send_max_loaded_PSF(); i++) { if(i != id_current && send_loaded_PSF_flag(i) > 0){ set_to_current_PSF(i); send_current_psf_file_header(psf_name); sprintf(title, "%d: %s", i, psf_name); glutAddMenuEntry(title,i); } }; set_to_current_PSF(id_current); return; }
void SubMenu() { SubMenu1 = glutCreateMenu(MenuFunc); glutAddMenuEntry("Sphere", 0); glutAddMenuEntry("Cube", 2); glutAddMenuEntry("Torus", 4); glutAddMenuEntry("Teapot", 6); SubMenu2 = glutCreateMenu(MenuFunc); glutAddMenuEntry("Sphere", 1); glutAddMenuEntry("Cube", 3); glutAddMenuEntry("Torus", 5); glutAddMenuEntry("Teapot", 7); MainMenu = glutCreateMenu(MenuFunc); glutAddSubMenu("Solid Object", SubMenu1); glutAddSubMenu("Wire Object", SubMenu2); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void createMenu(void) { glutPostRedisplay(); submenu_id = glutCreateMenu(menu); glutAddMenuEntry("Line", 2); glutAddMenuEntry("Circle", 3); glutAddMenuEntry("Triangle", 4); glutAddMenuEntry("Teapot", 5); menu_id = glutCreateMenu(menu); glutAddMenuEntry("Clear", 1); glutAddSubMenu("Draw", submenu_id); glutAddMenuEntry("Quit", 0); glutAttachMenu(GLUT_RIGHT_BUTTON); }
/* Initialises the menu of toggles. */ void create_menu_opengl_cinetheodolite(void) { glutCreateMenu(menu_opengl_cinetheodolite); //glutAttachMenu(GLUT_LEFT_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); //glutAddMenuEntry("Shaded", 1); glutAddMenuEntry(" start/stop animation 1 : MGI ", _ANIMATION1); glutAddMenuEntry(" start/stop animation 2 : qi ", _ANIMATION2); glutAddMenuEntry(" start/stop simulation 1 ,Open Loop : Fq =0 ", _SIMULATION1); glutAddMenuEntry(" start/stop simulation 2 , Internal loop : d2qsurdt2=0", _SIMULATION2); glutAddMenuEntry(" start/stop simulation 3 , Internal loop : d2qsurdt2=0", _SIMULATION3); glutAddMenuEntry(" start/stop simulation 4 , Internal loop : d2qsurdt2=0", _SIMULATION4); }
//================================================================== void RibRendToy::addDirToMenu( const char *pDirName, const char *pFilesExt ) { #if defined(WIN32) DStr buff = DUT::SSPrintFS( "%s/*.%s", pDirName, pFilesExt ); _finddatai64_t findData; intptr_t handle = _findfirst64( buff.c_str(), &findData ); if ( handle != -1 ) { int ret = 0; do { mTestRibFiles.push_back( findData.name ); mTestRibFilesPaths.push_back( pDirName ); glutAddMenuEntry( DUT::SSPrintFS( "%s / %s", pDirName, findData.name ).c_str(), MENUID_FILES + (int)mTestRibFiles.size()-1 ); ret = _findnext64( handle, &findData ); } while ( ret == 0 ); _findclose( handle ); } #elif defined(__linux__) DIR *pDir = opendir( pDirName ); if ( pDir ) { struct dirent *pDirent; while ( pDirent = readdir( pDir ) ) { //pDirent-> } closedir( pDir ); } #endif }
int main(int argc, char **argv) { GLboolean fullscreen = GL_FALSE; GLint time_menu; srand(0); glutInit(&argc, argv); if (argc > 1 && !strcmp(argv[1], "-w")) fullscreen = GL_FALSE; //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitDisplayString("rgba double depth=24"); if (fullscreen) { glutGameModeString("1024x768:32"); glutEnterGameMode(); } else { glutInitWindowSize(320, 240); glutCreateWindow("Atlantis Timing"); } Init(); glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); moving = GL_TRUE; glutIdleFunc(Animate); glutVisibilityFunc(Visible); time_menu = glutCreateMenu(timingSelect); glutAddMenuEntry("GL_VENDOR", 1); glutAddMenuEntry("GL_RENDERER", 2); glutAddMenuEntry("GL_VERSION", 3); glutAddMenuEntry("GL_EXTENSIONS", 4); glutCreateMenu(menuSelect); glutAddMenuEntry("Start motion", 1); glutAddMenuEntry("Stop motion", 2); glutAddSubMenu("Timing Mode", time_menu); glutAddMenuEntry("Quit", 4); //glutAttachMenu(GLUT_RIGHT_BUTTON); glutAttachMenu(GLUT_RIGHT_BUTTON); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }
/* * Menu creation */ void SetUpMenu(void) { int SampleMenu; SampleMenu = glutCreateMenu(SelectSampleRate); glutAddMenuEntry("1", 1); glutAddMenuEntry("5", 5); glutAddMenuEntry("10", 10); glutAddMenuEntry("20", 20); glutCreateMenu(MainMenu); glutAddMenuEntry("Mouse Motion", 0); glutAddMenuEntry("Line antialias", 1); glutAddSubMenu("Sample rate", SampleMenu); glutAddMenuEntry("Quit", 2); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void OpenGLApplicationBase::setupMenus() { GLuint menu1id = createPolygonMenu(); GLuint menu2id = createFrontFaceMenu(); GLuint menu3id = createPointSizeMenu(); GLuint menu4id = createLineWidthMenu(); GLuint menu5id = createAntiAliasingMenu(); //Create main menu topMenu = glutCreateMenu(mainMenu); glutAddSubMenu("Polygon Mode", menu1id); glutAddSubMenu("Rendered Polygon Face", menu2id); glutAddSubMenu("Point Size", menu3id); glutAddSubMenu("Line Width", menu4id); glutAddSubMenu("Anti-aliasing", menu5id); glutAddMenuEntry("Quit", 1); //Quit identifier. glutAttachMenu(GLUT_RIGHT_BUTTON);//Menu responds to right button }
//Create Right Click Menu void initMenu() { int id = glutCreateMenu(menu); glutSetMenu(id); glutAddMenuEntry("Clear", 0); glutAddMenuEntry("Play/Pause", 1); glutAddMenuEntry("Increment Speed", 2); glutAddMenuEntry("Decrement Speed", 3); glutAddMenuEntry("Randomize Grid", 4); glutAddMenuEntry("Quit", 5); glutAttachMenu(GLUT_RIGHT_BUTTON); }
void createMenuEntry(const char* csName, ActionFunc func, int arg) { strcpy(g_MenuEntries[g_MenuBuilder.nCurrMenuItem].csName, csName); char key = getRegisteredKey(func, arg); if (key != 0) { if (key == 27) strcat(g_MenuEntries[g_MenuBuilder.nCurrMenuItem].csName + strlen(csName), " [Esc]"); else sprintf(g_MenuEntries[g_MenuBuilder.nCurrMenuItem].csName + strlen(csName), " [%c]", key); } g_MenuEntries[g_MenuBuilder.nCurrMenuItem].pCallbackFunc = func; g_MenuEntries[g_MenuBuilder.nCurrMenuItem].nCallbackArg = arg; glutAddMenuEntry(g_MenuEntries[g_MenuBuilder.nCurrMenuItem].csName, g_MenuBuilder.nCurrMenuItem); (g_MenuBuilder.nCurrMenuItem)++; }
int main(int argc, char * argv[]) { gltSetWorkingDirectory(argv[0]); glutInit(&argc, argv); glutInitDisplayMode(GL_DOUBLE | GL_DEPTH | GL_STENCIL); glutInitWindowSize(1440, 900); glutCreateWindow("Tunnel @Jingz"); glutReshapeFunc(ChangeSize); glutDisplayFunc(RenderScene); glutSpecialFunc(SpecialKeys); glutCreateMenu(ProcessMenu); glutAddMenuEntry("GL_NEAREST", 0); glutAddMenuEntry("GL_LINEAR", 1); glutAddMenuEntry("GL_NEAREST_MIPMAP_NEAREST", 2); glutAddMenuEntry("GL_NEAREST_MIPMAP_LINEAR", 3); glutAddMenuEntry("GL_LINEAR_MIPMAP_NEAREST", 4); glutAddMenuEntry("GL_LINEAR_MIPMAP_LINEAR", 5); glutAddMenuEntry("Anisotropic Filter", 6); glutAddMenuEntry("Anisotropic Off", 7); glutAttachMenu(GLUT_RIGHT_BUTTON); GLenum err = glewInit(); if (err != GLEW_OK) { fprintf(stderr, "GLEW ERROR: %s\n", glewGetErrorString(err)); } SetupRC(); glutMainLoop(); ShutdownRC(); return 0; }
/*! * */ static void init(void) { glClearColor(0.5, 0.5, 0.5, 1.0); glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); //glDisable(GL_NORMALIZE); //glPolygonOffset(1.0, 2); file=lib3ds_file_load(filename); if (!file) { puts("***ERROR*** Loading 3DS file failed."); exit(1); } if (!file->cameras) { puts("***ERROR*** No Camera found."); lib3ds_file_free(file); file=0; exit(1); } if (!camera) { camera=file->cameras->name; } camera_menu_id=glutCreateMenu(camera_menu); { Lib3dsCamera *c; int i; for (c=file->cameras,i=0; c; c=c->next,++i) { glutAddMenuEntry(c->name, i); } } glutAttachMenu(0); lib3ds_file_eval(file,0); }