00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VRS_GL2_UNIFORM_SAMPLER_H
00019 #define VRS_GL2_UNIFORM_SAMPLER_H
00020
00021 #include <vrs/opengl/gl2/programvariable.h>
00022 #include <vrs/opengl/gl2/samplervariable.h>
00023 #include <vrs/opengl/gl2/shadertextureunitselector.h>
00024
00025 namespace VRS {
00026
00027 class TextureGL;
00028
00029 namespace GL2 {
00030
00031
00038 class UniformSampler : public ProgramVariable
00039 {
00040 public:
00041 UniformSampler(
00042 const std::string& name,
00043 SO<TextureGL> texture
00044 ) : m_texture(texture)
00045 {
00046 VRS_Error(texture, "no texture for sampler");
00047
00048 m_samplerVariable = new GL2::SamplerVariable(name, 0);
00049 m_textureUnitSelector = new GL2::ShaderTextureUnitSelector(0);
00050 }
00051
00052 SO<GL2::SamplerVariable> getSamplerVariable() const {
00053 return m_samplerVariable;
00054 }
00055
00056 SO<TextureGL> getTexture() const {
00057 return m_texture;
00058 }
00059
00060 SO<GL2::ShaderTextureUnitSelector> getTextureUnitSelector() const {
00061 return m_textureUnitSelector;
00062 }
00063
00064 VRS_TYPEINFO(UniformSampler, ProgramVariable);
00065 VRS_SERIALIZABLE(UniformSampler);
00066
00067 protected:
00068
00069 UniformSampler() {}
00070
00071 SO<GL2::SamplerVariable> m_samplerVariable;
00072 SO<GL2::ShaderTextureUnitSelector> m_textureUnitSelector;
00073 SO<TextureGL> m_texture;
00074 };
00075
00076
00077 inline void UniformSampler::serialize(SerializationManager& manager)
00078 {
00079 UINT8 version = 0;
00080 manager.classVersion(version);
00081
00082 VRS_SERIALIZATION_PARENT_CLASS(manager, ProgramVariable);
00083 serialization(manager, "samplerVariable", m_samplerVariable);
00084 serialization(manager, "textureUnitSelector", m_textureUnitSelector);
00085 serialization(manager, "texture", m_texture);
00086 }
00087
00088 VRS_SERIALIZATION_REGISTRATION(UniformSampler);
00089
00090
00091 }
00092 }
00093
00094 #endif // VRS_GL2_UNIFORM_SAMPLER_H