Subversion Repositories Kolibri OS

Rev

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