Subversion Repositories Kolibri OS

Rev

Rev 6189 | Rev 7929 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6189 Rev 6200
Line 1... Line 1...
1
use32
1
use32
2
	org 0x0
2
	org 0x0
3
	db 'MENUET01'
3
	db 'MENUET01'
4
	dd 1,start,i_end
-
 
5
	dd mem,stacktop
-
 
6
	dd 0,cur_dir_path
4
	dd 1,start,i_end,mem,stacktop,0,cur_dir_path
Line 7... Line 5...
7
 
5
 
8
include '../../../../../proc32.inc'
6
include '../../../../../proc32.inc'
9
include '../../../../../macros.inc'
7
include '../../../../../macros.inc'
10
include '../../../../../KOSfuncs.inc'
-
 
11
include '../../../../../develop/libraries/box_lib/load_lib.mac'
8
include '../../../../../KOSfuncs.inc'
12
include '../../../../../dll.inc'
9
include '../../../../../load_img.inc'
13
include '../opengl_const.inc'
10
include '../opengl_const.inc'
Line 14... Line 11...
14
include '../../../../../develop/info3ds/info_fun_float.inc'
11
include '../../../../../develop/info3ds/info_fun_float.inc'
Line 15... Line -...
15
 
-
 
16
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
-
 
17
 
-
 
18
struct FileInfoBlock
-
 
19
	Function dd ?
-
 
20
	Position dd ?
-
 
21
	Flags	 dd ?
-
 
22
	Count	 dd ?
-
 
23
	Buffer	 dd ?
-
 
24
		db ?
-
 
25
	FileName dd ?
12
 
26
ends
-
 
27
 
13
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
28
align 4
14
 
Line 29... Line -...
29
open_b rb 560
-
 
30
image_data_toolbar dd 0
-
 
31
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
-
 
32
 
-
 
33
;макрос для загрузки изображений
-
 
34
; path - может быть переменной или строковым параметром
-
 
35
; buf - переменная куда будет записан указатель на изображение в формате rgb
-
 
36
; img_w, img_h - переменные куда будут записаны размеры открываемого
-
 
37
;    изображения, не обязательные параметры
-
 
38
macro load_image_file path, buf, img_w, img_h
-
 
39
{
-
 
40
if path eqtype '' ;проверяем задан ли строкой параметр path
-
 
41
	local .path_str
-
 
42
	jmp @f
-
 
43
		.path_str db path ;формируем локальную переменную
-
 
44
		db 0
-
 
45
	@@:
-
 
46
	;32 - стандартный адрес по которому должен быть буфер с системным путем
-
 
47
	copy_path .path_str,[32],file_name,0
-
 
48
else
-
 
49
	copy_path path,[32],file_name,0 ;формируем полный путь к файлу изображения, подразумеваем что он в одной папке с программой
-
 
50
end if
-
 
51
    mov [run_file_70.Function], SSF_GET_INFO
-
 
52
    mov [run_file_70.Position], 0
-
 
53
    mov [run_file_70.Flags], 0
-
 
54
    mov dword[run_file_70.Count], 0
-
 
55
    mov dword[run_file_70.Buffer], open_b
-
 
56
    mov byte[run_file_70+20], 0
-
 
57
    mov dword[run_file_70.FileName], file_name
-
 
58
    mcall SF_FILE,run_file_70
-
 
59
	or eax,eax
-
 
60
	jnz @f
-
 
61
 
-
 
62
    mov ecx,dword[open_b+32] ;+32 qword: размер файла в байтах
-
 
63
    stdcall mem.Alloc,ecx ;выделяем память для изображения
-
 
64
	mov [buf],eax
-
 
65
	mov [run_file_70.Function], SSF_READ_FILE
-
 
66
	mov [run_file_70.Position], 0
-
 
67
	mov [run_file_70.Flags], 0
-
 
68
	mov [run_file_70.Count], ecx
-
 
69
	mov [run_file_70.Buffer], eax
-
 
70
	mov byte[run_file_70+20], 0
-
 
71
	mov [run_file_70.FileName], file_name
-
 
72
	mcall SF_FILE,run_file_70 ;загружаем файл изображения
-
 
73
	cmp ebx,0xffffffff
-
 
74
	je @f
-
 
75
		;определяем вид изображения и пишем его параметры
-
 
76
		stdcall [img_decode], [buf],ebx,0
-
 
77
		mov ebx,eax
-
 
78
		;определяем размер декодированного изображения
-
 
79
		mov ecx,[eax+4] ;+4 = image width
-
 
80
if img_w eq
-
 
81
else
-
 
82
		mov dword[img_w],ecx
-
 
83
end if
-
 
84
if img_h eq
-
 
85
		imul ecx,[eax+8] ;+8 = image height
-
 
86
else
-
 
87
		mov eax,[eax+8] ;+8 = image height
-
 
88
		mov dword[img_h],eax
-
 
89
		imul ecx,eax
-
 
90
end if
-
 
91
		imul ecx,3 ;need for r,g,b
-
 
92
		stdcall mem.ReAlloc,[buf],ecx ;изменяем размер для буфера
-
 
93
		mov [buf],eax
-
 
94
		stdcall [img_to_rgb2], ebx,[buf] ;преобразуем изображение к формату rgb
-
 
95
		stdcall [img_destroy], ebx ;удаляем временный буфер с параметрами изображения
15
align 4
Line 96... Line 16...
96
	@@:
16
image_data_toolbar dd 0
97
}
17
IMAGE_TOOLBAR_ICON_SIZE equ 21*21*3
98
 
