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

📄 3d.cpp

📁 a source code for banker s algorithm
💻 CPP
字号:
#include<windows.h>
#include<glut.h>
#include<gl.h>


void myInit(void)
{
 glClearColor(1.0,1.0,1.0,1.0);
 glColor3f(0.0f,0.0f,0.0f);
 glPointSize(4.0);
 glOrtho(-50.0,50.0,-50.0,50.0,-50.0,50.0);
}

void myDisplay(void)
{
	float V[4][3]={{0.0,0.0,0.0},{25.0,50.0,10.0},{50.0,0.0,25.0},{25.0,10.0,25.0}};
	float P[3]={25.0,10.0,25.0};
	int i,j;
	int rand();
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_POINTS);
		for(i=0;i<500000;i++)
		{
			j=rand()%4;
			P[0]=(P[0]+V[j][0])/2.0;
			P[1]=(P[1]+V[j][1])/2.0;
			P[2]=(P[2]+V[j][2])/2.0;

			glColor3f(P[0]/25.0,P[1]/25.0,P[2]/25.0);
			glVertex3fv(P);
		}
	glEnd();
	glFlush();
	
}

void main()
{
 //glutInit(&argc,argv);
 glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
 glutInitWindowSize(600,400);
 glutInitWindowPosition(100,50);
 glutCreateWindow("vertices");
 glutDisplayFunc(myDisplay);
 myInit();
 glutMainLoop();
}

⌨️ 快捷键说明

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