コード例 #1
0
ファイル: main.cpp プロジェクト: Felard/MoSync
	/**
	 *  \brief Draw, Call back from the GLMoblet.
	 */
	void draw()
	{
		mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
		MoGraph::Scene &scene = mGraph->getScene();	// get scene information
		const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
		const int iGridX = scene.getGridX();
		const int sz = iGridX * iGridZ;

		mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
		mGraph->setColors(mColors,sz); // set the color array to the Graph to read from

		mGraph->draw(); // Draw the whole graph system


		// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
		//---------------------------------------------------------------------
		glm::vec4 col(1.0f,1.0f,1.0f,1.0f);	// White color
		glm::vec3 pos(0.0f,0.0f,10.0f); // set screen position upper left corner 0,0.. note need z depth value for order.
		float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
		mText.setScale(sy,sy);

		char buf[64]; // create text string
		sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
		mText.drawText(buf,pos,col); // call drawText
	}
コード例 #2
0
ファイル: main.cpp プロジェクト: Vallenain/MoSync
	/**
	 *  \brief Draw, Call back from the GLMoblet.
	 */
	void draw()
	{
		mDTime.tick(); // update delta time ticker. our fps timer (resets for every tick call)
		MoGraph::Scene &scene = mGraph->getScene();	// get scene information
		const int iGridZ = scene.getGridZ(); // need to be able to read the grid size
		const int iGridX = scene.getGridX();
		const int sz = iGridX * iGridZ;
		float dt = static_cast<float>(mDTime.getElapsed())*0.001f; // calculate a delta time factor for omega
		mOmega += dt; // accumulate the omega used for sin/cos func

		if (mOmega > M_PI*2.0f)	// for high precision make sure omega 0..2*PI
			mOmega -= M_PI*2.0f; // wrapping a x value is also faster not to use large values in sin(x).

		const float f = 2.5f/255.0f; // prepare for a scale value of result being max 2.5f
		for(int j=0; j<iGridZ; j++)	// Build the data arrays for colors and for tables.
		{
			const float jcos = 2.0f + cos(j*0.3f+mOmega); // calculate the Depth Wave with cos
			for(int i=0; i<iGridX; i++)
			{
				const int id 	= j*iGridX+i;
				Color *c 		= (Color *)&mLogoH.getData()[id];
				mTables[id] 	= (float)c->r * f + (sin(i*0.3f+mOmega) + jcos); // generate a sine wave and add depth wave
			}
		}

		mGraph->setValues(mTables,sz); // set the value array to the Graph to read from
		mGraph->setColors(mColors,sz); // set the color array to the Graph to read from

		mGraph->draw();	// Draw the whole graph system


		// DRAW ADDITIONAL TEXT ON SCREEN (Orthogonal projections)
		//---------------------------------------------------------------------
		glm::vec4 col(1.0f,1.0f,1.0f,1.0f);	// White color
		glm::vec3 pos(0.0f,0.0f,10.0f);	// set screen position upper left corner 0,0.. note need z depth value for order.
		float sy = (0.6f*(float)scene.getWidth())/320.0f; // scale size regardless to resolution our reference resolution is 320..
		mText.setScale(sy,sy);

		char buf[64]; // create text string
		sprintf ( buf, "FPS=%.2f ms=%d",mDTime.currentFps(),mDTime.getElapsed());
		mText.drawText(buf,pos,col); // call drawText
	}