18
 
Line 128... Line 48...
128
	mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
48
	mov eax,dword[ctx1] ;eax -> TinyGLContext.GLContext
129
	mov eax,[eax] ;eax -> ZBuffer
49
	mov eax,[eax] ;eax -> ZBuffer
130
	mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
50
	mov eax,[eax+offs_zbuf_pbuf] ;eax -> ZBuffer.pbuf
131
	mov dword[buf_ogl],eax
51
	mov dword[buf_ogl],eax
Line 132... Line 52...
132
 
52
 
133
	load_image_file 'font8x9.bmp', image_data_toolbar
53
	load_image_file 'font8x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
134
	stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;создаем буфер
54
	stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;создаем буфер
135
	stdcall mem.Free,[image_data_toolbar] ;освобождаем память
55
	stdcall mem.Free,[image_data_toolbar] ;освобождаем память
136
	stdcall [buf2d_conv_24_to_8], buf_1,1 ;делаем буфер прозрачности 8 бит
56
	stdcall [buf2d_conv_24_to_8], buf_1,1 ;делаем буфер прозрачности 8 бит
Line 179... Line 99...
179
	mcall SF_CREATE_WINDOW,(50 shl 16)+420,(30 shl 16)+410,0x33ffffff,,caption
99
	mcall SF_CREATE_WINDOW,(50 shl 16)+420,(30 shl 16)+410,0x33ffffff,,caption
Line 180... Line 100...
180
 
100
 
181
	mov esi,[sc.work_button]
101
	mov esi,[sc.work_button]
182
	mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;сферы
102
	mcall SF_DEFINE_BUTTON,(6 shl 16)+19,(6 shl 16)+19,3+0x40000000 ;сферы
-
 
103
	mcall ,(36 shl 16)+19,,4+0x40000000 ;куб
-
 
104
	mcall ,(66 shl 16)+19,,5+0x40000000 ;масштаб +
Line 183... Line 105...
183
	mcall ,(36 shl 16)+19,,4+0x40000000 ;куб
105
	mcall ,(96 shl 16)+19,,6+0x40000000 ;масштаб -
184
 
106
 
185
	mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+5 ;сферы
107
	mcall SF_PUT_IMAGE,[image_data_toolbar],(21 shl 16)+21,(5 shl 16)+5 ;сферы
-
 
108
	add ebx,2*IMAGE_TOOLBAR_ICON_SIZE
-
 
109
	mcall ,,,(35 shl 16)+5 ;куб
-
 
110
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
-
 
111
	mcall ,,,(65 shl 16)+5 ;масштаб +
Line 186... Line 112...
186
	add ebx,2*IMAGE_TOOLBAR_ICON_SIZE
112
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
187
	mcall ,,,(35 shl 16)+5 ;куб
