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

📄 main.cpp

📁 光滑质点无网格法SPH并行计算程序
💻 CPP
字号:
//      ___                       ___           ___           ___       ___     //     /\__\          ___        /\__\         /\  \         /\__\     /\  \.   //    /::|  |        /\  \      /::|  |       /::\  \       /:/  /    /::\  \.  //   /:|:|  |        \:\  \    /:|:|  |      /:/\:\  \     /:/  /    /:/\:\  \. //  /:/|:|__|__      /::\__\  /:/|:|  |__   /:/  \:\  \   /:/  /    /::\~\:\  \.// /:/ |::::\__\  __/:/\/__/ /:/ |:| /\__\ /:/__/_\:\__\ /:/__/    /:/\:\ \:\__\.// \/__/~~/:/  / /\/:/  /    \/__|:|/:/  / \:\  /\ \/__/ \:\  \    \:\~\:\ \/__///       /:/  /  \::/__/         |:/:/  /   \:\ \:\__\    \:\  \    \:\ \:\__\. //      /:/  /    \:\__\         |::/  /     \:\/:/  /     \:\  \    \:\ \/__/  //     /:/  /      \/__/         /:/  /       \::/  /       \:\__\    \:\__\.   //     \/__/                     \/__/         \/__/         \/__/     \/__/    // // =============================================================================//                       Minimalist OpenGL Environment// =============================================================================//// Copyright 2007 Balazs Domonkos// // This program 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 2// of the License, or (at your option) any later version.// // This program 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 this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// Image handling demo// mingle.h should be included before all other// OpenGL headers#include <mingle.h>using namespace MinGLE;//#include <GL/glut.h> TODO#include <iostream>static Image *image = 0;static GLuint texture = 0;class MyListener : public WindowListener, public TimerListener {    protected:			virtual bool onRender() {	    	//glutSolidTeapot(0.75); TODO			GLUtils::drawGears(0.0);	    	return true;		}			virtual bool onKeyEvent(int key, unsigned modifiers, KeyEventState state) {			switch(key) {				case KEY_SPACE:					// Toggle animation					if(mTimer->isRunning())						mTimer->stop();					else						mTimer->start();					return true;				default:					return false;			}			return false;		}			// This method is called when the timer ticks		virtual void onTick() {		    glMatrixMode(GL_MODELVIEW);	    	glRotatef(30.0 * mTimer->getElapsedTime(), 0.0, 1.0, 0.0);	    	redisplayRequest();		}};int main(int argc, char **argv) {	try {    	// Initialize Rendering system    	System::initialize(&argc, argv);    	// Create window    	Window *win = System::createWindow();    	// Register the listener and timer    	MyListener *myListener = new MyListener();    	Timer *timer = win->createTimer(0.04);    	    	// Register the listener for the window and the timer events    	win->registerWindowListener((WindowListener *)myListener);    	timer->registerTimerListener((TimerListener *) myListener);		// Add navigator		Navigator *navigator = new ExaminerNavigator();		win->registerNavigator(navigator);		// Add keyhandler		ApplicationKeyHandler *keyHandler = new ApplicationKeyHandler();		win->registerWindowListener(keyHandler);    	// Setup OpenGL    	glEnable(GL_DEPTH_TEST);    	glEnable(GL_TEXTURE_2D);    	glShadeModel(GL_SMOOTH);        	GLfloat position[] = { 3.0f, 3.0f, 3.0f, 1.0f };    	GLfloat diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };    	GLfloat specular[] = {1.0f, 1.0f, 1.0f , 1.0f};    	glEnable(GL_LIGHTING);    	glEnable(GL_LIGHT0);    	glLightfv(GL_LIGHT0, GL_POSITION, position);    	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);    	glLightfv(GL_LIGHT0, GL_SPECULAR, specular);		// Load image (the accurate path is resolved using     	// the `fileSystems' block of configuration file)		image = Imaging::createImage("data", "textures/image.png");		// Create texture using the image    	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);    	glGenTextures(1, &texture);    	glBindTexture(GL_TEXTURE_2D, texture);		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);    	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);    	image->texImage2D();    	// Enter the event handing loop    	System::enterMainLoop();    		} catch(const Exception& e) {		std::cerr << "Error: " << e.mDescription << " (Thrown in " << e.mFile << ':'			<< e.mMethod << " line " << e.mLine << ')' << std::endl;	}    return 0;}

⌨️ 快捷键说明

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