Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8408 | IgorA | 1 | #include |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | |||
6 | using namespace Kolibri; |
||
7 | |||
8 | const char header[] = "Test tinygl library, [<-] and [->] - rotate"; |
||
9 | char library_path[2048]; |
||
10 | |||
11 | namespace Kolibri{ |
||
12 | char CurrentDirectoryPath[2048]; |
||
13 | } |
||
14 | |||
15 | TinyGLContext ctx1; |
||
16 | float angle_z = 0.0, delt_size = 3.0; |
||
17 | |||
18 | void draw_3d() |
||
19 | { |
||
20 | glClear(GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT); //очистим буфер цвета и глубины |
||
21 | |||
22 | glPushMatrix(); |
||
23 | glRotatef(angle_z,0.0,0.0,1.0); |
||
24 | |||
25 | glColor3f(1.0, 0.0, 0.0); |
||
26 | glBegin(GL_TRIANGLES); |
||
27 | glColor3f(0.0, 0.0, 1.0); |
||
28 | glVertex3f(0.0, 0.5, 0.1); |
||
29 | glVertex3f(0.475, 0.823, 0.1); |
||
30 | glVertex3f(0.433, 0.25, 0.1); |
||
31 | |||
32 | glColor3f(0.0, 1.0, 0.0); |
||
33 | glVertex3f(0.5, 0.0, 0.1); |
||
34 | glVertex3f(0.823,-0.475, 0.1); |
||
35 | glVertex3f(0.25, -0.433, 0.1); |
||
36 | |||
37 | glColor3f(1.0, 0.0, 0.0); |
||
38 | glVertex3f(0.0, -0.5, 0.1); |
||
39 | glVertex3f(-0.475,-0.823,0.1); |
||
40 | glVertex3f(-0.433,-0.25, 0.1); |
||
41 | |||
42 | glVertex3f(-0.5, 0.0, 0.1); |
||
43 | glColor3f(1.0, 1.0, 0.0); |
||
44 | glVertex3f(-0.823, 0.475, 0.1); |
||
45 | glColor3f(1.0, 1.0, 1.0); |
||
46 | glVertex3f(-0.25, 0.433, 0.1); |
||
47 | glEnd(); |
||
48 | |||
49 | glPopMatrix(); |
||
50 | } |
||
51 | |||
52 | bool KolibriOnStart(TStartData &kos_start, TThreadData /*th*/) |
||
53 | { |
||
54 | kos_start.Left = 10; |
||
55 | kos_start.Top = 40; |
||
56 | kos_start.Width = 330; |
||
57 | kos_start.Height = 275; |
||
58 | kos_start.WinData.WindowColor = 0xd0d0d0; |
||
59 | kos_start.WinData.WindowType = 0x33; // 0x34 - fixed, 0x33 - not fixed |
||
60 | kos_start.WinData.Title = header; |
||
61 | if(LoadLibrary("tinygl.obj", library_path, "/sys/lib/tinygl.obj", &import_tinygl)) |
||
62 | { |
||
63 | kosglMakeCurrent(0,0,kos_start.Width,kos_start.Height,&ctx1); |
||
64 | glEnable(GL_DEPTH_TEST); |
||
65 | glClearColor(0.2,0.0,0.2,0.0); |
||
66 | draw_3d(); |
||
67 | return true; |
||
68 | } |
||
69 | else return false; |
||
70 | } |
||
71 | |||
72 | void KolibriOnPaint(void) |
||
73 | { |
||
74 | kosglSwapBuffers(); |
||
75 | } |
||
76 | |||
77 | void KolibriOnKeyPress(TThreadData /*th*/) |
||
78 | { |
||
79 | long key = GetKey(); |
||
80 | switch(key){ |
||
81 | case 176: //Left |
||
82 | angle_z+=delt_size; |
||
83 | draw_3d(); |
||
84 | kosglSwapBuffers(); |
||
85 | break; |
||
86 | case 179: //Right |
||
87 | angle_z-=delt_size; |
||
88 | draw_3d(); |
||
89 | kosglSwapBuffers(); |
||
90 | //break; |
||
91 | }; |
||
92 | }-]> |