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.
18 #include "game-renderer.h"
19 #include "game-model.h"
20 #include "game-texture.h"
22 #include "generated/game-renderer-frag.h"
23 #include "generated/game-renderer-vert.h"
25 #include <dali/dali.h>
27 GameRenderer::GameRenderer()
33 GameRenderer::~GameRenderer()
37 void GameRenderer::SetModel(GameModel* model)
43 void GameRenderer::SetMainTexture(GameTexture* texture)
49 void GameRenderer::Setup()
51 if(!mRenderer && mModel)
53 Dali::Shader shader = Dali::Shader::New(SHADER_GAME_RENDERER_VERT, SHADER_GAME_RENDERER_FRAG);
54 mRenderer = Dali::Renderer::New(mModel->GetGeometry(), shader);
55 mRenderer.SetProperty(Dali::Renderer::Property::DEPTH_WRITE_MODE, Dali::DepthWriteMode::ON);
56 mRenderer.SetProperty(Dali::Renderer::Property::DEPTH_FUNCTION, Dali::DepthFunction::LESS_EQUAL);
57 mRenderer.SetProperty(Dali::Renderer::Property::DEPTH_TEST_MODE, Dali::DepthTestMode::ON);
60 Dali::TextureSet textureSet;
61 Dali::Geometry geometry;
65 geometry = mModel->GetGeometry();
68 if(mTexture && mTexture->GetTextureSet())
70 textureSet = mTexture->GetTextureSet();
73 if(textureSet && geometry)
75 mRenderer.SetGeometry(geometry);
76 mRenderer.SetTextures(textureSet);
80 Dali::Renderer& GameRenderer::GetRenderer()