33#include "../2D/color.h"
34#include "../Image/texture_format.h"
36#include "../../Core/Math/mat4.h"
37#include "../../Core/Math/rect.h"
38#include "../../Core/Signals/signal.h"
39#include "primitives_array.h"
40#include "frame_buffer.h"
41#include "element_array_vector.h"
52 class PrimitivesArray;
55 class GraphicContextProvider;
56 class GraphicContext_Impl;
60 class FontProvider_Freetype;
63 class RasterizerState;
65 class DepthStencilState;
271 explicit operator bool()
const {
return bool(impl); }
514 template<
typename Type>
686 std::shared_ptr<GraphicContext_Impl> impl;
Blend state setup.
Definition blend_state.h:44
Floating point color description class (for float).
Definition color.h:799
DepthStencil state setup.
Definition depth_stencil_state.h:44
Element Array Buffer.
Definition element_array_buffer.h:46
Element Array Vector.
Definition element_array_vector.h:43
Frame-buffer object class.
Definition frame_buffer.h:72
Interface for implementing a GraphicContext target.
Definition graphic_context_provider.h:86
Interface to drawing graphics.
Definition graphic_context.h:257
PixelBuffer get_pixeldata(TextureFormat texture_format=TextureFormat::rgba8, bool clamp=true)
Return the content of the read buffer into a pixel buffer.
std::vector< Texture > get_textures() const
void clear(const Colorf &color=StandardColorf::black())
Clears the whole context using the specified color.
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned short > &element_array, size_t offset, int instance_count)
Definition graphic_context.h:616
GraphicContext create(FrameBuffer &buffer) const
Create a new default graphic context with a frame buffer selected.
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayBuffer &element_array, VertexAttributeDataType indices_type, size_t offset, int instance_count)
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayBuffer &element_array, VertexAttributeDataType indices_type, size_t offset=0)
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned char > &element_array, size_t offset, int instance_count)
Definition graphic_context.h:629
PixelBuffer get_pixeldata(const Rect &rect, TextureFormat texture_format=TextureFormat::rgba8, bool clamp=true)
Return the content of the read buffer into a pixel buffer.
void set_blend_state(const BlendState &state, const Colorf &blend_color=StandardColorf::white(), unsigned int sample_mask=0xffffffff)
Set active blend state.
void set_scissor(const Rect &rect, TextureImageYAxis y_axis)
Set the current clipping rectangle.
void reset_blend_state()
Set active blend state.
void set_image_texture(std::vector< Texture > &textures)
ProgramObject get_program_object() const
Returns the currently selected program object.
bool has_compute_shader_support() const
void draw_primitives_array(PrimitivesType type, int offset, int num_vertices)
bool is_primitives_array_owner(const PrimitivesArray &primitives_array)
GraphicContextProvider * get_provider()
Returns the provider for this graphic context.
void reset_image_texture(int unit_index)
GraphicContext create() const
Create a new default graphic context compatible with this one.
bool operator!=(const GraphicContext &other) const
Definition graphic_context.h:683
void clear_stencil(int value=0)
void set_storage_buffer(int index, const StorageBuffer &buffer)
Select storage buffer into index.
const GraphicContextProvider * get_provider() const
void set_primitives_array(const PrimitivesArray &array)
Set the primitives array on the gc.
Sizef get_dip_size() const
Definition graphic_context.h:353
void set_frame_buffer(const FrameBuffer &write_buffer, const FrameBuffer &read_buffer)
ClipZRange get_clip_z_range() const
Returns in what range clip space z values are clipped.
void set_rasterizer_state(const RasterizerState &state)
Set active rasterizer state.
void clear_depth(float value=0)
void set_primitives_elements(ElementArrayVector< Type > &element_array)
Sets current elements array buffer.
Definition graphic_context.h:515
void set_image_texture(int unit_index, const Texture &texture)
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned char > &element_array, size_t offset=0)
Definition graphic_context.h:580
float get_dip_height() const
Definition graphic_context.h:349
void reset_image_textures()
Remove all selected textures.
void draw_primitives_elements_instanced(PrimitivesType type, int count, ElementArrayVector< unsigned int > &element_array, size_t offset, int instance_count)
Definition graphic_context.h:603
void reset_primitives_elements()
Resets current elements array buffer.
void reset_depth_stencil_state()
Set active depth stencil state.
Size get_max_texture_size() const
Size get_size() const
Returns the current actual size of the context.
void draw_primitives(PrimitivesType type, int num_vertices, const PrimitivesArray &array)
Draw primitives on gc.
FrameBuffer get_read_frame_buffer() const
void draw_primitives_array_instanced(PrimitivesType type, int offset, int num_vertices, int instance_count)
void reset_uniform_buffer(int index)
Remove uniform buffer from index.
void draw_primitives_elements(PrimitivesType type, int count, VertexAttributeDataType indices_type, size_t offset=0)
void reset_texture(int unit_index)
float get_dip_width() const
Definition graphic_context.h:345
GraphicContext clone() const
Create a new default graphic context cloned with this one.
FrameBuffer get_write_frame_buffer() const
void set_frame_buffer(const FrameBuffer &write_buffer)
Sets the current frame buffer.
void set_viewport(int index, const Rectf &viewport)
void set_draw_buffer(DrawBuffer buffer)
Set used draw buffer.
bool operator==(const GraphicContext &other) const
Definition graphic_context.h:682
void reset_textures()
Remove all selected textures.
bool is_null() const
Returns true if this object is invalid.
Definition graphic_context.h:270
ShaderLanguage get_shader_language() const
Returns the shader language used.
void set_depth_stencil_state(const DepthStencilState &state, int stencil_ref=0)
Set active depth stencil state.
Texture get_texture(int index) const
GraphicContext()
Constructs a null instance.
void reset_program_object()
Remove active program object.
int get_minor_version() const
bool is_frame_buffer_owner(const FrameBuffer &fb)
void reset_frame_buffer()
Resets the current frame buffer to be the initial frame buffer.
void set_program_object(const ProgramObject &program)
TextureImageYAxis get_texture_image_y_axis() const
Returns the Y axis direction for viewports, clipping rects, textures and render targets.
void flush()
Flush the command buffer.
void set_program_object(StandardProgram standard_program)
Set active program object to the standard program specified.
void reset_rasterizer_state()
Set active rasterizer state.
GraphicContext(GraphicContextProvider *provider)
void dispatch(int x=1, int y=1, int z=1)
Execute a compute shader.
void reset_primitives_array()
Reset the primitives arrays.
void set_primitives_elements(ElementArrayBuffer &element_array)
Sets current elements array buffer.
void set_depth_range(float n, float f)
Specifies the depth range for all viewports.
int get_height() const
Returns the current actual height of the context.
void draw_primitives_elements_instanced(PrimitivesType type, int count, VertexAttributeDataType indices_type, size_t offset, int instance_count)
void draw_primitives_array(PrimitivesType type, int num_vertices)
Draws primitives from the current assigned primitives array.
int get_major_version() const
void set_uniform_buffer(int index, const UniformBuffer &buffer)
Select uniform buffer into index.
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned int > &element_array, size_t offset=0)
Definition graphic_context.h:556
void set_textures(std::vector< Texture > &textures)
void reset_scissor()
Removes the set clipping rectangle.
void reset_storage_buffer(int index)
Remove storage buffer from index.
void draw_primitives_elements(PrimitivesType type, int count, ElementArrayVector< unsigned short > &element_array, size_t offset=0)
Definition graphic_context.h:568
void throw_if_null() const
Throw an exception if this object is invalid.
float get_pixel_ratio() const
void set_depth_range(int viewport, float n, float f)
Specifies the depth range for the specified viewport.
void set_texture(int unit_index, const Texture &texture)
void set_viewport(const Rectf &viewport)
int get_width() const
Returns the current actual width of the context.
OpenGL utility class.
Definition opengl.h:74
Pixel data container.
Definition pixel_buffer.h:68
Primitives array description.
Definition primitives_array.h:68
Program Object.
Definition program_object.h:69
Rasterizer state setup.
Definition rasterizer_state.h:44
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
2D (left,top,right,bottom) rectangle structure - Float
Definition rect.h:460
2D (width,height) size structure - Integer
Definition size.h:176
2D (width,height) size structure - Float
Definition size.h:189
static Colorf black()
Definition color.h:1747
static Colorf white()
Definition color.h:1884
Storage Buffer.
Definition storage_buffer.h:47
Texture object class.
Definition texture.h:103
ClipZRange
Definition mat4.h:51
BlendFunc
Blending functions.
Definition graphic_context.h:154
FaceSide
Front face modes.
Definition graphic_context.h:85
CompareFunction
Compare functions.
Definition graphic_context.h:92
TextureFormat
Texture format.
Definition texture_format.h:39
PrimitivesType
Primitive types.
Definition graphic_context.h:220
ShaderLanguage
Shader language used.
Definition graphic_context.h:248
FillMode
Polygon filling modes.
Definition graphic_context.h:77
const float pixelcenter_constant
Definition graphic_context.h:691
PointSpriteOrigin
Point Sprite Origin.
Definition graphic_context.h:213
LogicOp
Logic Op.
Definition graphic_context.h:133
StencilOp
Stencil operations.
Definition graphic_context.h:105
TextureImageYAxis
Y axis direction for viewports, clipping rects, textures and render targets.
Definition graphic_context.h:232
DrawBuffer
Drawing buffers.
Definition graphic_context.h:118
StandardProgram
Standard Program.
Definition graphic_context.h:239
VertexAttributeDataType
Primitives array description.
Definition primitives_array.h:56
CullMode
Polygon culling modes.
Definition graphic_context.h:69
BlendEquation
Blending equations.
Definition graphic_context.h:203
@ one_minus_dest_alpha
source or destination (1, 1, 1, 1) - (Ad, Ad, Ad, Ad)
@ one_minus_dest_color
source (1, 1, 1, 1) - (Rd, Gd, Bd, Ad)
@ src_color
destination (Rs, Gs, Bs, As)
@ src_alpha_saturate
source (f, f, f, 1) - f = min(As, 1 - Ad)
@ one_minus_constant_color
source or destination (1, 1, 1, 1) - (Rc, Gc, Bc, Ac)
@ dest_color
source (Rd, Gd, Bd, Ad)
@ constant_alpha
source or destination (Ac, Ac, Ac, Ac)
@ one_minus_src_alpha
source or destination (1, 1, 1, 1) - (As, As, As, As)
@ one_minus_src_color
destination (1, 1, 1, 1) - (Rs, Gs, Bs, As)
@ one_minus_constant_alpha
source or destination (1, 1, 1, 1) - (Ac, Ac, Ac, Ac)
@ constant_color
source or destination (Rc, Gc, Bc, Ac)
@ one
source or destination (1, 1, 1, 1)
@ dest_alpha
source or destination (Ad, Ad, Ad, Ad)
@ src_alpha
source or destination (As, As, As, As)
@ y_bottom_up
OpenGL, origin is lower left with Y going upwards.
@ y_top_down
Direct3D, origin is upper left with Y going downwards.