#define CHECKER_CONNECT_GROUP 0
namespace HDK_Sample
{
static const char *theVert =
"#version 150\n"
"in vec2 P;\n"
"out vec2 uv;\n"
"uniform int width;\n"
"uniform int height;\n"
"uniform float check_size;\n"
"void main() {\n"
" gl_Position = vec4(P,0.,1.);\n"
" uv = P * 0.5;\n"
" uv.x *= width / check_size;\n"
" uv.y *= height / check_size;\n"
"}\n";
static const char *theFrag =
"#version 150\n"
"in vec2 uv;\n"
"out vec4 color;\n"
"uniform sampler2D checker;\n"
"void main() {\n"
" color = texture(checker, uv);\n"
"}\n";
{
public:
myCheckerTex(NULL),
myQuad(NULL)
{}
~DM_BackgroundRenderHook() override
{
delete myCheckerTex;
delete myQuad;
}
void viewportClosed() override;
private:
};
RE_Shader *DM_BackgroundRenderHook::theBGShader = NULL;
{
public:
DM_BackgroundHook()
{}
~DM_BackgroundHook() override {}
};
}
using namespace HDK_Sample;
{
return new DM_BackgroundRenderHook(vport);
}
void
{
delete hook;
}
bool
{
return false;
if(!theBGShader)
{
if(!theBGShader->linkShaders(r))
return false;
}
if(!myCheckerTex)
{
const uint8 data[] = { 190,190,190, 180,180,180,
180,180,180, 190,190,190 };
myCheckerTex->setResolution(2,2);
myCheckerTex->setTexture(r, data);
myQuad->connectAllPrims(r,
CHECKER_CONNECT_GROUP,
}
else
pos = myQuad->getAttribute("P");
p(0).assign(-1, -1);
p(1).assign(-1, 1);
p(2).assign( 1, -1);
p(3).assign( 1, 1);
viewport().getViewStateRef().getViewParameterRef();
{
}
else
{
}
const int tex_bind = theBGShader->getUniformTextureUnit("checker");
theBGShader->bindFloat(r, RE_UniformNames::check_size, check_size);
myQuad->draw(r, CHECKER_CONNECT_GROUP);
return true;
}
void
DM_BackgroundRenderHook::viewportClosed()
{
delete myCheckerTex;
myCheckerTex = NULL;
delete myQuad;
myQuad = NULL;
}
void
{
}