blob: 67d009544402a2f9b77f68abcd8a482f5c26963c [file] [log] [blame]
Jason Sams4b962e52009-06-22 17:15:15 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "rsContext.h"
18
19using namespace android;
20using namespace android::renderscript;
21
22
23Light::Light(bool isLocal, bool isMono)
24{
25 mIsLocal = isLocal;
26 mIsMono = isMono;
27
28 mX = 0;
29 mY = 0;
30 mZ = 0;
31
32 mR = 1.f;
33 mG = 1.f;
34 mB = 1.f;
35}
36
37Light::~Light()
38{
39}
40
41void Light::setPosition(float x, float y, float z)
42{
43 mX = x;
44 mY = y;
45 mZ = z;
46}
47
48void Light::setColor(float r, float g, float b)
49{
50 mR = r;
51 mG = g;
52 mB = b;
53}
54
55////////////////////////////////////////////
56
57LightState::LightState()
58{
59 clear();
60}
61
62LightState::~LightState()
63{
64}
65
66void LightState::clear()
67{
68 mIsLocal = false;
69 mIsMono = false;
70}
71
72
73////////////////////////////////////////////////////
74//
75
76namespace android {
77namespace renderscript {
78
79void rsi_LightBegin(Context *rsc)
80{
81 rsc->mStateLight.clear();
82}
83
84void rsi_LightSetLocal(Context *rsc, bool isLocal)
85{
86 rsc->mStateLight.mIsLocal = isLocal;
87}
88
89void rsi_LightSetMonochromatic(Context *rsc, bool isMono)
90{
91 rsc->mStateLight.mIsMono = isMono;
92}
93
94RsLight rsi_LightCreate(Context *rsc)
95{
96 Light *l = new Light(rsc->mStateLight.mIsLocal,
97 rsc->mStateLight.mIsMono);
98 l->incRef();
99 return l;
100}
101
102void rsi_LightDestroy(Context *rsc, RsLight vl)
103{
104 Light *l = static_cast<Light *>(vl);
105 l->decRef();
106}
107
108void rsi_LightSetColor(Context *rsc, RsLight vl, float r, float g, float b)
109{
110 Light *l = static_cast<Light *>(vl);
111 l->setColor(r, g, b);
112}
113
114void rsi_LightSetPosition(Context *rsc, RsLight vl, float x, float y, float z)
115{
116 Light *l = static_cast<Light *>(vl);
117 l->setPosition(x, y, z);
118}
119
120
121
122}
123}