1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Sampler.h: Defines the es2::Sampler class 16 17 #ifndef LIBGLESV2_SAMPLER_H_ 18 #define LIBGLESV2_SAMPLER_H_ 19 20 #include "common/Object.hpp" 21 #include "Renderer/Renderer.hpp" 22 23 #include <GLES2/gl2.h> 24 25 namespace es2 26 { 27 28 class Sampler : public gl::NamedObject 29 { 30 public: Sampler(GLuint name)31 Sampler(GLuint name) : NamedObject(name) 32 { 33 mMinFilter = GL_NEAREST_MIPMAP_LINEAR; 34 mMagFilter = GL_LINEAR; 35 36 mWrapModeS = GL_REPEAT; 37 mWrapModeT = GL_REPEAT; 38 mWrapModeR = GL_REPEAT; 39 40 mMinLod = -1000.0f; 41 mMaxLod = 1000.0f; 42 mCompareMode = GL_NONE; 43 mCompareFunc = GL_LEQUAL; 44 mMaxAnisotropy = 1.0f; 45 } 46 setMinFilter(GLenum minFilter)47 void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; } setMagFilter(GLenum magFilter)48 void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; } setWrapS(GLenum wrapS)49 void setWrapS(GLenum wrapS) { mWrapModeS = wrapS; } setWrapT(GLenum wrapT)50 void setWrapT(GLenum wrapT) { mWrapModeT = wrapT; } setWrapR(GLenum wrapR)51 void setWrapR(GLenum wrapR) { mWrapModeR = wrapR; } setMinLod(GLfloat minLod)52 void setMinLod(GLfloat minLod) { mMinLod = minLod; } setMaxLod(GLfloat maxLod)53 void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; } setCompareMode(GLenum compareMode)54 void setCompareMode(GLenum compareMode) { mCompareMode = compareMode; } setCompareFunc(GLenum compareFunc)55 void setCompareFunc(GLenum compareFunc) { mCompareFunc = compareFunc; } setMaxAnisotropy(GLfloat maxAnisotropy)56 void setMaxAnisotropy(GLfloat maxAnisotropy) { mMaxAnisotropy = maxAnisotropy; } 57 getMinFilter()58 GLenum getMinFilter() const { return mMinFilter; } getMagFilter()59 GLenum getMagFilter() const { return mMagFilter; } getWrapS()60 GLenum getWrapS() const { return mWrapModeS; } getWrapT()61 GLenum getWrapT() const { return mWrapModeT; } getWrapR()62 GLenum getWrapR() const { return mWrapModeR; } getMinLod()63 GLfloat getMinLod() const { return mMinLod; } getMaxLod()64 GLfloat getMaxLod() const { return mMaxLod; } getCompareMode()65 GLenum getCompareMode() const { return mCompareMode; } getCompareFunc()66 GLenum getCompareFunc() const { return mCompareFunc; } getMaxAnisotropy()67 GLfloat getMaxAnisotropy() const { return mMaxAnisotropy; } 68 69 private: 70 GLenum mMinFilter; 71 GLenum mMagFilter; 72 73 GLenum mWrapModeS; 74 GLenum mWrapModeT; 75 GLenum mWrapModeR; 76 77 GLfloat mMinLod; 78 GLfloat mMaxLod; 79 GLenum mCompareMode; 80 GLenum mCompareFunc; 81 GLfloat mMaxAnisotropy; 82 }; 83 84 } 85 86 #endif // LIBGLESV2_SAMPLER_H_ 87