1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
26 // File: vogl_default_framebuffer_state.h
27 #ifndef VOGL_DEFAULT_FRAMEBUFFER_STATE_H
28 #define VOGL_DEFAULT_FRAMEBUFFER_STATE_H
30 #include "vogl_dynamic_string.h"
31 #include "vogl_json.h"
34 #include "vogl_common.h"
35 #include "vogl_general_context_state.h"
36 #include "vogl_texture_state.h"
38 struct vogl_default_framebuffer_attribs
49 bool m_double_buffered;
51 vogl_default_framebuffer_attribs()
58 utils::zero_object(*this);
61 bool serialize(json_node &node) const
63 node.add_key_value("width", m_width);
64 node.add_key_value("height", m_height);
65 node.add_key_value("r_size", m_r_size);
66 node.add_key_value("g_size", m_g_size);
67 node.add_key_value("b_size", m_b_size);
68 node.add_key_value("a_size", m_a_size);
69 node.add_key_value("depth_size", m_depth_size);
70 node.add_key_value("stencil_size", m_stencil_size);
71 node.add_key_value("samples", m_samples);
72 node.add_key_value("double_buffered", m_double_buffered);
76 bool deserialize(const json_node &node)
78 m_width = node.value_as_uint32("width");
79 m_height = node.value_as_uint32("height");
80 m_r_size = node.value_as_uint32("r_size");
81 m_g_size = node.value_as_uint32("g_size");
82 m_b_size = node.value_as_uint32("b_size");
83 m_a_size = node.value_as_uint32("a_size");
84 m_depth_size = node.value_as_uint32("depth_size");
85 m_stencil_size = node.value_as_uint32("stencil_size");
86 m_samples = node.value_as_uint32("samples");
87 m_double_buffered = node.value_as_bool("double_buffered");
92 bool vogl_get_default_framebuffer_attribs(vogl_default_framebuffer_attribs &attribs, uint screen);
94 enum vogl_default_framebuffer_t
96 cDefFramebufferFrontLeft,
97 cDefFramebufferBackLeft,
98 cDefFramebufferFrontRight,
99 cDefFramebufferBackRight,
100 cDefFramebufferDepthStencil,
105 class vogl_default_framebuffer_state
108 vogl_default_framebuffer_state();
109 ~vogl_default_framebuffer_state();
111 bool snapshot(const vogl_context_info &context_info, const vogl_default_framebuffer_attribs &fb_attribs);
112 bool restore(const vogl_context_info &context_info) const;
116 bool serialize(json_node &node, vogl_blob_manager &blob_manager) const;
117 bool deserialize(const json_node &node, const vogl_blob_manager &blob_manager);
119 bool is_valid() const
124 const vogl_texture_state &get_texture(vogl_default_framebuffer_t index) const
126 VOGL_ASSERT(index < cDefFramebufferTotal);
127 return m_textures[index];
130 vogl_texture_state &get_texture(vogl_default_framebuffer_t index)
132 VOGL_ASSERT(index < cDefFramebufferTotal);
133 return m_textures[index];
138 vogl_default_framebuffer_attribs m_fb_attribs;
140 vogl_texture_state m_textures[cDefFramebufferTotal];
145 #endif // VOGL_DEFAULT_FRAMEBUFFER_STATE_H