Last active
August 29, 2015 14:07
-
-
Save t-takasaka/1f986578ed63e6055d2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Model::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags){ | |
double t = (live2d::UtSystem::getUserTimeMSec()/1000.0) * 2 * M_PI ; | |
m_live2DModel->setParamFloat("PARAM_ANGLE_X", (float)(30 * sin( t/3.0 )) ); | |
cocos2d::Sprite *sprite = m_redderTexture->getSprite(); | |
GLint oldFBO; | |
GLuint frame_buffer = 0; | |
GLuint color_buffer = sprite->getTexture()->getName(); | |
glGenFramebuffers(1, &frame_buffer); | |
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO); | |
glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer); | |
glBindTexture(GL_TEXTURE_2D, color_buffer); | |
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_buffer, 0); | |
glClearColor(255, 255, 255, 0); | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); | |
if(status != GL_FRAMEBUFFER_COMPLETE){} //エラー処理 | |
live2d::DrawProfileCocos2D::preDraw(); | |
m_live2DModel->update(); | |
m_live2DModel->draw(); | |
live2d::DrawProfileCocos2D::postDraw() ; | |
glBindTexture(GL_TEXTURE_2D, 0); | |
glBindFramebuffer(GL_FRAMEBUFFER, oldFBO); | |
glDeleteFramebuffers(1, &frame_buffer); | |
sprite->draw(renderer, transform, flags); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment