| 128 | } |
| 129 | |
| 130 | bool ccFrameBufferObject::initColor(GLint internalformat/*=GL_RGBA*/, |
| 131 | GLenum format/*=GL_RGBA*/, |
| 132 | GLenum type/*=GL_UNSIGNED_BYTE*/, |
| 133 | GLint minMagFilter/*=GL_NEAREST*/, |
| 134 | GLenum target/*=GL_TEXTURE_2D*/) |
| 135 | { |
| 136 | if (!m_isValid || m_fboId == 0) |
| 137 | { |
| 138 | assert(false); |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | //create the new texture |
| 143 | m_glFunc.glPushAttrib(GL_ENABLE_BIT); |
| 144 | m_glFunc.glEnable(GL_TEXTURE_2D); |
| 145 | |
| 146 | GLuint texID = 0; |
| 147 | m_glFunc.glGenTextures(1, &texID); |
| 148 | m_glFunc.glBindTexture(target, texID); |
| 149 | m_glFunc.glTexParameteri(target, GL_TEXTURE_MAG_FILTER, minMagFilter); |
| 150 | m_glFunc.glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minMagFilter); |
| 151 | m_glFunc.glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 152 | m_glFunc.glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 153 | m_glFunc.glTexImage2D(target, 0, internalformat, m_width, m_height, 0, format, type, nullptr); |
| 154 | m_glFunc.glBindTexture(target, 0); |
| 155 | |
| 156 | m_glFunc.glPopAttrib(); |
| 157 | |
| 158 | if (attachColor(texID, true, target)) |
| 159 | { |
| 160 | return true; |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | m_glFunc.glDeleteTextures(1, &texID); |
| 165 | return false; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | bool ccFrameBufferObject::attachColor( GLuint texID, |
| 170 | bool ownTexture/*=false*/, |
no outgoing calls
no test coverage detected