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


C++ Person::draw_BlackArea方法代码示例

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


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

示例1: drawScene

void drawScene()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHT1);
	glEnable(GL_NORMALIZE);


	/*	GLuint texture = LoadGLTexture("water.bmp", 396, 734);
		glEnable(GL_TEXTURE_2D);
		glBindTexture( GL_TEXTURE_2D, texture );*/

	//Add ambient light
	/*	GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f}; //Color(0.2, 0.2, 0.2)
		glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
	//Add positioned light
	GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5)
	GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8)
	glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
	glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);
	//Add directed light
	GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f}; //Color (0.5, 0.2, 0.2)
	//Coming from the direction (-1, 0.5, 0.5)
	GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f};
	glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);*/
	glRotatef(-0.0, 0.0f, 1.0f, 0.0f);
	glTranslatef(-4*1.5, 0.0, 4*1.5);
	//int gifts_x1 = -1, gifts_x2 = -1, gifts_z1 = -1, gifts_z2 = -1;
	int g=0,h=0,gg=-1,hh=-2,fl1=0,fl2=0,kk=0;
	int tile_x1=-1,tile_z1=-1;
	int tile_x2=-1,tile_z2=-1,cok = 0;
	int obs_x1=-1,obs_z1=-1,obs_x2=-1,obs_z2=-1;
	//int gifts_x1=-1,gifts_z1=-1,gifts_x2=-1,gifts_z2=-1;
	p1.drawtree(-40.0,0.0,-40.0);
	p1.drawtree(-30.0,0.0,-40.0);
	p1.drawtree(-20.0,0.0,-40.0);
	p1.drawtree(-10.0,0.0,-40.0);
	p1.drawtree(0.0,0.0,-40.0);
	p1.drawtree(10.0,0.0,-40.0);
	p1.drawtree(20.0,0.0,-40.0);
	p1.drawtree(30.0,0.0,-40.0);
	p1.drawtree(40.0,0.0,-40.0);
	p1.drawtree(0.0,0.0,0.0);
	p1.drawtree(12.0,0.0,0.0);
	glPushMatrix();
	glTranslatef(-50*1.5, 0.0, 50*1.5);
	//change = 10.0f;
	for(float j=0.0;j>(-100*1.5);j-=1.5)
	{
		k++;
		for(i=0.0;i<(50*3.0);i+=3.0)
		{
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, x);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);

			if(k%2==0)
			{
				glPushMatrix();
				glTranslatef(i,-1.0,j);
	p1.draw_BlackArea(); //Add commands for drawing a black area to the display list
			//	glCallList(_displayListId_blackArea);
				glPopMatrix();

			}
			else
			{
				glPushMatrix();
				glTranslatef(i+1.5,-1.0,j);
	p1.draw_BlackArea(); //Add commands for drawing a black area to the display list
			//	glCallList(_displayListId_blackArea);
				glPopMatrix();

			}
			glDisable(GL_TEXTURE_2D);
		}
	}
	for(float j=0.0;j>(-100*1.5);j-=1.5)
	{
		k++;
		for(i=0.0;i<(50*3.0);i+=3.0)
		{
			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, x);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
			if(k%2!=0)
			{
				glPushMatrix();
				glTranslatef(i,-1.0,j);
	p1.draw_whiteArea(); //Add commands for drawing a black to the display list
	//			glCallList(_displayListId_whiteArea);
				glPopMatrix();

			}
//.........这里部分代码省略.........
开发者ID:VishrutMehta,项目名称:OpenGL-Game,代码行数:101,代码来源:game.cpp

示例2: initRendering

void initRendering()
{
	/*	glDisable(GL_LIGHTING);
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, x);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glDisable(GL_NORMALIZE);
		glEnable(GL_BLEND);
		glColor4f(1, 1, 1, WATER_ALPHA);
		glNormal3f(0, 1, 0);

		glBegin(GL_QUADS);
		glTexCoord2f(200 / WATER_TEXTURE_SIZE,
		-waterTextureOffset / WATER_TEXTURE_SIZE);
		glVertex3f(-100, 0, -100);
		glTexCoord2f(200 / WATER_TEXTURE_SIZE,
		(200 - waterTextureOffset) / WATER_TEXTURE_SIZE);
		glVertex3f(-100, 0, 100);
		glTexCoord2f(0, (200 - waterTextureOffset) / WATER_TEXTURE_SIZE);
		glVertex3f(100, 0, 100);
		glTexCoord2f(0, -waterTextureOffset / WATER_TEXTURE_SIZE);
		glVertex3f(100, 0, -100);
		glEnd();
		glDisable(GL_BLEND);
		glEnable(GL_LIGHTING);
	 */

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_COLOR_MATERIAL);
	glClearColor(0.0f,0.0f,0.2f,1.0f);
	Image* image = loadBMP("images.bmp");
	grassTextureId = loadTexture(image);

	Image* image1 = loadBMP("fire2.bmp");
	x = loadTexture(image1);
	//Set up a display list for drawing a cube
	_displayListId_blackArea = glGenLists(1); // Make room for the display list
	glNewList(_displayListId_blackArea, GL_COMPILE); // Begin the display list
	change = 1.0f;
	p1.draw_BlackArea(); //Add commands for drawing a black area to the display list
	glEndList(); //End the display list

	//Set up a display list for drawing a cube
	_displayListId_whiteArea = glGenLists(2); //Make room for the display list
	glNewList(_displayListId_whiteArea, GL_COMPILE); //Begin the display list
	p1.draw_whiteArea(); //Add commands for drawing a black to the display list
	glEndList(); //End the display list



	// To uncomment later
	GLfloat sun_direction[] = { 0.0, 2.0, -1.0, 1.0 };
	GLfloat sun_intensity[] = { 0.7, 0.7, 0.7, 1.0 };
	GLfloat ambient_intensity[] = { 0.3, 0.3, 0.3, 1.0 };
	glEnable(GL_DEPTH_TEST);        // Enable objects to be drawn ahead/behind one another
	glEnable(GL_COLOR_MATERIAL);    // Enable coloring
	glClearColor(0.0f, 0.0f, 1.0f, 1.0f);   // Setting a background color
	glEnable(GL_LIGHTING);              // Set up ambient light.
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_intensity);

	glEnable(GL_LIGHT0);                // Set up sunlight.
	glLightfv(GL_LIGHT0, GL_POSITION, sun_direction);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, sun_intensity);

	glEnable(GL_COLOR_MATERIAL);        // Configure glColor().
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	
	delete image;
	delete image1;


}
开发者ID:VishrutMehta,项目名称:OpenGL-Game,代码行数:73,代码来源:game.cpp


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