34 #include "../2D/color.h"
35 #include "../Image/texture_format.h"
37 #include "../../Core/Math/mat4.h"
38 #include "../../Core/Math/rect.h"
39 #include "../../Core/Signals/signal.h"
40 #include "primitives_array.h"
41 #include "frame_buffer.h"
42 #include "element_array_vector.h"
53 class PrimitivesArray;
56 class GraphicContextProvider;
57 class GraphicContext_Impl;
61 class FontProvider_Freetype;
64 class RasterizerState;
66 class DepthStencilState;
525 template<
typename Type>
709 std::shared_ptr<GraphicContext_Impl> impl;
@ cull_front
Definition: graphic_context.h:71
GraphicContext(GraphicContextProvider *provider)
C clamp(A val, B minval, C maxval)
Definition: cl_math.h:98
@ equation_min
Definition: graphic_context.h:208
@ blend_dest_color
source (Rd, Gd, Bd, Ad)
Definition: graphic_context.h:163
@ logic_or
Definition: graphic_context.h:142
@ logic_copy
Definition: graphic_context.h:138
FrameBuffer get_read_frame_buffer() const
void set_primitives_elements(ElementArrayBuffer &element_array)
Sets current elements array buffer.
@ shader_hlsl
Definition: graphic_context.h:251
void set_depth_range(float n, float f)
Specifies the depth range for all viewports.
@ logic_set
Definition: graphic_context.h:150
ClipZRange
Definition: mat4.h:52
PointSpriteOrigin
Point Sprite Origin.
Definition: graphic_context.h:214
@ blend_constant_color
source or destination (Rc, Gc, Bc, Ac)
Definition: graphic_context.h:190
ProgramObject get_program_object() const
Returns the currently selected program object.
bool operator!=(const GraphicContext &other) const
Definition: graphic_context.h:703
void reset_textures()
Remove all selected textures.
@ fill_point
Definition: graphic_context.h:79
void set_scissor(const Rect &rect, TextureImageYAxis y_axis)
Set the current clipping rectangle.
void reset_storage_buffer(int index)
Remove storage buffer from index.
void reset_depth_stencil_state()
Set active depth stencil state.
PixelBuffer get_pixeldata(TextureFormat texture_format=tf_rgba8, bool clamp=true)
Return the content of the read buffer into a pixel buffer.
void set_program_object(const ProgramObject &program)
Texture object class.
Definition: texture.h:104
void set_frame_buffer(const FrameBuffer &write_buffer, const FrameBuffer &read_buffer)
@ fill_line
Definition: graphic_context.h:80
@ logic_and
Definition: graphic_context.h:136
void clear_depth(float value=0)
void reset_image_texture(int unit_index)
@ stencil_incr_wrap
Definition: graphic_context.h:113
@ blend_src_color
destination (Rs, Gs, Bs, As)
Definition: graphic_context.h:166
void throw_if_null() const
Throw an exception if this object is invalid.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
@ logic_copy_inverted
Definition: graphic_context.h:147
FaceSide
Front face modes.
Definition: graphic_context.h:86
void draw_primitives_array(PrimitivesType type, int offset, int num_vertices)
@ blend_one_minus_constant_color
source or destination (1, 1, 1, 1) - (Rc, Gc, Bc, Ac)
Definition: graphic_context.h:193
DrawBuffer
Drawing buffers.
Definition: graphic_context.h:119
@ tf_rgba8
Definition: texture_format.h:43
@ blend_one_minus_src_color
destination (1, 1, 1, 1) - (Rs, Gs, Bs, As)
Definition: graphic_context.h:172
@ blend_one
source or destination (1, 1, 1, 1)
Definition: graphic_context.h:160
void clear_stencil(int value=0)
ShaderLanguage
Shader language used.
Definition: graphic_context.h:249
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned int > &element_array, size_t offset, int instance_count)
Definition: graphic_context.h:614
float get_dip_width() const
Definition: graphic_context.h:352
@ buffer_none
Definition: graphic_context.h:120
@ buffer_back_left
Definition: graphic_context.h:123
CullMode
Polygon culling modes.
Definition: graphic_context.h:70
void set_textures(std::vector< Texture > &textures)
@ origin_lower_left
Definition: graphic_context.h:216
Sizef get_dip_size() const
Definition: graphic_context.h:360
BlendEquation
Blending equations.
Definition: graphic_context.h:204
@ fill_polygon
Definition: graphic_context.h:81
@ type_unsigned_short
Definition: primitives_array.h:59
void dispatch(int x=1, int y=1, int z=1)
Execute a compute shader.
@ blend_dest_alpha
source or destination (Ad, Ad, Ad, Ad)
Definition: graphic_context.h:181
void flush()
Flush the command buffer.
@ stencil_replace
Definition: graphic_context.h:109
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned short > &element_array, size_t offset, int instance_count)
Definition: graphic_context.h:627
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:485
Primitives array description.
Definition: primitives_array.h:69
void set_primitives_elements(ElementArrayVector< Type > &element_array)
Sets current elements array buffer.
Definition: graphic_context.h:526
@ logic_clear
Definition: graphic_context.h:135
@ buffer_front
Definition: graphic_context.h:125
Floating point color description class (for float).
Definition: color.h:661
void draw_primitives(PrimitivesType type, int num_vertices, const PrimitivesArray &array)
Draw primitives on gc.
void set_image_texture(std::vector< Texture > &textures)
@ logic_and_inverted
Definition: graphic_context.h:139
int get_height() const
Returns the current actual height of the context.
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned char > &element_array, size_t offset=0)
Definition: graphic_context.h:591
void set_depth_stencil_state(const DepthStencilState &state, int stencil_ref=0)
Set active depth stencil state.
@ program_sprite
Definition: graphic_context.h:243
void draw_primitives_array(PrimitivesType type, int num_vertices)
Draws primitives from the current assigned primitives array.
void set_storage_buffer(int index, const StorageBuffer &buffer)
Select storage buffer into index.
void reset_scissor()
Removes the set clipping rectangle.
@ num_shader_languages
Definition: graphic_context.h:253
@ logic_nor
Definition: graphic_context.h:143
bool is_frame_buffer_owner(const FrameBuffer &fb)
@ blend_one_minus_dest_color
source (1, 1, 1, 1) - (Rd, Gd, Bd, Ad)
Definition: graphic_context.h:169
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayBuffer &element_array, VertexAttributeDataType indices_type, size_t offset=0)
@ cull_back
Definition: graphic_context.h:72
StencilOp
Stencil operations.
Definition: graphic_context.h:106
void set_draw_buffer(DrawBuffer buffer)
Set used draw buffer.
void reset_rasterizer_state()
Set active rasterizer state.
void reset_primitives_array()
Reset the primitives arrays.
void set_primitives_array(const PrimitivesArray &array)
Set the primitives array on the gc.
Size get_max_texture_size() const
@ equation_max
Definition: graphic_context.h:209
@ equation_add
Definition: graphic_context.h:205
@ compare_gequal
Definition: graphic_context.h:95
@ logic_xor
Definition: graphic_context.h:141
PixelBuffer get_pixeldata(const Rect &rect, TextureFormat texture_format=tf_rgba8, bool clamp=true)
Return the content of the read buffer into a pixel buffer.
GraphicContext create() const
Create a new default graphic context compatible with this one.
void reset_texture(int unit_index)
FillMode
Polygon filling modes.
Definition: graphic_context.h:78
ClipZRange get_clip_z_range() const
Returns in what range clip space z values are clipped.
StandardProgram
Standard Program.
Definition: graphic_context.h:240
@ type_triangle_fan
Definition: graphic_context.h:227
@ logic_invert
Definition: graphic_context.h:145
@ compare_lequal
Definition: graphic_context.h:94
Interface to drawing graphics.
Definition: graphic_context.h:258
@ buffer_front_left
Definition: graphic_context.h:121
@ buffer_left
Definition: graphic_context.h:127
@ stencil_zero
Definition: graphic_context.h:108
@ type_points
Definition: graphic_context.h:222
@ blend_src_alpha
source or destination (As, As, As, As)
Definition: graphic_context.h:175
TextureImageYAxis
Y axis direction for viewports, clipping rects, textures and render targets.
Definition: graphic_context.h:233
float get_pixel_ratio() const
void draw_primitives_elements_instanced(PrimitivesType type, int count, VertexAttributeDataType indices_type, size_t offset, int instance_count)
const float pixelcenter_constant
Definition: graphic_context.h:715
GraphicContextProvider * get_provider()
Returns the provider for this graphic context.
GraphicContext clone() const
Create a new default graphic context cloned with this one.
Rasterizer state setup.
Definition: rasterizer_state.h:45
void reset_uniform_buffer(int index)
Remove uniform buffer from index.
void set_rasterizer_state(const RasterizerState &state)
Set active rasterizer state.
@ y_axis_bottom_up
OpenGL, origin is lower left with Y going upwards.
Definition: graphic_context.h:234
@ type_lines
Definition: graphic_context.h:225
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned char > &element_array, size_t offset, int instance_count)
Definition: graphic_context.h:640
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned short > &element_array, size_t offset=0)
Definition: graphic_context.h:579
OpenGL utility class.
Definition: opengl.h:74
@ y_axis_top_down
Direct3D, origin is upper left with Y going downwards.
Definition: graphic_context.h:235
@ compare_greater
Definition: graphic_context.h:97
@ face_counter_clockwise
Definition: graphic_context.h:88
void reset_image_textures()
Remove all selected textures.
@ program_single_texture
Definition: graphic_context.h:242
TextureFormat
Texture format.
Definition: texture_format.h:41
BlendFunc
Blending functions.
Definition: graphic_context.h:155
Element Array Buffer.
Definition: element_array_buffer.h:47
@ shader_glsl
Definition: graphic_context.h:250
GraphicContext()
Constructs a null instance.
@ buffer_right
Definition: graphic_context.h:128
int get_width() const
Returns the current actual width of the context.
@ blend_zero
source or destination (0, 0, 0, 0)
Definition: graphic_context.h:157
@ equation_subtract
Definition: graphic_context.h:206
@ type_triangles
Definition: graphic_context.h:228
@ program_color_only
Definition: graphic_context.h:241
@ stencil_invert
Definition: graphic_context.h:112
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned int > &element_array, size_t offset=0)
Definition: graphic_context.h:567
Frame-buffer object class.
Definition: frame_buffer.h:73
void set_program_object(StandardProgram standard_program)
Set active program object to the standard program specified.
void set_depth_range(int viewport, float n, float f)
Specifies the depth range for the specified viewport.
@ compare_less
Definition: graphic_context.h:96
ShaderLanguage get_shader_language() const
Returns the shader language used.
void set_viewport(int index, const Rectf &viewport)
@ type_triangle_strip
Definition: graphic_context.h:226
int get_major_version() const
void set_uniform_buffer(int index, const UniformBuffer &buffer)
Select uniform buffer into index.
void draw_primitives_array_instanced(PrimitivesType type, int offset, int num_vertices, int instance_count)
Pixel data container.
Definition: pixel_buffer.h:69
TextureImageYAxis get_texture_image_y_axis() const
Returns the Y axis direction for viewports, clipping rects, textures and render targets.
VertexAttributeDataType
Primitives array description.
Definition: primitives_array.h:57
@ blend_one_minus_constant_alpha
source or destination (1, 1, 1, 1) - (Ac, Ac, Ac, Ac)
Definition: graphic_context.h:199
@ compare_always
Definition: graphic_context.h:100
static Colorf black
Definition: color.h:843
const GraphicContextProvider * get_provider() const
void draw_primitives_elements(PrimitivesType type, int count, VertexAttributeDataType indices_type, size_t offset=0)
@ blend_constant_alpha
source or destination (Ac, Ac, Ac, Ac)
Definition: graphic_context.h:196
@ type_unsigned_int
Definition: primitives_array.h:60
void reset_frame_buffer()
Resets the current frame buffer to be the initial frame buffer.
void set_blend_state(const BlendState &state, const Colorf &blend_color=Colorf::white, unsigned int sample_mask=0xffffffff)
Set active blend state.
float get_dip_height() const
Definition: graphic_context.h:356
@ type_line_strip
Definition: graphic_context.h:223
void reset_program_object()
Remove active program object.
void clear(const Colorf &color=Colorf::black)
Clears the whole context using the specified color.
@ compare_notequal
Definition: graphic_context.h:99
@ stencil_decr_wrap
Definition: graphic_context.h:114
@ type_unsigned_byte
Definition: primitives_array.h:58
void reset_blend_state()
Set active blend state.
CompareFunction
Compare functions.
Definition: graphic_context.h:93
@ compare_equal
Definition: graphic_context.h:98
@ shader_fixed_function
Definition: graphic_context.h:252
void reset_primitives_elements()
Resets current elements array buffer.
@ logic_or_inverted
Definition: graphic_context.h:148
@ buffer_front_and_back
Definition: graphic_context.h:129
Interface for implementing a GraphicContext target.
Definition: graphic_context_provider.h:87
@ logic_and_reverse
Definition: graphic_context.h:137
@ stencil_incr
Definition: graphic_context.h:110
DepthStencil state setup.
Definition: depth_stencil_state.h:45
Blend state setup.
Definition: blend_state.h:45
FrameBuffer get_write_frame_buffer() const
Storage Buffer.
Definition: storage_buffer.h:48
bool is_null() const
Returns true if this object is invalid.
Definition: graphic_context.h:278
@ logic_noop
Definition: graphic_context.h:140
GraphicContext create(FrameBuffer &buffer) const
Create a new default graphic context with a frame buffer selected.
@ buffer_back_right
Definition: graphic_context.h:124
Size get_size() const
Returns the current actual size of the context.
Texture get_texture(int index) const
@ blend_one_minus_src_alpha
source or destination (1, 1, 1, 1) - (As, As, As, As)
Definition: graphic_context.h:178
2D (width,height) size structure - Integer
Definition: size.h:157
@ stencil_keep
Definition: graphic_context.h:107
@ logic_equiv
Definition: graphic_context.h:144
@ cull_front_and_back
Definition: graphic_context.h:73
void set_texture(int unit_index, const Texture &texture)
2D (width,height) size structure - Float
Definition: size.h:170
Program Object.
Definition: program_object.h:70
int get_minor_version() const
@ buffer_back
Definition: graphic_context.h:126
LogicOp
Logic Op.
Definition: graphic_context.h:134
@ compare_never
Definition: graphic_context.h:101
@ stencil_decr
Definition: graphic_context.h:111
bool has_compute_shader_support() const
@ origin_upper_left
Definition: graphic_context.h:215
PrimitivesType
Primitive types.
Definition: graphic_context.h:221
@ logic_or_reverse
Definition: graphic_context.h:146
std::vector< Texture > get_textures() const
@ program_path
Definition: graphic_context.h:244
Element Array Vector.
Definition: element_array_vector.h:44
bool operator==(const GraphicContext &other) const
Definition: graphic_context.h:702
@ equation_reverse_subtract
Definition: graphic_context.h:207
@ blend_one_minus_dest_alpha
source or destination (1, 1, 1, 1) - (Ad, Ad, Ad, Ad)
Definition: graphic_context.h:184
@ buffer_front_right
Definition: graphic_context.h:122
@ type_line_loop
Definition: graphic_context.h:224
@ face_clockwise
Definition: graphic_context.h:87
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayBuffer &element_array, VertexAttributeDataType indices_type, size_t offset, int instance_count)
void set_frame_buffer(const FrameBuffer &write_buffer)
Sets the current frame buffer.
bool is_primitives_array_owner(const PrimitivesArray &primitives_array)
void set_viewport(const Rectf &viewport)
static Colorf white
Definition: color.h:1251
@ logic_nand
Definition: graphic_context.h:149
@ blend_src_alpha_saturate
source (f, f, f, 1) - f = min(As, 1 - Ad)
Definition: graphic_context.h:187
void set_image_texture(int unit_index, const Texture &texture)