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; |
44 | mMaxAnisotropy = 1.0f; |
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; } |
54 | void setCompareMode(GLenum compareMode) { mCompareMode = compareMode; } |
55 | void setCompareFunc(GLenum compareFunc) { mCompareFunc = compareFunc; } |
56 | void setMaxAnisotropy(GLfloat maxAnisotropy) { mMaxAnisotropy = maxAnisotropy; } |
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; } |
65 | GLenum getCompareMode() const { return mCompareMode; } |
66 | GLenum getCompareFunc() const { return mCompareFunc; } |
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 | |