blob: 493668c083a14037fc9a1eb12870c3ca31cb94bc [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -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#ifndef ANDROID_RS_PROGRAM_VERTEX_H
18#define ANDROID_RS_PROGRAM_VERTEX_H
19
20#include "rsProgram.h"
21
22// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
Jason Samscfb1d112009-08-05 13:57:03 -070026class ProgramVertexState;
Jason Sams326e0dd2009-05-22 14:03:28 -070027
28class ProgramVertex : public Program
29{
30public:
Jason Samsb5909ce2009-07-21 12:20:54 -070031 const static uint32_t MAX_LIGHTS = 8;
Jason Sams326e0dd2009-05-22 14:03:28 -070032
Jason Samse514b452009-09-25 14:51:22 -070033 ProgramVertex(Context *, Element *in, Element *out);
Jason Sams326e0dd2009-05-22 14:03:28 -070034 virtual ~ProgramVertex();
35
Jason Samsafcb25c2009-08-25 11:34:49 -070036 virtual void setupGL(const Context *rsc, ProgramVertexState *state);
Jason Sams326e0dd2009-05-22 14:03:28 -070037
38
Jason Sams326e0dd2009-05-22 14:03:28 -070039 void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;}
Jason Samsb5909ce2009-07-21 12:20:54 -070040 void addLight(const Light *);
Jason Sams326e0dd2009-05-22 14:03:28 -070041
Jason Samsc9d43db2009-07-28 12:02:16 -070042 void setProjectionMatrix(const rsc_Matrix *) const;
43 void setModelviewMatrix(const rsc_Matrix *) const;
44 void setTextureMatrix(const rsc_Matrix *) const;
45
Jason Sams3a97c592009-09-30 17:36:20 -070046 void transformToScreen(const Context *, float *v4out, const float *v3in) const;
47
48
Jason Sams326e0dd2009-05-22 14:03:28 -070049protected:
Jason Samsb5909ce2009-07-21 12:20:54 -070050 uint32_t mLightCount;
Jason Samsb5909ce2009-07-21 12:20:54 -070051 ObjectBaseRef<const Light> mLights[MAX_LIGHTS];
52
Jason Sams326e0dd2009-05-22 14:03:28 -070053 // Hacks to create a program for now
54 bool mTextureMatrixEnable;
Jason Sams326e0dd2009-05-22 14:03:28 -070055};
56
57
Jason Samscfb1d112009-08-05 13:57:03 -070058class ProgramVertexState
Jason Sams326e0dd2009-05-22 14:03:28 -070059{
60public:
61 ProgramVertexState();
62 ~ProgramVertexState();
63
Jason Sams8ce125b2009-06-17 16:52:59 -070064 void init(Context *rsc, int32_t w, int32_t h);
Jason Samsf2649a92009-09-25 16:37:33 -070065 void deinit(Context *rsc);
Jason Sams8ce125b2009-06-17 16:52:59 -070066
67 ObjectBaseRef<ProgramVertex> mDefault;
Jason Samscfb1d112009-08-05 13:57:03 -070068 ObjectBaseRef<ProgramVertex> mLast;
Jason Sams8ce125b2009-06-17 16:52:59 -070069 ObjectBaseRef<Allocation> mDefaultAlloc;
Jason Samscfb1d112009-08-05 13:57:03 -070070
Jason Samsf2649a92009-09-25 16:37:33 -070071 ObjectBaseRef<Type> mAllocType;
Jason Sams8ce125b2009-06-17 16:52:59 -070072
Jason Sams326e0dd2009-05-22 14:03:28 -070073 ProgramVertex *mPV;
74
75 //ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE];
76
77
78};
79
80
81}
82}
83#endif
84
85