00001 #ifndef GLW_FRAGMENTSHADER_H 00002 #define GLW_FRAGMENTSHADER_H 00003 00004 #include "./shader.h" 00005 00006 namespace glw 00007 { 00008 00009 class FragmentShaderArguments : public ShaderArguments 00010 { 00011 public: 00012 00013 typedef ShaderArguments BaseType; 00014 typedef FragmentShaderArguments ThisType; 00015 00016 FragmentShaderArguments(void) 00017 : BaseType() 00018 { 00019 ; 00020 } 00021 00022 void clear(void) 00023 { 00024 BaseType::clear(); 00025 } 00026 }; 00027 00028 class FragmentShader : public Shader 00029 { 00030 friend class Context; 00031 00032 public: 00033 00034 typedef Shader BaseType; 00035 typedef FragmentShader ThisType; 00036 00037 virtual Type type(void) const 00038 { 00039 return FragmentShaderType; 00040 } 00041 00042 protected: 00043 00044 FragmentShader(Context * ctx) 00045 : BaseType(ctx) 00046 { 00047 ; 00048 } 00049 00050 virtual GLenum shaderType(void) const 00051 { 00052 return GL_FRAGMENT_SHADER; 00053 } 00054 00055 bool create(const FragmentShaderArguments & args) 00056 { 00057 return BaseType::create(args); 00058 } 00059 }; 00060 00061 namespace detail { template <> struct BaseOf <FragmentShader> { typedef Shader Type; }; }; 00062 typedef detail::ObjectSharedPointerTraits <FragmentShader> ::Type FragmentShaderPtr; 00063 00064 class SafeFragmentShader : public SafeShader 00065 { 00066 friend class Context; 00067 friend class BoundFragmentShader; 00068 00069 public: 00070 00071 typedef SafeShader BaseType; 00072 typedef SafeFragmentShader ThisType; 00073 00074 protected: 00075 00076 SafeFragmentShader(const FragmentShaderPtr & fragmentShader) 00077 : BaseType(fragmentShader) 00078 { 00079 ; 00080 } 00081 00082 const FragmentShaderPtr & object(void) const 00083 { 00084 return static_cast<const FragmentShaderPtr &>(BaseType::object()); 00085 } 00086 00087 FragmentShaderPtr & object(void) 00088 { 00089 return static_cast<FragmentShaderPtr &>(BaseType::object()); 00090 } 00091 }; 00092 00093 namespace detail { template <> struct BaseOf <SafeFragmentShader> { typedef SafeShader Type; }; }; 00094 namespace detail { template <> struct ObjectBase <SafeFragmentShader> { typedef FragmentShader Type; }; }; 00095 namespace detail { template <> struct ObjectSafe <FragmentShader > { typedef SafeFragmentShader Type; }; }; 00096 typedef detail::ObjectSharedPointerTraits <SafeFragmentShader> ::Type FragmentShaderHandle; 00097 00098 class FragmentShaderBindingParams : public ShaderBindingParams 00099 { 00100 public: 00101 00102 typedef ShaderBindingParams BaseType; 00103 typedef FragmentShaderBindingParams ThisType; 00104 00105 FragmentShaderBindingParams(void) 00106 : BaseType(GL_FRAGMENT_SHADER, 0) 00107 { 00108 ; 00109 } 00110 }; 00111 00112 class BoundFragmentShader : public BoundShader 00113 { 00114 friend class Context; 00115 00116 public: 00117 00118 typedef BoundShader BaseType; 00119 typedef BoundFragmentShader ThisType; 00120 00121 const FragmentShaderHandle & handle(void) const 00122 { 00123 return static_cast<const FragmentShaderHandle &>(BaseType::handle()); 00124 } 00125 00126 FragmentShaderHandle & handle(void) 00127 { 00128 return static_cast<FragmentShaderHandle &>(BaseType::handle()); 00129 } 00130 00131 protected: 00132 00133 BoundFragmentShader(const FragmentShaderHandle & handle, const ShaderBindingParams & params) 00134 : BaseType(handle, params) 00135 { 00136 ; 00137 } 00138 00139 const FragmentShaderPtr & object(void) const 00140 { 00141 return this->handle()->object(); 00142 } 00143 00144 FragmentShaderPtr & object(void) 00145 { 00146 return this->handle()->object(); 00147 } 00148 }; 00149 00150 namespace detail { template <> struct ParamsOf <BoundFragmentShader> { typedef FragmentShaderBindingParams Type; }; }; 00151 namespace detail { template <> struct BaseOf <BoundFragmentShader> { typedef BoundShader Type; }; }; 00152 namespace detail { template <> struct ObjectBase <BoundFragmentShader> { typedef FragmentShader Type; }; }; 00153 namespace detail { template <> struct ObjectBound <FragmentShader > { typedef BoundFragmentShader Type; }; }; 00154 typedef detail::ObjectSharedPointerTraits <BoundFragmentShader> ::Type BoundFragmentShaderHandle; 00155 00156 }; 00157 00158 #endif // GLW_FRAGMENTSHADER_H