Subversion Repositories Kolibri OS

Rev

Rev 5189 | Rev 8069 | 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:
8062 IgorA 37
	mcall SF_CHECK_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]
5187 IgorA 75
	@@:
76
	cmp ah,179 ;Right
77
	jne @f
78
		fld dword[angle_z]
79
		fsub dword[delt_size]
80
		fstp dword[angle_z]
81
		call draw_3d
8062 IgorA 82
		call [kosglSwapBuffers]
5187 IgorA 83
	@@:
84
 
85
	jmp still
86
 
87
align 4
88
button:
8062 IgorA 89
	mcall SF_GET_BUTTON
5187 IgorA 90
	cmp ah,1
91
	jne still
92
.exit:
8062 IgorA 93
	mcall SF_TERMINATE_PROCESS
5187 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]
5187 IgorA 104
	stdcall [glRotatef], [angle_z],0.0,0.0,1.0
105
 
5189 IgorA 106
	stdcall [glBegin],GL_TRIANGLES
5187 IgorA 107
 
5189 IgorA 108
	stdcall [glColor3f],0.0, 0.0, 1.0
109
	stdcall [glVertex3f], 0.0,   0.5,   0.1
110
	stdcall [glVertex3f], 0.475, 0.823, 0.1
111
	stdcall [glVertex3f], 0.433, 0.25,  0.1
112
 
113
	stdcall [glColor3f],0.0, 1.0, 0.0
114
	stdcall [glVertex3f], 0.5,   0.0,   0.1
115
	stdcall [glVertex3f], 0.823,-0.475, 0.1
116
	stdcall [glVertex3f], 0.25, -0.433, 0.1
117
 
5187 IgorA 118
	stdcall [glColor3f],1.0, 0.0, 0.0
5189 IgorA 119
	stdcall [glVertex3f], 0.0,  -0.5,   0.1
120
	stdcall [glVertex3f], -0.475,-0.823,0.1
121
	stdcall [glVertex3f], -0.433,-0.25, 0.1
122
 
123
	stdcall [glVertex3f], -0.5,   0.0,   0.1
124
	stdcall [glColor3f],1.0, 1.0, 0.0
125
	stdcall [glVertex3f], -0.823, 0.475, 0.1
126
	stdcall [glColor3f],1.0, 1.0, 1.0
127
	stdcall [glVertex3f], -0.25,  0.433, 0.1
128
 
5187 IgorA 129
	stdcall [glEnd]
130
 
131
stdcall [glPopMatrix]
132
ret
133
 
134
angle_z dd 15.0
135
delt_size dd 3.0
136
 
137
;--------------------------------------------------
138
align 4
139
import_lib_tinygl:
140
 
141
macro E_LIB n
142
{
143
	n dd sz_#n
144
}
145
include '../export.inc'
146
	dd 0,0
147
macro E_LIB n
148
{
149
	sz_#n db `n,0
150
}
151
include '../export.inc'
152
 
153
;--------------------------------------------------
154
system_path db '/sys/lib/'
155
name_tgl db 'tinygl.obj',0
8062 IgorA 156
 
5187 IgorA 157
head_f_i:
8062 IgorA 158
head_f_l db '"System error',0
159
err_message_import db 'Error on load import library ',39,'tinygl.obj',39,'" -tE',0
160
err_message_found_lib db 'Sorry I cannot load library ',39,'tinygl.obj',39,'" -tE',0
5187 IgorA 161
;--------------------------------------------------
162
 
8062 IgorA 163
align 16
5187 IgorA 164
i_end:
8062 IgorA 165
ctx1 db 28 dup (0) ;TinyGLContext or KOSGLContext
166
;sizeof.TinyGLContext = 28
5187 IgorA 167
	rb 1024
168
stacktop:
169
cur_dir_path:
170
	rb 4096
171
library_path:
172
	rb 4096
8062 IgorA 173
mem: