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
25namespace es2
26{
27
28class Sampler : public gl::NamedObject
29{
30public:
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
46	void setMinFilter(GLenum minFilter) { mMinFilter = minFilter; }
47	void setMagFilter(GLenum magFilter) { mMagFilter = magFilter; }
48	void setWrapS(GLenum wrapS) { mWrapModeS = wrapS; }
49	void setWrapT(GLenum wrapT) { mWrapModeT = wrapT; }
50	void setWrapR(GLenum wrapR) { mWrapModeR = wrapR; }
51	void setMinLod(GLfloat minLod) { mMinLod = minLod; }
52	void setMaxLod(GLfloat maxLod) { mMaxLod = maxLod; }
53	void setComparisonMode(GLenum comparisonMode) { mCompareMode = comparisonMode; }
54	void setComparisonFunc(GLenum comparisonFunc) { mCompareFunc = comparisonFunc; }
55
56	GLenum getMinFilter() const { return mMinFilter; }
57	GLenum getMagFilter() const { return mMagFilter; }
58	GLenum getWrapS() const { return mWrapModeS; }
59	GLenum getWrapT() const { return mWrapModeT; }
60	GLenum getWrapR() const { return mWrapModeR; }
61	GLfloat getMinLod() const { return mMinLod; }
62	GLfloat getMaxLod() const { return mMaxLod; }
63	GLenum getComparisonMode() const { return mCompareMode; }
64	GLenum getComparisonFunc() const { return mCompareFunc; }
65
66private:
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