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