graphic_context_provider.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2009 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 
00062 class CL_PrimitivesArrayData
00063 {
00064 public:
00065         struct VertexData
00066         {
00067                 int size;
00068                 CL_VertexAttributeDataType type;
00069                 int stride;
00070                 CL_VertexArrayBufferProvider *array_provider;
00071                 bool single_value;
00072                 union
00073                 {
00074                         void *data;
00075                         unsigned char value_ubyte[4];
00076                         char value_byte[4];
00077                         unsigned short value_ushort[4];
00078                         short value_short[4];
00079                         unsigned int value_uint[4];
00080                         int value_int[4];
00081                         float value_float[4];
00082                         bool value_boolean;
00083                 };
00084         };
00085 
00086         int num_attributes;
00087         int *attribute_indexes;
00088         VertexData *attributes;
00089         bool *normalize_attributes;
00090 };
00091 
00095 class CL_API_DISPLAY CL_GraphicContextProvider
00096 {
00099 
00100 public:
00101         virtual ~CL_GraphicContextProvider() { return; }
00102 
00106 
00107 public:
00109         virtual int get_max_attributes() = 0;
00110 
00112 
00114         virtual CL_Size get_max_texture_size() const = 0;
00115 
00117         virtual int get_width() const = 0;
00118 
00120         virtual int get_height() const = 0;
00121 
00125 
00126 public:
00128         virtual void destroy() = 0;
00129 
00131         virtual CL_GraphicContext create_worker_gc() = 0;
00132 
00134         virtual CL_PixelBuffer get_pixeldata(const CL_Rect& rect) const = 0;
00135 
00137         virtual CL_TextureProvider *alloc_texture(CL_TextureDimensions texture_dimensions) = 0;
00138 
00140         virtual CL_OcclusionQueryProvider *alloc_occlusion_query() = 0;
00141 
00143         virtual CL_ProgramObjectProvider *alloc_program_object() = 0;
00144 
00146         virtual CL_ShaderObjectProvider *alloc_shader_object() = 0;
00147 
00149         virtual CL_FrameBufferProvider *alloc_frame_buffer() = 0;
00150 
00152         virtual CL_RenderBufferProvider *alloc_render_buffer() = 0;
00153 
00155         virtual CL_VertexArrayBufferProvider *alloc_vertex_array_buffer() = 0;
00156 
00158         virtual CL_ElementArrayBufferProvider *alloc_element_array_buffer() = 0;
00159 
00161         virtual void set_program_object(CL_StandardProgram standard_program) = 0;
00162 
00164         virtual void set_program_object(const CL_ProgramObject &program) = 0;
00165 
00167         virtual void reset_program_object() = 0;
00168 
00170         virtual void set_texture(int unit_index, const CL_Texture &texture) = 0;
00171 
00173         virtual void reset_texture(int unit_index) = 0;
00174 
00176         virtual void set_frame_buffer(const CL_FrameBuffer &buffer) = 0;
00177 
00179         virtual void reset_frame_buffer() = 0;
00180 
00182         virtual void set_blend_mode(const CL_BlendMode &blendmode) = 0;
00183 
00185         virtual void set_buffer_control(const CL_BufferControl &buffer_control) = 0;
00186 
00188         virtual void set_pen(const CL_Pen &pen) = 0;
00189 
00191         virtual void set_polygon_rasterizer(const CL_PolygonRasterizer &raster) = 0;
00192 
00194         virtual void draw_primitives(CL_PrimitivesType type, int num_vertices, const CL_PrimitivesArrayData * const prim_array) = 0;
00195 
00197         virtual void set_primitives_array(const CL_PrimitivesArrayData * const prim_array) = 0;
00198 
00200         virtual void draw_primitives_array(CL_PrimitivesType type, int offset, int num_vertices) = 0;
00201 
00207         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned int *indices) = 0;
00208 
00214         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned short *indices) = 0;
00215 
00221         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, unsigned char *indices) = 0;
00222 
00230         virtual void draw_primitives_elements(CL_PrimitivesType type, int count, CL_ElementArrayBufferProvider *array_provider, CL_VertexAttributeDataType indices_type, void *offset) = 0;
00231 
00233         virtual void primitives_array_freed(const CL_PrimitivesArrayData * const prim_array) = 0;
00234 
00236         virtual void reset_primitives_array() = 0;
00237 
00239         virtual void draw_pixels(float x, float y, float zoom_x, float zoom_y, const CL_PixelBufferRef &pixel_buffer, const CL_Colorf &color) = 0;
00240 
00242         virtual void set_clip_rect(const CL_Rect &rect) = 0;
00243 
00245         virtual void reset_clip_rect() = 0;
00246 
00248         virtual void clear(const CL_Colorf &color) = 0;
00249 
00253         virtual void clear_depth(float value) = 0;
00254 
00258         virtual void clear_stencil(int value) = 0;
00259 
00261         virtual void set_map_mode(CL_MapMode mode) = 0;
00262 
00264         virtual void set_viewport(const CL_Rectf &viewport) = 0;
00265 
00267         virtual void set_projection(const CL_Mat4f &matrix) = 0;
00268 
00270         virtual void set_modelview(const CL_Mat4f &matrix) = 0;
00271 
00275 
00276 private:
00278 };
00279 

Generated on Thu Dec 3 02:39:29 2009 for ClanLib by  doxygen 1.4.6