Exemplo n.º 1
0
void MyApp::OnPaint3D()
{ 
  // set rendertarget

  sSetTarget(sTargetPara(sST_CLEARALL,0xff405060)); 

  // get timing

  Timer.OnFrame(sGetTime());
  static sInt time;
  if(sHasWindowFocus())
    time = Timer.GetTime();

  // set camera

  View.SetTargetCurrent();
  View.SetZoom(1.0f);
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0015f);
  View.Model.l.Init(0,0,0);
  View.Camera.l.Init(0,0,-8);
  View.Prepare();

  // set material

  sCBuffer<TestMain> cb;
  sCBuffer<TestTrans> cbt;
  sCBuffer<TestPS1> cb2;
  sCBuffer<TestPS2> cb3;

  cb.Data->ms_ss = View.ModelScreen;
  cb2.Data->Mul.InitColor(0xff406080);
  cb3.Data->Add.InitColor(0x00000000);
  
  // draw

  for(sInt i=0;i<27;i++)
  {
    cbt.Modify();
    cbt.Data->mat[0].Init(1,0,0,((i/1)%3-1)*3.0f);
    cbt.Data->mat[1].Init(0,1,0,((i/3)%3-1)*3.0f);
    cbt.Data->mat[2].Init(0,0,1,((i/9)%3-1)*3.0f);

    cb3.Modify();
    sF32 f = sFSin(i*0.5f+time*0.01f)*0.25f+0.5f;
    cb3.Data->Add.Init(f,f,f,0);

    Mtrl->Set(&cb,&cb2,&cb3,&cbt);
    Geo->Draw();
  }

  // debug output

  sF32 avg = Timer.GetAverageDelta();
  Painter->SetTarget();
  Painter->Begin();
  Painter->SetPrint(0,0xff000000,2);
  Painter->SetPrint(0,~0,2);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}
Exemplo n.º 2
0
void contactMerge::sPopulateCntctMenu(QMenu *pMenu)
{
  if (_cntct->id() == -1)
    return;

  QAction *menuItem;

  if (_cntct->altId() == 0 || // cNone
      _cntct->altId() == 4)  // cError
  {
    menuItem = pMenu->addAction(tr("Set as Source..."), this, SLOT(sAdd()));
  }

  if (_cntct->altId() != 1) // cTarget
  {
    menuItem = pMenu->addAction(tr("Set as Target..."), this, SLOT(sSetTarget()));
  }

  if (_cntct->altId() == 1 || // cTarget
      _cntct->altId() == 2)  // cSource
  {
    menuItem = pMenu->addAction(tr("Deselect..."), this, SLOT(sDeselectCntct()));
  }

  if (_cntct->altId() == 3) // cMerged
  {
    menuItem = pMenu->addAction(tr("Restore..."), this, SLOT(sRestore()));
    menuItem = pMenu->addAction(tr("Purge..."), this, SLOT(sPurge()));
  }

  pMenu->addSeparator();

  menuItem = pMenu->addAction(tr("Edit..."), this, SLOT(sCntctEdit()));
  menuItem->setEnabled(_privileges->check("MaintainContacts"));

  menuItem = pMenu->addAction(tr("View..."), this, SLOT(sCntctView()));
  menuItem->setEnabled(_privileges->check("MaintainContacts") || _privileges->check("ViewContacts"));

  if (_cntct->altId() != 3) // cMerged
  {
    // Check to see if this contact is used, if not add delete action
    ParameterList params;
    params.append("cntct_id", _cntct->id());
    MetaSQLQuery mql = mqlLoad("contactmerge", "contactused");
    q = mql.toQuery(params);
    if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
    if (q.first() && !q.value("used").toBool())
    {
        menuItem = pMenu->addAction(tr("Delete"), this, SLOT(sCntctDelete()));
        menuItem->setEnabled(_privileges->check("MaintainContacts"));
    }
  }
}
Exemplo n.º 3
0
void MyApp::PaintScreen(sInt screen,sInt time)
{ 
  time += screen*1234;

  // set rendertarget

  static sU32 colors[4] = { 0xff405060,0xffc04040,0xff40c040,0xff4040c0 };

  sTargetPara tp(sST_CLEARALL,colors[screen&3],0,sGetScreenColorBuffer(screen),sGetScreenDepthBuffer(screen));

  sSetTarget(tp);

  // set camera

  View.SetTargetCurrent();
  View.SetZoom(1.0f);
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0015f);
  View.Model.l.Init(0,0,0);
  View.Camera.l.Init(0,0,-4);
  View.Prepare();

  // set material

  sCBuffer<sSimpleMaterialEnvPara> cb;
  cb.Data->Set(View,Env);
  Mtrl->Set(&cb);

  // draw

  Geo->Draw();

  // debug

  sF32 avg = Timer.GetAverageDelta();
  Painter->SetTarget();
  Painter->Begin();
  Painter->SetPrint(0,0xff000000,2);
  Painter->SetPrint(0,~0,2);
  Painter->PrintF(10,10,L"screen %d: %s",screen,ScreenNames[screen]);
  if (screen)
    Painter->PrintF(10,30,L"on %s",AdapterName);
  else
    Painter->PrintF(10,30,L"%5.2ffps %5.3fms",1000.0f/avg,avg);
  Painter->End();

  // resolve multisampling

  sResolveTarget();
}
Exemplo n.º 4
0
void MyApp::OnPaint3D()
{
  // clear screen

  sSetTarget(sTargetPara(sCLEAR_ALL,0xff405060));

  // timing

  Timer.OnFrame(sGetTime());
  sInt time = Timer.GetTime();

  // set camera

  View.SetTargetCurrent();
  View.Model.EulerXYZ(time*0.00041f,time*0.00043f,time*0.00045f);
  View.SetZoom(1);
  View.Camera.l.Init(0,0,-2);
  View.Prepare();

  // set material

  sMatrix34 mat = View.Camera;

  sCBuffer<TestMtrlHSPara> cbh;
  sCBuffer<TestMtrlGSPara> cbg;
  cbg.Data->mvp = View.ModelScreen;
  cbg.Data->ldir.Init(-View.ModelView.i.z,-View.ModelView.j.z,-View.ModelView.k.z,0);
//  cbg.Data->uvoffset.Init(time*0.00011f,time*0.00012f,time*0.00013f,time*0.00014f);
  cbh.Data->tess.Init(4-sCos(time*0.0001)*3,0,0,0);
  Mtrl->Set(&cbh,&cbg);

  // draw 

  Geo->Draw();

  // debug out: framerate.
  sF32 avg = Timer.GetAverageDelta();
  Painter->Begin();
  Painter->SetTarget();
  Painter->SetPrint(0,~0,1);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}