113
	mcall ,,,(95 shl 16)+5 ;масштаб -
188
 
114
 
189
	stdcall [kosglSwapBuffers]
115
	stdcall [kosglSwapBuffers]
Line 198... Line 124...
198
	cmp ah,27 ;Esc
124
	cmp ah,27 ;Esc
199
	je button.exit
125
	je button.exit
Line 200... Line 126...
200
 
126
 
201
	cmp ah,61 ;+
127
	cmp ah,61 ;+
202
	jne @f
-
 
203
		finit
-
 
204
		fld dword[scale]
-
 
205
		fadd dword[delt_sc]
-
 
206
		fst dword[scale]
-
 
207
		mov word[NumberSymbolsAD],3
-
 
208
		fstp qword[Data_Double]
128
	jne @f
209
		call DoubleFloat_to_String
-
 
210
		mov byte[txt_scale.v],0
-
 
211
		stdcall str_cat, txt_scale.v,Data_String
129
		call but_zoom_p
212
		call draw_3d
-
 
213
		stdcall [kosglSwapBuffers]
130
		jmp still
214
	@@:
131
	@@:
215
	cmp ah,45 ;-
132
	cmp ah,45 ;-
216
	jne @f
-
 
217
		finit
-
 
218
		fld dword[scale]
-
 
219
		fsub dword[delt_sc]
-
 
220
		fst dword[scale]
-
 
221
		mov word[NumberSymbolsAD],3
-
 
222
		fstp qword[Data_Double]
133
	jne @f
223
		call DoubleFloat_to_String
-
 
224
		mov byte[txt_scale.v],0
-
 
225
		stdcall str_cat, txt_scale.v,Data_String
134
		call but_zoom_m
226
		call draw_3d
-
 
227
		stdcall [kosglSwapBuffers]
135
		jmp still
228
	@@:
136
	@@:
229
	cmp ah,178 ;Up
137
	cmp ah,178 ;Up
230
	jne @f
138
	jne @f
231
		finit
139
		finit
Line 296... Line 204...
296
	cmp ah,4
204
	cmp ah,4
297
	jne @f
205
	jne @f
298
		call but_dr_1
206
		call but_dr_1
299
		jmp still
207
		jmp still
300
	@@:
208
	@@:
-
 
209
	cmp ah,5
-
 
210
	jne @f
-
 
211
		call but_zoom_p
-
 
212
		jmp still
-
 
213
	@@:
-
 
214
	cmp ah,6
-
 
215
	jne @f
-
 
216
		call but_zoom_m
-
 
217
		jmp still
-
 
218
	@@:
301
	cmp ah,1
219
	cmp ah,1
302
	jne still
220
	jne still
303
.exit:
221
.exit:
304
	stdcall [gluDeleteQuadric], [qObj]
222
	stdcall [gluDeleteQuadric], [qObj]
305
	stdcall mem.Free,[image_data_toolbar]
223
	stdcall mem.Free,[image_data_toolbar]
Line 318... Line 236...
318
	call draw_3d
236
	call draw_3d
319
	stdcall [kosglSwapBuffers]
237
	stdcall [kosglSwapBuffers]
320
	ret
238
	ret
Line 321... Line 239...
321
 
239
 
-
 
240
align 4
-
 
241
but_zoom_p:
-
 
242
	finit
-
 
243
	fld dword[scale]
-
 
244
	fadd dword[sc_delt]
-
 
245
	fcom dword[sc_max]
-
 
246
	fstsw ax
-
 
247
	sahf
-
 
248
	jbe @f
-
 
249
		ffree st0
-
 
250
		fincstp
-
 
251
		fld dword[sc_max]
-
 
252
	@@:
-
 
253
	fst dword[scale]
-
 
254
	mov word[NumberSymbolsAD],3
-
 
255
	fstp qword[Data_Double]
-
 
256
	call DoubleFloat_to_String
-
 
257
	mov byte[txt_scale.v],0
-
 
258
	stdcall str_cat, txt_scale.v,Data_String
-
 
259
	call draw_3d
-
 
260
	stdcall [kosglSwapBuffers]
-
 
261
	ret
-
 
262
 
-
 
263
align 4
-
 
264
but_zoom_m:
-
 
