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

📄 glutwindow.h

📁 光滑质点无网格法SPH并行计算程序
💻 H
字号:
//      ___                       ___           ___           ___       ___     //     /\__\          ___        /\__\         /\  \         /\__\     /\  \.    //    /::|  |        /\  \      /::|  |       /::\  \       /:/  /    /::\  \.   //   /:|:|  |        \:\  \    /:|:|  |      /:/\:\  \     /:/  /    /:/\:\  \.  //  /:/|:|__|__      /::\__\  /:/|:|  |__   /:/  \:\  \   /:/  /    /::\~\:\  \. // /:/ |::::\__\  __/:/\/__/ /:/ |:| /\__\ /:/__/_\:\__\ /:/__/    /:/\:\ \:\__\.// \/__/~~/:/  / /\/:/  /    \/__|:|/:/  / \:\  /\ \/__/ \:\  \    \:\~\:\ \/__///       /:/  /  \::/__/         |:/:/  /   \:\ \:\__\    \:\  \    \:\ \:\__\.  //      /:/  /    \:\__\         |::/  /     \:\/:/  /     \:\  \    \:\ \/__/  //     /:/  /      \/__/         /:/  /       \::/  /       \:\__\    \:\__\.    //     \/__/                     \/__/         \/__/         \/__/     \/__/    // // =============================================================================//                       Minimalist OpenGL Environment// =============================================================================//// This file is part of Minimalist OpenGL Environment (MinGLE)//// Version: 0.2.0// Author: Balazs Domonkos// Filename: src/GLUT/include/GLUTWindow.h// 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 GLUTWindow.h/// GLUT render window class#ifndef __MINGLE_GLUTWINDOW_H__#define __MINGLE_GLUTWINDOW_H__// Include class definitions#include <classes.h>// MinGLE headers#include <Window.h>#include <WindowListener.h>// System headers#include <map>namespace MinGLE {class GLUTWindow : public Window {	friend class GLUTSystem;protected:	static const double MAX_PRESS_TIME = 0.1;	static const double MAX_CLICK_TIME = 0.1;	static const int WHEEL_SCROLLING = 1;	static const double KEY_EVENT_DELAY_THRESHOLD = 0.1;	typedef struct {		int key;		unsigned modifiers;		double downTime;	} KeyEvent;	typedef std::map<int, KeyEvent> KeyEventMap;	typedef KeyEventMap::iterator KeyEventMapIterator;	enum ClickState {		BUTTON_STATE_REST,		BUTTON_STATE_DOWN1,		BUTTON_STATE_UP1,		BUTTON_STATE_DOWN2,		BUTTON_STATE_UP2	};	typedef struct {		int x, y;		InputListener::MouseButton button;		ClickState state;	} MouseEvent;protected:	int mWindowId;	bool mGameModeSupported;	static GLUTWindow *msInstance;	/// Key press support	KeyEventMap mCachedKeyEvents;	/// Click and dblclick support	double mLastMouseActionTime;	MouseEvent mCachedMouseEvent;	/// The key repeat is on (normally MinGLE tries to disable it)	static bool mKeyRepeatOn;	/// Time when the last GLUT keyboard event was generated.	/// When the key repeats cannot be disabled on some systems	/// MinGLE tries to filter the repeats ignoring the frequent 	/// events.	static double mLastKeyEventTime;	/// Code of the last pressed/released normal key	/// When the key repeats cannot be disabled on some systems	/// MinGLE tries to filter the repeats ignoring the frequent 	/// events.	static unsigned char mLastNormalKey;	/// Code of the last pressed/released special key	/// When the key repeats cannot be disabled on some systems	/// MinGLE tries to filter the repeats ignoring the frequent 	/// events.	static int mLastSpecialKey;public:			GLUTWindow(					unsigned width = DEFAULT_WIDTH,					unsigned height = DEFAULT_HEIGHT,					WindowAttributes::ColorMode colorMode = WindowAttributes::DIRECT_COLORS,					bool doubleBuffer = true, bool fullScreen = false,					unsigned videoRate = 0, unsigned char *colorBits = 0,					unsigned char depthBits = 16,					unsigned char stencilBits = 0,					unsigned char *accumColorBits = 0, unsigned auxBuffers = 0,					bool stereo = false);	virtual ~GLUTWindow();	virtual void setPosition(int left, int top);	virtual void setSize(unsigned width, unsigned height);	virtual void setFullScreen(bool fullScreen);	virtual void setVisible(bool visible);	virtual void iconify();	virtual void setTitle(const std::string& title);	virtual void finishFrame();	virtual void redisplay();	virtual void clearFrame();	virtual Timer *createTimer(double period,			Timer::TimerType type = Timer::TIMER_PERIODIC);protected:	virtual void _disableKeyRepeat();	virtual void _setupWindowListener();	virtual void _setupWindowListenerIdle();	virtual void _windowIsReadyToBeShown();	virtual void _close();	virtual void _setPosition(int left, int top);	virtual void _setSize(unsigned width, unsigned height);	// GLUT graphics events	static void _onRender();	static void _onIdle();	static void _onResize(int width, int height);	// GLUT keyboard events	static void _onNormalKeyboardEvent(unsigned char glutCode, int x, int y);	static void _onNormalKeyboardUpEvent(unsigned char glutCode, int x, int y);	static void _onSpecialKeyboardEvent(int glutKey, int x, int y);	static void _onSpecialKeyboardUpEvent(int glutKey, int x, int y);	static void _onKeyboardTimer(int key);	// GLUT mouse events	static void _onMouseEvent(int button, int state, int x, int y);	static void _onMotionEvent(int x, int y);	static void _onPassiveMotionEvent(int x, int y);	static void _onEntryEvent(int state);	static void _onMouseTimer(int value);	// Code and key conversion	static void _handleNormalKeyboardEvent(unsigned char glutCode,			InputListener::KeyEventState state);	static void _handleSpecialKeyboardEvent(int glutKey,			InputListener::KeyEventState state);	static void _handleKeyboardEvent(int key, unsigned modifiers,			InputListener::KeyEventState state);	static int _convertKeyNormal(unsigned char glutCode);	static int _convertKeySpecial(int glutKey);	static unsigned _getModifiers();	// Keyboard helper methods	static void _startPressTimeOut(int key, unsigned modifiers);	// Mouse helper methods	static inline void _resetClickInfo() {		// Fire cached event		_fireMouseEvent();		msInstance->mLastMouseActionTime = 0.0;		msInstance->mCachedMouseEvent.x = msInstance->mCachedMouseEvent.y = 0;		msInstance->mCachedMouseEvent.button = InputListener::LEFT_BUTTON;		msInstance->mCachedMouseEvent.state = BUTTON_STATE_REST;	}	static void _startClickTimeOut(int x, int y,			InputListener::MouseButton button, ClickState state);	static void _fireMouseEvent();}; // class GLUTWindow} // namespace MinGLE#endif // __MINGLE_GLUTWINDOW_H__

⌨️ 快捷键说明

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