⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gluttimer.cpp

📁 光滑质点无网格法SPH并行计算程序
💻 CPP
字号:
//      ___                       ___           ___           ___       ___     //     /\__\          ___        /\__\         /\  \         /\__\     /\  \.    //    /::|  |        /\  \      /::|  |       /::\  \       /:/  /    /::\  \.   //   /:|:|  |        \:\  \    /:|:|  |      /:/\:\  \     /:/  /    /:/\:\  \.  //  /:/|:|__|__      /::\__\  /:/|:|  |__   /:/  \:\  \   /:/  /    /::\~\:\  \. // /:/ |::::\__\  __/:/\/__/ /:/ |:| /\__\ /:/__/_\:\__\ /:/__/    /:/\:\ \:\__\.// \/__/~~/:/  / /\/:/  /    \/__|:|/:/  / \:\  /\ \/__/ \:\  \    \:\~\:\ \/__///       /:/  /  \::/__/         |:/:/  /   \:\ \:\__\    \:\  \    \:\ \:\__\.  //      /:/  /    \:\__\         |::/  /     \:\/:/  /     \:\  \    \:\ \/__/  //     /:/  /      \/__/         /:/  /       \::/  /       \:\__\    \:\__\.    //     \/__/                     \/__/         \/__/         \/__/     \/__/    // // =============================================================================//                       Minimalist OpenGL Environment// =============================================================================//// This file is part of Minimalist OpenGL Environment (MinGLE)//// Version: 0.2.0// Author: Balazs Domonkos// Filename: src/GLUT/src/GLUTTimer.cpp// Creation Date: December 12th 2007// Revision Date: December 12th 2007////// The Minimalist OpenGL Environment is free software: you can// redistribute it and/or modify it under the terms of the GNU// General Public License as published by the Free Software// Foundation, either version 3 of the License, or (at your// option) any later version.//// The Minimalist OpenGL Environment 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 General Public License// for more details.//// You should have received a copy of the GNU General Public License// along with Minimalist OpenGL Environment.  If not, see // <http://www.gnu.org/licenses/>. See the COPYING file included // with this distribution file for license details.///// @file GLUTTimer.cpp/// GLUT timer class// Header that contains the declaration#include <GLUTTimer.h>// MinGLE headers#include <Exception.h>#include <TimerListener.h>#include <System.h>// System headers#include <GL/glut.h>#include <algorithm>namespace MinGLE {GLUTTimer::TimerTable GLUTTimer::mTimerTable;GLUTTimer::GLUTTimer(GLUTWindow *window, double period, TimerType type) :	Timer((Window *) window, period, type), mPausing(false), mIndex(0) {}GLUTTimer::~GLUTTimer() {}void GLUTTimer::start() {	_addToTimerTable();	_registerGlutCallback();	// Generic operations	Timer::start();}void GLUTTimer::pause() {	mPausing = true;	// Generic operations	Timer::pause();}void GLUTTimer::_onTick() {	if (mPausing) {		_removeFromTimerTable();		mPausing = false;	}	else {		double time = System::getTime();		mElapsedTime = time - mLastTickTime;		// Invoke the listener		if (mTimerListener)			mTimerListener->onTick();		mLastTickTime = time;		if (mType == TIMER_PERIODIC)			// Reregister the event event			_registerGlutCallback();		else {			// One shot event means pause			Timer::pause();			_removeFromTimerTable();		}		mWindow->checkRedisplay();	}}void GLUTTimer::_addToTimerTable() {	mIndex = mTimerTable.size();	mTimerTable.push_back(this);}void GLUTTimer::_removeFromTimerTable() {	TimerTable::iterator i = find(mTimerTable.begin(), mTimerTable.end(), this);	mTimerTable.erase(i);}void GLUTTimer::_registerGlutCallback() {	glutTimerFunc(int (mPeriod*1000.0), GLUTTimer::_onTickStatic, mIndex);}} // namespace MinGLE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -