void drawTargetToScreen() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, double(window_->getWidth() * 2), 0.0, double(window_->getHeight() * 2), -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, targetTexture_->getName()); glColor3ub(255, 255, 255); glBegin(GL_QUADS); { glTexCoord2i(0, 0); glVertex2i(0, 0); glTexCoord2i(1, 0); glVertex2i(window_->getWidth() * 2, 0); glTexCoord2i(1, 1); glVertex2i(window_->getWidth() * 2, window_->getHeight() * 2); glTexCoord2i(0, 1); glVertex2i(0, window_->getHeight() * 2); } glEnd(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); }
void drawSceneToTarget() { if (!targetTexture_ || targetTexture_->getWidth() != 2 * window_->getWidth() || targetTexture_->getHeight() != 2 * window_->getHeight()) { targetTexture_ = window_->getContext()->createTexture(); targetTexture_->setSize(2 * window_->getWidth(), 2 * window_->getHeight()); targetTexture_->setMinFilter(GL_LINEAR); targetTexture_->setMagFilter(GL_LINEAR); targetFrameBuffer_ = window_->getContext()->createFrameBuffer(); targetFrameBuffer_->setColorAttachment(targetTexture_); } targetFrameBuffer_->create(); glViewport(0, 0, window_->getWidth() * 2, window_->getHeight() * 2); glBindFramebuffer(GL_FRAMEBUFFER, targetFrameBuffer_->getName()); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); drawScene(); glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, window_->getWidth(), window_->getHeight()); }
void drawLogoToTarget() { logoTexture_->create(); targetFrameBuffer_->create(); glViewport(0, 0, targetTexture_->getWidth(), targetTexture_->getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float aspectRatio = (float(logoTexture_->getWidth()) / float(logoTexture_->getHeight())); float scale = 0.2f; glBindFramebuffer(GL_FRAMEBUFFER, targetFrameBuffer_->getName()); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, logoTexture_->getName()); glPushMatrix(); glRotatef(angle_, 0.0f, 0.0f, 1.0f); glColor3f(1.0f, 0.8f, 0.2f); glBegin(GL_QUADS); { glTexCoord2i(0, 0); glVertex2f(-scale * aspectRatio, -scale); glTexCoord2i(1, 0); glVertex2f(scale * aspectRatio, -scale); glTexCoord2i(1, 1); glVertex2f(scale * aspectRatio, scale); glTexCoord2i(0, 1); glVertex2f(-scale * aspectRatio, scale); } glEnd(); glPopMatrix(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); glBindFramebuffer(GL_FRAMEBUFFER, 0); }
void drawTargetToScreen() { float aspectRatio = (float(window_->getWidth()) / float(window_->getHeight())); float scale = 1.5f; glViewport(0, 0, window_->getWidth(), window_->getHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-aspectRatio, aspectRatio, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, targetTexture_->getName()); glPushMatrix(); glRotatef(-angle_, 0.0f, 0.0f, 1.0f); glBegin(GL_QUADS); { glTexCoord2i(0, 0); glVertex2f(-scale, -scale); glTexCoord2i(1, 0); glVertex2f(scale, -scale); glTexCoord2i(1, 1); glVertex2f(scale, scale); glTexCoord2i(0, 1); glVertex2f(-scale, scale); } glEnd(); glPopMatrix(); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); }