Exemplo n.º 5
0
void MyApp::OnPaint3D()
{
  sVector30 n;
  sVector31 p;
  sMatrix34 mat;
  sMatrix44 mat4;

  // timer

  Timer.OnFrame(sGetTime());
  sInt time = Timer.GetTime();

  // init viewport

  View.Camera.EulerXYZ(0.3,time*0.0001f,0);
  View.Camera.l = sVector31(View.Camera.k * -3);
  View.Model.Init();
  View.SetTargetCurrent();
  View.SetZoom(1.5f);
  View.Prepare();

  // start painting

  sSetTarget(sTargetPara(sST_CLEARALL,0xff405060));
  sCBuffer<TorusPara> cb;
  cb.Data->mvp = View.ModelScreen;
  cb.Data->scale.x = sFSin(time*0.004f)*0.125f;

  // torus: paint a ring of rings

  TorusMtrl->Set(&cb);
  TorusGeo->Draw();

  // paint debug info

  sF32 avg = Timer.GetAverageDelta();
  Painter->Begin();
  Painter->SetPrint(0,~0,1);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}
Exemplo n.º 6
0
void MyApp::OnPaint3D()
{
  // clear screen

  sSetTarget(sTargetPara(sCLEAR_ALL,0xff405060));

  // timing

  Timer.OnFrame(sGetTime());
  sInt time = Timer.GetTime();

  // set camera

  View.SetTargetCurrent();
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0012f);
  View.SetZoom(1);
  View.Camera.l.Init(0,0,-2);
  View.Prepare();

  // set material

  sCBuffer<MaterialFlatPara> MtrlPara;
  MtrlPara.Data->mvp = View.ModelScreen;
  MtrlPara.Data->ldir.Init(-View.ModelView.i.z,-View.ModelView.j.z,-View.ModelView.k.z,0);
  Mtrl->Set(&MtrlPara);

  // draw a cube

  Geo->Draw();

  // debug out: framerate.
  sF32 avg = Timer.GetAverageDelta();
  Painter->Begin();
  Painter->SetPrint(0,~0,1);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}
