Jason Sams | 326e0dd | 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 | |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 26 | class ProgramVertexState; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 27 | |
| 28 | class ProgramVertex : public Program |
| 29 | { |
| 30 | public: |
Jason Sams | b5909ce | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 31 | const static uint32_t MAX_LIGHTS = 8; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 32 | |
Jason Sams | 4815c0d | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 33 | ProgramVertex(Context *,const char * shaderText, uint32_t shaderLength, |
| 34 | const uint32_t * params, uint32_t paramLength); |
| 35 | ProgramVertex(Context *, bool texMat); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | virtual ~ProgramVertex(); |
| 37 | |
Jason Sams | afcb25c | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 38 | virtual void setupGL(const Context *rsc, ProgramVertexState *state); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 39 | virtual void setupGL2(const Context *rsc, ProgramVertexState *state, ShaderCache *sc); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | |
| 41 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 42 | void setTextureMatrixEnable(bool e) {mTextureMatrixEnable = e;} |
Jason Sams | b5909ce | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 43 | void addLight(const Light *); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 44 | |
Jason Sams | c9d43db | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 45 | void setProjectionMatrix(const rsc_Matrix *) const; |
| 46 | void setModelviewMatrix(const rsc_Matrix *) const; |
| 47 | void setTextureMatrix(const rsc_Matrix *) const; |
| 48 | |
Jason Sams | 3a97c59 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 49 | void transformToScreen(const Context *, float *v4out, const float *v3in) const; |
| 50 | |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 51 | virtual void createShader(); |
Jason Sams | cd50653 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 52 | virtual void loadShader(Context *); |
Jason Sams | c460e55 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 53 | virtual void init(Context *); |
| 54 | |
Jason Sams | 3a97c59 | 2009-09-30 17:36:20 -0700 | [diff] [blame] | 55 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 56 | protected: |
Jason Sams | b5909ce | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 57 | uint32_t mLightCount; |
Jason Sams | b5909ce | 2009-07-21 12:20:54 -0700 | [diff] [blame] | 58 | ObjectBaseRef<const Light> mLights[MAX_LIGHTS]; |
| 59 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 60 | // Hacks to create a program for now |
| 61 | bool mTextureMatrixEnable; |
Jason Sams | 433eca3 | 2010-01-06 11:57:52 -0800 | [diff] [blame] | 62 | |
| 63 | private: |
Jason Sams | 9ebb0c4 | 2010-01-12 12:12:28 -0800 | [diff] [blame] | 64 | void initAddUserElement(const Element *e, String8 *names, uint32_t *count, const char *prefix); |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 68 | class ProgramVertexState |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 69 | { |
| 70 | public: |
| 71 | ProgramVertexState(); |
| 72 | ~ProgramVertexState(); |
| 73 | |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 74 | void init(Context *rsc, int32_t w, int32_t h); |
Jason Sams | f2649a9 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 75 | void deinit(Context *rsc); |
Jason Sams | e18844a | 2009-11-12 16:09:45 -0800 | [diff] [blame] | 76 | void updateSize(Context *rsc, int32_t w, int32_t h); |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 77 | |
| 78 | ObjectBaseRef<ProgramVertex> mDefault; |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 79 | ObjectBaseRef<ProgramVertex> mLast; |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 80 | ObjectBaseRef<Allocation> mDefaultAlloc; |
Jason Sams | cfb1d11 | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 81 | |
Jason Sams | f2649a9 | 2009-09-25 16:37:33 -0700 | [diff] [blame] | 82 | ObjectBaseRef<Type> mAllocType; |
Jason Sams | 8ce125b | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 83 | |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 84 | |
Jason Sams | e9ed6cc | 2009-12-16 14:13:06 -0800 | [diff] [blame] | 85 | float color[4]; |
Jason Sams | 326e0dd | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | |
| 89 | } |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | |