Max 5 API Reference
00001 #ifndef JIT_GL_FBO_H 00002 #define JIT_GL_FBO_H 00003 00004 /* 00005 * Copyright 2001-2005 - Cycling '74 00006 * Derek Gerstmann - derek@cycling74.com 00007 * 00008 * Struct and associated methods for maintaining an offscreen OpenGL 00009 * framebuffer object (fbo) with multiple attached image buffers 00010 * (either textures or renderbuffers). 00011 * 00012 */ 00013 00014 /****************************************************************************/ 00015 00016 #include "jit.gl.h" 00017 #include "jit.gl.renderbuffer.h" 00018 #include "jit.common.h" 00019 00020 /****************************************************************************/ 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 #if C74_PRAGMA_STRUCT_PACKPUSH 00027 #pragma pack(push, 2) 00028 #elif C74_PRAGMA_STRUCT_PACK 00029 #pragma pack(2) 00030 #endif 00031 00032 /****************************************************************************/ 00033 00034 /* 00035 * As of Aug 2005, FBO EXT supports 16 color + 1 depth + 1 stencil. We use 00036 * 64 as the maximum to allow the enumerated types for the attachments to 00037 * be converted into an index for the FBO attached array, thus insuring that 00038 * we only maintain a single buffer per attachment slot. 00039 */ 00040 #define JIT_GL_FBO_MAX_ATTACHMENTS (65) 00041 #define JIT_GL_FBO_MAX_COLOR_ATTACHMENTS (16) 00042 00043 /****************************************************************************/ 00044 00045 typedef struct _jit_gl_fbo_attachment 00046 { 00047 GLenum type; // attachment type (GL_COLOR_ATTACHMENT#_EXT, etc) 00048 GLenum target; // attachment target for textures (GL_TEXTURE_1D/2D/3D/RECTANGLE/CUBE_MAP, etc) 00049 GLint miplevel; // mipmap level 00050 GLint zslice; // z-slice for 3D targets 00051 GLint id; // attachment id 00052 } t_jit_gl_fbo_attachment; 00053 00054 typedef struct _jit_gl_fbo 00055 { 00056 00057 t_jit_object jitob; // fbo object 00058 void *ob3d; // object 3d 00059 t_symbol *depthtex; // depth texture name 00060 t_jit_gl_fbo_attachment *attached[JIT_GL_FBO_MAX_ATTACHMENTS]; // attachments 00061 t_jit_gl_renderbuffer *renderbuffers[JIT_GL_FBO_MAX_ATTACHMENTS]; // attachments 00062 GLuint attachedcount; // attachment count 00063 GLuint previous; // saved fbo id 00064 GLuint id; // fbo id 00065 GLint depth; // size of depth buffer 00066 GLint stencil; // stencil buffer flag (on/off) 00067 00068 t_symbol *color_attachment[JIT_GL_FBO_MAX_COLOR_ATTACHMENTS]; //color attachments (named textures) 00069 } t_jit_gl_fbo; 00070 00071 /****************************************************************************/ 00072 00073 // creation / deletion 00074 t_jit_gl_fbo_attachment *jit_gl_fbo_attachment_new(void); 00075 void jit_gl_fbo_attachment_free(t_jit_gl_fbo_attachment *x); 00076 00077 // reset / destroy 00078 t_jit_err jit_gl_fbo_attachment_reset(t_jit_gl_fbo_attachment *x); 00079 t_jit_err jit_gl_fbo_attachment_destroy(t_jit_gl_fbo_attachment *x); 00080 00081 /****************************************************************************/ 00082 00083 // creation / deletion 00084 t_jit_err jit_gl_fbo_init(void); 00085 t_jit_gl_fbo * jit_gl_fbo_new(t_symbol * dest_name); 00086 void jit_gl_fbo_free(t_jit_gl_fbo *x); 00087 00088 //ob3d methods 00089 t_jit_err jit_gl_fbo_draw(t_jit_gl_fbo *x); 00090 t_jit_err jit_gl_fbo_dest_changed(t_jit_gl_fbo *x); 00091 t_jit_err jit_gl_fbo_dest_closing(t_jit_gl_fbo *x); 00092 00093 //attr methods 00094 t_jit_err jit_gl_fbo_setattr_color_attachment(t_jit_gl_fbo *x, void *attr, long argc, t_atom *argv); 00095 00096 // usage methods 00097 t_jit_err jit_gl_fbo_create(t_jit_gl_fbo *x); 00098 t_jit_err jit_gl_fbo_attach_depthtex(t_jit_gl_fbo *x, void *attr, long argc, t_atom *argv); 00099 t_jit_err jit_gl_fbo_attach_tex_image(t_jit_gl_fbo *x, t_symbol *texname, GLenum attachment, t_symbol **attachment_name); 00100 t_jit_err jit_gl_fbo_attach_depth_image(t_jit_gl_fbo *x, void *attr, long argc, t_atom *argv); 00101 t_jit_err jit_gl_fbo_attach_stencil_image(t_jit_gl_fbo *x, void *attr, long argc, t_atom *argv); 00102 t_jit_err jit_gl_fbo_attach_texture(t_jit_gl_fbo *x, GLenum attachment, GLenum target, GLuint id, GLint miplevel, GLint zslice); 00103 t_jit_err jit_gl_fbo_attach_renderbuffer(t_jit_gl_fbo *x, GLenum attachment, GLuint id); 00104 t_jit_err jit_gl_fbo_detach(t_jit_gl_fbo *x, GLenum attachment); 00105 t_jit_err jit_gl_fbo_update_attached(t_jit_gl_fbo *x); 00106 t_jit_err jit_gl_fbo_update_attachment(t_jit_gl_fbo *x, GLenum attachment); 00107 t_jit_err jit_gl_fbo_bind(t_jit_gl_fbo *x); 00108 t_jit_err jit_gl_fbo_unbind(t_jit_gl_fbo *x); 00109 t_jit_err jit_gl_fbo_disable(t_jit_gl_fbo *x); 00110 t_jit_err jit_gl_fbo_destroy(t_jit_gl_fbo *x); 00111 t_jit_err jit_gl_fbo_reset(t_jit_gl_fbo *x); 00112 00113 // system query methods across all framebuffer object instances 00114 t_jit_err jit_gl_fbo_verify_support(t_jit_gl_fbo *x); 00115 t_jit_err jit_gl_fbo_report_error(t_jit_gl_fbo *x, const char *prefix); 00116 t_jit_err jit_gl_fbo_query_max_color_attachments(t_jit_gl_fbo *x, GLint *value); 00117 t_jit_err jit_gl_fbo_query_attached_type(t_jit_gl_fbo *x, GLenum attachment, GLenum *value ); 00118 t_jit_err jit_gl_fbo_query_attached_id(t_jit_gl_fbo *x, GLenum attachment, GLuint *value ); 00119 t_jit_err jit_gl_fbo_query_attached_miplevel(t_jit_gl_fbo *x, GLenum attachment, GLint *value ); 00120 t_jit_err jit_gl_fbo_query_attached_zslice(t_jit_gl_fbo *x, GLenum attachment, GLint *value ); 00121 00122 /****************************************************************************/ 00123 00124 #if C74_PRAGMA_STRUCT_PACKPUSH 00125 #pragma pack(pop) 00126 #elif C74_PRAGMA_STRUCT_PACK 00127 #pragma pack() 00128 #endif 00129 00130 #ifdef __cplusplus 00131 } 00132 #endif 00133 00134 /****************************************************************************/ 00135 00136 #endif // JIT_GL_FBO
Copyright © 2008, Cycling '74