added convenience defaults and functions to glw.
This commit is contained in:
parent
80363d2ff0
commit
7a79c7c292
|
@ -37,6 +37,15 @@ class RenderTarget
|
|||
;
|
||||
}
|
||||
|
||||
RenderTarget(RenderableHandle & rTarget)
|
||||
: target (rTarget)
|
||||
, level (0)
|
||||
, layer (0)
|
||||
, face (GL_NONE)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void clear(void)
|
||||
{
|
||||
this->target.setNull();
|
||||
|
|
|
@ -42,6 +42,16 @@ class TextureSampleMode
|
|||
this->wrapT = GLW_DONT_CARE;
|
||||
this->wrapR = GLW_DONT_CARE;
|
||||
}
|
||||
|
||||
static TextureSampleMode dontCare(void)
|
||||
{
|
||||
return ThisType();
|
||||
}
|
||||
|
||||
static TextureSampleMode texelFetch(void)
|
||||
{
|
||||
return ThisType(GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
};
|
||||
|
||||
inline TextureSampleMode textureSampleMode(GLenum minFilter = GLW_DONT_CARE, GLenum magFilter = GLW_DONT_CARE, GLenum wrapS = GLW_DONT_CARE, GLenum wrapT = GLW_DONT_CARE, GLenum wrapR = GLW_DONT_CARE)
|
||||
|
|
|
@ -210,6 +210,38 @@ inline Texture2DHandle createTexture2D(Context & ctx, GLenum format, GLsizei wid
|
|||
return ctx.createTexture2D(args);
|
||||
}
|
||||
|
||||
inline FramebufferHandle createFramebufferWithDepthStencil
|
||||
(
|
||||
Context & ctx,
|
||||
const RenderTarget & depthTarget,
|
||||
const RenderTarget & stencilTarget,
|
||||
const RenderTarget & colorTarget0 = RenderTarget(),
|
||||
const RenderTarget & colorTarget1 = RenderTarget(),
|
||||
const RenderTarget & colorTarget2 = RenderTarget(),
|
||||
const RenderTarget & colorTarget3 = RenderTarget(),
|
||||
const RenderTarget & colorTarget4 = RenderTarget(),
|
||||
const RenderTarget & colorTarget5 = RenderTarget(),
|
||||
const RenderTarget & colorTarget6 = RenderTarget(),
|
||||
const RenderTarget & colorTarget7 = RenderTarget()
|
||||
)
|
||||
{
|
||||
FramebufferArguments args;
|
||||
|
||||
args.depthTarget = depthTarget;
|
||||
args.stencilTarget = stencilTarget;
|
||||
|
||||
if (colorTarget0.target) { args.colorTargets[0] = colorTarget0; args.targetInputs[0] = 0; }
|
||||
if (colorTarget1.target) { args.colorTargets[1] = colorTarget1; args.targetInputs[1] = 1; }
|
||||
if (colorTarget2.target) { args.colorTargets[2] = colorTarget2; args.targetInputs[2] = 2; }
|
||||
if (colorTarget3.target) { args.colorTargets[3] = colorTarget3; args.targetInputs[3] = 3; }
|
||||
if (colorTarget4.target) { args.colorTargets[4] = colorTarget4; args.targetInputs[4] = 4; }
|
||||
if (colorTarget5.target) { args.colorTargets[5] = colorTarget5; args.targetInputs[5] = 5; }
|
||||
if (colorTarget6.target) { args.colorTargets[6] = colorTarget6; args.targetInputs[6] = 6; }
|
||||
if (colorTarget7.target) { args.colorTargets[7] = colorTarget7; args.targetInputs[7] = 7; }
|
||||
|
||||
return ctx.createFramebuffer(args);
|
||||
}
|
||||
|
||||
inline FramebufferHandle createFramebuffer
|
||||
(
|
||||
Context & ctx,
|
||||
|
@ -224,20 +256,8 @@ inline FramebufferHandle createFramebuffer
|
|||
const RenderTarget & colorTarget7 = RenderTarget()
|
||||
)
|
||||
{
|
||||
FramebufferArguments args;
|
||||
|
||||
args.depthTarget = depthTarget;
|
||||
|
||||
if (colorTarget0.target) { args.colorTargets[0] = colorTarget0; args.targetInputs[0] = 0; }
|
||||
if (colorTarget1.target) { args.colorTargets[1] = colorTarget1; args.targetInputs[1] = 1; }
|
||||
if (colorTarget2.target) { args.colorTargets[2] = colorTarget2; args.targetInputs[2] = 2; }
|
||||
if (colorTarget3.target) { args.colorTargets[3] = colorTarget3; args.targetInputs[3] = 3; }
|
||||
if (colorTarget4.target) { args.colorTargets[4] = colorTarget4; args.targetInputs[4] = 4; }
|
||||
if (colorTarget5.target) { args.colorTargets[5] = colorTarget5; args.targetInputs[5] = 5; }
|
||||
if (colorTarget6.target) { args.colorTargets[6] = colorTarget6; args.targetInputs[6] = 6; }
|
||||
if (colorTarget7.target) { args.colorTargets[7] = colorTarget7; args.targetInputs[7] = 7; }
|
||||
|
||||
return ctx.createFramebuffer(args);
|
||||
RenderTarget nullTarget;
|
||||
return createFramebufferWithDepthStencil(ctx, depthTarget, nullTarget, colorTarget0, colorTarget1, colorTarget2, colorTarget3, colorTarget4, colorTarget5, colorTarget6, colorTarget7);
|
||||
}
|
||||
|
||||
inline ProgramHandle createProgram(Context & ctx, const std::string & srcPrefix, const std::string & vertexSrc, const std::string & geometrySrc, const std::string & fragmentSrc, const ProgramArguments & args = ProgramArguments())
|
||||
|
|
Loading…
Reference in New Issue