14 int windowWidth,
int windowHeight,
int textureWidth,
int textureHeight,
15 SamplerState::Filter
filter, SamplerState::Mode mode0, SamplerState::Mode mode1,
18 mWindowWidth(static_cast<float>(windowWidth)),
19 mWindowHeight(static_cast<float>(windowHeight))
21 Initialize(windowWidth, windowHeight, textureWidth, textureHeight);
30 std::shared_ptr<SamplerState>
sampler =
31 std::make_shared<SamplerState>();
33 sampler->mode[0] = mode0;
34 sampler->mode[1] = mode1;
35 mProgram->GetPShader()->Set(
"imageSampler", sampler);
41 int windowWidth,
int windowHeight,
int textureWidth,
int textureHeight,
48 Initialize(windowWidth, windowHeight, textureWidth, textureHeight);
64 std::array<int, 4>
const& textureRectangle)
76 && y < mOverlayRectangle[1] + mOverlayRectangle[3];
83 #if defined(GTE_DEV_OPENGL) 84 mEffect->GetPixelShader()->Set(
"imageSampler", texture);
86 mEffect->GetPixelShader()->Set(
"imageTexture", texture);
92 std::shared_ptr<Texture2>
const&
texture)
96 mEffect->GetPixelShader()->Set(textureName, texture);
101 int textureWidth,
int textureHeight)
103 if (windowWidth <= 0 || windowHeight <= 0
104 || textureWidth <= 0 || textureHeight <= 0)
106 LogError(
"Invalid input rectangle.");
132 mVBuffer = std::make_shared<VertexBuffer>(vformat, 4);
138 sizeof(
unsigned int));
140 indices[0] = 0; indices[1] = 2; indices[2] = 3;
141 indices[3] = 0; indices[4] = 3; indices[5] = 1;
161 vertex[0].
tcoord = { tx, ty };
162 vertex[1].
position = { px + pw, py };
163 vertex[1].
tcoord = { tx + tw, ty };
164 vertex[2].
position = { px, py + ph };
165 vertex[2].
tcoord = { tx, ty + th };
166 vertex[3].
position = { px + pw, py + ph };
167 vertex[3].
tcoord = { tx + tw, ty + th };
172 "layout(location = 0) in vec3 modelPosition;\n" 173 "layout(location = 1) in vec2 modelTCoord;\n" 174 "layout(location = 0) out vec2 vertexTCoord;\n" 178 " vertexTCoord = modelTCoord;\n" 179 " gl_Position.x = 2.0f*modelPosition.x - 1.0f;\n" 180 " gl_Position.y = -2.0f*modelPosition.y + 1.0f;\n" 181 " gl_Position.z = -1.0f;\n" 182 " gl_Position.w = 1.0f;\n" 186 "uniform sampler2D imageSampler;\n" 188 "layout(location = 0) in vec2 vertexTCoord;\n" 189 "layout(location = 0) out vec4 pixelColor;\n" 193 " pixelColor = texture(imageSampler, vertexTCoord);\n" 197 "uniform sampler2D imageSampler;\n" 199 "layout(location = 0) in vec2 vertexTCoord;\n" 200 "layout(location = 0) out vec4 pixelColor;\n" 204 " float gray = texture(imageSampler, vertexTCoord).r;\n" 205 " pixelColor = vec4(gray, gray, gray, 1.0f);\n" 211 " float2 modelPosition : POSITION;\n" 212 " float2 modelTCoord : TEXCOORD0;\n" 217 " float2 vertexTCoord : TEXCOORD0;\n" 218 " float4 clipPosition : SV_POSITION;\n" 221 "VS_OUTPUT VSMain (VS_INPUT input)\n" 223 " VS_OUTPUT output;\n" 224 " output.clipPosition.x = 2.0f*input.modelPosition.x - 1.0f;\n" 225 " output.clipPosition.y = -2.0f*input.modelPosition.y + 1.0f;\n" 226 " output.clipPosition.z = 0.0f;\n" 227 " output.clipPosition.w = 1.0f;\n" 228 " output.vertexTCoord = input.modelTCoord;\n" 233 "Texture2D<float4> imageTexture;\n" 234 "SamplerState imageSampler;\n" 238 " float2 vertexTCoord : TEXCOORD0;\n" 243 " float4 pixelColor0 : SV_TARGET0;\n" 246 "PS_OUTPUT PSMain(PS_INPUT input)\n" 248 " PS_OUTPUT output;\n" 249 " output.pixelColor0 = imageTexture.Sample(imageSampler, input.vertexTCoord);\n" 254 "Texture2D<float> imageTexture;\n" 255 "SamplerState imageSampler;\n" 259 " float2 vertexTCoord : TEXCOORD0;\n" 264 " float4 pixelColor0 : SV_TARGET0;\n" 267 "PS_OUTPUT PSMain(PS_INPUT input)\n" 269 " PS_OUTPUT output;\n" 270 " float gray = imageTexture.Sample(imageSampler, input.vertexTCoord);\n" 271 " output.pixelColor0 = float4(gray, gray, gray, 1.0f);\n" std::array< int, 4 > mTextureRectangle
static std::string const msGLSLVSSource
void SetTextureRectangle(std::array< int, 4 > const &rectangle)
static std::string const * msPSGraySource[ProgramFactory::PF_NUM_API]
std::shared_ptr< VertexBuffer > mVBuffer
static std::string const * msVSSource[ProgramFactory::PF_NUM_API]
std::shared_ptr< VisualProgram > mProgram
void UpdateVertexBuffer()
Vector2< float > position
static std::string const msHLSLVSSource
std::shared_ptr< VisualEffect > mEffect
void SetTexture(std::shared_ptr< Texture2 > const &texture)
static std::string const * msPSColorSource[ProgramFactory::PF_NUM_API]
void SetRectangles(std::array< int, 4 > const &overlayRectangle, std::array< int, 4 > const &textureRectangle)
GLsizei const GLchar *const * string
GLsizei GLenum const void * indices
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
std::array< int, 4 > mOverlayRectangle
static std::string const msHLSLPSColorSource
OverlayEffect(std::shared_ptr< ProgramFactory > const &factory, int windowWidth, int windowHeight, int textureWidth, int textureHeight, SamplerState::Filter filter, SamplerState::Mode mode0, SamplerState::Mode mode1, bool useColorPShader)
static std::string const msHLSLPSGraySource
std::shared_ptr< IndexBuffer > mIBuffer
static std::string const msGLSLPSColorSource
bool Contains(int x, int y) const
static std::string const msGLSLPSGraySource
void Initialize(int windowWidth, int windowHeight, int textureWidth, int textureHeight)