added convenience defaults and functions to glw.

This commit is contained in:
Marco Di Benedetto 2012-05-23 18:02:22 +00:00
parent 80363d2ff0
commit 7a79c7c292
3 changed files with 42 additions and 3 deletions

View File

@ -37,6 +37,15 @@ class RenderTarget
;
}
RenderTarget(RenderableHandle & rTarget)
: target (rTarget)
, level (0)
, layer (0)
, face (GL_NONE)
{
;
}
void clear(void)
{
this->target.setNull();

View File

@ -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)

View File

@ -210,10 +210,11 @@ inline Texture2DHandle createTexture2D(Context & ctx, GLenum format, GLsizei wid
return ctx.createTexture2D(args);
}
inline FramebufferHandle createFramebuffer
inline FramebufferHandle createFramebufferWithDepthStencil
(
Context & ctx,
const RenderTarget & depthTarget ,
const RenderTarget & depthTarget,
const RenderTarget & stencilTarget,
const RenderTarget & colorTarget0 = RenderTarget(),
const RenderTarget & colorTarget1 = RenderTarget(),
const RenderTarget & colorTarget2 = RenderTarget(),
@ -226,7 +227,8 @@ inline FramebufferHandle createFramebuffer
{
FramebufferArguments args;
args.depthTarget = depthTarget;
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; }
@ -240,6 +242,24 @@ inline FramebufferHandle createFramebuffer
return ctx.createFramebuffer(args);
}
inline FramebufferHandle createFramebuffer
(
Context & ctx,
const RenderTarget & depthTarget,
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()
)
{
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())
{
ProgramArguments pArgs = args;