• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 	}
45 
setMinFilter(GLenum minFilter)46 	void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; }
setMagFilter(GLenum magFilter)47 	void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; }
setWrapS(GLenum wrapS)48 	void setWrapS(GLenum wrapS) { mWrapModeS = wrapS; }
setWrapT(GLenum wrapT)49 	void setWrapT(GLenum wrapT) { mWrapModeT = wrapT; }
setWrapR(GLenum wrapR)50 	void setWrapR(GLenum wrapR) { mWrapModeR = wrapR; }
setMinLod(GLfloat minLod)51 	void setMinLod(GLfloat minLod) { mMinLod = minLod; }
setMaxLod(GLfloat maxLod)52 	void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; }
setCompareMode(GLenum compareMode)53 	void setCompareMode(GLenum compareMode) { mCompareMode = compareMode; }
setCompareFunc(GLenum compareFunc)54 	void setCompareFunc(GLenum compareFunc) { mCompareFunc = compareFunc; }
55 
getMinFilter()56 	GLenum getMinFilter() const { return mMinFilter; }
getMagFilter()57 	GLenum getMagFilter() const { return mMagFilter; }
getWrapS()58 	GLenum getWrapS() const { return mWrapModeS; }
getWrapT()59 	GLenum getWrapT() const { return mWrapModeT; }
getWrapR()60 	GLenum getWrapR() const { return mWrapModeR; }
getMinLod()61 	GLfloat getMinLod() const { return mMinLod; }
getMaxLod()62 	GLfloat getMaxLod() const { return mMaxLod; }
getCompareMode()63 	GLenum getCompareMode() const { return mCompareMode; }
getCompareFunc()64 	GLenum getCompareFunc() const { return mCompareFunc; }
65 
66 private:
67 	GLenum mMinFilter;
68 	GLenum mMagFilter;
69 
70 	GLenum mWrapModeS;
71 	GLenum mWrapModeT;
72 	GLenum mWrapModeR;
73 
74 	GLfloat mMinLod;
75 	GLfloat mMaxLod;
76 	GLenum mCompareMode;
77 	GLenum mCompareFunc;
78 };
79 
80 }
81 
82 #endif // LIBGLESV2_SAMPLER_H_
83