frame_buffer.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 **    Harry Storbacka
00028 */
00029 
00032 
00033 #pragma once
00034 
00035 #include "../api_display.h"
00036 #include "../../Core/System/sharedptr.h"
00037 
00038 class CL_Size;
00039 class CL_Rect;
00040 class CL_Texture;
00041 class CL_RenderBuffer;
00042 class CL_GraphicContext;
00043 class CL_FrameBufferProvider;
00044 class CL_FrameBuffer_Impl;
00045 
00049 enum CL_TextureSubtype
00050 {
00051         cl_subtype_cube_map_positive_x,
00052         cl_subtype_cube_map_negative_x,
00053         cl_subtype_cube_map_positive_y,
00054         cl_subtype_cube_map_negative_y,
00055         cl_subtype_cube_map_positive_z,
00056         cl_subtype_cube_map_negative_z
00057 };
00058 
00062 enum CL_FrameBufferBindTarget 
00063 {
00064         cl_framebuffer_draw,
00065         cl_framebuffer_read
00066 };
00067 
00071 class CL_API_DISPLAY CL_FrameBuffer
00072 {
00075 public:
00077         CL_FrameBuffer();
00078 
00084         CL_FrameBuffer(CL_GraphicContext &context);
00085 
00089 public:
00091         bool is_null() const { return !impl; }
00092 
00094         void throw_if_null() const;
00095 
00099         CL_FrameBufferProvider *get_provider() const;
00100 
00104         CL_Size get_size() const;
00105 
00109         CL_FrameBufferBindTarget get_bind_target() const;
00110 
00114 public:
00116         bool operator==(const CL_FrameBuffer &other) const;
00117 
00122         void attach_color_buffer(int attachment_index, const CL_RenderBuffer &render_buffer);
00123 
00128         void detach_color_buffer(int attachment_index, const CL_RenderBuffer &render_buffer);
00129 
00136         void attach_color_buffer(int attachment_index, const CL_Texture &texture, int level = 0, int zoffset = 0);
00137 
00145         void attach_color_buffer(int attachment_index, const CL_Texture &texture, CL_TextureSubtype subtype, int level = 0, int zoffset = 0);
00146 
00153         void detach_color_buffer(int attachment_index, const CL_Texture &texture, int level = 0, int zoffset = 0);
00154 
00155         void attach_stencil_buffer(const CL_RenderBuffer &render_buffer);
00156         void detach_stencil_buffer(const CL_RenderBuffer &render_buffer);
00157         void attach_stencil_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00158         void attach_stencil_buffer(const CL_Texture &texture, CL_TextureSubtype subtype, int level = 0, int zoffset = 0);
00159         void detach_stencil_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00160 
00161         void attach_depth_buffer(const CL_RenderBuffer &render_buffer);
00162         void detach_depth_buffer(const CL_RenderBuffer &render_buffer);
00163         void attach_depth_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00164         void attach_depth_buffer(const CL_Texture &texture, CL_TextureSubtype subtype, int level = 0, int zoffset = 0);
00165         void detach_depth_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00166 
00167         void attach_depth_stencil_buffer(const CL_RenderBuffer &render_buffer);
00168         void detach_depth_stencil_buffer(const CL_RenderBuffer &render_buffer);
00169         void attach_depth_stencil_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00170         void attach_depth_stencil_buffer(const CL_Texture &texture, CL_TextureSubtype subtype, int level = 0, int zoffset = 0);
00171         void detach_depth_stencil_buffer(const CL_Texture &texture, int level = 0, int zoffset = 0);
00172 
00178         void set_bind_target(CL_FrameBufferBindTarget target);
00179 
00183 private:
00184         CL_SharedPtr<CL_FrameBuffer_Impl> impl;
00186 };
00187