47 m_num_color_attach_points = 0;
48 m_has_depth_buffer = m_has_stencil_buffer =
false;
61 glGenFramebuffersEXT(1, &m_fbo);
62 m_num_color_attach_points = 0;
63 m_has_depth_buffer = m_has_stencil_buffer =
false;
66 InitAttachPointsArray();
72 if (m_has_depth_buffer && m_has_stencil_buffer)
74 glDeleteTextures(1, &m_DepthStencilTex);
75 m_has_depth_buffer =
false;
76 m_has_stencil_buffer =
false;
80 glDeleteFramebuffersEXT(1, &m_fbo);
89 if (!m_has_depth_buffer && !m_has_stencil_buffer && (0 < m_width) && (0 < m_height))
91 glGenTextures(1, &m_DepthStencilTex);
92 glBindTexture(GL_TEXTURE_2D, m_DepthStencilTex);
93 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
94 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_EXT,
95 m_width, m_height, 0, GL_DEPTH_STENCIL_EXT,
96 GL_UNSIGNED_INT_24_8_EXT, NULL);
100 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
101 GL_DEPTH_ATTACHMENT_EXT,
102 GL_TEXTURE_2D, m_DepthStencilTex, 0);
106 m_has_depth_buffer =
true;
107 m_has_stencil_buffer =
true;
127 if (p_attach_point < m_num_color_attach_points)
133 if (p_attach_point < m_num_color_attach_points)
140 if (i == -1)
AttachTexture(p_width, p_height, p_param, p_glid, p_attach_point);
141 else p_attach_point = (
MOuint)i;
148 if (i == -1)
AttachTexture(p_width, p_height, p_param, p_glid, p_attach_point);
149 else p_attach_point = (
MOuint)i;
155 if (p_attach_point < m_num_color_attach_points)
156 return m_attach_points_array[p_attach_point];
162 if (p_attach_point < m_num_color_attach_points)
163 return m_tex_glid_array[p_attach_point];
169 for (
MOuint i = 0; i < m_num_color_attach_points; i++)
170 if (m_tex_glid_array[i] == p_glid)
return i;
180 if (m_num_color_attach_points == 0)
182 m_target = p_param.
target;
191 (m_width == p_width) && (m_height == p_height);
201 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
202 m_attach_points_array[m_num_color_attach_points],
203 m_target, p_glid, 0);
207 if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
209 m_tex_glid_array[m_num_color_attach_points] = p_glid;
210 p_attach_point = m_num_color_attach_points;
211 m_num_color_attach_points++;
224 if (m_num_color_attach_points == 0)
226 m_target = p_param.
target;
235 (m_width == p_width) && (m_height == p_height);
245 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
246 m_attach_points_array[p_attach_point],
247 m_target, p_glid, 0);
251 if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
253 m_tex_glid_array[p_attach_point] = p_glid;
262 if (m_num_color_attach_points > 0)
265 for (
MOuint i = 0; i < m_num_color_attach_points; i++)
266 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
267 m_attach_points_array[i],
277 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
280 case GL_FRAMEBUFFER_COMPLETE_EXT:
283 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
284 if (
MODebug2 != NULL)
MODebug2->
Error(
"moFBO::CheckStatus > GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT");
286 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
287 if (
MODebug2 != NULL)
MODebug2->
Error(
"moFBO::CheckStatus > GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT");
292 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
293 if (
MODebug2 != NULL)
MODebug2->
Error(
"moFBO::CheckStatus > GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT");
296 case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
299 case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
300 if (
MODebug2 != NULL)
MODebug2->
Error(
"moFBO::CheckStatus > GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT");
302 case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
303 if (
MODebug2 != NULL)
MODebug2->
Error(
"moFBO::CheckStatus > GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT");
306 case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
318 if (m_num_color_attach_points == 0)
return true;
321 (m_width == p_width) && (m_height == p_height);
324 void moFBO::InitAttachPointsArray()
327 m_attach_points_array[i] = GL_COLOR_ATTACHMENT0_EXT + i;
Parámetros internos de una textura.
void Error(moText p_text)
Anuncia y registra un error.
MOint GetColorAttachPointIndex(MOuint p_glid)
MOuint AttachTexture(MOuint p_width, MOuint p_height, const moTexParam &p_param, MOuint p_glid, MOuint p_attach_point)
virtual MOboolean Init()
Inicializa el objeto.
void SetDrawTexture(MOuint p_attach_point)
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
void SetCurrentDrawBuffer(MOint p_buffer)
void SetCurrentReadBuffer(MOint p_buffer)
MOuint AddTexture(MOuint p_width, MOuint p_height, const moTexParam &p_param, MOuint p_glid, MOuint &p_attach_point)
#define MO_MAX_COLOR_ATTACHMENTS_EXT
void SetCurrentFBO(MOuint m_fbo)
MOboolean IsValidTexture(MOuint p_width, MOuint p_height, const moTexParam &p_param) const
#define MO_FRAMEBUFFER_INVALID_TEX
MOboolean AddDepthStencilBuffer()
virtual MOboolean Finish()
MOint GetTextureGLId(MOuint p_attach_point)
MOuint CheckStatus() const
MOint GetColorAttachPoint(MOuint p_attach_point)
manejador de operaciones comunes de Open GL
static moDebug * MODebug2
Clase de impresión de errores para depuración
#define MO_FRAMEBUFFER_FULL
void SetReadTexture(MOuint p_attach_point)
moDefineDynamicArray(moFBOArray) moFBO