blob: e64ff3e2901cc450ce5f13fe0f34c2e1ac8f31f7 [file] [log] [blame]
Kristian Høgsbergffd710e2008-12-02 15:15:01 -05001/*
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -05002 * Copyright © 2008 Kristian Høgsberg
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
Kristian Høgsbergffd710e2008-12-02 15:15:01 -050021 */
22
Kristian Høgsberg96ce9682011-01-07 14:42:49 -050023#include "config.h"
24
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050025#include <stdint.h>
26#include <stdio.h>
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050027#include <stdlib.h>
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050028#include <string.h>
29#include <fcntl.h>
30#include <unistd.h>
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050031#include <math.h>
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050032#include <time.h>
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050033#include <glib.h>
34
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050035#include <GL/gl.h>
Kristian Høgsberg3afd45d2010-03-03 09:54:29 -050036#include <EGL/egl.h>
37#include <EGL/eglext.h>
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050038
Kristian Høgsbergda1f30a2009-03-06 21:24:01 -050039#include "wayland-util.h"
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050040#include "wayland-client.h"
41#include "wayland-glib.h"
42
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050043#include "window.h"
44
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050045struct gears {
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050046 struct window *window;
47
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -050048 struct display *d;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050049
50 EGLDisplay display;
Benjamin Franzkecff904e2011-02-18 23:00:55 +010051 EGLDisplay config;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050052 EGLContext context;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050053 GLfloat angle;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050054
55 GLint gear_list[3];
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050056};
57
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050058struct gear_template {
59 GLfloat material[4];
60 GLfloat inner_radius;
61 GLfloat outer_radius;
62 GLfloat width;
63 GLint teeth;
64 GLfloat tooth_depth;
65};
66
67const static struct gear_template gear_templates[] = {
68 { { 0.8, 0.1, 0.0, 1.0 }, 1.0, 4.0, 1.0, 20, 0.7 },
69 { { 0.0, 0.8, 0.2, 1.0 }, 0.5, 2.0, 2.0, 10, 0.7 },
70 { { 0.2, 0.2, 1.0, 1.0 }, 1.3, 2.0, 0.5, 10, 0.7 },
71};
72
73static GLfloat light_pos[4] = {5.0, 5.0, 10.0, 0.0};
74
75static void die(const char *msg)
76{
77 fprintf(stderr, "%s", msg);
78 exit(EXIT_FAILURE);
79}
80
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050081static void
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050082make_gear(const struct gear_template *t)
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050083{
84 GLint i;
85 GLfloat r0, r1, r2;
86 GLfloat angle, da;
87 GLfloat u, v, len;
88
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050089 glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, t->material);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050090
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -050091 r0 = t->inner_radius;
92 r1 = t->outer_radius - t->tooth_depth / 2.0;
93 r2 = t->outer_radius + t->tooth_depth / 2.0;
94
95 da = 2.0 * M_PI / t->teeth / 4.0;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -050096
97 glShadeModel(GL_FLAT);
98
99 glNormal3f(0.0, 0.0, 1.0);
100
101 /* draw front face */
102 glBegin(GL_QUAD_STRIP);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500103 for (i = 0; i <= t->teeth; i++) {
104 angle = i * 2.0 * M_PI / t->teeth;
105 glVertex3f(r0 * cos(angle), r0 * sin(angle), t->width * 0.5);
106 glVertex3f(r1 * cos(angle), r1 * sin(angle), t->width * 0.5);
107 if (i < t->teeth) {
108 glVertex3f(r0 * cos(angle), r0 * sin(angle), t->width * 0.5);
109 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500110 }
111 }
112 glEnd();
113
114 /* draw front sides of teeth */
115 glBegin(GL_QUADS);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500116 da = 2.0 * M_PI / t->teeth / 4.0;
117 for (i = 0; i < t->teeth; i++) {
118 angle = i * 2.0 * M_PI / t->teeth;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500119
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500120 glVertex3f(r1 * cos(angle), r1 * sin(angle), t->width * 0.5);
121 glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), t->width * 0.5);
122 glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), t->width * 0.5);
123 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500124 }
125 glEnd();
126
127 glNormal3f(0.0, 0.0, -1.0);
128
129 /* draw back face */
130 glBegin(GL_QUAD_STRIP);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500131 for (i = 0; i <= t->teeth; i++) {
132 angle = i * 2.0 * M_PI / t->teeth;
133 glVertex3f(r1 * cos(angle), r1 * sin(angle), -t->width * 0.5);
134 glVertex3f(r0 * cos(angle), r0 * sin(angle), -t->width * 0.5);
135 if (i < t->teeth) {
136 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -t->width * 0.5);
137 glVertex3f(r0 * cos(angle), r0 * sin(angle), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500138 }
139 }
140 glEnd();
141
142 /* draw back sides of teeth */
143 glBegin(GL_QUADS);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500144 da = 2.0 * M_PI / t->teeth / 4.0;
145 for (i = 0; i < t->teeth; i++) {
146 angle = i * 2.0 * M_PI / t->teeth;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500147
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500148 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -t->width * 0.5);
149 glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -t->width * 0.5);
150 glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -t->width * 0.5);
151 glVertex3f(r1 * cos(angle), r1 * sin(angle), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500152 }
153 glEnd();
154
155 /* draw outward faces of teeth */
156 glBegin(GL_QUAD_STRIP);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500157 for (i = 0; i < t->teeth; i++) {
158 angle = i * 2.0 * M_PI / t->teeth;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500159
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500160 glVertex3f(r1 * cos(angle), r1 * sin(angle), t->width * 0.5);
161 glVertex3f(r1 * cos(angle), r1 * sin(angle), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500162 u = r2 * cos(angle + da) - r1 * cos(angle);
163 v = r2 * sin(angle + da) - r1 * sin(angle);
164 len = sqrt(u * u + v * v);
165 u /= len;
166 v /= len;
167 glNormal3f(v, -u, 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500168 glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), t->width * 0.5);
169 glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500170 glNormal3f(cos(angle), sin(angle), 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500171 glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), t->width * 0.5);
172 glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500173 u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
174 v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
175 glNormal3f(v, -u, 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500176 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), t->width * 0.5);
177 glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500178 glNormal3f(cos(angle), sin(angle), 0.0);
179 }
180
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500181 glVertex3f(r1 * cos(0), r1 * sin(0), t->width * 0.5);
182 glVertex3f(r1 * cos(0), r1 * sin(0), -t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500183
184 glEnd();
185
186 glShadeModel(GL_SMOOTH);
187
188 /* draw inside radius cylinder */
189 glBegin(GL_QUAD_STRIP);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500190 for (i = 0; i <= t->teeth; i++) {
191 angle = i * 2.0 * M_PI / t->teeth;
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500192 glNormal3f(-cos(angle), -sin(angle), 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500193 glVertex3f(r0 * cos(angle), r0 * sin(angle), -t->width * 0.5);
194 glVertex3f(r0 * cos(angle), r0 * sin(angle), t->width * 0.5);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500195 }
196 glEnd();
197}
198
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500199static void
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100200draw_gears(struct gears *gears)
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500201{
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100202 GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
203 struct rectangle window_allocation;
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500204 struct rectangle allocation;
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500205
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500206 window_draw(gears->window);
207
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500208 window_get_child_allocation(gears->window, &allocation);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100209 window_get_allocation(gears->window, &window_allocation);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500210
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100211 display_acquire_window_surface(gears->d,
212 gears->window,
213 gears->context);
214
215 glViewport(allocation.x,
216 window_allocation.height - allocation.height - allocation.x,
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500217 allocation.width, allocation.height);
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100218 glScissor(allocation.x,
219 window_allocation.height - allocation.height - allocation.y,
220 allocation.width, allocation.height);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500221
222 glEnable(GL_SCISSOR_TEST);
Kristian Høgsberg78231c82008-11-08 15:06:01 -0500223 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Kristian Høgsbergb8bf19b2008-11-05 07:38:46 -0500224
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500225 glPushMatrix();
226
227 glTranslatef(0.0, 0.0, -50);
228
229 glRotatef(view_rotx, 1.0, 0.0, 0.0);
230 glRotatef(view_roty, 0.0, 1.0, 0.0);
231 glRotatef(view_rotz, 0.0, 0.0, 1.0);
232
233 glPushMatrix();
234 glTranslatef(-3.0, -2.0, 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500235 glRotatef(gears->angle, 0.0, 0.0, 1.0);
236 glCallList(gears->gear_list[0]);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500237 glPopMatrix();
238
239 glPushMatrix();
240 glTranslatef(3.1, -2.0, 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500241 glRotatef(-2.0 * gears->angle - 9.0, 0.0, 0.0, 1.0);
242 glCallList(gears->gear_list[1]);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500243 glPopMatrix();
244
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500245 glPushMatrix();
246 glTranslatef(-3.1, 4.2, 0.0);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500247 glRotatef(-2.0 * gears->angle - 25.0, 0.0, 0.0, 1.0);
248 glCallList(gears->gear_list[2]);
Kristian Høgsberg8a9cda82008-11-03 15:31:30 -0500249 glPopMatrix();
250
251 glPopMatrix();
252
253 glFlush();
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500254
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100255 display_release(gears->d);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500256 window_flush(gears->window);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500257}
258
259static void
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500260resize_handler(struct window *window,
261 int32_t width, int32_t height, void *data)
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500262{
263 struct gears *gears = data;
264
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500265 /* Constrain child size to be square and at least 300x300 */
266 if (width > height)
267 height = width;
268 else
269 width = height;
270 if (width < 300) {
271 width = 300;
272 height = 300;
273 }
274
275 window_set_child_size(gears->window, width, height);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500276}
277
278static void
Kristian Høgsberg9ae561d2009-09-21 13:47:53 -0400279keyboard_focus_handler(struct window *window,
Kristian Høgsberg43788b12010-07-28 23:50:12 -0400280 struct input *device, void *data)
Kristian Høgsberg9ae561d2009-09-21 13:47:53 -0400281{
282 struct gears *gears = data;
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500283 struct rectangle allocation;
Kristian Høgsberg9ae561d2009-09-21 13:47:53 -0400284
Kristian Høgsbergda846ca2011-01-11 10:00:52 -0500285 window_get_child_allocation(gears->window, &allocation);
286 resize_handler(window, allocation.width, allocation.height, gears);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500287}
288
289static void
290redraw_handler(struct window *window, void *data)
291{
292 struct gears *gears = data;
293
294 draw_gears(gears);
Kristian Høgsberg9ae561d2009-09-21 13:47:53 -0400295}
296
297static void
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400298frame_callback(void *data, uint32_t time)
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500299{
300 struct gears *gears = data;
301
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400302 gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;
303
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500304 window_schedule_redraw(gears->window);
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400305 wl_display_frame_callback(display_get_display(gears->d),
306 frame_callback, gears);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500307}
308
309static struct gears *
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400310gears_create(struct display *display)
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500311{
Kristian Høgsberg82da52b2010-12-17 09:53:12 -0500312 const int width = 450, height = 500;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500313 struct gears *gears;
314 int i;
315
316 gears = malloc(sizeof *gears);
317 memset(gears, 0, sizeof *gears);
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500318 gears->d = display;
Kristian Høgsberg248c1b62011-01-21 18:03:15 -0500319 gears->window = window_create(display, width, height);
320 window_set_title(gears->window, "Wayland Gears");
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500321
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400322 gears->display = display_get_egl_display(gears->d);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500323 if (gears->display == NULL)
324 die("failed to create egl display\n");
325
Kristian Høgsbergf88ae452010-06-05 10:17:55 -0400326 eglBindAPI(EGL_OPENGL_API);
327
Benjamin Franzkecff904e2011-02-18 23:00:55 +0100328 gears->config = display_get_egl_config(gears->d);
329
330 gears->context = eglCreateContext(gears->display, gears->config,
331 EGL_NO_CONTEXT, NULL);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500332 if (gears->context == NULL)
333 die("failed to create context\n");
334
Kristian Høgsberga341fa02010-01-24 18:10:15 -0500335 if (!eglMakeCurrent(gears->display, NULL, NULL, gears->context))
336 die("faile to make context current\n");
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500337
338 for (i = 0; i < 3; i++) {
339 gears->gear_list[i] = glGenLists(1);
340 glNewList(gears->gear_list[i], GL_COMPILE);
341 make_gear(&gear_templates[i]);
342 glEndList();
343 }
344
345 glEnable(GL_NORMALIZE);
346
347 glMatrixMode(GL_PROJECTION);
348 glLoadIdentity();
349 glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 200.0);
350 glMatrixMode(GL_MODELVIEW);
351
352 glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
353 glEnable(GL_CULL_FACE);
354 glEnable(GL_LIGHTING);
355 glEnable(GL_LIGHT0);
356 glEnable(GL_DEPTH_TEST);
357 glClearColor(0, 0, 0, 0.92);
358
Kristian Høgsbergc8c37342010-06-25 11:19:22 -0400359 window_set_user_data(gears->window, gears);
360 window_set_resize_handler(gears->window, resize_handler);
361 window_set_keyboard_focus_handler(gears->window, keyboard_focus_handler);
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500362 window_set_redraw_handler(gears->window, redraw_handler);
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400363
Kristian Høgsberg2b43bd72010-11-08 15:45:55 -0500364 draw_gears(gears);
Kristian Høgsberg9d69f8e2010-09-03 14:46:38 -0400365 wl_display_frame_callback(display_get_display(gears->d),
366 frame_callback, gears);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500367
368 return gears;
369}
370
371int main(int argc, char *argv[])
372{
Kristian Høgsberg43c28ee2009-01-26 23:42:46 -0500373 struct display *d;
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500374
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400375 d = display_create(&argc, &argv, NULL);
Yuval Fledele9f5e362010-11-22 21:34:19 +0200376 if (d == NULL) {
377 fprintf(stderr, "failed to create display: %m\n");
378 return -1;
379 }
Kristian Høgsberg00439612011-01-25 15:16:01 -0500380 gears_create(d);
Kristian Høgsberg7824d812010-06-08 14:59:44 -0400381 display_run(d);
Kristian Høgsberg0c4457f2008-12-07 19:59:11 -0500382
383 return 0;
384}