Subversion Repositories Kolibri OS

Rev

Rev 8824 | Rev 8875 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8824 Rev 8849
Line 366... Line 366...
366
		mcall SF_REDRAW,SSF_END_DRAW
366
		mcall SF_REDRAW,SSF_END_DRAW
367
		pop ebx
367
		pop ebx
368
	}
368
	}
369
}
369
}
Line -... Line 370...
-
 
370
 
-
 
371
bool OpenModel(char* f_path)
-
 
372
{
-
 
373
	FileInfoBlock* file;
-
 
374
	unsigned long int k;
-
 
375
 
-
 
376
	file = FileOpen(f_path);
-
 
377
	if (!file){
-
 
378
		SetWindowCaption("Error open file ...");
-
 
379
		return false;
-
 
380
	}
-
 
381
	k = FileGetLength(file);
-
 
382
	if (k > 0){
-
 
383
		if(f_data) delete f_data;
-
 
384
		f_data = new unsigned char[k];
-
 
385
		if (f_data){
-
 
386
			if (FileRead(file, f_data, k) != k){
-
 
387
				delete f_data; f_data = 0;
-
 
388
			}
-
 
389
			else{
-
 
390
				init_model();
-
 
391
				draw_3d();
-
 
392
				SetWindowCaption(ofd.openfile_path);
-
 
393
				Redraw(1);
-
 
394
			}
-
 
395
		}
-
 
396
	}
-
 
397
	FileClose(file);
-
 
398
	return (bool)f_data;
-
 
399
}
370
 
400
 
371
bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/)
401
bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/)
372
{
402
{
373
	kos_start.Left = 10;
403
	kos_start.Left = 10;
374
	kos_start.Top = 40;
404
	kos_start.Top = 40;
Line 406... Line 436...
406
		angle_dhm = kos_start.Height/180.0;
436
		angle_dhm = kos_start.Height/180.0;
407
		glEnable(GL_DEPTH_TEST);
437
		glEnable(GL_DEPTH_TEST);
408
		glClearColor(0.2,0.2,0.2,0.0);
438
		glClearColor(0.2,0.2,0.2,0.0);
409
		glEnable(GL_NORMALIZE);
439
		glEnable(GL_NORMALIZE);
410
		//draw_3d();
440
		//draw_3d();
411
		return init_block();
441
		if(init_block()){
-
 
442
			if(CommandLine[0]) OpenModel(CommandLine);
-
 
443
			return true;
-
 
444
		}
-
 
445
	}
412
	} else return false;
446
	return false;
413
}
447
}
Line 414... Line 448...
414
 
448
 
415
void KolibriOnPaint(void)
449
void KolibriOnPaint(void)
416
{
450
{
Line 421... Line 455...
421
	DrawText(20,16,0,"Open");
455
	DrawText(20,16,0,"Open");
422
}
456
}
Line 423... Line 457...
423
 
457
 
424
void KolibriOnButton(long id, TThreadData /*th*/)
458
void KolibriOnButton(long id, TThreadData /*th*/)
425
{
-
 
426
	FileInfoBlock* file;
-
 
427
	unsigned long int k;
-
 
428
 
459
{
429
	switch(id){
460
	switch(id){
430
	case 2:
461
	case 2:
431
		ofd.type = 0; // 0 - open
462
		ofd.type = 0; // 0 - open
432
		OpenDialog_Start(&ofd);
-
 
433
		if(ofd.status==1){
463
		OpenDialog_Start(&ofd);
434
			file = FileOpen(ofd.openfile_path);
-
 
435
			if (!file){
-
 
436
				SetWindowCaption("Error open file ...");
-
 
437
				break;
-
 
438
			}
-
 
439
			k = FileGetLength(file);
-
 
440
			if (k > 0){
-
 
441
				if(f_data) delete f_data;
-
 
442
				f_data = new unsigned char[k];
-
 
443
				if (f_data){
-
 
444
					if (FileRead(file, f_data, k) != k){
-
 
445
						delete f_data; f_data = 0;
-
 
446
					}
-
 
447
					else{
-
 
448
						init_model();
-
 
449
						draw_3d();
-
 
450
						SetWindowCaption(ofd.openfile_path);
-
 
451
						Redraw(1);
-
 
452
					}
-
 
453
				}
-
 
454
			}
-
 
455
			FileClose(file);
-
 
456
		}
464
		if(ofd.status==1) OpenModel(ofd.openfile_path);
457
		//break;
465
		//break;
458
	};
466
	};
Line 459... Line 467...
459
}
467
}