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