Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5218 IgorA 1
use32
8069 IgorA 2
	org 0
5218 IgorA 3
	db 'MENUET01'
8069 IgorA 4
	dd 1,start,i_end,mem,stacktop,0,cur_dir_path
5218 IgorA 5
 
8069 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'
5218 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
8069 IgorA 19
	cmp eax,SF_TERMINATE_PROCESS
5218 IgorA 20
	jz button.exit
21
 
8069 IgorA 22
	mcall SF_SET_EVENTS_MASK,0x27
5218 IgorA 23
 
24
stdcall [kosglMakeCurrent], 10,10,300,225,ctx1
25
stdcall [glEnable], GL_DEPTH_TEST
26
stdcall [gluNewQuadric]
27
mov [qObj],eax
28
 
29
stdcall [glClearColor], 0.5,0.5,0.5,0.0
30
 
31
call draw_3d
32
 
33
align 4
34
red_win:
35
	call draw_window
36
 
8069 IgorA 37
align 16
5218 IgorA 38
still:
8069 IgorA 39
	mcall SF_WAIT_EVENT
5218 IgorA 40
	cmp al,1
41
	jz red_win
42
	cmp al,2
43
	jz key
44
	cmp al,3
45
	jz button
46
	jmp still
47
 
48
align 4
49
draw_window:
50
	pushad
8069 IgorA 51
	mcall SF_REDRAW,SSF_BEGIN_DRAW
5218 IgorA 52
 
53
	mov edx,0x33ffffff ;0x73ffffff
8069 IgorA 54
	mcall SF_CREATE_WINDOW,(50 shl 16)+330,(30 shl 16)+275,,,caption
55
	call [kosglSwapBuffers]
5218 IgorA 56
 
8069 IgorA 57
	mcall SF_REDRAW,SSF_END_DRAW
5218 IgorA 58
	popad
59
	ret
60
 
61
align 4
62
key:
8069 IgorA 63
	mcall SF_GET_KEY
5218 IgorA 64
 
65
	cmp ah,27 ;Esc
66
	je button.exit
67
 
68
	cmp ah,61 ;+
69
	jne @f
70
	    fld dword[scale]
71
	    fadd dword[delt_sc]
72
	    fstp dword[scale]
73
	    call draw_3d
8069 IgorA 74
	    call [kosglSwapBuffers]
75
		jmp still
5218 IgorA 76
	@@:
77
	cmp ah,45 ;-
78
	jne @f
79
	    fld dword[scale]
80
	    fsub dword[delt_sc]
81
	    fstp dword[scale]
82
	    call draw_3d
8069 IgorA 83
	    call [kosglSwapBuffers]
84
		jmp still
5218 IgorA 85
	@@:
86
	cmp ah,178 ;Up
87
	jne @f
88
		fld dword[angle_y]
89
		fadd dword[delt_size]
90
		fstp dword[angle_y]
91
		call draw_3d
8069 IgorA 92
		call [kosglSwapBuffers]
93
		jmp still
5218 IgorA 94
	@@:
95
	cmp ah,177 ;Down
96
	jne @f
97
		fld dword[angle_y]
98
		fsub dword[delt_size]
99
		fstp dword[angle_y]
100
		call draw_3d
8069 IgorA 101
		call [kosglSwapBuffers]
102
		jmp still
5218 IgorA 103
	@@:
104
	cmp ah,176 ;Left
105
	jne @f
106
		fld dword[angle_z]
107
		fadd dword[delt_size]
108
		fstp dword[angle_z]
109
		call draw_3d
8069 IgorA 110
		call [kosglSwapBuffers]
111
		jmp still
5218 IgorA 112
	@@:
113
	cmp ah,179 ;Right
114
	jne @f
115
		fld dword[angle_z]
116
		fsub dword[delt_size]
117
		fstp dword[angle_z]
118
		call draw_3d
8069 IgorA 119
		call [kosglSwapBuffers]
120
		;jmp still
5218 IgorA 121
	@@:
122
 
123
	jmp still
124
 
125
align 4
126
button:
8069 IgorA 127
	mcall SF_GET_BUTTON
5218 IgorA 128
	cmp ah,1
129
	jne still
130
.exit:
131
	stdcall [gluDeleteQuadric], [qObj]
8069 IgorA 132
	mcall SF_TERMINATE_PROCESS
5218 IgorA 133
 
134
 
135
align 4
136
caption db 'Test gluSphere, [Esc] - exit, [<-],[->],[Up],[Down] - rotate',0
137
 
138
align 4
139
draw_3d:
140
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
141
 
142
stdcall [glColor3f], 1.0, 1.0, 0.0
143
 
8069 IgorA 144
call [glPushMatrix]
5218 IgorA 145
	stdcall [glTranslatef], 0.0,0.0,0.5
146
	stdcall [glScalef], [scale], [scale], [scale]
147
 
148
	stdcall [glRotatef], [angle_z],0.0,0.0,1.0
149
	stdcall [glRotatef], [angle_y],0.0,1.0,0.0
150
	stdcall [gluSphere], [qObj], 1.0, 16,16
151
 
152
	stdcall [glColor3f], 1.0, 0.0, 0.0
153
	stdcall [glTranslatef], -1.6,0.0,0.0
154
	stdcall [gluSphere], [qObj], 0.55, 8,8
155
 
156
	stdcall [glColor3f], 0.0, 0.0, 1.0
157
	stdcall [glTranslatef], 3.2,0.0,0.0
158
	stdcall [gluSphere], [qObj], 0.55, 8,8
8069 IgorA 159
call [glPopMatrix]
5218 IgorA 160
ret
161
 
8069 IgorA 162
align 4
5218 IgorA 163
qObj dd 0
164
 
165
scale dd 0.4
166
delt_sc dd 0.05
167
angle_z dd 0.0
168
angle_y dd 0.0
169
delt_size dd 3.0
170
 
171
;--------------------------------------------------
172
align 4
173
import_lib_tinygl:
174
 
175
macro E_LIB n
176
{
177
	n dd sz_#n
178
}
179
include '../export.inc'
180
	dd 0,0
181
macro E_LIB n
182
{
183
	sz_#n db `n,0
184
}
185
include '../export.inc'
186
 
187
;--------------------------------------------------
188
system_path db '/sys/lib/'
189
name_tgl db 'tinygl.obj',0
8069 IgorA 190
 
5218 IgorA 191
head_f_i:
8069 IgorA 192
head_f_l db '"System error',0
193
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
194
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
5218 IgorA 195
;--------------------------------------------------
196
 
8069 IgorA 197
align 16
5218 IgorA 198
i_end:
8069 IgorA 199
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
200
;sizeof.TinyGLContext = 28
201
	rb 2048
5218 IgorA 202
stacktop:
203
cur_dir_path:
204
	rb 4096
205
library_path:
206
	rb 4096
207
mem: