static int AuxBuffers(lua_State *L) { int n; if(!lua_isnoneornil(L, 1)) /* set */ { n = luaL_checkinteger(L, 1); glutSetOption(GLUT_AUX, n); } lua_pushinteger(L, glutGet(GLUT_AUX)); return 1; }
int main(int argc, char** argv) { // Create GLUT window glutInit(&argc, argv); #ifdef __FREEGLUT_EXT_H__ glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE); glutInitWindowSize(1280, 720); glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example"); // Setup GLUT display function // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us, // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves. glutDisplayFunc(glut_display_func); // Setup Dear ImGui context ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); // Setup Platform/Renderer bindings ImGui_ImplGLUT_Init(); ImGui_ImplGLUT_InstallFuncs(); ImGui_ImplOpenGL2_Init(); // Load Fonts // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. // - Read 'misc/fonts/README.txt' for more instructions and details. // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); //IM_ASSERT(font != NULL); glutMainLoop(); // Cleanup ImGui_ImplOpenGL2_Shutdown(); ImGui_ImplGLUT_Shutdown(); ImGui::DestroyContext(); return 0; }
static int SkipStaleMotionEvents(lua_State *L) { int b; if(!lua_isnoneornil(L, 1)) /* set */ { b = checkboolean(L, 1); glutSetOption(GLUT_SKIP_STALE_MOTION_EVENTS, b); } lua_pushboolean(L, (glutGet(GLUT_SKIP_STALE_MOTION_EVENTS) == GL_TRUE)); return 1; }
static int StrokeFontDrawJoinDots(lua_State *L) { int b; if(!lua_isnoneornil(L, 1)) /* set */ { b = checkboolean(L, 1); glutSetOption(GLUT_STROKE_FONT_DRAW_JOIN_DOTS, b); } lua_pushboolean(L, (glutGet(GLUT_STROKE_FONT_DRAW_JOIN_DOTS) == GL_TRUE)); return 1; }
//--------------------------------------------------------------------------------- int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) { int argc = 0; char* argv = ""; // Exit handler to check memory on exit. const int result_1 = std::atexit(CheckMemCallback); std::wstring commandLine(lpCmdLine); gEditorMode = commandLine.find(L"-Editor") != std::string::npos; // Setup glut. glutInit(&argc, &argv); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutInitWindowPosition(100, 100); int glutWind = glutCreateWindow(APP_WINDOW_TITLE); HDC dc = wglGetCurrentDC(); MAIN_WINDOW_HANDLE = WindowFromDC(dc); glutIdleFunc(Idle); glutDisplayFunc(Display); // Register callback handler for window re-paint event glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); InitGL(); // Our own OpenGL initialization // Init sounds system. CSimpleSound::GetInstance().Initialize(MAIN_WINDOW_HANDLE); // Call user defined init. if (gEditorMode) { EditorInit(); } else { Init(); } // Enter glut the event-processing loop glutMainLoop(); // Call user shutdown. if (gEditorMode) { EditorShutdown(); } else { Shutdown(); } // Shutdown sound system. CSimpleSound::GetInstance().Shutdown(); // And we are done. return 0; }
int main(int argc, char** argv) { glutInit(&argc, argv); int width = 500; int height = 500; unsigned int displayMode = GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL; displayMode = defaults(displayMode, width, height); glutInitDisplayMode (displayMode); glutInitContextVersion (3, 3); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); #ifdef DEBUG glutInitContextFlags(GLUT_DEBUG); #endif glutInitWindowSize (width, height); glutInitWindowPosition (300, 200); int window = glutCreateWindow (argv[0]); glload::LoadFunctions(); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); if(!glload::IsVersionGEQ(3, 3)) { printf("Your OpenGL version is %i, %i. You must have at least OpenGL 3.3 to run this tutorial.\n", glload::GetMajorVersion(), glload::GetMinorVersion()); glutDestroyWindow(window); return 0; } if(glext_ARB_debug_output) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glDebugMessageCallbackARB(DebugFunc, (void*)15); } init(); UserListener listener; Leap::Controller controller; controller.addListener(listener); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); controller.removeListener(listener); return 0; }
/*----------------------------------------------------------------------------------------------- Description: Program start and end. Parameters: argc The number of strings in argv. argv A pointer to an array of null-terminated, C-style strings. Returns: 0 if program ended well, which it always does or it crashes outright, so returning 0 is fine Exception: Safe Creator: John Cox (2-13-2016) -----------------------------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { glutInit(&argc, argv); int width = 500; int height = 500; unsigned int displayMode = GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL; displayMode = Defaults(displayMode, width, height); glutInitDisplayMode(displayMode); glutInitContextVersion(4, 4); glutInitContextProfile(GLUT_CORE_PROFILE); // enable this for automatic message reporting (see OpenGlErrorHandling.cpp) #define DEBUG #ifdef DEBUG glutInitContextFlags(GLUT_DEBUG); #endif glutInitWindowSize(width, height); glutInitWindowPosition(300, 200); int window = glutCreateWindow(argv[0]); glload::LoadTest glLoadGood = glload::LoadFunctions(); // ??check return value?? glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); if (!glload::IsVersionGEQ(3, 3)) { printf("Your OpenGL version is %i, %i. You must have at least OpenGL 3.3 to run this tutorial.\n", glload::GetMajorVersion(), glload::GetMinorVersion()); glutDestroyWindow(window); return 0; } if (glext_ARB_debug_output) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); glDebugMessageCallbackARB(DebugFunc, (void*)15); } Init(); glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutKeyboardFunc(Keyboard); glutMainLoop(); CleanupAll(); return 0; }
void LensFlareSunDemo::doSomeMagic() { glutDisplayFunc(renderWrapper); glutReshapeFunc(reshapeWrapper); glutIdleFunc(updateWrapper); glutPassiveMotionFunc(mouseInputWrapper); glutKeyboardFunc(keyboardInputWrapper); glutWarpPointer(WIDTH/2,HEIGHT/2); glutSetCursor(GLUT_CURSOR_NONE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutMainLoop(); }
int main(int argc, char **argv) { // GLUT initialization glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA); //glutInitContextVersion (3, 3); //glutInitContextProfile (GLUT_CORE_PROFILE ); //glutInitContextFlags(GLUT_DEBUG); glutInitWindowPosition(100,100); glutInitWindowSize(320,320); glutCreateWindow("Lighthouse3D - Simplest Demo"); // Callback Registration glutDisplayFunc(renderScene); glutReshapeFunc(changeSize); glutIdleFunc(renderScene); // return from main loop glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); // Init GLEW glewExperimental = GL_TRUE; glewInit(); if (glewIsSupported("GL_VERSION_3_3")) printf("Ready for OpenGL 3.3\n"); else { printf("OpenGL 3.3 not supported\n"); exit(1); } printf ("Vendor: %s\n", glGetString (GL_VENDOR)); printf ("Renderer: %s\n", glGetString (GL_RENDERER)); printf ("Version: %s\n", glGetString (GL_VERSION)); printf ("GLSL: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION)); int param; glGetIntegerv(GL_CONTEXT_PROFILE_MASK, ¶m); if (param == GL_CONTEXT_CORE_PROFILE_BIT) printf("Context Profile: Core\n"); else printf("Context Profile: Compatibility\n"); glGetIntegerv(GL_CONTEXT_FLAGS, ¶m); glEnable(GL_DEPTH_TEST); setupShaders(); glutMainLoop(); return(1); }
/* initializes the GUI class for later use and returns true in case of success */ bool glutGUI::init() { if (wrap_ptr==NULL) wrap_ptr = this; int argcount = 0; glutInit(&argcount, NULL); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); #ifdef APP_USING_FREEGLUT //If we use freeglut API instead of the usual one, we like to return from the //main loop instead of exiting without prior notice. glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif return true; }
int main(int argc, char **argv) { // GLUT initialization glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA|GLUT_MULTISAMPLE); glutInitContextVersion (3, 3); glutInitContextProfile (GLUT_CORE_PROFILE ); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG); glutInitWindowPosition(100,100); glutInitWindowSize(WinX, WinY); WindowHandle = glutCreateWindow(CAPTION); // Callback Registration glutDisplayFunc(renderScene); glutReshapeFunc(changeSize); glutIdleFunc(idle); // Mouse and Keyboard Callbacks glutKeyboardFunc(keyPressed); //Funcao a ser chamada ao pressionar uma tecla glutIgnoreKeyRepeat(1); //Impedir que, ao pressionar uma tecla continuamente, seja chamada a funcao keyPressed repetidamente glutKeyboardUpFunc(keyReleased); //Funcao a ser chamada ao libertar uma tecla glutMouseFunc(processMouseButtons); glutMotionFunc(processMouseMotion); glutMouseWheelFunc ( mouseWheel ) ; glutTimerFunc(0,timer,0); glutTimerFunc(0, refresh, 0); glutTimerFunc(0, iterate, 0); // return from main loop glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); // Init GLEW glewExperimental = GL_TRUE; glewInit(); printf ("Vendor: %s\n", glGetString (GL_VENDOR)); printf ("Renderer: %s\n", glGetString (GL_RENDERER)); printf ("Version: %s\n", glGetString (GL_VERSION)); printf ("GLSL: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION)); if (!setupShaders()) return(1); init(); // GLUT main loop glutMainLoop(); return(0); }
/////////////////////////////////////////////////////////////////////////////// // // tlb_gui function // // author: Shaun Gruenig, Hannah Aker, Kelsey Bellew // // description: This is a helper function that initializes the GUI and then // calls the function to print the TLB. // // /////////////////////////////////////////////////////////////////////////////// void tlb_gui() { ScreenWidth = 200; ScreenHeight = TLB_SIZE * 30; glutInit ( & ( *superargc ), ( *superargv ) ); glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ); initOpenGL(); glutDisplayFunc ( draw_tlb ); glutMainLoop(); }
bool GLUTEngine::Init( int argc, char** argv ) { // Initialize with command-line arguments glutInit(&argc, argv); // Request double buffer, Red-Green-Blue-Alpha color components and multisampling support glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE ); // return to main() for the grand final glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); init = true; return SUCCESS; }
/* * Performs basic initialization for an OpenGL GLUT application. */ void GLUTBaseInit(int argc, char** argv) { // Pass any applicable command line arguments to GLUT. These arguments // are platform dependent. glutInit(&argc, argv); // Set initial display mode for double buffering and RGBA color. // Explicitly request double buffering, RGBA (Red Green Blue Alpha) color mode and // a depth buffer for hidden surface removal. glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ); // Indicate to GLUT that the flow of control should return to the program after // the window is closed and the GLUTmain loop is exited. glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); } // end GLUTBaseInit
void Window::createWindow(int width, int height, std::string title) { int argc = 1; char a = '1'; char* argv[] = {&a}; glutInit(&argc, argv); glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH ); glutInitWindowPosition( 0, 0 ); glutInitWindowSize(width, height); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutCreateWindow( title.c_str() ); glutWMCloseFunc( onClosing ); }
/////////////////////////////////////////////////////////////////////////////// // // pt_gui function // // author: Shaun Gruenig, Hannah Aker, Kelsey Bellew // // description: This is a helper function that initializes the GUI and then // calls the function to print the page table. // // /////////////////////////////////////////////////////////////////////////////// void pt_gui() { ScreenWidth = 240; ScreenHeight = ptvec.size() / 2 * 30; glutInit ( & ( *superargc ), ( *superargv ) ); glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ); initOpenGL(); glutDisplayFunc ( draw_pt ); glutMainLoop(); }
void WinOpen(int w, int h) { int argc = 0; FATAL_IF(window, "A window is already opened"); PF_MSG_V("GLUT: initialization"); glutInitWindowSize(w, h); glutInitWindowPosition(64, 64); glutInit(&argc, NULL); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); PF_MSG_V("GLUT: creating window"); window = glutCreateWindow("point-frag"); previousInput = PF_NEW(InputControl); previousInput->processEvents(); }
/////////////////////////////////////////////////////////////////////////////// // // mem_gui function // // author: Shaun Gruenig, Hannah Aker, Kelsey Bellew // // description: This is a helper function that initializes the GUI and then // calls the function to print the physical memory. // // /////////////////////////////////////////////////////////////////////////////// void mem_gui() { ScreenWidth = 8 * 130; ScreenHeight = memvec.size() / 8 * 25; glutInit ( & ( *superargc ), ( *superargv ) ); glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ); initOpenGL(); glutDisplayFunc ( draw_mem ); glutMainLoop(); }
int main(int argc, char* argv[]) { /* Glut-related initialising functions */ glutInit(&argc, argv); //glutInitContextVersion(4, 0); //glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); //alternative GLUT_ACTION_GLUTMAINLOOP_RETURNS glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(640, 480); glutCreateWindow("Tetris"); /* Extension wrangler initialising */ GLenum glew_status = glewInit(); if (glew_status != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status)); return EXIT_FAILURE; } /* When all init functions run without errors, the program can initialise the resources */ if (1 == init_resources()) { /* We can display it if everything goes OK */ glutDisplayFunc(onDisplay); glutReshapeFunc(onReshape); glutKeyboardFunc(onKeyPressed); glutSpecialFunc(specialKeyPressed); glutMouseFunc(onMouse); glutMotionFunc(onMotion); glutMouseWheelFunc(onMouseWheel); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); glutTimerFunc(0, timerCallBack, 0); //glDepthFunc(GL_LESS); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); } /* If the program exits in the usual way, free resources and exit with a success */ free_resources(); return EXIT_SUCCESS; }
//Ruft alle FreeGLUT Funktionen um ein Window zu öffnen auf void InitWindow(int argc, char* argv[]) { //Initialisiert die FreeGLUT lib (ist die erste FreeGLUT Funktion, die aufgerufen werden sollte) glutInit(&argc, argv); //*************Angabe des OpenGL Kontextes************* glutInitContextVersion(3, 3);//OpenGL Version 3.3 glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);//Setzt die Kompatibilität so, dass es auch mit späteren OpenGL Versionen funktioniert glutInitContextProfile(GLUT_CORE_PROFILE);//nutzt OpenGL nur mit den neuesten Funktionen (compatibility mode = um ältere Versionen zu nutzen) //***************************************************** //GLUT_ACTION_ON_WINDOW_CLOSE und GLUT_ACTION_GLUTMAINLOOP_RETURNS bewirkt, dass die mainLoop Funktion das Programm nicht beendet sondern zum Programm zurückkehrt glutSetOption( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS ); //setzt die Größe des render-Fensters glutInitWindowSize(CurrentWidth, CurrentHeight); //Displaymode gibt an, wie das Gerät die Szene rendern soll //GLUT_DEPTH = enthält die Tiefeninformation von Z für jeden Pixel (verhindert, dass neue Objekte nicht Objekte näher an der Kamera überlappen) //GLUT_DOUBLE = Flag um doppelbuffering zu aktivieren (reduziert flackern - 2 Buffer werden immer wieder Ausgewechselt - einer zum anzeigen, der andere zum rendern) //GLUT_RGBA = Flag um Farbkompositionen anzugeben (RGBA = Rot, Grün, Blau, Alpha) //es sind mehrere zusätzliche Optionen möglich glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); //erstellt ein Window und speichert das Handle dazu in WindowHandle (Parameter ist Window Title String) WindowHandle = glutCreateWindow("Test"); //Handle checken, ob er kleiner als 1 ist, wenn ja wird Error geworfen und Programm beendet if(WindowHandle < 1) { fprintf( stderr, "ERROR: Could not create a new rendering window.\n" ); glutExit(); } //Glut function callbacks //TODO: add keyboard and mouse functions glutTimerFunc(0, TimerFunction, 0); //startet direkt die Funktion TimerFunction und übergibt 0 (damit der Titel am anfang nicht geändert wird) glutReshapeFunc(ResizeFunction); //wird jedes mal aufgerufen, wenn das Window verkleinert oder vergrößert wird glutDisplayFunc(RenderFunction); //wird jedes mal ausgeführt, wenn die szene auf den Bildschirm gezeichnet werden soll glutIdleFunc(IdleFunction); //macht die Idle Funktion bekannt glutKeyboardFunc(KeyEventProcessing); }
int main(int argc, char *argv[]) { glutInitWindowSize(640,480); glutInitWindowPosition(40,40); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); glutCreateWindow("FreeGLUT Shapes"); glutReshapeFunc(resize); glutDisplayFunc(display); glutKeyboardFunc(key); glutSpecialFunc(special); glutIdleFunc(idle); glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ; glClearColor(1,1,1,1); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glutMainLoop(); #ifdef _MSC_VER /* DUMP MEMORY LEAK INFORMATION */ _CrtDumpMemoryLeaks () ; #endif return EXIT_SUCCESS; }
void Engine::initGLUT() { int argc = 1; char *argv[] = {"Bin", NULL}; glutInit(&argc, argv); if(context->core) { glutInitContextVersion(context->majorVersion, context->minorVersion); glutInitContextProfile(GLUT_CORE_PROFILE); } else { glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE); } glutInitDisplayMode(framebuffer->flags); glutInitWindowPosition(window->positionX, window->positionY); glutInitWindowSize(window->width, window->height); // in case GL_DEBUG_OUTPUT doesn't work // glutInitContextFlags(GLUT_DEBUG); glutCreateWindow(window->name.c_str()); std::cout << "GLUT initialized\n"; glEnable(GL_DEBUG_OUTPUT); glutSetWindowData(static_cast<void *>(this)); glutIdleFunc(idleCallback); glutDisplayFunc(displayCallback); glutReshapeFunc(reshapeCallback); glutCloseFunc(closeCallback); glutKeyboardFunc(handleKeyboardCallback); glutKeyboardUpFunc(handleKeyboardUpCallback); glutSpecialFunc(handleKeyboardSpecialCallback); glutSpecialUpFunc(handleKeyboardSpecialUpCallback); glutMotionFunc(handleMouseMovement); glutPassiveMotionFunc(handleMouseMovement); initGLEW(); glDebugMessageCallback(DebugOutput::printDebugOutput, NULL); //GLenum severity = GL_DEBUG_SEVERITY_LOW | GL_DEBUG_SEVERITY_MEDIUM | GL_DEBUG_SEVERITY_HIGH | GL_DEBUG_SEVERITY_NOTIFICATION; glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, NULL, GL_FALSE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); std::cout << "Info | Vendor: " << glGetString(GL_VENDOR) << " | Renderer: " << glGetString(GL_RENDERER) << " | OpenGl version: " << glGetString(GL_VERSION) << std::endl; }
glutGet(): case GLUT_DIRECT_RENDERING: return fgState.DirectContext; @@ case : return fgState.SkipStaleMotion; @@ default: return fgPlatformGlutGet ( eWhat ); break; @@ #endif static int Multisample(lua_State *L) { int n; if(!lua_isnoneornil(L, 1)) /* set */ { n = luaL_checkinteger(L, 1); glutSetOption(GLUT_MULTISAMPLE, n); } lua_pushinteger(L, glutGet(GLUT_MULTISAMPLE)); return 1; }
//Initialization functions void initWindow(int argc, _TCHAR* argv[], const BratsGLUtilities::WindowData& winData) { //Initialize glut and pass "command-line" parameters to it. glutInit(&argc, (char**) argv); //TODO: Find out the correct type of C++ //cast to use //Initialize an OpenGL context. //Get an OpenGL 4.1 compatible context - glutInitContextVersion(4, 1); #ifndef REQUEST_DEBUG_PROFILE //which is forward compatible (General) - glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); #else //which is forward compatible and a debug context (For debug builds) - glutInitContextFlags(GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG); #endif //and is a core profile context without Fixed Function Pipeline stuff. glutInitContextProfile(GLUT_CORE_PROFILE); //Tell GLUT to return to the main program on window close. glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); //Initialize OpenGL for double buffering, RGBA colour and depth buffering. glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE); //Initialize a GLUT window from the winData struct passed in. glutInitWindowSize(winData.width, winData.height); //Try creating a GLUT window. int windowHandle = glutCreateWindow(winData.windowTitle.c_str()); //See if that worked //If window creation failed, report an error and exit with a fail status. if(windowHandle < 1) { std::cerr << "Failed to create rendering window." << std::endl; exit(EXIT_FAILURE); } //Register callbacks. glutDisplayFunc(draw); glutReshapeFunc(resize); //Initialize OpenGL state (and GLEW). initGL(); }
int main(int argc, char* argv[]) { ////////////////////////////////////////// RakNet ////////////////////////////////////////////////////// initNetwork(false); ////////////////////////////////////////// OPEN GL ////////////////////////////////////////////////////// // Initialize GLUT glutInit(&argc, argv); // Set up some memory buffers for our display glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); // This one allows me to close the network before the program exits after "X" is pressed. glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutInitWindowPosition(10, 10); glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT); glutCreateWindow("BoizStone"); //glutFullScreen(); // Bind functions glutReshapeFunc(changeViewPort); glutDisplayFunc(render); glutIdleFunc(idleFunction); glutKeyboardFunc(keyPress); glutSpecialFunc(specPress); glutMouseFunc(mouseClick); glutPassiveMotionFunc(mousePassive); glutMotionFunc(mouseActive); // Very important! This initializes the entry points in the OpenGL driver so we can // call all the functions in the API. GLenum err = glewInit(); if (GLEW_OK != err) { fprintf(stderr, "GLEW error"); return 1; } if (net_isServer()) { gameData.toggle_turn(); } srand(time(NULL)); start_game(); glutMainLoop(); closeNetworking(); return 0; }
void openwin2(){ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_MULTISAMPLE); GLenum err = glewInit(); if (err != GLEW_OK){ std::cout << "fail" << std::endl; return; } glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutInitWindowPosition(520, 10); glutInitWindowSize(WIDTH, HEIGHT); window2 = glutCreateWindow("shadow sample"); init2(); glutDisplayFunc(display2); glutReshapeFunc(reshape2); glutIdleFunc(idle2); //glutMainLoop(); }
void setupGLUT(int argc, char* argv[]) { glutInit(&argc, argv); glutInitContextVersion(3, 3); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS); glutInitWindowSize(WinX, WinY); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); WindowHandle = glutCreateWindow(CAPTION); if(WindowHandle < 1) { std::cerr << "ERROR: Could not create a new rendering window." << std::endl; exit(EXIT_FAILURE); } }
void init_graphics(int nargs, char** args, const char* title_bar, int x, int y) { /*KKCODEBLOCKSSUCKS*/#define SKMK_GLUT #ifdef SKMK_GLUT glutInit(&nargs, args); glutInitDisplayMode(GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL); //kk glutInitContextVersion(3, 3); glutInitContextVersion(3, 1); glutInitContextProfile(GLUT_CORE_PROFILE); #ifdef SKMK_DEBUG glutInitContextFlags(GLUT_DEBUG); #endif glutInitWindowSize(x, y); glutInitWindowPosition(300, 300); int window = glutCreateWindow(title_bar); ogl_load_funcs(); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); skmk.ogl_state = malloc(sizeof(struct ogl_state)); init_ogl(skmk.ogl_state); //!! glutDisplayFunc(ogl_draw); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); #elif SKMK_SDL2 //SDL_GLContext glcontext = SDL_GL_CreateContext(SDL_WINDOW); { SDL_Init(SDL_INIT_EVERYTHING); //TODO: Check errors K_SDL_WINDOW = SDL_CreateWindow(title_bar, 0, 0, x, y, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); K_GL_CONTEXT = SDL_GL_CreateContext(K_SDL_WINDOW); ogl_init(); } #else #error You have to either use GLUT or SDL. #endif }
int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp, int posX, int posY, bool showWindow) { gDemoApplication = demoApp; glutInit(&argc, argv); //glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); glutInitWindowPosition(posX, posY); glutInitWindowSize(width, height); glutCreateWindow(title); #ifdef BT_USE_FREEGLUT glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif gDemoApplication->myinit(); glutKeyboardFunc(glutKeyboardCallback); glutKeyboardUpFunc(glutKeyboardUpCallback); glutSpecialFunc(glutSpecialKeyboardCallback); glutSpecialUpFunc(glutSpecialKeyboardUpCallback); glutReshapeFunc(glutReshapeCallback); //createMenu(); glutIdleFunc(glutMoveAndDisplayCallback); glutMouseFunc(glutMouseFuncCallback); glutPassiveMotionFunc(glutMotionFuncCallback); glutMotionFunc(glutMotionFuncCallback); glutDisplayFunc( glutDisplayCallback ); glutMoveAndDisplayCallback(); //enable vsync to avoid tearing on Apple (todo: for Windows) #if defined(__APPLE__) && !defined (VMDMESA) int swap_interval = 1; CGLContextObj cgl_context = CGLGetCurrentContext(); CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval); #endif if (!showWindow) glutHideWindow(); glutMainLoop(); return 0; }
/* matlab interface */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { int i; double *p; int argc = 1; char* argv[1]; argv[0] = ""; glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(WIDTH, HEIGHT); glutInitWindowPosition(100, 100); glutCreateWindow("render_cad_model"); if (nrhs != 2) mexErrMsgTxt("Wrong number of inputs"); /* parse vertices and faces */ p = (double*)mxGetPr(prhs[0]); Nvertice = mxGetN(prhs[0]); Vertices = (GLdouble*)malloc(sizeof(GLdouble)*Nvertice*3); for(i = 0; i < 3*Nvertice; i++) Vertices[i] = (GLdouble)p[i]; p = (double*)mxGetPr(prhs[1]); Nface = mxGetN(prhs[1]); Faces = (GLuint*)malloc(sizeof(GLuint)*Nface*3); for(i = 0; i < 3*Nface; i++) Faces[i] = (GLuint)p[i]; /* compute face normals */ Fnormals = compute_face_normals(Nvertice, Vertices, Nface, Faces); /* compute vertex normals */ Vnormals = compute_vertex_normals(Nvertice, Vertices, Nface, Faces, Fnormals); /* draw the CAD model */ glutDisplayFunc(display); glutReshapeFunc(reshape); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glutMainLoop(); return; }