Subversion Repositories Kolibri OS

Rev

Rev 5171 | Rev 8069 | 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:
8062 IgorA 65
	mcall SF_CHECK_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]
5171 IgorA 103
	@@:
104
	cmp ah,179 ;Right
105
	jne @f
106
		fld dword[angle_z]
107
		fsub dword[delt_size]
108
		fstp dword[angle_z]
109
		call draw_3d
8062 IgorA 110
		call [kosglSwapBuffers]
5171 IgorA 111
	@@:
112
 
113
	jmp still
114
 
115
align 4
116
button:
8062 IgorA 117
	mcall SF_GET_BUTTON
5171 IgorA 118
	cmp ah,1
119
	jne still
120
.exit:
8062 IgorA 121
	mcall SF_TERMINATE_PROCESS
5171 IgorA 122
 
123
 
124
align 4
125
caption db 'Test tinygl library, [Esc] - exit, [<-] and [->] - rotate',0
126
 
127
align 4
128
draw_3d:
129
stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;очистим буфер цвета и глубины
130
 
8062 IgorA 131
call [glPushMatrix]
5171 IgorA 132
	stdcall [glRotatef], [angle_z],0.0,0.0,1.0
133
	stdcall [glScalef], 0.3,0.3,0.3
134
 
135
	stdcall [glCallList],[obj1]
136
 
137
stdcall [glPopMatrix]
138
ret
139
 
140
align 4
141
angle_z dd 0.0
142
delt_size dd 3.0
143
obj1 dd ?
144
 
145
;--------------------------------------------------
146
align 4
147
import_lib_tinygl:
148
 
149
macro E_LIB n
150
{
151
	n dd sz_#n
152
}
153
include '../export.inc'
154
	dd 0,0
155
macro E_LIB n
156
{
157
	sz_#n db `n,0
158
}
159
include '../export.inc'
160
 
161
;--------------------------------------------------
162
system_path db '/sys/lib/'
163
name_tgl db 'tinygl.obj',0
8062 IgorA 164
 
5171 IgorA 165
head_f_i:
8062 IgorA 166
head_f_l db '"System error',0
167
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
168
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
5171 IgorA 169
;--------------------------------------------------
170
 
8062 IgorA 171
align 16
5171 IgorA 172
i_end:
8062 IgorA 173
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
174
;sizeof.TinyGLContext = 28
5171 IgorA 175
	rb 1024
176
stacktop:
177
cur_dir_path:
178
	rb 4096
179
library_path:
180
	rb 4096
181
mem: