2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
26 Geometry CreateQuadGeometry()
28 // Create geometry -- unit square with whole of the texture mapped to it.
34 Vertex vertexData[] = {
35 {Vector3(-.5f, .5f, .0f)},
36 {Vector3(.5f, .5f, .0f)},
37 {Vector3(-.5f, -.5f, .0f)},
38 {Vector3(.5f, -.5f, .0f)},
41 VertexBuffer vertexBuffer = VertexBuffer::New(Property::Map()
42 .Add("aPosition", Property::VECTOR3));
43 vertexBuffer.SetData(vertexData, std::extent<decltype(vertexData)>::value);
45 Geometry geometry = Geometry::New();
46 geometry.AddVertexBuffer(vertexBuffer);
47 geometry.SetType(Geometry::TRIANGLE_STRIP);
51 Renderer CreateRenderer(TextureSet textures, Geometry geometry, Shader shader, uint32_t options)
53 Renderer renderer = Renderer::New(geometry, shader);
54 renderer.SetProperty(Renderer::Property::BLEND_MODE,
55 (options & RendererOptions::BLEND) ? BlendMode::ON : BlendMode::OFF);
56 renderer.SetProperty(Renderer::Property::DEPTH_TEST_MODE,
57 (options & RendererOptions::DEPTH_TEST) ? DepthTestMode::ON : DepthTestMode::OFF);
58 renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE,
59 (options & RendererOptions::DEPTH_WRITE) ? DepthWriteMode::ON : DepthWriteMode::OFF);
61 int faceCulling = (((options & RendererOptions::CULL_BACK) != 0) << 1) |
62 ((options & RendererOptions::CULL_FRONT) != 0);
63 renderer.SetProperty(Renderer::Property::FACE_CULLING_MODE, faceCulling);
67 textures = TextureSet::New();
70 renderer.SetTextures(textures);
74 void CenterActor(Actor actor)
76 actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
77 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);