当前位置: 首页>>代码示例>>C++>>正文


C++ Stroke::draw方法代码示例

本文整理汇总了C++中Stroke::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Stroke::draw方法的具体用法?C++ Stroke::draw怎么用?C++ Stroke::draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stroke的用法示例。


在下文中一共展示了Stroke::draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display

/// OpenGL display function
void display(void) {

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	glMultMatrixf(&sceneT);

	//   glEnable(GL_LIGHTING);
	//   glShadeModel(GL_SMOOTH);
	//   glEnableClientState(GL_VERTEX_ARRAY);
	//   glEnableClientState(GL_NORMAL_ARRAY);
	//   glVertexPointer(3, GL_FLOAT, 0, meshmodel->points());
	//   glNormalPointer(GL_FLOAT, 0, meshmodel->vertex_normals());
	//   glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, &indices[0]);
	//   glDisableClientState(GL_VERTEX_ARRAY);
	//   glDisableClientState(GL_NORMAL_ARRAY);

	/// 
	if (mycloth != 0) {
		glPushAttrib(GL_LIGHTING_BIT | GL_LINE_BIT);
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_LIGHTING);

		GLdouble mMtx[16], pMtx[16];  /// modelview/projection matrix
		GLint viewport[4];         /// the viewport
		glGetIntegerv(GL_VIEWPORT, viewport);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glGetDoublev(GL_MODELVIEW_MATRIX, mMtx);
		glGetDoublev(GL_PROJECTION_MATRIX, pMtx);

		glLineWidth(1.0);
		PolyMesh::ConstFaceIter f_it = mycloth->faces_sbegin();
		while (f_it != mycloth->faces_end()) {
			PolyMesh::ConstFaceVertexIter fv_it(mycloth->cfv_iter(f_it));
			if (mycloth->getType(f_it) == 'B') glColor4f(1.0, 1.0, 0.0, 1.0);
			if (mycloth->getType(f_it) == 'I') glColor4f(1.0, 0.0, 0.0, 1.0);
			if (mycloth->getType(f_it) == 'O') glColor4f(0.0, 1.0, 0.0, 1.0);
			if (mycloth->getType(f_it) == 'X') glColor4f(0.5, 0.5, 0.5, 0.5);
			glBegin(GL_POLYGON);
			do {
				const Point3 &p = mycloth->point(fv_it);
				gluUnProject(p[0], p[1], 1.0, mMtx, pMtx, viewport, &xwini, &ywini, &zwini);
				glVertex3f(xwini, ywini, 0.0);
				//               glVertex3f(p[0], p[1], 0.0);
			} while (++fv_it);
			glEnd();

			fv_it = mycloth->cfv_iter(f_it);
			glColor4f(1.0, 0.5, 0.0, 1.0);
			glBegin(GL_LINE_LOOP);
			do {
				const Point3 &p = mycloth->point(fv_it);
				gluUnProject(p[0], p[1], 1.0, mMtx, pMtx, viewport, &xwini, &ywini, &zwini);
				glVertex3f(xwini, ywini, 0.0);
				//            glVertex3f(p[0], p[1], 0.0);
			} while (++fv_it);
			glEnd();
			++f_it;
		}
		glPopAttrib();
	}

	stroke.draw();

	/// FPS info
	frame++;
	std::time(&end);
	double ddifftime = std::difftime(end, start);
	if (ddifftime > 1) {
		cfps = frame / ddifftime;
		start = end;
		frame = 0;
		ostringstream s1;
		s1 << cfps;
		fps = "FPS: " + s1.str();
	}

	renderInfo();

	glutSwapBuffers();
}
开发者ID:yuduosheng,项目名称:OpenGL_common,代码行数:83,代码来源:example.cpp


注:本文中的Stroke::draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。