Exemplo n.º 7
0
void MyApp::OnPaint3D()
{ 
  // set rendertarget

  sTargetPara tp;

  tp.ClearColor[0].InitColor(0xff405060);
  tp.ClearColor[1].InitColor(0xff808080);
  tp.Flags = sST_CLEARALL;
  tp.Depth = sGetScreenDepthBuffer();
  tp.Target[0] = RT[0];
  tp.Target[1] = RT[1];
  tp.Target[2] = RT[2];
  tp.Aspect = sGetScreenAspect();
  tp.Window.Init(0,0,RT[0]->SizeX,RT[0]->SizeY);

  sSetTarget(tp);

  // get timing

  Timer.OnFrame(sGetTime());
  static sInt time;
  if(sHasWindowFocus())
    time = Timer.GetTime();

  // set camera

  View.SetTargetCurrent();
  View.SetZoom(1.0f);
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0015f);
  View.Model.l.Init(0,0,0);
  View.Camera.l.Init(0,0,-4);
  View.Prepare();
 
  // set material

  sCBuffer<MrtVSPara> cb;
  cb.Data->Set(View,Env);
  CubeMtrl->Set(&cb);

  // draw

  CubeGeo->Draw();
 
  // blit

  sViewport View2;
  View2.Orthogonal = sVO_SCREEN;

  sSetTarget(sTargetPara(0,0,0,sGetScreenColorBuffer(),0));
  sCBuffer<MrtVSPara> cb2;
  cb2.Data->Set(View2,Env);
  sCBuffer<MrtPSPara> cbp;
  cbp.Data->Set(View2,Env);
  BlitMtrl->Set(&cb2,&cbp);
  BlitGeo->Draw();

  // debug output

  sF32 avg = Timer.GetAverageDelta();
  Painter->SetTarget();
  Painter->Begin();
  Painter->SetPrint(0,0xff000000,2);
  Painter->SetPrint(0,~0,2);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}
