Skip to content

Commit

Permalink
Uses uniform instead of attribute in PassThrough.vs
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Aug 22, 2013
1 parent 79ab1ad commit fbf864d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Resources/Shaders/PostFilters/PassThrough.vs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


attribute vec2 positionAttribute;
attribute vec4 colorAttribute;
uniform vec4 colorUniform;

uniform vec4 texCoordRange;

Expand All @@ -16,7 +16,7 @@ void main() {

gl_Position = vec4(scrPos, 0.5, 1.);

color = colorAttribute;
color = colorUniform;
texCoord = pos * texCoordRange.zw + texCoordRange.xy;
}

6 changes: 3 additions & 3 deletions Sources/Draw/GLBloomFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace spades {

GLProgram *thru = renderer->RegisterProgram("Shaders/PostFilters/PassThrough.program");
static GLProgramAttribute thruPosition("positionAttribute");
static GLProgramAttribute thruColor("colorAttribute");
static GLProgramUniform thruColor("colorUniform");
static GLProgramUniform thruTexture("texture");
static GLProgramUniform thruTexCoordRange("texCoordRange");

Expand All @@ -66,7 +66,7 @@ namespace spades {
gammaMixMix2(gammaMix);

thru->Use();
dev->VertexAttrib(thruColor(), 1, 1, 1, 1);
thruColor.SetValue(1.f, 1.f, 1.f, 1.f);
thruTexture.SetValue(0);
dev->Enable(IGLDevice::Blend, false);

Expand Down Expand Up @@ -120,7 +120,7 @@ namespace spades {
dev->BindTexture(IGLDevice::Texture2D, curLevel.GetTexture());
dev->BindFramebuffer(IGLDevice::Framebuffer, targLevel.GetFramebuffer());
dev->Viewport(0, 0, targLevel.GetWidth(), targLevel.GetHeight());
dev->VertexAttrib(thruColor(), 1, 1, 1, alpha);
thruColor.SetValue(1.f, 1.f, 1.f, alpha);
qr.Draw();
dev->BindTexture(IGLDevice::Texture2D, 0);
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Draw/GLSoftSpriteRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,20 @@ namespace spades {
// composite
program = renderer->RegisterProgram("Shaders/PostFilters/PassThrough.program");
static GLProgramAttribute positionAttribute("positionAttribute");
static GLProgramAttribute colorAttribute("colorAttribute");
static GLProgramUniform colorUniform("colorUniform");
static GLProgramUniform textureUniform("texture");
static GLProgramUniform texCoordRange("texCoordRange");

positionAttribute(program);
textureUniform(program);
texCoordRange(program);
colorAttribute(program);
colorUniform(program);

program->Use();

textureUniform.SetValue(0);
texCoordRange.SetValue(0.f, 0.f, 1.f, 1.f);
device->VertexAttrib(colorAttribute(), 1.f, 1.f, 1.f, 1.f);
colorUniform.SetValue(1.f, 1.f, 1.f, 1.f);

qr.SetCoordAttributeIndex(positionAttribute());
device->BindFramebuffer(IGLDevice::Framebuffer, lastFb);
Expand Down

0 comments on commit fbf864d

Please sign in to comment.