| 1 | /* |
| 2 | Copyright (C) 2005 Rice1964 |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License |
| 6 | as published by the Free Software Foundation; either version 2 |
| 7 | of the License, or (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _OGL_FRAGMENT_SHADER_H_ |
| 20 | #define _OGL_FRAGMENT_SHADER_H_ |
| 21 | |
| 22 | #include <vector> |
| 23 | |
| 24 | #include "osal_opengl.h" |
| 25 | |
| 26 | #include "OGLCombiner.h" |
| 27 | #include "OGLExtCombiner.h" |
| 28 | #include "GeneralCombiner.h" |
| 29 | |
| 30 | typedef struct { |
| 31 | uint32 dwMux0; |
| 32 | uint32 dwMux1; |
| 33 | |
| 34 | bool fogIsUsed; |
| 35 | bool alphaTest; |
| 36 | GLuint fragmentShaderID; |
| 37 | GLuint vertexShaderID; |
| 38 | GLuint programID; |
| 39 | |
| 40 | GLint PrimColorLocation; |
| 41 | GLint EnvColorLocation; |
| 42 | GLint PrimFracLocation; |
| 43 | GLint EnvFracLocation; |
| 44 | GLint AlphaRefLocation; |
| 45 | GLint FogColorLocation; |
| 46 | GLint FogMinMaxLocation; |
| 47 | |
| 48 | } OGLShaderCombinerSaveType; |
| 49 | |
| 50 | |
| 51 | class COGL_FragmentProgramCombiner : public COGLColorCombiner4 |
| 52 | { |
| 53 | public: |
| 54 | bool Initialize(void); |
| 55 | void SetFogState(bool bEnable) |
| 56 | { |
| 57 | bFogState = bEnable; |
| 58 | } |
| 59 | void SetAlphaTestState(bool bEnable) |
| 60 | { |
| 61 | bAlphaTestState = bEnable; |
| 62 | } |
| 63 | |
| 64 | protected: |
| 65 | friend class OGLDeviceBuilder; |
| 66 | |
| 67 | void DisableCombiner(void); |
| 68 | void InitCombinerCycleCopy(void); |
| 69 | void InitCombinerCycleFill(void); |
| 70 | void InitCombinerCycle12(void); |
| 71 | |
| 72 | COGL_FragmentProgramCombiner(CRender *pRender); |
| 73 | ~COGL_FragmentProgramCombiner(); |
| 74 | |
| 75 | bool m_bFragmentProgramIsSupported; |
| 76 | std::vector<OGLShaderCombinerSaveType> m_vCompiledShaders; |
| 77 | |
| 78 | private: |
| 79 | virtual int ParseDecodedMux(); |
| 80 | virtual void GenerateProgramStr(); |
| 81 | int FindCompiledMux(); |
| 82 | virtual void GenerateCombinerSetting(int index); |
| 83 | virtual void GenerateCombinerSettingConstants(int index); |
| 84 | float m_AlphaRef; |
| 85 | bool bAlphaTestState; |
| 86 | bool bAlphaTestPreviousState; |
| 87 | bool bFogState; |
| 88 | bool bFogPreviousState; |
| 89 | |
| 90 | #ifdef DEBUGGER |
| 91 | void DisplaySimpleMuxString(void); |
| 92 | #endif |
| 93 | |
| 94 | }; |
| 95 | |
| 96 | |
| 97 | |
| 98 | class COGLFragmentShaderCombiner : public COGLColorCombiner |
| 99 | { |
| 100 | public: |
| 101 | bool Initialize(void); |
| 102 | void InitCombinerBlenderForSimpleTextureDraw(uint32 tile=0); |
| 103 | protected: |
| 104 | friend class OGLDeviceBuilder; |
| 105 | |
| 106 | void DisableCombiner(void); |
| 107 | void InitCombinerCycleCopy(void); |
| 108 | void InitCombinerCycleFill(void); |
| 109 | void InitCombinerCycle12(void); |
| 110 | |
| 111 | COGLFragmentShaderCombiner(CRender *pRender); |
| 112 | ~COGLFragmentShaderCombiner(); |
| 113 | |
| 114 | bool m_bShaderIsSupported; |
| 115 | |
| 116 | #ifdef DEBUGGER |
| 117 | void DisplaySimpleMuxString(void); |
| 118 | #endif |
| 119 | |
| 120 | }; |
| 121 | |
| 122 | |
| 123 | #endif |
| 124 | |