Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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: |
| 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; |
Krzysztof Kosiński | cbb80f5 | 2018-05-17 19:20:47 -0700 | [diff] [blame] | 44 | mMaxAnisotropy = 1.0f; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; } |
| 48 | void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; } |
| 49 | void setWrapS(GLenum wrapS) { mWrapModeS = wrapS; } |
| 50 | void setWrapT(GLenum wrapT) { mWrapModeT = wrapT; } |
| 51 | void setWrapR(GLenum wrapR) { mWrapModeR = wrapR; } |
| 52 | void setMinLod(GLfloat minLod) { mMinLod = minLod; } |
| 53 | void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; } |
Nicolas Capens | f878d50 | 2017-11-06 15:29:46 -0500 | [diff] [blame] | 54 | void setCompareMode(GLenum compareMode) { mCompareMode = compareMode; } |
| 55 | void setCompareFunc(GLenum compareFunc) { mCompareFunc = compareFunc; } |
Krzysztof Kosiński | cbb80f5 | 2018-05-17 19:20:47 -0700 | [diff] [blame] | 56 | void setMaxAnisotropy(GLfloat maxAnisotropy) { mMaxAnisotropy = maxAnisotropy; } |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 57 | |
| 58 | GLenum getMinFilter() const { return mMinFilter; } |
| 59 | GLenum getMagFilter() const { return mMagFilter; } |
| 60 | GLenum getWrapS() const { return mWrapModeS; } |
| 61 | GLenum getWrapT() const { return mWrapModeT; } |
| 62 | GLenum getWrapR() const { return mWrapModeR; } |
| 63 | GLfloat getMinLod() const { return mMinLod; } |
| 64 | GLfloat getMaxLod() const { return mMaxLod; } |
Nicolas Capens | f878d50 | 2017-11-06 15:29:46 -0500 | [diff] [blame] | 65 | GLenum getCompareMode() const { return mCompareMode; } |
| 66 | GLenum getCompareFunc() const { return mCompareFunc; } |
Krzysztof Kosiński | cbb80f5 | 2018-05-17 19:20:47 -0700 | [diff] [blame] | 67 | GLfloat getMaxAnisotropy() const { return mMaxAnisotropy; } |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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; |
Krzysztof Kosiński | cbb80f5 | 2018-05-17 19:20:47 -0700 | [diff] [blame] | 81 | GLfloat mMaxAnisotropy; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | } |
| 85 | |
| 86 | #endif // LIBGLESV2_SAMPLER_H_ |