Exemplo n.º 8
0
void s3DWindow::OnPaint3D()
{
  if(Enable)
  {
    // initial setup

    QuakeCam();                   // quake cam
    PrepareView();                // viewport
  }

  sScreenMode sm;
  sGetScreenMode(sm);

  if(Enable && !Client.IsEmpty())
  {
    // repare rendertarget spec

    sTargetSpec spec;
#if sRENDERER==sRENDER_DX11       // blit back
    sInt xs = Client.SizeX();
    sInt ys = Client.SizeY();
    if(ColorRT==0 || xs!=ColorRT->SizeX || ys!=ColorRT->SizeY || sm.MultiLevel!=RTMultiLevel)
    {
      sDelete(ColorRT);
      sDelete(DepthRT);
      ColorRT = new sTexture2D(xs,ys,sTEX_2D|sTEX_ARGB8888|sTEX_RENDERTARGET|sTEX_MSAA,1);
      DepthRT = new sTexture2D(xs,ys,sTEX_2D|sTEX_DEPTH24|sTEX_RENDERTARGET|sTEX_MSAA,1);
      RTMultiLevel = sm.MultiLevel;
    }
    spec.Depth = DepthRT;
    spec.Color = ColorRT;
    spec.Window.Init(0,0,xs,ys);
#else
    spec.Init(Client);
#endif

    // painting

    Paint(View);                  // paint 3d
    Paint(View,spec);

    View.Model.Init();            // prepare for wireframe
    View.SetTargetCurrent(&Client);
    View.Prepare();

    GridUnit = 0;                 // pain t grid
    if(Grid)
    {
      sEnableGraphicsStats(0);
      sSetTarget(sTargetPara(0,0,spec));
      PaintGrid();
      sEnableGraphicsStats(1);
    }

    PaintWire(View);                // custom wireframe
    PaintWire(View,spec);

    // screenshots

    if(ScreenshotFlag)
    {
      const sU8 *data;
      sS32 pitch;
      sTextureFlags flags;
      sImage img;

      sRect r=spec.Window;
      img.Init(r.SizeX(),r.SizeY());
      img.Fill(0xffff0000);

      sBeginReadTexture(data,pitch,flags,spec.Color2D);
      if(flags==sTEX_ARGB8888)
      {
        data += r.x0*4 + r.y0*pitch;
        sU32 *dest = img.Data;
        for(sInt y=r.y0;y<r.y1;y++)
        {
          sCopyMem(dest,data,r.SizeX()*4);
          dest += img.SizeX;
          data += pitch;
        }
      }
      sEndReadTexture();

      if(flags==sTEX_ARGB8888)
      {
        sInt nr = 0;
        sArray<sDirEntry> dir;
        sDirEntry *ent;
        sInt len = sGetStringLen(SCREENSHOTNAME);
        if(sLoadDir(dir,SCREENSHOTDIR))
        {
          sFORALL(dir,ent)
          {
            if(sCmpStringILen(ent->Name,SCREENSHOTNAME,len)==0)
            {
              sInt newnr;
              const sChar *scan = ent->Name+len;
              if(sScanInt(scan,newnr))
                nr = sMax(nr,newnr);
            }
          }
        }
        else
        {
          sMakeDirAll(SCREENSHOTDIR);
        }
        sString<64> name;
        sSPrintF(name,SCREENSHOTDIR L"/" SCREENSHOTNAME L"%04d.bmp",nr+1);
        img.SaveBMP(name);
      }
Exemplo n.º 9
0
void MyApp::OnPaint3D()
{ 
  // set rendertarget

  sSetTarget(sTargetPara(sST_CLEARALL,0xff405060));

  // get timing

  Timer.OnFrame(sGetTime());
  sInt time = Timer.GetTime();

  // set camera

  View.SetTargetCurrent();
  View.SetZoom(1.0f);
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0015f);
  View.Model.l.Init(0,0,0);
  View.Camera.l.Init(0,0,-4);
  View.Prepare();
 
  // set material

  sCBuffer<sVolumeVS> cb;
  cb.Data->mvp = View.ModelScreen;
  cb.Data->mv = View.ModelView;
  sF32 s = 0.125f;
  cb.Data->scaleuv.Init(s,s,s,0);
  Mtrl->Set(&cb);

  // load vertices and indices

  sVertexStandard *vp=0;
  Geo->BeginLoadVB(24,sGD_STREAM,&vp);

  vp->Init(-1, 1,-1,  0, 0,-1, 1,0); vp++; // 3
  vp->Init( 1, 1,-1,  0, 0,-1, 1,1); vp++; // 2
  vp->Init( 1,-1,-1,  0, 0,-1, 0,1); vp++; // 1
  vp->Init(-1,-1,-1,  0, 0,-1, 0,0); vp++; // 0

  vp->Init(-1,-1, 1,  0, 0, 1, 0,1); vp++; // 4
  vp->Init( 1,-1, 1,  0, 0, 1, 1,1); vp++; // 5
  vp->Init( 1, 1, 1,  0, 0, 1, 1,0); vp++; // 6
  vp->Init(-1, 1, 1,  0, 0, 1, 0,0); vp++; // 7

  vp->Init(-1,-1,-1,  0,-1, 0, 0,0); vp++; // 0
  vp->Init( 1,-1,-1,  0,-1, 0, 0,1); vp++; // 1
  vp->Init( 1,-1, 1,  0,-1, 0, 1,1); vp++; // 5
  vp->Init(-1,-1, 1,  0,-1, 0, 0,1); vp++; // 4

  vp->Init( 1,-1,-1,  1, 0, 0, 0,1); vp++; // 1
  vp->Init( 1, 1,-1,  1, 0, 0, 1,1); vp++; // 2
  vp->Init( 1, 1, 1,  1, 0, 0, 1,0); vp++; // 6
  vp->Init( 1,-1, 1,  1, 0, 0, 1,1); vp++; // 5

  vp->Init( 1, 1,-1,  0, 1, 0, 1,1); vp++; // 2
  vp->Init(-1, 1,-1,  0, 1, 0, 1,0); vp++; // 3
  vp->Init(-1, 1, 1,  0, 1, 0, 1,1); vp++; // 7
  vp->Init( 1, 1, 1,  0, 1, 0, 1,0); vp++; // 6

  vp->Init(-1, 1,-1, -1, 0, 0, 0,1); vp++; // 3
  vp->Init(-1,-1,-1, -1, 0, 0, 0,0); vp++; // 0
  vp->Init(-1,-1, 1, -1, 0, 0, 1,0); vp++; // 4
  vp->Init(-1, 1, 1, -1, 0, 0, 0,0); vp++; // 7

  Geo->EndLoadVB();

  // draw

  Geo->Draw();

  sF32 avg = Timer.GetAverageDelta();
  Painter->SetTarget();
  Painter->Begin();
  Painter->SetPrint(0,0xff000000,2);
  Painter->SetPrint(0,~0,2);
  Painter->PrintF(10,10,L"%5.2ffps %5.3fms",1000/avg,avg);
  Painter->End();
}