buffer_control.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 **    Harry Storbacka
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "../../Core/System/sharedptr.h"
00036 #include "compare_function.h"
00037 
00041 enum CL_StencilOp
00042 {
00043         cl_stencil_keep,
00044         cl_stencil_zero,
00045         cl_stencil_replace,
00046         cl_stencil_incr,
00047         cl_stencil_decr,
00048         cl_stencil_invert,
00049         cl_stencil_incr_wrap,
00050         cl_stencil_decr_wrap
00051 };
00052 
00054 enum CL_DrawBuffer
00055 {
00056         cl_buffer_none,
00057         cl_buffer_front_left,
00058         cl_buffer_front_right,
00059         cl_buffer_back_left,
00060         cl_buffer_back_right,
00061         cl_buffer_front,
00062         cl_buffer_back,
00063         cl_buffer_left,
00064         cl_buffer_right,
00065         cl_buffer_front_and_back
00066 };
00067 
00071 enum CL_LogicOp
00072 {
00073         cl_logic_op_clear,
00074         cl_logic_op_and, 
00075         cl_logic_op_and_reverse,
00076         cl_logic_op_copy,
00077         cl_logic_op_and_inverted,
00078         cl_logic_op_noop,
00079         cl_logic_op_xor,
00080         cl_logic_op_or,
00081         cl_logic_op_nor,
00082         cl_logic_op_equiv,
00083         cl_logic_op_invert,
00084         cl_logic_op_or_reverse,
00085         cl_logic_op_copy_inverted,
00086         cl_logic_op_or_inverted,
00087         cl_logic_op_nand,
00088         cl_logic_op_set
00089 };
00090 
00091 class CL_BufferControl_Impl;
00092 
00096 class CL_API_DISPLAY CL_BufferControl
00097 {
00100 
00101 public:
00103         CL_BufferControl();
00104 
00105         virtual ~CL_BufferControl();
00106 
00110 
00111 public:
00113         bool is_stencil_test_enabled() const;
00114 
00116         CL_CompareFunction get_stencil_compare_func_front() const;
00117 
00119         CL_CompareFunction get_stencil_compare_func_back() const;
00120 
00122         int get_stencil_compare_reference_front() const;
00123 
00125         int get_stencil_compare_reference_back() const;
00126 
00128         CL_StencilOp get_stencil_fail_front() const;
00129 
00131         CL_StencilOp get_stencil_fail_back() const;
00132 
00134         CL_StencilOp get_stencil_pass_depth_pass_front() const;
00135 
00137         CL_StencilOp get_stencil_pass_depth_pass_back() const;
00138 
00140         CL_StencilOp get_stencil_pass_depth_fail_front() const;
00141 
00143         CL_StencilOp get_stencil_pass_depth_fail_back() const;
00144 
00146         unsigned char get_stencil_compare_mask_front() const;
00147 
00149         unsigned char get_stencil_compare_mask_back() const;
00150 
00152         unsigned char get_stencil_write_mask_front() const;
00153 
00155         unsigned char get_stencil_write_mask_back() const;
00156 
00158         bool is_depth_test_enabled() const;
00159 
00161         bool is_depth_write_enabled() const;
00162 
00164         CL_CompareFunction get_depth_compare_function() const;
00165 
00167         void is_color_write_enabled(bool &red, bool &green, bool &blue, bool &alpha) const;
00168 
00170         CL_DrawBuffer get_draw_buffer() const;
00171 
00173         bool is_logic_op_enabled() const;
00174 
00176         CL_LogicOp get_logic_op() const;
00177 
00181 
00182 public:
00184         void enable_stencil_test(bool enabled);
00185 
00187         void set_stencil_compare_func(CL_CompareFunction front, CL_CompareFunction back);
00188 
00190         void set_stencil_compare_reference(int front_ref, int back_ref);
00191 
00193         void set_stencil_write_mask(unsigned char front_facing_mask, unsigned char back_facing_mask);
00194 
00196         void set_stencil_fail(CL_StencilOp front, CL_StencilOp back);
00197 
00199         void set_stencil_pass_depth_pass(CL_StencilOp front, CL_StencilOp back);
00200 
00202         void set_stencil_pass_depth_fail(CL_StencilOp front, CL_StencilOp back);
00203 
00205         void set_stencil_compare_mask(int front_mask, int back_mask);
00206 
00208         void enable_depth_test(bool enabled);
00209 
00211         void enable_depth_write(bool enabled);
00212 
00214         void set_depth_compare_function(CL_CompareFunction func);
00215 
00217         void enable_color_write(bool enabled);
00218 
00225         void enable_color_write(bool red, bool green, bool blue, bool alpha);
00226 
00228         void set_draw_buffer(CL_DrawBuffer buffer);
00229 
00231         void enable_logic_op(bool enabled);
00232 
00234         void set_logic_op(CL_LogicOp op);
00235 
00239 
00240 private:
00241         CL_SharedPtr<CL_BufferControl_Impl> impl;
00243 };
00244