+static int
+_create_rt_buffers(Render_Engine *data __UNUSED__,
+ Render_Engine_GL_Surface *sfc)
+{
+ int ret = 0;
+ GLuint fbo = 0, curr_fbo = 0;
+
+ //------------------------------------//
+ // Render Target texture
+ if (sfc->rt_fmt)
+ {
+ glGenTextures(1, &sfc->rt_tex);
+ }
+
+ // First check if packed buffer is to be used.
+ if (sfc->rb_depth_stencil_fmt)
+ {
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ glGenTextures(1, &sfc->rb_depth_stencil);
+#else
+ glGenRenderbuffers(1, &sfc->rb_depth_stencil);
+#endif
+ }
+ else
+ {
+ // Depth RenderBuffer - Create storage here...
+ if (sfc->rb_depth_fmt)
+ glGenRenderbuffers(1, &sfc->rb_depth);
+
+ // Stencil RenderBuffer - Create Storage here...
+ if (sfc->rb_stencil_fmt)
+ glGenRenderbuffers(1, &sfc->rb_stencil);
+ }
+ //------------------------------------//
+ // Try attaching the given configuration
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
+ glGenFramebuffers(1 ,&fbo);
+
+ ret = _attach_fbo_surface(NULL, sfc, fbo);
+
+ if (fbo) glDeleteFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, curr_fbo);
+
+ if (!ret)
+ {
+ if (sfc->rt_tex) glDeleteTextures(1, &sfc->rt_tex);
+ if (sfc->rb_depth) glDeleteRenderbuffers(1, &sfc->rb_depth);
+ if (sfc->rb_stencil) glDeleteRenderbuffers(1, &sfc->rb_stencil);
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ if (sfc->rb_depth_stencil) glDeleteTextures(1, &sfc->rb_depth_stencil);
+#else
+ if (sfc->rb_depth_stencil) glDeleteRenderbuffers(1, &sfc->rb_depth_stencil);
+#endif
+ ERR("_attach_fbo_surface() failed.");
+ return 0;
+ }
+ else
+ return 1;
+}
+