void Renderer::initGlState() { // move this to an extra function - otherwice it's called twice due to mulitsampling loadExtensions(); glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations glHint(GL_TEXTURE_COMPRESSION_HINT,GL_FASTEST); glEnable(GL_TEXTURE_2D); GLint maxTexSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); ImgTexture::setMaxGlTextureSize(maxTexSize); if (isExtensionSupported("GL_EXT_fog_coord")){ glFogi(GL_FOG_MODE, GL_EXP); glFogf(GL_FOG_DENSITY, 5); GLfloat fogColor[4] = {0.0f, 0.0f, 0.0f, 1.0f}; // Fog Color - should be BG color glFogfv(GL_FOG_COLOR, fogColor); // Set The Fog Color glHint(GL_FOG_HINT, GL_NICEST); // Per-Pixel Fog Calculation glFogi(GL_FOG_COORD_SRC, GL_FOG_COORD); // Set Fog Based On Vertice Coordinates } glfwSwapInterval(0); vSyncEnabled = false; }
void REPL(bool verbose){ Context *globalContext = context_new(); context_enterScope(globalContext); fillOpTable(globalContext); int ext_num = loadExtensions(EXT_LOCATION, globalContext); printf("Loaded %d extensions\n", ext_num); import(globalContext, "stl.x"); int n_bytes = 100; char *source = malloc(n_bytes + 1); for(int i = 0;i < n_bytes + 1;i++) source[i] = 0; while (1){ getline(&source, &n_bytes, stdin); //printf("%s\n", source); TokenStream ts; fillTokenStream(&ts, source); while(!isEndOfStream(&ts)){ Node head = parse(&ts, 0); if(verbose) printTree(head, 0); ObjectNode *node = execute(globalContext, &head); printf("res>"); printObjectNode(node); printf("\n"); } } // closeExtensions(lib_handle, ext_num); context_leaveScope(globalContext); }
int DS_Init(void) { // Already initialized? if(initOk) return true; // Open the default playback device. device = alcOpenDevice(NULL); if(!device) { Con_Message("OpenAL init failed (default playback device)."); return false; } // Create and make current a new context. alcMakeContextCurrent(context = alcCreateContext(device, NULL)); DSOPENAL_ERRCHECK(alGetError()); // Attempt to load and configure the EAX extensions. loadExtensions(); // Configure the listener and global OpenAL properties/state. alListenerf(AL_GAIN, 1); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); headYaw = headPitch = 0; unitsPerMeter = 36; // Everything is OK. DSOPENAL_TRACE("DS_Init: OpenAL initialized%s." << (hasEAX? " (EAX 2.0 available)" : "")); initOk = true; return true; }
/*! Returns the list of file extensions associated with the MIME type. */ QStringList QMimeType::extensions() const { if(loadedTimes()->count() == 0) loadExtensions(); return extFor()->value(mimeId); }
View::View(RootSection *document, MainWindow* parent) : QWidget(parent) , m_doc(document) , m_canvas(0) , m_activeSection(0) , m_mainWindow(parent) , m_cutController(0) , m_copyController(0) { setXMLFile("braindumpview.rc"); m_doc->viewManager()->addView(this); m_editPaste = actionCollection()->addAction(KStandardAction::Paste, "edit_paste", this, SLOT(editPaste())); m_editCut = actionCollection()->addAction(KStandardAction::Cut, "edit_cut", 0, 0); m_editCopy = actionCollection()->addAction(KStandardAction::Copy, "edit_copy", 0, 0); initGUI(); initActions(); loadExtensions(); if(m_doc->sections().count() > 0) { setActiveSection(m_doc->sections()[0]); } else { setActiveSection(0); } m_doc->viewManager()->viewHasFocus(this); }
void testExecute(const char *source, bool verbose){ LOG("testExecuteSecond", "begin"); Context *globalContext = context_new(); context_enterScope(globalContext); LOG("testExecuteSecond", "filling op table"); fillOpTable(globalContext); LOG("testExecuteSecond", "loading extensions"); int ext_num = loadExtensions(EXT_LOCATION, globalContext); printf("Loaded %d extensions\n", ext_num); LOG("testExecuteSecond", "op table filled"); import(globalContext, "stl.x"); TokenStream ts; LOG("testExecuteSecond", "starting fill token stream"); fillTokenStream(&ts, source); LOG("testExecuteSecond", "token stream filled"); while(!isEndOfStream(&ts)){ LOG("testExecuteSecond", "calling parse"); Node head = parse(&ts, 0); LOG("testExecuteSecond", "returning form parse"); LOG("TestExecuteSecond", "calling execute"); if(verbose) printTree(head, 0); LOG("testExecuteSecond", "calling execute"); ObjectNode *node = execute(globalContext, &head); if(verbose){ printf("res>"); printObjectNode(node); printf("\n"); } } // closeExtensions(lib_handle, ext_num); context_leaveScope(globalContext); }
/*! Constructs a QMimeType from a \a fileName. */ QMimeType QMimeType::fromFileName( const QString &fileName ) { QMimeType type; int slashIndex = fileName.lastIndexOf( QLatin1Char( '/' ) ); int dotIndex = fileName.lastIndexOf( QLatin1Char( '.' ) ); if( dotIndex > slashIndex ) { if(loadedTimes()->count() == 0) loadExtensions(); QString extension = fileName.mid( dotIndex + 1 ).toLower(); type.mimeId = typeFor()->value( extension ); } if( type.mimeId.isEmpty() ) { const char elfMagic[] = { '\177', 'E', 'L', 'F', '\0' }; QFile ef( fileName ); if ( ef.size() > 5 && ef.open( QIODevice::ReadOnly ) && ef.peek(5) == elfMagic) // try to find from magic type.mimeId = QLatin1String("application/x-executable"); // could be a shared library or an exe else type.mimeId = QLatin1String("application/octet-stream"); } return type; }
void HeadlessView::activate() { if (thread != std::thread::id()) { throw std::runtime_error("OpenGL context was already current"); } thread = std::this_thread::get_id(); if (!glContext) { createContext(); } #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(glContext); if (error != kCGLNoError) { throw std::runtime_error(std::string("Switching OpenGL context failed:") + CGLErrorString(error) + "\n"); } #endif #if MBGL_USE_GLX if (!glXMakeContextCurrent(xDisplay, glxPbuffer, glxPbuffer, glContext)) { throw std::runtime_error("Switching OpenGL context failed.\n"); } #endif loadExtensions(); }
/*! Constructs a QMimeType from a file \a extension. To note, do not include the period. */ QMimeType QMimeType::fromExtension( const QString &extension ) { if(loadedTimes()->count() == 0) loadExtensions(); QMimeType type; type.mimeId = typeFor()->value( extension.toLower() ); return type; }
MainWindow::MainWindow(QWidget *widget, Qt::WFlags fl) : QMainWindow(widget, fl) , Ui::MainWindow() { setupUi(this); Ui_MainWindow::mainToolBar->setIconSize(QSize(35, 35)); connect(actionVolumeUp, SIGNAL(triggered()), this, SLOT(onVolumeUp())); connect(actionVolumeDown, SIGNAL(triggered()), this, SLOT(onVolumeDown())); connect(actionMute, SIGNAL(triggered()), this, SLOT(onMute())); connect(actionSkip, SIGNAL(triggered()), this, SLOT(onSkip())); connect(actionStop, SIGNAL(triggered()), this, SLOT(onStop())); connect(actionPlay, SIGNAL(triggered()), this, SLOT(onUnpause())); connect(actionPause, SIGNAL(triggered()), this, SLOT(onPause())); actionPlay->setVisible(false); connect(actionLogoutAndQuit, SIGNAL(triggered()), qApp, SLOT(logoutAndQuit())); connect(actionQuit, SIGNAL(triggered()), qApp, SLOT(logout())); connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAboutSpotfm())); m_settingsDlg = new SettingsDialog(this); connect(actionSettings, SIGNAL(triggered()), m_settingsDlg, SLOT(show())); Radio *radio = SpotFm::app()->radio(); connect(radio, SIGNAL(trackStarted(Track)), this, SLOT(onTrackStarted(Track))); connect(radio, SIGNAL(skipsLeft(int)), this, SLOT(enableSkipButton(int))); connect(radio, SIGNAL(trackProgress(int)), this, SLOT(onTrackProgress(int))); connect(radio, SIGNAL(error(int, QString)), this, SLOT(onRadioError(int, QString))); connect(volumeSlider, SIGNAL(valueChanged(int)), radio, SLOT(setVolume(int))); connect(stationWidget, SIGNAL(clicked()), this, SLOT(onNewStation())); stationWidget->setFocus(); QSettings *s = SpotFm::app()->settings(); volumeSlider->setValue(s->value("volume", 80).toInt()); radio->setVolume(volumeSlider->value()); m_lastVolume = volumeSlider->value(); defaultWindow(); setupTrayIcon(); loadExtensions(); }
/*! Returns the string mime type based on the filename \a filename. */ QString QMail::mimeTypeFromFileName(const QString& filename) { if (filename.isEmpty()) return QString(); loadExtensions(); // do a case insensitive search for a known mime type. QString lwrExtOrId = filename.toLower(); QHash<QString,QStringList>::const_iterator it = extFor()->find(lwrExtOrId); if (it != extFor()->end()) { return lwrExtOrId; } // either it doesnt have exactly one mime-separator, or it has // a path separator at the beginning QString mime_sep = QLatin1String("/"); bool doesntLookLikeMimeString = (filename.count(mime_sep) != 1) || (filename[0] == QDir::separator()); if (doesntLookLikeMimeString || QFile::exists(filename)) { int dot = filename.lastIndexOf('.'); QString ext = dot >= 0 ? filename.mid(dot+1) : filename; QHash<QString,QString>::const_iterator it = typeFor()->find(ext.toLower()); if (it != typeFor()->end()) { return *it; } const char elfMagic[] = { '\177', 'E', 'L', 'F', '\0' }; QFile ef(filename); if (ef.exists() && (ef.size() > 5) && ef.open(QIODevice::ReadOnly) && (ef.peek(5) == elfMagic)) { // try to find from magic return QLatin1String("application/x-executable"); // could be a shared library or an exe } else { return QLatin1String("application/octet-stream"); } } // could be something like application/vnd.oma.rights+object return lwrExtOrId; }
/*! \internal Loads the information from /etc/mime.types from all installpaths, and the root directory */ void QMimeType::loadExtensions() { QStringList paths; paths << QLatin1String("/") << Qtopia::installPaths(); const int CheckIntervalSeconds = 60 * 10; const QString etcMimeTypesConst = QLatin1String("etc/mime.types"); QFileInfo fi; foreach(QString path, paths) { QString file = QDir::cleanPath(path+etcMimeTypesConst); if(!loadedTimes()->contains(path) || loadedTimes()->value(path).secsTo(QDateTime::currentDateTime()) > CheckIntervalSeconds) { fi.setFile(file); if(fi.exists() && fi.created() > loadedTimes()->value(path)) { loadExtensions(file); loadedTimes()->insert(path, fi.created()); } } }
/*! Construct a new TasServerServiceManager */ TasServerServiceManager::TasServerServiceManager(QObject *parent) :QObject(parent) { mClientManager = TasClientManager::instance(); loadExtensions(); }
/* * main(argc, argv) - the standard C entry point for the program */ int main(int argc, char *argv[]) { GLuint quadList, sphereList; GLuint programObject[5]; // One quad and four spheres double fps = 0.0; GLFWvidmode vidmode; GLboolean running = GL_TRUE; // Main loop exits when this is set to GL_FALSE // Initialise GLFW glfwInit(); // Open a temporary OpenGL window just to determine the desktop size if( !glfwOpenWindow(256, 256, 8,8,8,8, 32,0, GLFW_WINDOW) ) { glfwTerminate(); // glfwOpenWindow failed, quit the program. return 1; } glfwGetDesktopMode(&vidmode); glfwCloseWindow(); // Open a window to cover the width of the current desktop if( !glfwOpenWindow(vidmode.Width-20, (int)(0.316*(vidmode.Width-20)), 8,8,8,8, 32,0, GLFW_WINDOW) ) { glfwTerminate(); // glfwOpenWindow failed, quit the program. return 1; } // Load the extensions for GLSL - note that this has to be done // *after* the window has been opened, or we won't have a GL context // to query for those extensions and connect to instances of them. loadExtensions(); printf("GL vendor: %s\n", glGetString(GL_VENDOR)); printf("GL renderer: %s\n", glGetString(GL_RENDERER)); printf("GL version: %s\n", glGetString(GL_VERSION)); printf("Desktop size: %d x %d pixels\n", vidmode.Width, vidmode.Height); glEnable(GL_DEPTH_TEST); // Use the Z buffer glfwSwapInterval(0); // Do not wait for screen refresh between frames // Compile a display list for the demo geometry, to render it efficiently initQuadList(&quadList); initSphereList(&sphereList); createShader(&programObject[0], PATH VERTSHADER0, PATH FRAGSHADER0); createShader(&programObject[1], PATH VERTSHADER1, PATH FRAGSHADER1); createShader(&programObject[2], PATH VERTSHADER2, PATH FRAGSHADER2); createShader(&programObject[3], PATH VERTSHADER3, PATH FRAGSHADER3); createShader(&programObject[4], PATH VERTSHADER4, PATH FRAGSHADER4); // Main loop while(running) { // Calculate and update the frames per second (FPS) display fps = computeFPS(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.0f, 0.3f, 0.5f, 0.0f); // Set up the camera projection. setupCamera(); // Draw the scene. renderScene(quadList, sphereList, programObject); // Swap buffers, i.e. display the image and prepare for next frame. glfwSwapBuffers(); // Exit if the ESC key is pressed or the window is closed. if(glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED)) { running = GL_FALSE; } } printf("Performance: %.1f FPS\n", fps); // Close the OpenGL window and terminate GLFW. glfwTerminate(); return 0; }
void Global_as::registerClasses() { registerNatives(*this); function_class_init(*this, NSV::CLASS_FUNCTION); initObjectClass(_objectProto, *this, NSV::CLASS_OBJECT); string_class_init(*this, NSV::CLASS_STRING); array_class_init(*this, NSV::CLASS_ARRAY); // No idea why, but it seems there's a NULL _global.o // defined at player startup... // Probably due to the AS-based initialization // Not enumerable but overridable and deletable. // as_value nullVal; nullVal.set_null(); init_member("o", nullVal, PropFlags::dontEnum); VM& vm = getVM(); // _global functions. // These functions are only available in SWF6+, but this is just // because SWF5 or lower did not have a "_global" // reference at all. init_member("ASnative", createFunction(global_asnative)); init_member("ASconstructor", createFunction(global_asconstructor)); init_member("ASSetPropFlags", vm.getNative(1, 0)); init_member("ASSetNative", vm.getNative(4, 0)); init_member("ASSetNativeAccessor", vm.getNative(4, 1)); init_member("AsSetupError", createFunction(global_assetuperror)); init_member("updateAfterEvent", vm.getNative(9, 0)); init_member("trace", vm.getNative(100, 4)); init_member("setInterval", vm.getNative(250, 0)); init_member("clearInterval", vm.getNative(250, 1)); init_member("setTimeout", vm.getNative(250, 2)); // This is an odd function with no properties. There ought to be // a better way of implementing this. See also TextFormat.getTextExtent. as_function* edc = createFunction(global_enableDebugConsole); edc->clearProperties(); init_member("enableDebugConsole", edc); init_member("showRedrawRegions", vm.getNative(1021, 1)); init_member("clearTimeout", getMember(*this, getURI(vm, "clearInterval"))); _classes.declareAll(avm1Classes()); // SWF8 visibility: const ObjectURI& flash = getURI(vm, "flash"); flash_package_init(*this, flash); init_member("escape", vm.getNative(100, 0)); init_member("unescape", vm.getNative(100, 1)); init_member("parseInt", vm.getNative(100, 2)); init_member("parseFloat", vm.getNative(100, 3)); init_member("isNaN", vm.getNative(200, 18)); init_member("isFinite", vm.getNative(200, 19)); init_member("NaN", as_value(NaN)); init_member("Infinity", as_value( std::numeric_limits<double>::infinity())); loadExtensions(); }
// Analyzes the specified context for possible recreation // int _glfwAnalyzeContextWGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { GLFWbool required = GLFW_FALSE; if (_glfw.wgl.extensionsLoaded) return _GLFW_RECREATION_NOT_NEEDED; makeContextCurrent(window); loadExtensions(); if (ctxconfig->client == GLFW_OPENGL_API) { if (ctxconfig->forward) { if (!_glfw.wgl.ARB_create_context) { _glfwInputError(GLFW_VERSION_UNAVAILABLE, "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable"); return _GLFW_RECREATION_IMPOSSIBLE; } required = GLFW_TRUE; } if (ctxconfig->profile) { if (!_glfw.wgl.ARB_create_context_profile) { _glfwInputError(GLFW_VERSION_UNAVAILABLE, "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable"); return _GLFW_RECREATION_IMPOSSIBLE; } required = GLFW_TRUE; } if (ctxconfig->release) { if (_glfw.wgl.ARB_context_flush_control) required = GLFW_TRUE; } } else { if (!_glfw.wgl.ARB_create_context || !_glfw.wgl.ARB_create_context_profile || !_glfw.wgl.EXT_create_context_es2_profile) { _glfwInputError(GLFW_API_UNAVAILABLE, "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable"); return _GLFW_RECREATION_IMPOSSIBLE; } required = GLFW_TRUE; } if (ctxconfig->major != 1 || ctxconfig->minor != 0) { if (_glfw.wgl.ARB_create_context) required = GLFW_TRUE; } if (ctxconfig->debug) { if (_glfw.wgl.ARB_create_context) required = GLFW_TRUE; } if (fbconfig->samples > 0) { // MSAA is not a hard constraint, so do nothing if it's not supported if (_glfw.wgl.ARB_multisample && _glfw.wgl.ARB_pixel_format) required = GLFW_TRUE; } if (fbconfig->sRGB) { // sRGB is not a hard constraint, so do nothing if it's not supported if ((_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) && _glfw.wgl.ARB_pixel_format) { required = GLFW_TRUE; } } if (required) return _GLFW_RECREATION_REQUIRED; return _GLFW_RECREATION_NOT_NEEDED; }
int main(int argc, char *argv[]) { GLint scene = 0; GLint location_MVP; GLint location_MV; GLdouble time; GLdouble lastTime=0; GLdouble dt; GLboolean running = GL_TRUE; GLuint programObject; glfwInit(); if( !glfwOpenWindow( 512, 512, 8, 8, 8,8, 32 ,0, GLFW_WINDOW )) { glfwTerminate(); return 1; } loadExtensions(); printf("GL Vendor: %s\n", glGetString(GL_VENDOR)); printf("GL Render: %s\n", glGetString(GL_RENDERER)); printf("GL Version: %s\n", glGetString(GL_VERSION)); glfwSwapInterval(0); //No need to call setupviewport every frame, lets do this instead: glfwSetWindowSizeCallback(SetupViewport); programObject = createShader("phong.vert", "phong.frag"); #pragma region Sphere & Cube w. triangleSoup triangleSoup sphere; soupInit(&sphere); soupCreateSphere(&sphere,1.0f, 20); triangleSoup cube; soupInit(&cube); soupCreateBox(&cube, 1.0f, 1.0f, 1.0f); #pragma endregion #pragma region Matrix setup float fov = deg2rad(40.0f); float n = 0.50f; int f= 10.0f; int ratio = 1; fov = 1/tan(fov/2); MATRIX float M[16]; MATRIX float V[] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 1.0f }; MATRIX float P[] = { fov/ratio, 0.0f, 0.0f, 0.0f, 0.0f, fov, 0.0f, 0.0f, 0.0f, 0.0f, (f+n)/(n-f), -1.0f, 0.0f, 0.0f, (2.0f*f*n)/(n-f), 0.0f }; location_MVP = glGetUniformLocation(programObject, "MVP"); location_MV = glGetUniformLocation(programObject, "MV"); #pragma endregion float zpos = 0; float xpos = 0; while(running) { time = glfwGetTime(); dt = time-lastTime; if(glfwGetKey('W')) zpos += 2.0f*dt; if(glfwGetKey('S')) zpos -= 2.0f*dt; if(glfwGetKey('A')) xpos -= 2.0f*dt; if(glfwGetKey('D')) xpos += 2.0f*dt; glClearColor(0.3f, 0.3f, 0.3f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); matrix4Eye(M); matrix4Scale(M, 0.4f ,0.4f ,0.8f); matrix4RotY(M,time*40); matrix4Tran(M,xpos, 0.0f, zpos); MATRIX float MVP[16]; MATRIX float MV[16]; matrix4Mult(M, V, MV); matrix4Mult(MV, P, MVP); glUseProgram(programObject); if(location_MVP != -1) glUniformMatrix4fv(location_MVP,1,GL_FALSE,MVP); if(location_MV != -1) glUniformMatrix4fv(location_MV,1,GL_FALSE,MV); glEnable(GL_CULL_FACE); soupRender(cube); glfwSwapBuffers(); lastTime = time; if(glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED)) running = GL_FALSE; } }
/*! Returns a list of valid file extensions for the mime type string \a mimeType or an empty list if the mime type is unrecognized. */ QStringList QMail::extensionsForMimeType(const QString& mimeType) { loadExtensions(); return extFor()->value(mimeType); }
int main(int argc, char *argv[]) { // UI-related variables int running = 0; int mousebtn1, lastmousebtn1; int mousex, mousey, lastmousex, lastmousey; float posx, posy, zoom, rotx, rotz; // Shader-related variables GLuint textureID; int texw = 0; int texh = 0; GLhandleARB programObj; // Initialise GLFW glfwInit(); // Open OpenGL window if( !glfwOpenWindow( 512, 512, 0,0,0,0, 0,0, GLFW_WINDOW ) ) { glfwTerminate(); return 0; } // Init user interface (mouse drag for pan/zoom/tilt/rotation) posx = 0.0f; posy = 0.0f; zoom = 1.0f; rotx = 0.0f; rotz = 0.0f; glfwGetMousePos(&mousex, &mousey); // Requires an open window lastmousex = mousex; lastmousey = mousey; mousebtn1 = lastmousebtn1 = GLFW_RELEASE; // Load OpenGL extensions (requires an open window) loadExtensions(); // Load textures glEnable(GL_TEXTURE_2D); glGenTextures( 1, &textureID ); loadDistTexture(PATH "disttex.tga", textureID, &texw, &texh); // Create, load and compile the shader programs programObj = createShader(PATH "vertex.glsl", PATH "fragment1.glsl"); // Disable vertical sync (on cards that support // it, and if current driver settings so permit) glfwSwapInterval( 1 ); // Main loop running = GL_TRUE; while( running ) { showFPS(texw, texh, zoom); // Set the uniform shader variables setUniformVariables(programObj, 0, (float)texw, (float)texh); renderScene(programObj, posx, posy, zoom, rotx, rotz); glfwSwapBuffers(); // Handle mouse pan (button 1 drag), zoom (shift-btn 1 drag up/down), // tilt (ctrl-btn 1 drag up/down) and rotation (ctrl-btn 1 drag left/right) lastmousebtn1 = mousebtn1; mousebtn1 = glfwGetMouseButton(GLFW_MOUSE_BUTTON_1); lastmousex = mousex; lastmousey = mousey; glfwGetMousePos(&mousex, &mousey); if((mousebtn1 == GLFW_PRESS) && (lastmousebtn1 == GLFW_PRESS)) { if(glfwGetKey(GLFW_KEY_LSHIFT)) { zoom *= pow(1.01, (lastmousey - mousey)); if(zoom < 0.26f) zoom = 0.26f; // Do not go beyond 180 degrees FOV } else if (glfwGetKey(GLFW_KEY_LCTRL)) { rotz -= (lastmousex - mousex) * 0.5; rotx += (lastmousey - mousey) * 0.5; if(rotx > 89.5f) rotx = 89.5f; if(rotx < 0.0f) rotx = 0.0f; } else { posx += (lastmousex - mousex) / zoom; posy += (lastmousey - mousey) / zoom; } } if(glfwGetKey('1')) { programObj = createShader(PATH "vertex.glsl", PATH "fragment1.glsl"); } if(glfwGetKey('2')) { programObj = createShader(PATH "vertex.glsl", PATH "fragment2.glsl"); } if(glfwGetKey('3')) { programObj = createShader(PATH "vertex.glsl", PATH "fragment3.glsl"); } if(glfwGetKey('4')) { programObj = createShader(PATH "vertex.glsl", PATH "fragment4.glsl"); } // Check if the ESC key is pressed or the window has been closed running = !glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam( GLFW_OPENED ); } // Close the window (if still open) and terminate GLFW glfwTerminate(); return 0; }