265
	finit
-
 
266
	fld dword[scale]
-
 
267
	fsub dword[sc_delt]
-
 
268
	fcom dword[sc_min]
-
 
269
	fstsw ax
-
 
270
	sahf
-
 
271
	ja @f
-
 
272
		ffree st0
-
 
273
		fincstp
-
 
274
		fld dword[sc_min]
-
 
275
	@@:
-
 
276
	fst dword[scale]
-
 
277
	mov word[NumberSymbolsAD],3
-
 
278
	fstp qword[Data_Double]
-
 
279
	call DoubleFloat_to_String
-
 
280
	mov byte[txt_scale.v],0
-
 
281
	stdcall str_cat, txt_scale.v,Data_String
-
 
282
	call draw_3d
-
 
283
	stdcall [kosglSwapBuffers]
-
 
284
	ret
-
 
285
 
322
align 4
286
align 4
323
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
287
caption db 'Test textures, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
324
align 4
288
align 4
325
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
289
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
Line 428... Line 392...
428
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
392
TexObj dd 0 ;массив указателей на текстуры (в данном случае 1 шт.)
429
texture dd 0 ;указатель на память с текстурой
393
texture dd 0 ;указатель на память с текстурой
430
text_w dd 0
394
text_w dd 0
431
text_h dd 0
395
text_h dd 0
Line 432... Line 396...
432
 
396
 
-
 
397
scale dd 0.4 ;начальный масштаб
433
scale dd 0.4
398
sc_delt dd 0.05 ;изменение масштаба при нажатии
-
 
399
sc_min dd 0.1 ;минимальный масштаб
434
delt_sc dd 0.05
400
sc_max dd 1.1 ;максимальный масштаб
435
angle_z dd 0.0
401
angle_z dd 0.0
436
angle_y dd 0.0
402
angle_y dd 0.0
Line 437... Line 403...
437
delt_size dd 3.0
403
delt_size dd 3.0
Line 605... Line 571...
605
	dd 0,24 ;+16 color,bit in pixel
571
	dd 0,24 ;+16 color,bit in pixel
Line 606... Line 572...
606
 
572
 
607
align 4
573
align 4
608
buf_1:
574
buf_1:
609
	dd 0 ;указатель на буфер изображения
575
	dd 0 ;указатель на буфер изображения
610
	dw 25,25 ;+4 left,top
576
	dd 0 ;+4 left,top
611
	dd 128,144 ;+8 w,h
577
.w: dd 0
Line 612... Line 578...
612
	dd 0,24 ;+16 color,bit in pixel
578
.h: dd 0,0,24 ;+16 color,bit in pixel
613
 
579
 
614
align 4
580
align 4
615
l_libs_start:
581
l_libs_start:
616
	lib_0 l_libs lib_name_0, cur_dir_path, library_path,  system_dir_0,\
582
	lib_0 l_libs lib_name_0, cur_dir_path, file_name,  system_dir_0,\
617
		err_msg_found_lib_0, head_f_l, import_lib_tinygl,err_msg_import_0,head_f_i
583
		err_msg_found_lib_0, head_f_l, import_lib_tinygl,err_msg_import_0,head_f_i
618
	lib_1 l_libs lib_name_1, cur_dir_path, library_path,  system_dir_1,\
584
	lib_1 l_libs lib_name_1, cur_dir_path, file_name,  system_dir_1,\
619
		err_msg_found_lib_1, head_f_l, import_buf2d,  err_msg_import_1,head_f_i
585
		err_msg_found_lib_1, head_f_l, import_buf2d,  err_msg_import_1,head_f_i
620
	lib_2 l_libs lib_name_2, cur_dir_path, file_name, system_dir_2,\
586
	lib_2 l_libs lib_name_2, cur_dir_path, file_name, system_dir_2,\
Line 627... Line 593...
627
	sc system_colors
593
	sc system_colors
628
align 16
594
align 16
629
	rb 4096
595
	rb 4096
630
stacktop:
596
stacktop:
631
	cur_dir_path rb 4096
597
	cur_dir_path rb 4096
632
	library_path rb 4096
-
 
633
	file_name rb 4096 
598
	file_name rb 4096 
634
mem:
599
mem: