Exemplo n.º 1
0
    void draw (int picking)
    {
	if(picking==2)return;
	gle();
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        gle();
	if(!picking)
	{
	    CameraUpdate ();
	    gle();
	    EntityUpdate ();
	    gle();
    	    WorldUpdate ();
	    gle();
    	    TextureUpdate ();
	    gle();
            VisibleUpdate ();
	    gle();
            CarUpdate ();
        }
        gle();
        RenderResize();
        gle();
        RenderUpdate (picking);
        resetviewport();
        gle();
        glPopAttrib();
        gle();
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
    }
Exemplo n.º 2
0
    pixel_city()
    {
	RandomInit (time (NULL));
        RenderInit ();
	CameraInit ();
        TextureInit ();
        WorldInit ();
        resetviewport();
        
    }
Exemplo n.º 3
0
void glk_make_sdl_window(void)
{


	s=initsdl(w,h,&bpp,SDL_OPENGL);
	SDL_EnableUNICODE(1);
	SDL_InitSubSystem( SDL_INIT_TIMER);
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY/2, SDL_DEFAULT_REPEAT_INTERVAL/3);
	gle();
	resetviewport();
	resetmatrices();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glClearColor( 0.0, 0.0, 0.0, 0.0 );
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	printf("LEMON\n");
}
void main()
{
	float x,y,p1,p2;
	int i,j,cop_x,cop_y,cop_z,plane_x,plane_y,choice,ch,dist,pass=-1;
	int mouse_x1,mouse_y1,button;
	clrscr();
	initgraph(&gd,&gm,"c://tc//bgi");
	initmouse();
	showmouseptr();
	resetviewport();
	restore();
	DrawCube();
	get_mouse_pos(&mouse_x1,&mouse_y1,&button);
	getch();
	while(!kbhit())
	{
		while(button!=1)
		{
			//showmouseptr();
			get_mouse_pos(&mouse_x1,&mouse_y1,&button);
			button=1;
			mouse_x1=541;mouse_y1=35;
		}
		if(button==1)
		{
			if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=30&&mouse_y1<=55)
				{
					choice=0;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=60&&mouse_y1<=80)
				{
					choice=1;
					ch=1;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=85&&mouse_y1<=105)
				{
					choice=1;
					ch=2;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=110&&mouse_y1<=130)
				{
					choice=1;
					ch=3;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=135&&mouse_y1<=155)
				{
					choice=2;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=160&&mouse_y1<=180)
				{
					choice=3;
					pass=1;
				}
			}
			else if(mouse_x1>=540&&mouse_x1<=620)
			{
				if(mouse_y1>=185&&mouse_y1<=205)
				{
					choice=4;
					pass=1;
				}
			}
			restore();
			if(pass==1)
			{
			switch(choice)
			{
				case 0: restore();
					DrawCube();
					choice=-1;
					pass=-1;
					break;

				case 1: if(ch==1)
					{
						closegraph();
						printf("enter the distance\n");
						scanf("%d",&dist);
						initgraph(&gd,&gm,"c://tc//bgi");
						resetviewport();
						x_perspective(dist);
						restore();
					}
					else if(ch==2)
					{
						closegraph();
						printf("enter the distance\n");
						scanf("%d",&dist);
						initgraph(&gd,&gm,"c://tc//bgi");
						resetviewport();
						y_perspective(dist);
						restore();
					}
					else if(ch==3)
					{
						closegraph();
						printf("enter the distance\n");
						scanf("%d",&dist);
						initgraph(&gd,&gm,"c://tc//bgi");
						resetviewport();
						z_perspective(dist);
						restore();
					}
					pass=-1;
					choice=-1;
					break;

				case 2: closegraph();
					printf("enter the center of projection(x,y,z)\n");
					scanf("%d%d%d",&cop_x,&cop_y,&cop_z);
					initgraph(&gd,&gm,"c://tc//bgi");
					resetviewport();
					rotate_x(atan(cop_x/cop_z));
					z_perspective(cop_z);
					restore();
					choice=-1;
					pass=-1;
					break;

				case 3: closegraph();
					printf("enter the center of projection(x,y,z)\n");
					scanf("%d%d%d",&cop_x,&cop_y,&cop_z);
					initgraph(&gd,&gm,"c://tc//bgi");
					resetviewport();
					rotate_x(atan(cop_x/cop_z));
					rotate_y(atan(cop_y/cop_z));
					z_perspective(cop_z);
					restore();
					choice=-1;
					pass=-1;
					break;

				case 4: exit(0);
			}
			}
		button=-1;
		}
	}
	//closegraph();
}