_tests/fsSurfCl/main.cpp

00001 
00002 //---------------------------------------------------------------------------
00003 #include <fs/rap/fsSurfCl.h>
00004 //---------------------------------------------------------------------------
00005 using namespace fs::rap;
00006 //---------------------------------------------------------------------------
00007 namespace {
00008 //---------------------------------------------------------------------------
00009 SurfCl_t g_SurfCl(false, 512, 512);
00010 //---------------------------------------------------------------------------
00011 } // anonymous namespace
00012 //---------------------------------------------------------------------------
00013 namespace test {
00014 //---------------------------------------------------------------------------
00015 struct Client_t : public WinApp_t::EvRcvr_i
00016 {
00017     virtual void OnEvent(const WinApp_t::InitEv_t &, WinApp_t &);
00018     virtual void OnEvent(const WinApp_t::RunEv_t &, WinApp_t &);
00019 };
00020 //---------------------------------------------------------------------------
00021 void Client_t::OnEvent(const WinApp_t::InitEv_t &, WinApp_t &)
00022 {
00023     SurfCl_t::PxFmt8888_t *pData = g_SurfCl.GetData();
00024             
00025     for(int y = 0, h = g_SurfCl.GetH(); y < h; ++y)
00026     {
00027         for(int x = 0, w = g_SurfCl.GetW(); x < w; ++x)
00028         {
00029             const SurfCl_t::PxFmt8888_t Clr = {
00030              static_cast<unsigned char>(x),
00031              static_cast<unsigned char>(y),
00032              0,
00033              0,
00034             };
00035         
00036             pData[w * y + x] = Clr;
00037         }
00038     }
00039 }
00040 //---------------------------------------------------------------------------
00041 void Client_t::OnEvent(const WinApp_t::RunEv_t &, WinApp_t &App)
00042 {
00043     static int i;
00044     ++i;
00045                         
00046     SurfCl_t::PxFmt8888_t *pData = g_SurfCl.GetData();
00047     for(int y = 0, h = g_SurfCl.GetH() / 2; y < h; ++y)
00048     {
00049         for(int x = 0, w = g_SurfCl.GetW(); x < w; ++x)
00050         {
00051             const SurfCl_t::PxFmt8888_t Clr = {
00052              static_cast<unsigned char>(x),
00053              static_cast<unsigned char>(y),
00054              static_cast<unsigned char>(x*y*i/1000),
00055              0
00056             };
00057         
00058             pData[w * y + x] = Clr;
00059         }
00060     }
00061     
00062     // send 'redraw' request
00063     App.Redraw();
00064 }
00065 //---------------------------------------------------------------------------
00066 } // namespace test
00067 //---------------------------------------------------------------------------
00068 namespace fs { namespace rap {
00069 //---------------------------------------------------------------------------
00070 bool WinAppInit(WinApp_t &App, WinApp_t::InitCfg_t &Cfg)
00071 {
00072     // modify default configuration
00073     Cfg.m_pszTitle = "SurfCl_t test";
00074     Cfg.m_nClW = 512;
00075     Cfg.m_nClH = 512;
00076     Cfg.m_bClrBgr = false;
00077     Cfg.m_bRtm = true; // enable 'run-time mode'
00078             
00079     // register event receivers, the order could be important
00080     static test::Client_t Client;
00081     App.RegEvRcvr(&g_SurfCl);
00082     App.RegEvRcvr(&Client);
00083         
00084     return true;
00085 }
00086 //---------------------------------------------------------------------------
00087 }} // namespace fs::rapid
00088 //---------------------------------------------------------------------------

FipS' Code (Thu Feb 15 22:43:35 2007) - (c) Filip STOKLAS (FipS) - [ www ] [ Guest Book ]