graphic_context_provider.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 #include "../../Core/Text/string_types.h"
00038 #include "../Render/graphic_context.h"
00039 #include "../Render/primitives_array.h"
00040 #include "../Render/texture.h"
00041 #include "../../Core/Math/mat4.h"
00042 
00043 class CL_Texture;
00044 class CL_Stencil;
00045 class CL_TextureProvider;
00046 class CL_FontProvider;
00047 class CL_BlendMode;
00048 class CL_PolygonRasterizer;
00049 class CL_Font;
00050 class CL_OcclusionQueryProvider;
00051 class CL_ProgramObjectProvider;
00052 class CL_ShaderObjectProvider;
00053 class CL_FrameBufferProvider;
00054 class CL_RenderBufferProvider;
00055 class CL_VertexArrayBufferProvider;
00056 class CL_ElementArrayBufferProvider;
00057 class CL_FontDescription;
00058 class CL_PixelBufferProvider;
00059 
00063 class CL_PrimitivesArrayData
00064 {
00065 public:
00066         struct VertexData
00067         {
00068                 int size;
00069                 CL_VertexAttributeDataType type;
00070                 int stride;
00071                 CL_VertexArrayBufferProvider *array_provider;
00072                 bool single_value;
00073                 union
00074                 {
00075                         void *data;
00076                         unsigned char value_ubyte[4];
00077                         char value_byte[4];
00078                         unsigned short value_ushort[4];
00079                         short value_short[4];
00080                         unsigned int value_uint[4];
00081                         int value_int[4];
00082                         float value_float[4];
00083                         bool value_boolean;
00084                 };
00085         };
00086 
00087         int num_attributes;
00088         int *attribute_indexes;
00089         VertexData *attributes;
00090         bool *normalize_attributes;
00091 };
00092 
00096 class CL_API_DISPLAY CL_GraphicContextProvider
00097 {
00100 
00101 public:
00102         virtual ~CL_GraphicContextProvider() { return; }
00103 
00107 
00108 public:
00110         virtual int get_max_attributes() = 0;
00111 
00113 
00115         virtual CL_Size get_max_texture_size() const = 0;
00116 
00118         virtual int get_width() const = 0;
00119 
00121         virtual int get_height() const = 0;
00122 
00126 
00127 public:
00129         virtual void destroy() = 0;
00130         
00132         virtual CL_PixelBuffer get_pixeldata(const CL_Rect& rect, CL_TextureFormat pixel_format, bool clamp) const = 0;
00133 
00135         virtual CL_TextureProvider *alloc_texture(CL_TextureDimensions texture_dimensions) = 0;
00136 
00138         virtual CL_OcclusionQueryProvider *alloc_occlusion_query() = 0;
00139 
00141         virtual CL_ProgramObjectProvider *alloc_program_object() = 0;
00142 
00144         virtual CL_ShaderObjectProvider *alloc_shader_object() = 0;
00145 
00147         virtual CL_FrameBufferProvider *alloc_frame_buffer() = 0;
00148 
00150         virtual CL_RenderBufferProvider *alloc_render_buffer() = 0;
00151 
00153         virtual CL_VertexArrayBufferProvider *alloc_vertex_array_buffer() = 0;
00154 
00156         virtual CL_ElementArrayBufferProvider *alloc_element_array_buffer() = 0;
00157 
00159         virtual CL_PixelBufferProvider *alloc_pixel_buffer() = 0;
00160 
00162         virtual void set_program_object(CL_StandardProgram standard_program) = 0;
00163 
00168         virtual void set_program_object(const CL_ProgramObject &program, int program_matrix_flags) = 0;
00169 
00171         virtual void reset_program_object() = 0;
00172 
00174         virtual void set_texture(int unit_index, const CL_Texture &texture) = 0;
00175 
00177         virtual void reset_texture(int unit_index, const CL_Texture &texture) = 0;
00178 
00180         virtual void set_frame_buffer(const CL_FrameBuffer &write_buffer, const CL_FrameBuffer &read_buffer) = 0;
00181 
00183         virtual void reset_frame_buffer() = 0;
00184 
00186         virtual void set_blend_mode(const CL_BlendMode &blendmode) = 0;
00187 
00189         virtual void set_buffer_control(const CL_BufferControl &buffer_control) = 0;
00190 
00192         virtual void set_pen(const CL_Pen &pen) = 0;
00193 
00195         virtual void set_polygon_rasterizer(const CL_PolygonRasterizer &raster) = 0;
00196 
00198         virtual void draw_primitives(CL_PrimitivesType type, int num_vertices, const CL_PrimitivesArrayData * const prim_array) = 0;
00199 
00201         virtual void set_primitives_array(const CL_PrimitivesArrayData * const prim_array) = 0;
00202 
00204         virtual void draw_primitives_array(CL_PrimitivesType type, int offset, int num_vertices) = 0;
00205 
00207         virtual void draw_primitives_array_instanced(CL_PrimitivesType type, int offset, int num_vertices, int instance_count) = 0;
00208 
00214         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned int *indices) = 0;
00215 
00221         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned short *indices) = 0;
00222 
00228         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned char *indices) = 0;
00229 
00236         virtual void draw_primitives_elements_instanced(CL_PrimitivesType type, int count, unsigned int *indices, int instance_count) = 0;
00237 
00244         virtual void draw_primitives_elements_instanced(CL_PrimitivesType type, int count, unsigned short *indices, int instance_count) = 0;
00245 
00252         virtual void draw_primitives_elements_instanced(CL_PrimitivesType type, int count, unsigned char *indices, int instance_count) = 0;
00253 
00261         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, CL_ElementArrayBufferProvider *array_provider, CL_VertexAttributeDataType indices_type, void *offset) = 0;
00262 
00270         virtual void draw_primitives_elements_instanced(CL_PrimitivesType type, int count, CL_ElementArrayBufferProvider *array_provider, CL_VertexAttributeDataType indices_type, void *offset, int instance_count) = 0;
00271 
00273         virtual void primitives_array_freed(const CL_PrimitivesArrayData * const prim_array) = 0;
00274 
00276         virtual void reset_primitives_array() = 0;
00277 
00279         virtual void draw_pixels(CL_GraphicContext &gc, float x, float y, float zoom_x, float zoom_y, const CL_PixelBuffer &pixel_buffer, const CL_Rect &src_rect, const CL_Colorf &color) = 0;
00280 
00282         virtual void set_clip_rect(const CL_Rect &rect) = 0;
00283 
00285         virtual void reset_clip_rect() = 0;
00286 
00288         virtual void clear(const CL_Colorf &color) = 0;
00289 
00293         virtual void clear_depth(float value) = 0;
00294 
00298         virtual void clear_stencil(int value) = 0;
00299 
00301         virtual void set_map_mode(CL_MapMode mode) = 0;
00302 
00304         virtual void set_viewport(const CL_Rectf &viewport) = 0;
00305 
00307         virtual void set_projection(const CL_Mat4f &matrix) = 0;
00308 
00310         virtual void set_modelview(const CL_Mat4f &matrix) = 0;
00311 
00315 
00316 private:
00318 };
00319