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

displaycard_directdraw.h

Go to the documentation of this file.
00001 /*
00002         $Id: displaycard_directdraw.h,v 1.3 2001/03/24 22:30:37 plasmoid 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_directdraw
00016 #define header_displaycard_directdraw
00017 
00018 #include "displaycard_win32compatible.h"
00019 
00020 
00021 #include "dx_target.h"
00022 
00023 class CL_DisplayCard_DirectDraw : public CL_DisplayCard_Win32Compatible
00024 {
00025 public:
00026         CL_DisplayCard_DirectDraw(
00027                 int card_no,
00028                 LPGUID card_guid,
00029                 std::string card_name);
00030 
00031         virtual ~CL_DisplayCard_DirectDraw();
00032 
00033         // CL_DisplayCard functions:
00034         // -------------------------
00035 
00036         virtual void set_palette(CL_Palette *palette);
00037         virtual CL_Palette *get_palette();
00038         virtual void flip_display(bool sync=false);
00039         virtual void put_display(const class CL_Rect &rect);
00040         virtual void set_videomode(
00041                 int width,
00042                 int height,
00043                 int bpp,
00044                 bool full_screen,
00045                 bool allow_resize,
00046                 bool video_memory);
00047 
00048         virtual void clear_display(float red=0, float green=0, float blue=0, float alpha=1);
00049         virtual void fill_rect(int x1, int y1, int x2, int y2, float r, float g, float b, float a);
00050         //virtual void draw_rect(int x1, int y1, int x2, int y2, float r, float g, float b, float a);
00051 
00052         virtual std::string get_name();
00053         virtual const std::list<CL_VidMode*> &get_videomodes();
00054         virtual int get_total_memory() { return -1; }
00055 
00056         virtual CL_Target *get_target() { return back_buffer; }
00057 
00058         virtual bool is_initialized() { return (get_hwnd() != NULL); }
00059 
00060         virtual void sync_buffers();
00061 
00062         // CL_DisplayCard_Generic functions:
00063         // ---------------------------------
00064 
00065         virtual CL_Target *get_frontbuffer() { return front_buffer; }
00066         virtual CL_Blitters create_hw_blitters(CL_SurfaceProvider *provider);
00067 
00068         // Used by CL_Blit_DX:
00069         // -------------------
00070 
00071         DDCAPS get_hel_caps();
00072         DDCAPS get_hal_caps();
00073         LPDIRECTDRAW get_directdraw() { return directdraw; }
00074         CL_Target_DX *get_back_buffer() { return back_buffer; }
00075 
00076 private:
00077         virtual void init_palette();
00078 
00079         void deinit();
00080 
00081         void enumerate_displaymodes();
00082         void destroy_displaymodes();
00083         static HRESULT CALLBACK enumerate_callback(
00084                 LPDDSURFACEDESC lpDDSurfaceDesc,
00085                 LPVOID lpContext);
00086 
00087         void create_fullscreen_targets(bool video_memory);
00088         void create_windowed_targets(bool video_memory);
00089         void create_windowed_backbuffer(int width, int height);
00090 
00091         void on_resize(int x, int y);
00092 
00093 private:
00094         LPDIRECTDRAW directdraw; 
00095         CL_Target_DX *back_buffer;
00096 
00097         class CL_FrontbufferTarget_DX : public CL_Target_DX
00098         {
00099         public:
00100                 CL_FrontbufferTarget_DX(
00101                         LPDIRECTDRAWSURFACE surf,
00102                         CL_DisplayCard_DirectDraw *parent);
00103                 virtual ~CL_FrontbufferTarget_DX() { ; }
00104                 virtual void *get_data() const;
00105                 virtual unsigned int get_width() const { return m_parent->get_width(); }
00106                 virtual unsigned int get_height() const { return m_parent->get_height(); }
00107         private:
00108                 CL_DisplayCard_DirectDraw *m_parent;
00109         };
00110         CL_Target_DX *front_buffer;
00111         bool can_flip;
00112         bool use_software_surfaces;
00113 
00114         CL_Palette pal;
00115 
00116         int card_no;
00117         LPGUID card_guid;
00118         std::string card_name;
00119 
00120         std::list<CL_VidMode*> videomodes;
00121 
00122         bool backbuffer_in_video_memory;
00123         CL_Slot slot_resize;
00124 };
00125 
00126 #endif

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