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

target_ximage_dga.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: target_ximage_dga.cpp,v 1.1 2001/03/06 15:09:17 mbn 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 #include <API/Display/Display/palette.h>
00017 #include <Display/Display/X11/target_ximage_dga.h>
00018 #include "API/Core/System/cl_assert.h"
00019 
00020 #include <iostream>
00021 #include <string.h>
00022 
00023 CL_Target_XImage_DGA::CL_Target_XImage_DGA(
00024         XVisualInfo visual_info,
00025         Display *dpy,
00026         unsigned int width,
00027         unsigned int height)
00028 {
00029 /*      m_visual_info = visual_info;
00030         m_dpy = dpy;
00031         m_width = width;
00032         m_height = height;
00033 
00034         // Figure out what the depth and pitch is:
00035         int num_formats;
00036         XPixmapFormatValues *formats = XListPixmapFormats(m_dpy, &num_formats);
00037         for (int i=0; i<num_formats; i++)
00038         {
00039                 if (formats[i].depth == m_visual_info.depth)
00040                 {
00041                         m_depth = formats[i].bits_per_pixel;
00042                         m_pitch = (width*m_depth+formats[i].scanline_pad-1)/formats[i].scanline_pad;
00043                         m_pitch *= formats[i].scanline_pad;
00044                         m_pitch = (m_pitch+7)/8;
00045                         break;
00046                 }
00047         }
00048         XFree(formats);
00049         
00050         // Create image:
00051         int image_size = get_pitch()*height;
00052         
00053         m_dga_image = XDGACreateImage(
00054                 dpy,
00055                 visual_info.visual,
00056                 visual_info.depth, // PTC does this: DefaultDepth(dpy,0),
00057                 ZPixmap,
00058                 NULL,
00059                 &m_dgainfo,
00060                 width,
00061                 height);
00062         
00063         cl_assert(m_dga_image != NULL);
00064 
00065         // Create shared memory segment:
00066         m_dgainfo.dgaid = dgaget(IPC_PRIVATE, image_size, IPC_CREAT|0777);
00067         cl_assert(m_dgainfo.dgaid >= 0);
00068         
00069         // Get memory address to segment:
00070         m_dgainfo.dgaaddr = (char *) dgaat(m_dgainfo.dgaid, 0, 0);
00071         
00072         // Tell XServer that it may only read from it and attach to display:
00073         m_dgainfo.readOnly = True;
00074         XDGAAttach (dpy, &m_dgainfo);
00075 
00076         // Fill the XImage struct:
00077         m_dga_image->data = m_dgainfo.dgaaddr;*/
00078 }
00079                 
00080 CL_Target_XImage_DGA::~CL_Target_XImage_DGA()
00081 {
00082 /*      XDestroyImage(m_dga_image);
00083 
00084         // Detach dga image from display:
00085         XDGADetach (m_dpy, &m_dgainfo);
00086         
00087         // Clean up shared memory:
00088         dgadt(m_dgainfo.dgaaddr);
00089         dgactl(m_dgainfo.dgaid, IPC_RMID, 0);*/
00090 }
00091 
00092 void CL_Target_XImage_DGA::put_image(int x, int y, Drawable win, GC gc)
00093 {
00094 /*      XDGAPutImage(
00095                 m_dpy,
00096                 win,
00097                 gc,
00098                 m_dga_image,
00099                 0, 0,
00100                 x, y,
00101                 m_width,
00102                 m_height,
00103                 False);*/
00104 }
00105 
00106 void CL_Target_XImage_DGA::put_image(
00107         int x, int y,
00108         const class CL_Rect &rect,
00109         Drawable win, GC gc)
00110 {
00111 }
00112 
00113 void CL_Target_XImage_DGA::lock()
00114 {
00115 //      return true;
00116 }
00117         
00118 void CL_Target_XImage_DGA::unlock()
00119 {
00120 }
00121 
00122 void *CL_Target_XImage_DGA::get_data() const
00123 {
00124         return m_dga_image->data;
00125 }
00126 
00127 unsigned int CL_Target_XImage_DGA::get_width() const
00128 {
00129         return m_width;
00130 }
00131 
00132 unsigned int CL_Target_XImage_DGA::get_height() const
00133 {
00134         return m_height;
00135 }
00136 
00137 unsigned int CL_Target_XImage_DGA::get_pitch() const
00138 {
00139         return m_pitch;
00140 }
00141         
00142 unsigned int CL_Target_XImage_DGA::get_depth() const
00143 {
00144         return m_depth;
00145 }
00146 
00147 unsigned int CL_Target_XImage_DGA::get_red_mask() const
00148 {
00149         return m_visual_info.red_mask;
00150 }
00151 
00152 unsigned int CL_Target_XImage_DGA::get_green_mask() const
00153 {
00154         return m_visual_info.green_mask;
00155 }
00156 
00157 unsigned int CL_Target_XImage_DGA::get_blue_mask() const
00158 {
00159         return m_visual_info.blue_mask;
00160 }
00161 
00162 bool CL_Target_XImage_DGA::is_indexed() const
00163 {
00164         return false;
00165 }
00166 
00167 unsigned int CL_Target_XImage_DGA::get_alpha_mask() const
00168 {
00169 //      return m_visual_info.alpha_mask; // no alpha mask in visualinfo struct!?
00170         return 0;
00171 }
00172 
00173 CL_Palette *CL_Target_XImage_DGA::get_palette() const
00174 {
00175         return NULL;
00176 }

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