2 * OpenGL ES 2.0 memory performance estimator
3 * Copyright (C) 2009 Nokia
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * \author Sami Kyöstilä <sami.kyostila@nokia.com>
21 * Framebuffer object blit test
23 #include "fboblittest.h"
27 FBOBlitTest::FBOBlitTest(GLenum format, GLenum type, int width, int height,
28 bool rotate, float texW, float texH, bool useDepth):
29 BlitTest(width, height, rotate, texW, texH),
37 void FBOBlitTest::prepare()
41 glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, m_format, m_type, NULL);
44 glGenRenderbuffers(1, &m_depthbuffer);
45 glBindRenderbuffer(GL_RENDERBUFFER, m_depthbuffer);
46 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, m_width, m_height);
49 glGenFramebuffers(1, &m_framebuffer);
50 glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
51 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0);
54 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
55 GL_RENDERBUFFER, m_depthbuffer);
59 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
60 assert(status == GL_FRAMEBUFFER_COMPLETE);
63 glGetIntegerv(GL_VIEWPORT, viewport);
64 glViewport(0, 0, m_width, m_height);
66 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
68 glBindFramebuffer(GL_FRAMEBUFFER, 0);
69 glBindRenderbuffer(GL_RENDERBUFFER, 0);
73 void FBOBlitTest::fillTexture()
76 glEnable(GL_SCISSOR_TEST);
77 for (i = 0; i < m_width; i++)
79 glScissor(i, 0, 1, m_height);
80 glClearColor(i / (float)m_width, 0.0f, 0.0f, 1.0f);
81 glClear(GL_COLOR_BUFFER_BIT);
83 glDisable(GL_SCISSOR_TEST);
86 void FBOBlitTest::teardown()
88 glDeleteFramebuffers(1, &m_framebuffer);
89 glDeleteRenderbuffers(1, &m_depthbuffer);
93 std::string FBOBlitTest::name() const
99 s << "blit_fbo_rot90_";
106 s << textureFormatName(m_format, m_type);
107 s << "_" << m_width << "x" << m_height;