Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

displaycard_gl_generic.h

Go to the documentation of this file.
00001 /*
00002         $Id: displaycard_gl_generic.h,v 1.7 2001/03/10 18:21:20 japj Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #ifndef header_displaycard_gl_generic
00016 #define header_displaycard_gl_generic
00017 
00018 #ifdef USE_OPENGL
00019 
00020 #include "API/Display/Display/palette.h"
00021 #include "Display/Display/Generic/displaycard_generic.h"
00022 
00023 #include <stack>
00024 
00025 // this is UGLY. someone do something about it some day.
00026 // OH MY GOD! This hack may burn down your PC and kill your cat!
00027 #ifdef USE_X11
00028 #include "Display/Display/X11/display_xwindow.h"
00029 class CL_GL_DisplayCard_Generic : public CL_XWindow_CompatibleCard
00030 #elif defined WIN32
00031 #include "Display/Display/DirectDraw/displaycard_win32compatible.h"
00032 class CL_GL_DisplayCard_Generic : public CL_DisplayCard_Win32Compatible
00033 #else
00034 class CL_GL_DisplayCard_Generic : public CL_DisplayCard_Generic
00035 #endif
00036 {
00037 public:
00038         CL_GL_DisplayCard_Generic(int card_no)
00039 #ifdef USE_X11
00040         : CL_XWindow_CompatibleCard(card_no)
00041 #elif defined WIN32
00042         : CL_DisplayCard_Win32Compatible(card_no)
00043 #else
00044         : CL_DisplayCard_Generic(card_no)
00045 #endif
00046         {
00047                 uses_count = 0;
00048                 translate_stack.push(std::pair<int, int>(0,0));
00049                 use_2d_projection = true;
00050         }       
00051 
00052         virtual void set_palette(CL_Palette *palette);
00053         virtual CL_Palette *get_palette();
00054 
00055         virtual std::string get_name() { return "OpenGL Display"; }
00056         virtual int get_total_memory() { return -1; }
00057         virtual bool is_initialized() { return initialized; }
00058         virtual const std::list<CL_VidMode*> &get_videomodes();
00059 
00060         virtual CL_Target *get_target();
00061         virtual CL_Target *get_frontbuffer();
00062 
00063         // whether the app uses OpenGL or not
00064         virtual bool uses_gl() { return m_uses_gl; }
00065         virtual int get_max_texture_size() = 0;
00066 
00067         virtual void begin_2d();
00068         virtual void end_2d();
00069         virtual void enable_2d_projection();
00070         virtual void disable_2d_projection();
00071 
00072         // display 2d translate support:
00073         virtual void push_translate_offset();
00074         virtual void push_translate_offset(int x, int y);
00075         virtual int  get_translate_offset_x();
00076         virtual int  get_translate_offset_y();
00077         virtual void set_translate_offset(int x, int y);
00078         virtual void pop_translate_offset();
00079 
00080         // set attribute functions
00081         virtual void set_use_gl( int v ) { gl_config.use_gl = v; }
00082         virtual void set_buffer_size( int v ) { gl_config.buffer_size = v; }
00083         virtual void set_level( int v ) { gl_config.level = v; }
00084         virtual void set_rgba( int v ) { gl_config.rgba = v; }
00085         virtual void set_doublebuffer( int v ) { gl_config.doublebuffer = v; }
00086         virtual void set_stereo( int v ) { gl_config.stereo = v; }
00087         virtual void set_aux_buffers( int v ) { gl_config.aux_buffers = v; }
00088         virtual void set_red_size( int v ) { gl_config.red_size = v; }
00089         virtual void set_green_size( int v ) { gl_config.green_size = v; }
00090         virtual void set_blue_size( int v ) { gl_config.blue_size = v; }
00091         virtual void set_alpha_size( int v ) { gl_config.alpha_size = v; }
00092         virtual void set_depth_size( int v ) { gl_config.depth_size = v; }
00093         virtual void set_stencil_size( int v ) { gl_config.stencil_size = v; }
00094         virtual void set_accum_red_size( int v ) { gl_config.accum_red_size = v; }
00095         virtual void set_accum_green_size( int v ) { gl_config.accum_green_size = v; }
00096         virtual void set_accum_blue_size( int v ) { gl_config.blue_size = v; }
00097         virtual void set_accum_alpha_size( int v ) { gl_config.alpha_size = v; }
00098         
00099         // Accelerator functions:
00100         // ----------------------
00101         virtual void clear_display(
00102                 float red,
00103                 float green,
00104                 float blue,
00105                 float alpha);
00106         
00107         virtual void fill_rect(
00108                 int x1,
00109                 int y1,
00110                 int x2,
00111                 int y2,
00112                 float r,
00113                 float g,
00114                 float b,
00115                 float a);
00116         
00117         virtual void draw_rect(
00118                 int x1,
00119                 int y1,
00120                 int x2,
00121                 int y2,
00122                 float r,
00123                 float g,
00124                 float b,
00125                 float a);
00126         
00127         virtual void draw_line(
00128                 int x1,
00129                 int y1,
00130                 int x2,
00131                 int y2,
00132                 float r,
00133                 float g,
00134                 float b,
00135                 float a);
00136 
00137         virtual void sync_buffers();
00138 
00139 protected:
00140                 
00141         virtual CL_Blitters create_hw_blitters(CL_SurfaceProvider *provider);
00142         virtual CL_Blitters create_hw_dynamic_blitters(CL_SurfaceProvider *provider);
00143         
00144         bool initialized;
00145         bool m_uses_gl;
00146         int uses_count;
00147         bool use_2d_projection;
00148 
00149         struct 
00150         {
00151                 int use_gl;
00152                 int buffer_size;
00153                 int level;
00154                 int rgba;
00155                 int doublebuffer;
00156                 int stereo;
00157                 int aux_buffers;
00158                 int red_size;
00159                 int green_size;
00160                 int blue_size;
00161                 int alpha_size;
00162                 int depth_size;
00163                 int stencil_size;
00164                 int accum_red_size;
00165                 int accum_green_size;
00166                 int accum_blue_size;
00167                 int accum_alpha_size;
00168         } gl_config;
00169         
00170 
00171 private:
00172         CL_Palette palette;
00173         std::stack< std::pair<int, int> > translate_stack;
00174 };
00175 
00176 #endif
00177 
00178 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001