Subversion Repositories Kolibri OS

Rev

Rev 8062 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5159 IgorA 1
use32
8062 IgorA 2
	org 0
5159 IgorA 3
	db 'MENUET01'
8062 IgorA 4
	dd 1,start,i_end,mem,stacktop,0,cur_dir_path
5159 IgorA 5
 
8062 IgorA 6
include '../../../../../proc32.inc'
7
include '../../../../../macros.inc'
8
include '../../../../../KOSfuncs.inc'
9
include '../../../../../develop/libraries/box_lib/load_lib.mac'
10
include '../../../../../dll.inc'
5159 IgorA 11
include '../opengl_const.inc'
12
 
13
@use_library
14
 
15
align 4
16
start:
17
	load_library name_tgl, cur_dir_path, library_path, system_path, \
18
		err_message_found_lib, head_f_l, import_lib_tinygl, err_message_import, head_f_i
8062 IgorA 19
	cmp eax,SF_TERMINATE_PROCESS
5159 IgorA 20
	jz button.exit
21
 
8062 IgorA 22
	mcall SF_SET_EVENTS_MASK,0x27
5159 IgorA 23
 
24
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
25
stdcall [glEnable], GL_DEPTH_TEST
26
 
27
call draw_3d
28
 
29
align 4
30
red_win:
31
	call draw_window
32
 
8062 IgorA 33
align 16
5159 IgorA 34
still:
8069 IgorA 35
	mcall SF_WAIT_EVENT
5159 IgorA 36
	cmp al,1
37
	jz red_win
38
	cmp al,2
39
	jz key
40
	cmp al,3
41
	jz button
42
	jmp still
43
 
44
align 4
45
draw_window:
46
	pushad
8062 IgorA 47
	mcall SF_REDRAW,SSF_BEGIN_DRAW
5159 IgorA 48
 
49
	mov edx,0x33ffffff ;0x73ffffff
8062 IgorA 50
	mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
51
	call [kosglSwapBuffers]
5159 IgorA 52
 
8062 IgorA 53
	mcall SF_REDRAW,SSF_END_DRAW
5159 IgorA 54
	popad
55
	ret
56
 
57
align 4
58
key:
8062 IgorA 59
	mcall SF_GET_KEY
5159 IgorA 60
 
61
	cmp ah,27 ;Esc
62
	je button.exit
63
 
64
	;178 ;Up
65
	;177 ;Down
66
	cmp ah,176 ;Left
67
	jne @f
68
		fld dword[angle_z]
69
		fadd dword[delt_size]
70
		fstp dword[angle_z]
71
		call draw_3d
8062 IgorA 72
		call [kosglSwapBuffers]
8069 IgorA 73
		jmp still
5159 IgorA 74
	@@:
75
	cmp ah,179 ;Right
76
	jne @f
77
		fld dword[angle_z]
78
		fsub dword[delt_size]
79
		fstp dword[angle_z]
80
		call draw_3d
8062 IgorA 81
		call [kosglSwapBuffers]
8069 IgorA 82
		;jmp still
5159 IgorA 83
	@@:
84
 
85
	jmp still
86
 
87
align 4
88
button:
8062 IgorA 89
	mcall SF_GET_BUTTON
5159 IgorA 90
	cmp ah,1
91
	jne still
92
.exit:
8062 IgorA 93
	mcall SF_TERMINATE_PROCESS
5159 IgorA 94
 
95
 
96
align 4
97
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
98
 
99
align 4
100
draw_3d:
101
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
102
 
8062 IgorA 103
call [glPushMatrix]
5159 IgorA 104
	stdcall [glRotatef], [angle_z],0.0,0.0,1.0
105
 
106
	stdcall [glScalef], 0.3,0.3,0.3
107
 
108
	stdcall [glColor3f],1.0, 0.0, 0.0
109
	stdcall [glBegin],GL_LINE_LOOP
110
		stdcall [glVertex3f], 0,      0.9, 0.1
111
		stdcall [glVertex3f], 0.636,  0.636, 0.1
112
		stdcall [glVertex3f], 0.9,    0.0, 0.1
113
		stdcall [glVertex3f], 0.636, -0.636, 0.1
114
		stdcall [glColor3f],0.0, 0.0, 1.0
115
		stdcall [glVertex3f], 0.0,   -0.9, 0.1
116
		stdcall [glVertex3f], -0.636,-0.636, 0.1
117
		stdcall [glVertex3f], -0.9,   0.0, 0.1
118
		stdcall [glVertex3f], -0.636, 0.636, 0.1
8069 IgorA 119
	call [glEnd]
5159 IgorA 120
 
121
	stdcall [glBegin],GL_LINE_LOOP
122
		stdcall [glVertex3f], 0.0, 1.1, 0.1
123
		stdcall [glVertex3f], 0.778, 0.778, 0.1
124
		stdcall [glVertex3f], 2.1, 0.0, 0.1
125
		stdcall [glVertex3f], 0.778, -0.778, 0.1
126
		stdcall [glVertex3f], 0.0, -1.1, 0.1
127
		stdcall [glVertex3f], -0.778, -0.778, 0.1
128
		stdcall [glVertex3f], -2.1, 0.0, 0.1
129
		stdcall [glVertex3f], -0.778, 0.778, 0.1
8069 IgorA 130
	call [glEnd]
5159 IgorA 131
 
8062 IgorA 132
call [glPopMatrix]
5159 IgorA 133
ret
134
 
135
angle_z dd 0.0
136
delt_size dd 3.0
137
 
138
;--------------------------------------------------
139
align 4
140
import_lib_tinygl:
141
 
142
macro E_LIB n
143
{
144
	n dd sz_#n
145
}
146
include '../export.inc'
147
	dd 0,0
148
macro E_LIB n
149
{
150
	sz_#n db `n,0
151
}
152
include '../export.inc'
153
 
154
;--------------------------------------------------
155
system_path db '/sys/lib/'
156
name_tgl db 'tinygl.obj',0
8062 IgorA 157
 
5159 IgorA 158
head_f_i:
8062 IgorA 159
head_f_l db '"System error',0
160
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
161
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
5159 IgorA 162
;--------------------------------------------------
163
 
8062 IgorA 164
align 16
5159 IgorA 165
i_end:
8062 IgorA 166
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
167
;sizeof.TinyGLContext = 28
5159 IgorA 168
	rb 1024
169
stacktop:
170
cur_dir_path:
171
	rb 4096
172
library_path:
173
	rb 4096
174
mem: