Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


RipeTomatoe

Member Since 25 Feb 2010
Offline Last Active Feb 29 2012 11:24 PM

Topics I've Started

[C++ DirectX9] Render to Texture

21 February 2012 - 07:12 PM

Let's just jump straight into code:

void beginRender(void)
{
  pd3dDev->GetRenderTarget(0, &pBackBuffer);
  pRenderTexture->GetSurfaceLevel(0, &pRenderSurface);
  pd3dDev->SetRenderTarget(0, pRenderSurface);
  pd3dDev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
  pd3dDev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
  pd3dDev->BeginScene();
};
void endRender(void)
{
  pd3dDev->EndScene();
  //Do RTT
  effect->SetTexture("Screen", pRenderTexture);
  effect->SetTechnique(effect->GetTechniqueByName("BlackAndWhite"));
  pd3dDev->SetRenderTarget(0, pBackBuffer);
  pd3dDev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(100, 0, 0), 1.0f, 0);
  pd3dDev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
  pd3dDev->BeginScene();
  setUIVertDecl();
  pd3dDev->SetTexture(0, pRenderTexture);
  pd3dDev->SetStreamSource(0, pRenderVB, 0, sizeof(VERTEX2D));
  UINT cPasses;
  effect->Begin(&cPasses, 0);
  for(UINT i = 0; i < cPasses; i++)
  {
   effect->BeginPass(i);
   pd3dDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
   effect->EndPass();
  }
  effect->End();
  pd3dDev->SetTexture(0, NULL);
  pd3dDev->EndScene();
  pd3dDev->Present(NULL, NULL, NULL, NULL);
  mouseState.x = mouseState.y = 0;
  SetCursorPos(wWidth/2,wHeight/2);
};

So basically this code works flawlessly on my laptop, but when I try and run it on my desktop the texture is black. I've experimented with the shader and the shader is working fine. The scene itself renders fine when I don't save it to a texture. I'm really stumped on this one, if anyone needs more code snippets I'll be happy to show some more.

Thanks in advance,
Daniel (Ripe)

[FMOD] Sound Card Problems.

27 November 2010 - 08:39 AM

http://www.fmod.org/forum/viewtopic.php?t=13593

That's my original thread over on the fmod forums. I decided to post here as well just to get more feedback, I'm really stuck. It's not hindering the development of my game, but I know that compatibility will be a big issue when my game is tested.

Thanks for your help in advance.

-Ripe

Texturing a Circle

25 February 2010 - 05:46 PM

OK, this should be a quick answer, but I need to texture a circle (home made coding a circle) if you need I can post how I do it, but it's really math intensive and I don't want to scare people. Also I need to know how to rotate it (once again HOME MADE ROTATE, none of that glRotatef crap) when need be. thanks in advance for all the help.

PARTNERS