14 std::shared_ptr<Texture2>
const&
texture)
16 auto api = factory->GetAPI();
27 SetColor({ 0.0f, 0.0f, 0.0f, 0.0f });
29 #if defined(GTE_DEV_OPENGL) 30 mProgram->GetPShader()->Set(
"baseSampler", texture);
32 mProgram->GetPShader()->Set(
"baseTexture", texture);
68 "layout(location = 0) in vec2 modelPosition;\n" 69 "layout(location = 1) in vec2 modelTCoord;\n" 70 "layout(location = 0) out vec2 vertexTCoord;\n" 74 " vertexTCoord = modelTCoord;\n" 75 " gl_Position.x = 2.0f * modelPosition.x - 1.0f + 2.0f * translate.x;\n" 76 " gl_Position.y = 2.0f * modelPosition.y - 1.0f + 2.0f * translate.y;\n" 77 " gl_Position.z = -1.0f;\n" 78 " gl_Position.w = 1.0f;\n" 87 "layout(location = 0) in vec2 vertexTCoord;\n" 88 "layout(location = 0) out vec4 pixelColor;\n" 90 "uniform sampler2D baseSampler;\n" 94 " float bitmapAlpha = texture(baseSampler, vertexTCoord).r;\n" 95 " if (bitmapAlpha > 0.5f)\n" 99 " pixelColor = textColor;\n" 103 "cbuffer Translate\n" 105 " float2 translate;\n" 109 " float2 modelPosition : POSITION;\n" 110 " float2 modelTCoord : TEXCOORD0;\n" 115 " float2 vertexTCoord : TEXCOORD0;\n" 116 " float4 clipPosition : SV_POSITION;\n" 119 "VS_OUTPUT VSMain (VS_INPUT input)\n" 121 " VS_OUTPUT output;\n" 122 " output.vertexTCoord = input.modelTCoord;\n" 123 " output.clipPosition.x = 2.0f*input.modelPosition.x - 1.0f + 2.0f*translate.x;\n" 124 " output.clipPosition.y = 2.0f*input.modelPosition.y - 1.0f + 2.0f*translate.y;\n" 125 " output.clipPosition.z = 0.0f;\n" 126 " output.clipPosition.w = 1.0f;\n" 130 "cbuffer TextColor\n" 132 " float4 textColor;\n" 135 "Texture2D baseTexture;\n" 136 "SamplerState baseSampler;\n" 140 " float2 vertexTCoord : TEXCOORD0;\n" 145 " float4 pixelColor0 : SV_TARGET0;\n" 148 "PS_OUTPUT PSMain(PS_INPUT input)\n" 150 " PS_OUTPUT output;\n" 151 " float bitmapAlpha = baseTexture.Sample(baseSampler, input.vertexTCoord).r;\n" 152 " if (bitmapAlpha > 0.5f)\n" 156 " output.pixelColor0 = textColor;\n" std::shared_ptr< ConstantBuffer > const & GetTranslate() const
void SetTranslate(float x, float y)
static std::string const msHLSLSource
static std::string const * msPSSource[ProgramFactory::PF_NUM_API]
void SetColor(Vector4< float > const &color)
TextEffect(std::shared_ptr< ProgramFactory > const &factory, std::shared_ptr< Texture2 > const &texture)
static std::string const msGLSLVSSource
std::shared_ptr< ConstantBuffer > mTranslate
GLsizei const GLchar *const * string
static std::string const * msVSSource[ProgramFactory::PF_NUM_API]
std::shared_ptr< ConstantBuffer > mColor
std::shared_ptr< SamplerState > mSamplerState
static std::string const msGLSLPSSource
std::shared_ptr< VisualProgram > mProgram
std::shared_ptr< ConstantBuffer > const & GetColor() const