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

📄 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.//// Font rendering in MinGLE// mingle.h should be included before all other// OpenGL headers#include <mingle.h>using namespace MinGLE;// #include <GL/glut.h> TODO#include <iostream>class SceneRenderer : public WindowListener {    protected:		virtual bool onRender() {	    	// glutSolidTeapot(0.5); TODO	    		    	// Enable the next window listener to render	    	return false;		}};class FontRenderer : public WindowListener {        protected:    	Font *mArialFont, *mZektonFont;        public:    	FontRenderer() {			// Load the fonts    		mArialFont = FontRendering::createFont("data", "fonts/arial.ttf", 40);    		mZektonFont = FontRendering::createFont("data", "fonts/zekton.ttf");    		// Save rasterized version    		//FontRendering::saveFont(mZektonFont, "zekton-save.xml");    		// Load rasterized version    		//mZektonFont = FontRendering::createFont("zekton-save.xml");    					// Set font color    		mZektonFont->setColor(0.8, 0.7, 0.6, 0.5);    	}        	virtual ~FontRenderer() {    		delete mArialFont;    		delete mZektonFont;    	}        protected:		virtual bool onRender() {			// Store matrices			glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0, mWindow->getWidth(), mWindow->getHeight(), 0.0);			glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();			glDisable(GL_DEPTH_TEST);			// Render fonts to the frame buffer directly	    	mArialFont->renderToFrameBuffer("Hello World!", 10, 50);	    	mZektonFont->renderToFrameBuffer("This is a font demo...", 10, mWindow->getHeight()-40);			// Restore matrices			glEnable(GL_DEPTH_TEST);			glMatrixMode(GL_PROJECTION); glPopMatrix();			glMatrixMode(GL_MODELVIEW); glPopMatrix();	    		    	return true;		}};int main(int argc, char **argv) {	try {    	// Initialize rendering system    	System::initialize(&argc, argv);    	// Create window    	Window *win = System::createWindow();    	//win->setRenderMode(Window::RENDER_WHEN_IDLE);    	// Register the renderers    	// (font renderer is a layer above the scene renderer)    	win->registerWindowListener(new SceneRenderer());    	win->registerWindowListener(new FontRenderer());		// Add navigator		WindowListener *navigator = new ExaminerNavigator();		win->registerWindowListener(navigator);		// Add keyhandler		ApplicationKeyHandler *keyHandler = new ApplicationKeyHandler();		win->registerWindowListener(keyHandler);    	// Setup OpenGL    	glEnable(GL_DEPTH_TEST);    	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);    	// 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 + -