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

target_ggi_db.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: target_ggi_db.cpp,v 1.2 2001/03/17 23:53:24 vaidhy 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 #include "Core/precomp.h"
00016 
00017 #ifdef USE_GGI
00018 
00019 #include <API/Core/System/error.h>
00020 #include <API/Display/Display/palette.h>
00021 #include <Display/Display/GGI/target_ggi.h>
00022 #include <Display/Display/GGI/target_ggi_db.h>
00023 #include "API/Core/System/cl_assert.h"
00024 #include "Core/System/Generic/string_asm.h"
00025 
00026 #include <iostream>
00027 #include <string.h>
00028 #include <math.h>
00029 #include <sys/mman.h>
00030 
00031 CL_Target_GGI_DB::CL_Target_GGI_DB(ggi_visual_t vis, int frame) : CL_Target_GGI(vis)
00032 {
00033         m_frame = frame;
00034 
00035         if (! (m_db = ggiDBGetBuffer (vis, frame)))
00036         {
00037                 throw CL_Error("CL_Target_GGI: No DirectBuffer available.");
00038         }
00039 
00040         if (! (m_db->type & GGI_DB_SIMPLE_PLB))
00041         {
00042                 throw CL_Error("CL_Target_GGI: non-standard display buffer!");
00043         }
00044 }
00045 
00046 CL_Target_GGI_DB::~CL_Target_GGI_DB()
00047 {
00048 }
00049 
00050 void CL_Target_GGI_DB::lock()
00051 {
00052         if (ggiResourceAcquire( m_db->resource, GGI_ACTYPE_WRITE ))
00053         {
00054                 throw CL_Error("CL_Target_GGI: Error acquiring DirectBuffer");
00055         }
00056         m_fb = m_db->write;
00057 }
00058         
00059 void CL_Target_GGI_DB::unlock()
00060 {
00061         ggiResourceRelease( m_db->resource );
00062 }
00063 
00064 void *CL_Target_GGI_DB::get_data() const
00065 {
00066         return m_fb;
00067 }
00068 
00069 void CL_Target_GGI_DB::to_front()
00070 {
00071         ggiSetDisplayFrame( m_vis, m_frame );
00072 //      ggiSetDisplayFrame( m_vis, 2 );
00073         ggiFlush( m_vis );
00074 }
00075 
00076 void CL_Target_GGI_DB::to_back()
00077 {
00078         ggiSetWriteFrame( m_vis, m_frame );
00079 }
00080 
00081 unsigned int CL_Target_GGI_DB::get_width() const
00082 {
00083         return m_mode.virt.x;
00084 }
00085 
00086 unsigned int CL_Target_GGI_DB::get_height() const
00087 {
00088         return m_mode.virt.y;
00089 }
00090 
00091 unsigned int CL_Target_GGI_DB::get_pitch() const
00092 {
00093         return m_db->buffer.plb.stride;
00094 }
00095 
00096 unsigned int CL_Target_GGI_DB::get_depth() const
00097 {
00098         return m_db->buffer.plb.pixelformat->depth;
00099 }
00100 
00101 unsigned int CL_Target_GGI_DB::get_red_mask() const
00102 {
00103         return m_db->buffer.plb.pixelformat->red_mask;
00104 }
00105 
00106 unsigned int CL_Target_GGI_DB::get_green_mask() const
00107 {
00108         return m_db->buffer.plb.pixelformat->green_mask;
00109 }
00110 
00111 unsigned int CL_Target_GGI_DB::get_blue_mask() const
00112 {
00113         return m_db->buffer.plb.pixelformat->blue_mask;
00114 }
00115 
00116 unsigned int CL_Target_GGI_DB::get_alpha_mask() const
00117 {
00118         return m_db->buffer.plb.pixelformat->alpha_mask;
00119 }
00120 
00121 CL_Palette *CL_Target_GGI_DB::get_palette() const
00122 {
00123         return NULL;
00124 }
00125 
00126 #endif

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