tizen 2.4 release
[sdk/emulator-yagl.git] / GLESv2 / yagl_gles2_interface.c
1 /*
2  * YaGL
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact :
7  * Stanislav Vorobiov <s.vorobiov@samsung.com>
8  * Jinhyung Jo <jinhyung.jo@samsung.com>
9  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a copy
12  * of this software and associated documentation files (the "Software"), to deal
13  * in the Software without restriction, including without limitation the rights
14  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  * copies of the Software, and to permit persons to whom the Software is
16  * furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27  * THE SOFTWARE.
28  *
29  * Contributors:
30  * - S-Core Co., Ltd
31  *
32  */
33
34 #include "GLES2/gl2.h"
35 #include "yagl_export.h"
36 #include "yagl_client_interface.h"
37 #include "yagl_gles2_context.h"
38 #include "yagl_gles3_context.h"
39 #include "yagl_gles_image.h"
40 #include "yagl_gles_texture.h"
41
42 static struct yagl_client_context *yagl_gles2_create_ctx(struct yagl_client_interface *iface,
43                                                          yagl_client_api client_api,
44                                                          struct yagl_sharegroup *sg)
45 {
46     switch (client_api) {
47     case yagl_client_api_gles2:
48         return yagl_gles2_context_create(sg);
49     case yagl_client_api_gles3:
50         return yagl_gles3_context_create(sg);
51     default:
52         return NULL;
53     }
54 }
55
56 static struct yagl_client_image
57     *yagl_gles2_create_image(struct yagl_client_interface *iface,
58                              yagl_object_name tex_global_name)
59 {
60     return &yagl_gles_image_create(tex_global_name)->base;
61 }
62
63 static struct yagl_client_image
64     *yagl_gles2_wrap_texture(struct yagl_client_interface *iface,
65                              struct yagl_client_context *ctx,
66                              yagl_object_name tex_local_name)
67 {
68     return &yagl_gles_image_wrap_tex(ctx, tex_local_name)->base;
69 }
70
71 static void yagl_gles2_release_tex_image(struct yagl_client_interface *iface,
72                                          void *cookie)
73 {
74     struct yagl_gles_texture *texture = cookie;
75
76     yagl_gles_texture_release_tex_image(texture);
77 }
78
79 YAGL_API struct yagl_client_interface yagl_gles2_interface =
80 {
81     .create_ctx = &yagl_gles2_create_ctx,
82     .create_image = &yagl_gles2_create_image,
83     .wrap_texture = &yagl_gles2_wrap_texture,
84     .release_tex_image = &yagl_gles2_release_tex_image
85 };