|
@@ -81,13 +81,13 @@ namespace oxygine
|
|
|
if (!_rt)
|
|
if (!_rt)
|
|
|
{
|
|
{
|
|
|
_rt = IVideoDriver::instance->createTexture();
|
|
_rt = IVideoDriver::instance->createTexture();
|
|
|
- _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
|
|
|
|
|
|
|
+ _rt->init(_screen.getWidth(), _screen.getHeight(), _format, true);
|
|
|
c = true;
|
|
c = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (_rt->getWidth() < _screen.getWidth() || _rt->getHeight() < _screen.getHeight())
|
|
if (_rt->getWidth() < _screen.getWidth() || _rt->getHeight() < _screen.getHeight())
|
|
|
{
|
|
{
|
|
|
- _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
|
|
|
|
|
|
|
+ _rt->init(_screen.getWidth(), _screen.getHeight(), _format, true);
|
|
|
c = true;
|
|
c = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -140,6 +140,7 @@ namespace oxygine
|
|
|
mat->Material::render(_actor, rs);
|
|
mat->Material::render(_actor, rs);
|
|
|
|
|
|
|
|
mat->finish();
|
|
mat->finish();
|
|
|
|
|
+ log::messageln("render actor to texture");
|
|
|
//driver->setRenderTarget(0);
|
|
//driver->setRenderTarget(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -192,11 +193,39 @@ namespace oxygine
|
|
|
ShaderProgram* TweenGlow::shaderBlit = 0;
|
|
ShaderProgram* TweenGlow::shaderBlit = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ void pass(spNativeTexture srcTexture, const Rect& srcRect, spNativeTexture destTexture, const Rect& destRect)
|
|
|
|
|
+ {
|
|
|
|
|
+ IVideoDriver* driver = IVideoDriver::instance;
|
|
|
|
|
+
|
|
|
|
|
+ const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(driver->getVertexDeclaration(vertexPCT2::FORMAT));
|
|
|
|
|
+ driver->setRenderTarget(destTexture);
|
|
|
|
|
+ driver->clear(0);
|
|
|
|
|
+
|
|
|
|
|
+ driver->setViewport(destRect);
|
|
|
|
|
+
|
|
|
|
|
+ driver->setTexture(0, srcTexture);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ vertexPCT2 v[4];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ RectF dst = srcRect.cast<RectF>() / Vector2(srcTexture->getWidth(), srcTexture->getHeight());
|
|
|
|
|
+ fillQuadT(v,
|
|
|
|
|
+ dst,
|
|
|
|
|
+ RectF(-1, -1, 2, 2),
|
|
|
|
|
+ AffineTransform::getIdentity(), 0);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
|
|
|
|
|
+ driver->setTexture(0, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
void TweenGlow::render2texture()
|
|
void TweenGlow::render2texture()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
- GLint prevFBO = 0;
|
|
|
|
|
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFBO);
|
|
|
|
|
|
|
+ IVideoDriver* driver = IVideoDriver::instance;
|
|
|
|
|
+
|
|
|
|
|
+ spNativeTexture prevRT = driver->getRenderTarget();
|
|
|
|
|
|
|
|
TweenPostProcess::render2texture();
|
|
TweenPostProcess::render2texture();
|
|
|
const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(IVideoDriver::instance->getVertexDeclaration(vertexPCT2::FORMAT));
|
|
const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(IVideoDriver::instance->getVertexDeclaration(vertexPCT2::FORMAT));
|
|
@@ -221,8 +250,12 @@ namespace oxygine
|
|
|
|
|
|
|
|
|
|
|
|
|
shaderBlurV = new ShaderProgramGL(ShaderProgramGL::createProgram(v, ps, decl));
|
|
shaderBlurV = new ShaderProgramGL(ShaderProgramGL::createProgram(v, ps, decl));
|
|
|
- shaderBlurH = new ShaderProgramGL(ShaderProgramGL::createProgram(h, ps, decl));
|
|
|
|
|
|
|
+ driver->setShaderProgram(shaderBlurV);
|
|
|
|
|
+ driver->setUniformInt("s_texture", 0);
|
|
|
|
|
|
|
|
|
|
+ shaderBlurH = new ShaderProgramGL(ShaderProgramGL::createProgram(h, ps, decl));
|
|
|
|
|
+ driver->setShaderProgram(shaderBlurH);
|
|
|
|
|
+ driver->setUniformInt("s_texture", 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
file::buffer vs_blit;
|
|
file::buffer vs_blit;
|
|
@@ -238,111 +271,45 @@ namespace oxygine
|
|
|
unsigned int fs = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, (const char*)&fs_blit.front(), "", "");
|
|
unsigned int fs = ShaderProgramGL::createShader(GL_FRAGMENT_SHADER, (const char*)&fs_blit.front(), "", "");
|
|
|
|
|
|
|
|
shaderBlit = new ShaderProgramGL(ShaderProgramGL::createProgram(vs, fs, decl));
|
|
shaderBlit = new ShaderProgramGL(ShaderProgramGL::createProgram(vs, fs, decl));
|
|
|
|
|
+ driver->setShaderProgram(shaderBlit);
|
|
|
|
|
+ driver->setUniformInt("s_texture", 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- Rect vp = _screen;
|
|
|
|
|
- vp.pos = Point(0, 0);
|
|
|
|
|
-
|
|
|
|
|
- vertexPCT2 v[4];
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
int w = _screen.size.x;
|
|
int w = _screen.size.x;
|
|
|
int h = _screen.size.y;
|
|
int h = _screen.size.y;
|
|
|
|
|
|
|
|
- IVideoDriver* driver = IVideoDriver::instance;
|
|
|
|
|
|
|
|
|
|
driver->setState(IVideoDriver::STATE_BLEND, 0);
|
|
driver->setState(IVideoDriver::STATE_BLEND, 0);
|
|
|
- /*
|
|
|
|
|
|
|
|
|
|
- oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt2.get())->getFboID());
|
|
|
|
|
- driver->clear(0);
|
|
|
|
|
- driver->setViewport(Rect(0, 0, w / 2, h / 2));
|
|
|
|
|
|
|
+ /*
|
|
|
driver->setShaderProgram(shaderBlit);
|
|
driver->setShaderProgram(shaderBlit);
|
|
|
- driver->setUniformInt("s_texture", 0);
|
|
|
|
|
- driver->setTexture(0, _rt);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- fillQuadT(v,
|
|
|
|
|
- RectF(0, 0, w / (float)_rt->getWidth(), h / (float)_rt->getHeight()),
|
|
|
|
|
- RectF(-1, -1, 2, 2),
|
|
|
|
|
- AffineTransform::getIdentity(), 0);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ pass(_rt, Rect(0, 0, w, h), _rt2, Rect(0, 0, w / 2, h / 2));
|
|
|
|
|
|
|
|
- driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
|
|
|
|
|
- driver->setTexture(0, 0);
|
|
|
|
|
w /= 2;
|
|
w /= 2;
|
|
|
h /= 2;
|
|
h /= 2;
|
|
|
|
|
+ pass(_rt2, Rect(0, 0, w, h), _rt, Rect(0, 0, w / 2, h / 2));
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt.get())->getFboID());
|
|
|
|
|
- driver->clear(0);
|
|
|
|
|
- driver->setViewport(Rect(0, 0, w / 2, h / 2));
|
|
|
|
|
- driver->setShaderProgram(shaderBlit);
|
|
|
|
|
- driver->setUniformInt("s_texture", 0);
|
|
|
|
|
- driver->setTexture(0, _rt2);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- fillQuadT(v,
|
|
|
|
|
- RectF(0, 0, w / (float)_rt2->getWidth(), h / (float)_rt2->getHeight()),
|
|
|
|
|
- RectF(-1, -1, 2, 2),
|
|
|
|
|
- AffineTransform::getIdentity(), 0);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
|
|
|
|
|
- driver->setTexture(0, 0);
|
|
|
|
|
w /= 2;
|
|
w /= 2;
|
|
|
h /= 2;
|
|
h /= 2;
|
|
|
-
|
|
|
|
|
|
|
+ _downsample = 4;
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
- oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt2.get())->getFboID());
|
|
|
|
|
- driver->clear(0);
|
|
|
|
|
|
|
+ Rect rc(0, 0, w, h);
|
|
|
|
|
|
|
|
- driver->setViewport(Rect(0, 0, w, h));
|
|
|
|
|
driver->setShaderProgram(shaderBlurH);
|
|
driver->setShaderProgram(shaderBlurH);
|
|
|
driver->setUniform("step", 1.0f / _rt->getWidth());
|
|
driver->setUniform("step", 1.0f / _rt->getWidth());
|
|
|
- driver->setUniformInt("s_texture", 0);
|
|
|
|
|
- driver->setTexture(0, _rt);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ pass(_rt, rc, _rt2, rc);
|
|
|
|
|
|
|
|
- fillQuadT(v,
|
|
|
|
|
- RectF(0, 0, w / (float)_rt->getWidth(), h / (float)_rt->getHeight()),
|
|
|
|
|
- RectF(-1, -1, 2, 2),
|
|
|
|
|
- AffineTransform::getIdentity(), 0);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
|
|
|
|
|
- driver->setTexture(0, 0);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt.get())->getFboID());
|
|
|
|
|
- driver->clear(0);
|
|
|
|
|
|
|
|
|
|
- driver->setViewport(Rect(0, 0, w, h));
|
|
|
|
|
driver->setShaderProgram(shaderBlurV);
|
|
driver->setShaderProgram(shaderBlurV);
|
|
|
driver->setUniform("step", 1.0f / _rt2->getHeight());
|
|
driver->setUniform("step", 1.0f / _rt2->getHeight());
|
|
|
- driver->setUniformInt("s_texture", 0);
|
|
|
|
|
- driver->setTexture(0, _rt2);
|
|
|
|
|
-
|
|
|
|
|
- fillQuadT(v,
|
|
|
|
|
- RectF(0, 0, w / (float)_rt2->getWidth(), h / (float)_rt2->getHeight()),
|
|
|
|
|
- RectF(-1, -1, 2, 2),
|
|
|
|
|
- AffineTransform::getIdentity(), 0);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
|
|
|
|
|
- driver->setTexture(0, 0);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ pass(_rt2, rc, _rt, rc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- oxglBindFramebuffer(GL_FRAMEBUFFER, prevFBO);
|
|
|
|
|
|
|
+ driver->setRenderTarget(prevRT);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void TweenGlow::rtCreated()
|
|
void TweenGlow::rtCreated()
|
|
@@ -350,6 +317,6 @@ namespace oxygine
|
|
|
TweenPostProcess::rtCreated();
|
|
TweenPostProcess::rtCreated();
|
|
|
_rt2 = IVideoDriver::instance->createTexture();
|
|
_rt2 = IVideoDriver::instance->createTexture();
|
|
|
//_rt2->init(_screen.getWidth() / 2, _screen.getHeight() / 2, TF_R8G8B8A8, true);
|
|
//_rt2->init(_screen.getWidth() / 2, _screen.getHeight() / 2, TF_R8G8B8A8, true);
|
|
|
- _rt2->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
|
|
|
|
|
|
|
+ _rt2->init(_screen.getWidth(), _screen.getHeight(), _format, true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|