Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 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 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
| 26 | |
| 27 | class ProgramVertex : public Program |
| 28 | { |
| 29 | public: |
| 30 | const static uint32_t MAX_CONSTANTS = 2; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 31 | const static uint32_t MAX_LIGHTS = 8; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | |
| 33 | ProgramVertex(Element *in, Element *out); |
| 34 | virtual ~ProgramVertex(); |
| 35 | |
| 36 | virtual void setupGL(); |
| 37 | |
| 38 | |
| 39 | void setConstantType(uint32_t slot, const Type *); |
| 40 | void bindAllocation(uint32_t slot, Allocation *); |
| 41 | void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;} |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 42 | void addLight(const Light *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 43 | |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 44 | void setProjectionMatrix(const rsc_Matrix *) const; |
| 45 | void setModelviewMatrix(const rsc_Matrix *) const; |
| 46 | void setTextureMatrix(const rsc_Matrix *) const; |
| 47 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 48 | protected: |
| 49 | bool mDirty; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 50 | uint32_t mLightCount; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 51 | |
| 52 | ObjectBaseRef<Allocation> mConstants[MAX_CONSTANTS]; |
| 53 | ObjectBaseRef<const Type> mConstantTypes[MAX_CONSTANTS]; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 54 | ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; |
| 55 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 56 | |
| 57 | // Hacks to create a program for now |
| 58 | bool mTextureMatrixEnable; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 59 | |
| 60 | }; |
| 61 | |
| 62 | |
| 63 | class ProgramVertexState |
| 64 | { |
| 65 | public: |
| 66 | ProgramVertexState(); |
| 67 | ~ProgramVertexState(); |
| 68 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 69 | void init(Context *rsc, int32_t w, int32_t h); |
| 70 | |
| 71 | ObjectBaseRef<ProgramVertex> mDefault; |
| 72 | ObjectBaseRef<Allocation> mDefaultAlloc; |
Jason Sams | ee41112 | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 73 | |
| 74 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 75 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 76 | ProgramVertex *mPV; |
| 77 | |
| 78 | //ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE]; |
| 79 | |
| 80 | |
| 81 | }; |
| 82 | |
| 83 | |
| 84 | } |
| 85 | } |
| 86 | #endif |
| 87 | |
| 88 | |