void CGUIWindowTestPatternDX::DrawCheckers(int top, int left, int bottom, int right)
{
  int c = (bottom-top+1)*(1+(right-left)/2);
  if (c < 1)
    return;
  CUSTOMVERTEX* vert = new CUSTOMVERTEX[c];
  int i=0;
  for (int y = top; y <= bottom; y++)
  {
    for (int x = left; x <= right; x += 2)
    {
      if (y % 2 == 0)
      {
        vert[i].x = (float)x;
        vert[i].y = (float)y;
        vert[i].z = 0.5f;
        vert[i].rhw = 1.0f;
        vert[i].color = D3DCOLOR_COLORVALUE(m_white, m_white, m_white, 1.0f);
      }
      else
      {
        vert[i].x = (float)x+1.0f;
        vert[i].y = (float)y;
        vert[i].z = 0.5f;
        vert[i].rhw = 1.0f;
        vert[i].color = D3DCOLOR_COLORVALUE(m_white, m_white, m_white, 1.0f);
      }
      ++i;
    }
  }
  g_Windowing.Get3DDevice()->SetFVF(D3DFVF_CUSTOMVERTEX);
  g_Windowing.Get3DDevice()->DrawPrimitiveUP(D3DPT_POINTLIST, i, vert, sizeof(CUSTOMVERTEX));

  delete [] vert;
}
Exemple #2
0
		bool DX::Clear(unsigned int count, const Common::Rect<int> *rect, clearFlag flags, Rendering::Color &color, float z, unsigned int stencil)
		{				
			D3DCOLOR d3dColor = D3DCOLOR_COLORVALUE(color.r, color.g, color.b, color.a);

			//SOC_dword flag;
			//if(flags & CLEAR_FLAG_TARGET)
			//	flag |= D3DCLEAR_TARGET;
			//if(flags & CLEAR_FLAG_STENCIL)
			//	flag |= D3DCLEAR_STENCIL

			bool success = false;

			if(rect == nullptr)	
				success = SUCCEEDED( device->Clear(0, NULL, flags, d3dColor, z, stencil) );
			else
			{
				D3DRECT d3dRect;
				d3dRect.x1 = rect->x;
				d3dRect.y1 = rect->y;
				d3dRect.x2 = rect->x + rect->size.w;
				d3dRect.y2 = rect->y + rect->size.h;

				success = SUCCEEDED( device->Clear(count, &d3dRect, flags, d3dColor, z, stencil) );
			}

			return success;
		}
/*
* draws the Emitter
* @author Rigardt de Vries
* @return void
*/
void
CPICParticleEmitter::Draw()
{
	if (!m_pVertexBuffer)
    {
        return;
    }
    if (!IsEmpty() )
	{
		TVertexParticleSize* pv;
		DWORD dwNumParticlesInBatch = 0;
		PreDraw();
        CRenderer* pRenderer = CTotalCubeDomination::GetInstance().GetRenderer();

		if (m_ePICType == PIC_BULLET_DAMAGE)
		{
			CTextureManager::GetInstance().SetTexture(0, s_uiBulletDamageID);
		}
		else if (m_ePICType == PIC_BULLET_SPEED)
		{
			CTextureManager::GetInstance().SetTexture(0, s_uiBulletMoveID);
		}
		else if (m_ePICType == PIC_MOVE_SPEED)
		{
			CTextureManager::GetInstance().SetTexture(0, s_uiMoveID);
		}
		else if (m_ePICType == PIC_EXPLODE_RADIUS)
		{
			CTextureManager::GetInstance().SetTexture(0, s_uiRadiusID);
		}
		else 
		{
			CTextureManager::GetInstance().SetTexture(0, s_uiShieldID);
		}

        pRenderer->SetWorldMatrix(m_matWorld);
		pRenderer->GetDevice()->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_PSIZE);
		pRenderer->GetDevice()->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(TVertexParticleSize) );

		SortParticles();

		m_pVertexBuffer->Lock(NULL, 0, (void**)&pv, D3DLOCK_DISCARD);

		for (int32 i = 0; i < static_cast<int32>(m_vecParticles.size() ); ++i)
		{
			pv->vec3Position = m_vecParticles[i].vec3Position;
			const D3DXCOLOR& kr = m_vecParticles[i].colour;
			pv->colour = D3DCOLOR_COLORVALUE(kr.r, kr.g, kr.b, kr.a);
			pv->fsize = m_vecParticles[i].fSize;
			pv++;
			++dwNumParticlesInBatch;			
		}
		m_pVertexBuffer->Unlock();
		//if (IsAlive() == true)
		//{
			pRenderer->GetDevice()->DrawPrimitive(D3DPT_POINTLIST, 0, dwNumParticlesInBatch);
		//}
		PostDraw();
	}
}
/*
	DrawQuad().

*/
void	CRendererDX::DrawQuad( const Base::Math::CRect &_rect, const Base::Math::CVector4 &_color, const Base::Math::CRect &_uvrect )
{
	m_pDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 );

	const fp4 w05 = (fp4)m_spDisplay->Width() * 0.5f;
	const fp4 h05 = (fp4)m_spDisplay->Height() * 0.5f;
	Base::Math::CRect r( lerpMacro( -w05, w05, _rect.m_X0 ), lerpMacro( -h05, h05, _rect.m_Y0 ), lerpMacro( -w05, w05, _rect.m_X1 ), lerpMacro( -h05, h05, _rect.m_Y1 ) );

	DWORD rgba = D3DCOLOR_COLORVALUE( _color.m_X, _color.m_Y, _color.m_Z, _color.m_W );

	struct Q {
		D3DXVECTOR3	vertex;
		uint32		color;
		D3DXVECTOR2	tc;
	};

	Q qv[4];

	qv[0].vertex = D3DXVECTOR3( r.m_X0-1.f, r.m_Y0-1.f, 0 );
	qv[1].vertex = D3DXVECTOR3( r.m_X1, r.m_Y0-1.f, 0 );
	qv[2].vertex = D3DXVECTOR3( r.m_X1, r.m_Y1, 0 );
	qv[3].vertex = D3DXVECTOR3( r.m_X0-1.f, r.m_Y1, 0 );
	qv[0].color = rgba;
	qv[1].color = rgba;
	qv[2].color = rgba;
	qv[3].color = rgba;
	qv[0].tc = D3DXVECTOR2( _uvrect.m_X0, _uvrect.m_Y0 );
	qv[1].tc = D3DXVECTOR2( _uvrect.m_X1, _uvrect.m_Y0 );
	qv[2].tc = D3DXVECTOR2( _uvrect.m_X1, _uvrect.m_Y1 );
	qv[3].tc = D3DXVECTOR2( _uvrect.m_X0, _uvrect.m_Y1 );

	if(!SUCCEEDED(m_pDevice->DrawPrimitiveUP( D3DPT_TRIANGLEFAN, 2, qv, sizeof(Q) ))) {
	    g_Log->Error("DrawPrimitiveUP 2 failed");
	}
}
Exemple #5
0
void AmjuGLDX9::Enable(uint32 flag)
{
  AMJU_CALL_STACK;

  switch (flag)
  {
  case AmjuGL::AMJU_DEPTH_WRITE:
    EnableZWrite(true);
    break;

  case AmjuGL::AMJU_DEPTH_READ:
    dd->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
    break;

  case AmjuGL::AMJU_LIGHTING:
    dd->SetRenderState(D3DRS_LIGHTING, TRUE);
    dd->LightEnable( 0, TRUE );
    {
      const float A = 0.5f;
      dd->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(A, A, A, 1.0f ) );
    }
    break;

  case AmjuGL::AMJU_BLEND:
    dd->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    break;

  case AmjuGL::AMJU_TEXTURE_2D:
//    dd->SetTexture(0, mostRecentlyUsedTexture); // TODO
    break;
  }
}
Exemple #6
0
void AmjuGLDX9::Disable(uint32 flag)
{
  AMJU_CALL_STACK;

  switch (flag)
  {
  case AmjuGL::AMJU_DEPTH_WRITE:
    EnableZWrite(false);
    break;

  case AmjuGL::AMJU_DEPTH_READ:
    dd->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    break;

  case AmjuGL::AMJU_LIGHTING:
    // TODO TEMP TEST
    // If lighting is disabled, set the ambient colour to white.
    // Then the material colour's ambient value will be used.
    dd->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE( 1.0f, 1.0f, 1.0f, 1.0f ) );
    
//    dd->SetRenderState(D3DRS_LIGHTING, FALSE);
//    dd->LightEnable( 0, FALSE);
    break;

  case AmjuGL::AMJU_BLEND:
    dd->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    break;

  case AmjuGL::AMJU_TEXTURE_2D:
    dd->SetTexture(0, 0); 
    break;
  }
}
CUSTOMVERTEX GetVertexOnSphere(int i, int iMax, int j, int jMax)
{
	const FLOAT radius = 0.5f;

	FLOAT theta = (FLOAT) D3DXToRadian(180.0 * j / (jMax - 1));
	FLOAT phi = (FLOAT) D3DXToRadian(360.0 * (i % iMax) / iMax);

	CUSTOMVERTEX v;
	{
		v.x		= radius * sinf(theta) * cosf(phi);
		v.z		= radius * cosf(theta);
		v.y		= radius * sinf(theta) * sinf(phi);

		D3DXVECTOR3 normal(v.x, v.y, v.z);
		D3DXVec3Normalize(&normal, &normal);
		v.nx	= normal.x;
		v.ny	= normal.y;
		v.nz	= normal.z;

		//v.color	= D3DCOLOR_COLORVALUE(1.0f * (rand() % 255) / 255, 1.0f * (rand() % 255) / 255, 1.0f * (rand() % 255) / 255, 1);		
		v.color	= D3DCOLOR_COLORVALUE(1, 1, 1, 1);
		v.u1 = ((float)(i)) / iMax;
		v.v1 = 1 - (float)j / (jMax - 1);
	}

	return v;
}
Exemple #8
0
bool D3DFB::Wiper_Crossfade::Run(int ticks, D3DFB *fb)
{
	Clock += ticks;

	// Put the initial screen back to the buffer, presumably with DMA.
	IDirect3DSurface9 *source = NULL, *target = NULL;

	if (SUCCEEDED(fb->InitialWipeScreen->GetSurfaceLevel(0, &source)) &&
		SUCCEEDED(fb->D3DDevice->GetRenderTarget(0, &target)))
	{
		fb->D3DDevice->UpdateSurface(source, NULL, target, NULL);
		target->Release();
	}
	if (source != NULL)
	{
		source->Release();
	}

	// Draw the new screen on top of it.
	FBVERTEX verts[4];

	fb->CalcFullscreenCoords(verts, false, false, D3DCOLOR_COLORVALUE(0,0,0,Clock / 32.f), D3DCOLOR_RGBA(255,255,255,0));
	fb->D3DDevice->SetFVF(D3DFVF_FBVERTEX);
	fb->SetTexture(0, fb->FinalWipeScreen);
	fb->SetAlphaBlend(D3DBLENDOP_ADD, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
	fb->SetPixelShader(fb->PlainShader);
	fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));

	return Clock >= 32;
}
Exemple #9
0
HRESULT setupDX ( void )
{
  // ---- projection matrix ----
	D3DXMATRIX matProj;
  D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ),
    (float)(g_d3dpp.BackBufferWidth) / float(g_d3dpp.BackBufferHeight), 
    0.1f, 100.0f );
  g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

	// ---- render states ----
	g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
  g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
  g_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
  g_pd3dDevice->SetRenderState( D3DRS_AMBIENT,
	D3DCOLOR_COLORVALUE( 0.2f, 0.2f, 0.2f, 1.0f ) );
  
  // ---- texture states ----
  //g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
  //g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );

  // ---- application ----
	g_app->setupDX(g_pd3dDevice);

	// done
	return S_OK;
}
Exemple #10
0
int HookD3D9::AddTexture(const std::string& fileName, int width, int height)
{
	D3DXIMAGE_INFO d3dxImageInfo;
	LPDIRECT3DTEXTURE9 texture = 0;
	LPD3DXSPRITE sprite = 0;

	if(D3DXCreateTextureFromFileEx(device, 
		fileName.c_str(), 
		width, 
		height, 
		0,
		D3DPOOL_DEFAULT,
		D3DFMT_UNKNOWN,
		D3DPOOL_DEFAULT,
		D3DX_DEFAULT,
		D3DX_DEFAULT,
		D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f),
		&d3dxImageInfo,
		NULL,
		&texture) != D3D_OK)
	{
		FILE_LOG(logERROR) << "Error loading texture " << fileName;
	}

	textures.push_back(texture);

	D3DXCreateSprite(device, &sprite);
	sprites.push_back(sprite);

	return sprites.size() - 1;
}
Exemple #11
0
LRESULT KPvsAttriPanel::OnColorChanged(WPARAM wParam, LPARAM lParam)
{
	if (!GetPvsScene())
		return 0;

	IEKG3DRepresentObject* pObj = GetPvsScene()->GetFirstSelectedObj();

	if (!pObj)
		return 0;

	IKG3DModel* pModel = NULL;

	pObj->GetModel(pModel, 0);

	if (!pModel)
		return 0;

	if (pModel->GetType() != MESHTYPE_POINTLIGHT)
		return 0;


	pModel->SetModelColor(0, m_PointLightColor);
	m_ColorWndPLight.SetColor(D3DCOLOR_COLORVALUE(m_PointLightColor.r, m_PointLightColor.g, m_PointLightColor.b, m_PointLightColor.a));

	return 1;
}
Exemple #12
0
// ---------- framework : display ----------
bool rtvsD3dApp::display (LPDIRECT3DDEVICE9 pd3dDevice)
{
 	// clear backbuffers
  pd3dDevice->Clear( 0,
	NULL,
	D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
	D3DCOLOR_COLORVALUE(0.0f,0.3f,0.7f,1.0f),
	1.0f,
	0);

  // check if should render
  if (m_antShouldRender) { // ant says render
    if (
      !m_pTracer->m_shouldRender // tracer isn't rendering
      && !m_pTracer->m_isRenderDone // tracer isn't done
    ) { 
      // tell it to render
      m_pTracer->startRender();
    }
    else if (
      !m_pTracer->m_shouldRender // tracer isn't rendering
      && m_pTracer->m_isRenderDone // tracer is done
    ) {
      // reset and tell it to render
      m_pTracer->resetRender(pTexture);
      m_pTracer->startRender();
    }
  }
  else // ant says don't render
  {
    if(m_pTracer->m_shouldRender) // tracer is rendering
      m_pTracer->m_shouldRender = false; // tell it to stop
  }

  // if tracer should be rendering
  if(m_pTracer->m_shouldRender)
  {
    // trace line by line & check if done
    m_antShouldRender = m_pTracer->traceNextLine();

    // try to render
    returnvalue = m_pTracer->render(pTexture);
    if (FAILED(returnvalue))
      return false;
  }

	// display solid textured quad
	pd3dDevice->SetMaterial( &quadMtrl );
	pd3dDevice->SetTexture( 0, pTexture );
	pd3dDevice->SetStreamSource( 0, pQuadVertexBuffer, 0, sizeof(QuadVertex) );
	pd3dDevice->SetFVF( QuadVertex::FVF_Flags );
	pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, numQuadTriangles );

	TwDraw();  // draw the tweak bar GUI

	// ok
	return true;

}
void GFXD3D9Device::setGlobalAmbientInternal(ColorF color)
{
#ifndef TORQUE_OS_XENON
   mD3DDevice->SetRenderState(D3DRS_AMBIENT,
      D3DCOLOR_COLORVALUE(color.red, color.green, color.blue, color.alpha));
#endif
}
Exemple #14
0
Material::Material(char* name, char* path) : Resource<Material>(name, path)
{
    D3DXIMAGE_INFO info;
    Script* script = new Script(name, path);

    if( script->GetColourData( "transparency" )->a == 0.0f )
    {
        // Load the texture without transparency.
        D3DXCreateTextureFromFileEx( Engine::GetInstance()->GetDevice(), script->GetStringData( "texture" ), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, 0, &info, NULL, &m_texture);
    }
    else
    {
        // Load the texture using a transparency colour value.
        D3DCOLORVALUE *colour = script->GetColourData( "transparency" );
        D3DCOLOR transparency = D3DCOLOR_COLORVALUE( colour->r, colour->g, colour->b, colour->a );
        D3DXCreateTextureFromFileEx( Engine::GetInstance()->GetDevice(), script->GetStringData( "texture" ), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE, D3DX_FILTER_TRIANGLE, transparency, &info, NULL, &m_texture);
    }

    m_width = info.Width;
    m_height = info.Height;

    m_lighting.Diffuse = *script->GetColourData("diffuse");
    m_lighting.Ambient = *script->GetColourData("ambient");
    m_lighting.Specular = *script->GetColourData("specular");
    m_lighting.Power = *script->GetFloatData("power");

    m_ignoreFace = *script->GetBoolData("ignore_face");
    m_ignoreFog = *script->GetBoolData("ignore_fog");
    m_ignoreRay = *script->GetBoolData("ignore_ray");

    SAFE_DELETE(script);
}
Exemple #15
0
//-----------------------------------------------------------------------------
// Name: render_1()
// Desc:
//-----------------------------------------------------------------------------
void render_1( void )
{
    D3DXMATRIX matView;
    D3DXMATRIX matWorld;
    D3DXMATRIX matRotation;
    D3DXMATRIX matTranslation;

    // Now we can clear just view-port's portion of the buffer to green...
    g_pd3dDevice_1->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 0.0f, 1.0f, 0.0f, 1.0f ), 1.0f, 0 );

    g_pd3dDevice_1->BeginScene();

    // For the left view-port, leave the view at the origin...
    D3DXMatrixIdentity( &matView );
    g_pd3dDevice_1->SetTransform( D3DTS_VIEW, &matView );

    // ... and use the world matrix to spin and translate the teapot
    // out where we can see it...
    D3DXMatrixRotationYawPitchRoll( &matRotation, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f );
    D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f );
    matWorld = matRotation * matTranslation;
    g_pd3dDevice_1->SetTransform( D3DTS_WORLD, &matWorld );


    g_pd3dDevice_1->SetMaterial( &g_teapotMtrl );
    g_pTeapotMesh_1->DrawSubset(0);

    g_pd3dDevice_1->EndScene();

    // We're done! Now, we just call Present()
    g_pd3dDevice_1->Present( NULL, NULL, NULL, NULL );
}
Exemple #16
0
void	CRendererDX::Text( spCBaseFont _spFont, const std::string &_text, const Base::Math::CVector4 &_color, const Base::Math::CRect &_rect, uint32 _flags )
{
    ASSERT( _text != "" );

	if( _spFont == NULL )
		return;

	const fp4 w05 = (fp4)m_spDisplay->Width() * 0.5f;
	const fp4 h05 = (fp4)m_spDisplay->Height() * 0.5f;
	Base::Math::CRect _r( lerpMacro( -w05, w05, _rect.m_X0 ), lerpMacro( -h05, h05, _rect.m_Y0 ), lerpMacro( -w05, w05, _rect.m_X1 ), lerpMacro( -h05, h05, _rect.m_Y1 ) );

	RECT r = { (LONG)_r.m_X0, (LONG)_r.m_Y0, (LONG)_r.m_X1, (LONG)_r.m_Y1, };

    DWORD d3dFlags = DT_NOCLIP;

	if( _flags & CBaseFont::Bottom )		d3dFlags |= DT_BOTTOM; // bug if CBaseFont::Bottom == 0 because of check _flag & 0 != 0
    if( _flags & CBaseFont::Top )			d3dFlags |= DT_TOP;
    if( _flags & CBaseFont::Center )		d3dFlags |= DT_CENTER;
    if( _flags & CBaseFont::Left )			d3dFlags |= DT_LEFT;
    if( _flags & CBaseFont::Right )			d3dFlags |= DT_RIGHT;
    if( _flags & CBaseFont::VCenter )		d3dFlags |= DT_VCENTER;
    if( _flags & CBaseFont::NoClip )		d3dFlags |= DT_NOCLIP;
    if( _flags & CBaseFont::ExpandTabs )	d3dFlags |= DT_EXPANDTABS;
    if( _flags & CBaseFont::WordBreak )		d3dFlags |= DT_WORDBREAK;

	DWORD d3dColor = D3DCOLOR_COLORVALUE( _color.m_X, _color.m_Y, _color.m_Z, _color.m_W );

	spCFontDX	spDXFont = _spFont;
	ID3DXFont	*pDXFont = spDXFont->GetDXFont();
    ASSERT( pDXFont );

    m_pSprite->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE | D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DO_NOT_ADDREF_TEXTURE );
    pDXFont->DrawTextA( m_pSprite, (const char *)_text.c_str(), -1, &r, d3dFlags, d3dColor );
    m_pSprite->End();
}
Exemple #17
0
// beginDraw applies the view transformation, sets the ambient lighting, and
// clears the backbuffer
//
void Display::beginDraw() {

    // construct the view transformation
    //
    Vector p = context->get(GF_CA_POSN);
    Vector h = context->get(GF_CA_HEAD);
    Vector u = context->get(GF_CA_UP  );
    Matrix view = ::view(p, p + h, u);

    if (d3dd) d3dd->SetTransform(D3DTS_VIEW, (D3DXMATRIX*)&view);

    // set global ambient light
    //
    Vector c = context->get(GF_LT_BKGD);

    if (d3dd) d3dd->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(c.x, c.y, c.z, 1));

    // clear the backbuffer
    //
    if (d3dd) {
        d3dd->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
         D3DCOLOR_XRGB(BGROUND_R, BGROUND_G, BGROUND_B), 1.0, 0);
        d3dd->BeginScene();
    }
}
RMeshNodeMtrl::RMeshNodeMtrl()
{
//	m_dwTFactorColor = D3DCOLOR_COLORVALUE(1.0f,0.0f,0.0f,1.0f);
	m_dwTFactorColor = D3DCOLOR_COLORVALUE(0.0f,1.0f,0.0f,0.0f);	//	완전 녹색..색이 없다는걸 의미
//	m_dwTFactorColor = 0xff808080;
	m_pMtrlTable = NULL;
	m_iMtrlCnt = 0;
}
 void Init(CDXUTDialogResourceManager* pManager)
 {
     const UINT NumTextLines = 14;
     const UINT QuadWidth = 300;
     const float QuadOpacity = 0.2f;
     m_BackgroundQuad.Init(pManager);
     m_BackgroundQuad.SetLocation(0,0);
     m_BackgroundQuad.SetSize(QuadWidth, g_TextLineHeight * NumTextLines);
     m_BackgroundQuad.SetBackgroundColors(D3DCOLOR_COLORVALUE(0,0,0,QuadOpacity));
 }
/*
* Draws the particles
*
* @author Michael McQuarrie
*
* @return void
*/
void
CFlagParticleEmitter::Draw()
{
    if (!m_pVertexBuffer)
    {
        return;
    }
    if (!IsEmpty() )
    {
        //First PreDraw it
        TVertexParticleSize* pv;
        DWORD dwNumParticlesInBatch = 0;
        PreDraw();

        //Get the renderer
        CRenderer* pRenderer = CTotalCubeDomination::GetInstance().GetRenderer();

        //Get the texture
        CTextureManager::GetInstance().SetTexture(0, s_uiTextureID);

        //Set Matrix
        pRenderer->SetWorldMatrix(m_matWorld);

        //Set FVF and source things
        pRenderer->GetDevice()->SetFVF(D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_PSIZE);
        pRenderer->GetDevice()->SetStreamSource(0, m_pVertexBuffer, 0, sizeof(TVertexParticleSize) );

        SortParticles();

        m_pVertexBuffer->Lock(NULL, 0, (void**)&pv, D3DLOCK_DISCARD);

        //Doing colour things
        for (int32 i = 0; i < static_cast<int32>(m_vecParticles.size() ); ++i)
        {
            if (m_vecParticles[i].bAlive)
            {
                pv->vec3Position = m_vecParticles[i].vec3Position;
                const D3DXCOLOR& kr = m_vecParticles[i].colour;
                pv->colour = D3DCOLOR_COLORVALUE(kr.r, kr.g, kr.b, 1.0f - kr.a);
                pv->fsize = m_vecParticles[i].fLifeTime + 0.5f;
                pv++;
                ++dwNumParticlesInBatch;
            }

        }
        m_pVertexBuffer->Unlock();
        //Draw it
        if (IsAlive() == true)
        {
            pRenderer->GetDevice()->DrawPrimitive(D3DPT_POINTLIST, 0, dwNumParticlesInBatch);
        }
        //End the drawing
        PostDraw();
    }
}
	bool Context::Clear(bool screen, bool depth, bool stencil)
	{
		const D3DRECT* subRectanglesToClear = nullptr;
		const DWORD subRectangleCount = 0;
		const DWORD buffersToClear = (screen ? D3DCLEAR_TARGET : 0x0) | (depth ? D3DCLEAR_ZBUFFER : 0x0) | (stencil ? D3DCLEAR_STENCIL : 0x0);
		const D3DCOLOR clearColor = D3DCOLOR_COLORVALUE(screen_clear_color.r(), screen_clear_color.g(), screen_clear_color.b(), screen_clear_color.a());
		const float depthBuffer = 1.0f;
		const DWORD stencilBuffer = 0;
		HRESULT result = direct3dDevice->Clear(subRectangleCount, subRectanglesToClear, buffersToClear, clearColor, depthBuffer, stencilBuffer);
		return SUCCEEDED(result);
	}
Exemple #22
0
void TextLabelComponent::draw(void* context, Statistic& statistic)
{
	RendererComponent::Impl& renderer = *reinterpret_cast<RendererComponent::Impl*>(context);
	LPDIRECT3DDEVICE9 device = getDevice();
	MCD_ASSUME(device);

	// Reference: http://www.gamedev.net/community/forums/topic.asp?topic_id=310926
	device->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_COLORVALUE(color.r, color.g, color.b, color.a));
	device->SetTextureStageState(0, D3DTSS_COLOROP,   D3DTOP_MODULATE);
	device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
	device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
	device->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE);
	device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
	device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);

	if(renderer.mCurrentCamera->frustum.projectionType == Frustum::Perspective)
	{
		// Create orthogonal projection
		const float width = (float)renderer.mCurrentRenderTarget->targetWidth();
		const float height = (float)renderer.mCurrentRenderTarget->targetHeight();
		Frustum f;
		f.projectionType = Frustum::YDown2D;
		f.create(-0, width, 0, height, -1, 1);
		Mat44f proj;
		f.computeOrtho(proj.data);
		MCD_VERIFY(device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)proj.data) == D3D_OK);

		// Calculate screen position (0,0 -> Lower left, Screen width,height -> upper right)
		Vec3f p(0);
		renderer.mWorldViewProjMatrix.transformPointPerspective(p);	// Homogeneous screen position
		p = (p + 1) * 0.5;
		p.x *= width;
		p.y *= height;

		MCD_VERIFY(device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)Mat44f::cIdentity.data) == D3D_OK);
		MCD_VERIFY(device->SetTransform(D3DTS_WORLD, (D3DMATRIX*) Mat44f::makeTranslation(p).data) == D3D_OK);
	}
	else
		MCD_VERIFY(device->SetTransform(D3DTS_WORLD, (D3DMATRIX*)renderer.mWorldMatrix.data) == D3D_OK);

	MCD_VERIFY(device->SetFVF(cQuadVertexFVF) == D3D_OK);
	MCD_VERIFY(device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, mVertexBuffer.size() / 3, &mVertexBuffer[0], sizeof(Vertex)) == D3D_OK);

	// Restore original transforms
	if(renderer.mCurrentCamera->frustum.projectionType == Frustum::Perspective)
	{
		MCD_VERIFY(device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)renderer.mViewMatrix.data) == D3D_OK);
		MCD_VERIFY(device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)renderer.mProjMatrix.data) == D3D_OK);
	}

	++statistic.drawCallCount;
	statistic.primitiveCount += mVertexBuffer.size() / 3;
}
Exemple #23
0
void AmjuGLDX9::InitFrame(float clearR, float clearG, float clearB)
{
  AMJU_CALL_STACK;

  dd->BeginScene();


  dd->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
    D3DCOLOR_COLORVALUE(clearR, clearG, clearB, 1.0f ), 1.0f, 0 );

  g_matrixStack->LoadIdentity();
}
Exemple #24
0
void Font_bitmap::End()
{
	pd->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DISABLE );
	pd->SetRenderState( D3DRS_ALPHABLENDENABLE, 0 );
	pd->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
	pd->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ZERO );
	pd->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
	pd->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)(void*) &proj);
	pd->SetTransform( D3DTS_WORLD, (D3DMATRIX*)(void*) &model);
	pd->SetRenderState( D3DRS_LIGHTING, 0 );
	pd->SetRenderState( D3DRS_AMBIENT, D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1) );
}
Exemple #25
0
void gld_NEW_FOG(
	struct gl_context *ctx)
{
	GLD_context			*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx7		*gld	= GLD_GET_DX7_DRIVER(gldCtx);

	D3DCOLOR	d3dFogColour;
	D3DFOGMODE	d3dFogMode = D3DFOG_LINEAR;

	// TODO: Fog is calculated seperately in the Mesa pipeline
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, FALSE));
	return;

	// Fog enable
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGENABLE, ctx->Fog.Enabled));
	if (!ctx->Fog.Enabled) {
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, D3DFOG_NONE));
		_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
		return; // If disabled, don't bother setting any fog state
	}

	// Fog colour
	d3dFogColour = D3DCOLOR_COLORVALUE(	ctx->Fog.Color[0],
								ctx->Fog.Color[1],
								ctx->Fog.Color[2],
								ctx->Fog.Color[3]);
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGCOLOR, d3dFogColour));

	// Fog density
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGDENSITY, *((DWORD*) (&ctx->Fog.Density))));

	// Fog start
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGSTART, *((DWORD*) (&ctx->Fog.Start))));

	// Fog end
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGEND, *((DWORD*) (&ctx->Fog.End))));

	// Fog mode
	switch (ctx->Fog.Mode) {
	case GL_LINEAR:
		d3dFogMode = D3DFOG_LINEAR;
		break;
	case GL_EXP:
		d3dFogMode = D3DFOG_EXP;
		break;
	case GL_EXP2:
		d3dFogMode = D3DFOG_EXP2;
		break;
	}
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGTABLEMODE, d3dFogMode));
	_GLD_DX7_DEV(SetRenderState(gld->pDev, D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE));
}
Exemple #26
0
bool D3DFB::Wiper_Crossfade::Run(int ticks, D3DFB *fb)
{
	Clock += ticks;

	// Put the initial screen back to the buffer.
	DrawScreen(fb, fb->InitialWipeScreen);

	// Draw the new screen on top of it.
	DrawScreen(fb, fb->FinalWipeScreen, D3DBLENDOP_ADD,
		D3DCOLOR_COLORVALUE(0,0,0,Clock / 32.f), D3DCOLOR_RGBA(255,255,255,0));

	return Clock >= 32;
}
Exemple #27
0
//  update print colors
//------------------------------
void cSnd::UpdPClr()
{
	//  print colors
	float f, l = PrClrs-1, r,g,b, h,s,v;
	for (int i=0; i < PrClrs; ++i)
	{
		f = float(i)/l;  //_par
		h = 0.65f - 0.13f * pow(f, 1.2f);
		s = 0.9f - 0.9f * pow(f, 1.8f);
		v = pow(f, 0.4f);
		hsv2rgb(h,s,v,&r,&g,&b);
		pcl[i] = D3DCOLOR_COLORVALUE(r,g,b,0);
	}
}
Exemple #28
0
//-----------------------------------------------------------------------------
// Name: render_0()
// Desc:
//-----------------------------------------------------------------------------
void render_0( void )
{
    D3DXMATRIX matView;
    D3DXMATRIX matWorld;
    D3DXMATRIX matRotation;
    D3DXMATRIX matTranslation;
    static int nFrameCount = 0;
    static double nTimeOfLastFPSUpdate = 0.0;
    static char fpsString[50] = "Frames Per Second = ";
    RECT destRect;

    // Now we can clear just view-port's portion of the buffer to red...
    g_pd3dDevice_0->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 1.0f, 0.0f, 0.0f, 1.0f ), 1.0f, 0 );

    g_pd3dDevice_0->BeginScene();

    // For the left view-port, leave the view at the origin...
    D3DXMatrixIdentity( &matView );
    g_pd3dDevice_0->SetTransform( D3DTS_VIEW, &matView );

    // ... and use the world matrix to spin and translate the teapot
    // out where we can see it...
    D3DXMatrixRotationYawPitchRoll( &matRotation, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f );
    D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f );
    matWorld = matRotation * matTranslation;
    g_pd3dDevice_0->SetTransform( D3DTS_WORLD, &matWorld );

    g_pd3dDevice_0->SetMaterial( &g_teapotMtrl );
    g_pTeapotMesh_0->DrawSubset(0);

    g_pd3dDevice_0->EndScene();

    // Report frames per second and the number of objects culled...
    ++nFrameCount;

    if( g_dElpasedAppTime - nTimeOfLastFPSUpdate > 1000 ) // Update once a second
    {
        sprintf( fpsString, "Frames Per Second = %4.2f", nFrameCount*1000.0/(g_dElpasedAppTime - nTimeOfLastFPSUpdate) );

        nTimeOfLastFPSUpdate = g_dElpasedAppTime;
        nFrameCount = 0;
    }

    SetRect( &destRect, 5, 5, 0, 0 );

    g_pd3dxFont->DrawText( NULL, fpsString, -1, &destRect, DT_NOCLIP, D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );

    g_pd3dDevice_0->Present( NULL, NULL, NULL, NULL );
}
void CGUIWindowTestPatternDX::DrawHorizontalLines(int top, int left, int bottom, int right)
{
  CUSTOMVERTEX* vert = new CUSTOMVERTEX[2+(bottom-top)];
  int p = 0;
  for (int i = top; i <= bottom; i += 2)
  {
    vert[p].x = (float)left;
    vert[p].y = (float)i;
    vert[p].z = 0.5f;
    vert[p].rhw = 1.0f;
    vert[p].color = D3DCOLOR_COLORVALUE(m_white, m_white, m_white, 1.0f);
    ++p;
    vert[p].x = (float)right;
    vert[p].y = (float)i;
    vert[p].z = 0.5f;
    vert[p].rhw = 1.0f;
    vert[p].color = D3DCOLOR_COLORVALUE(m_white, m_white, m_white, 1.0f);
    ++p;
  }
  g_Windowing.Get3DDevice()->SetFVF(D3DFVF_CUSTOMVERTEX);
  g_Windowing.Get3DDevice()->DrawPrimitiveUP(D3DPT_LINELIST, p/2, vert, sizeof(CUSTOMVERTEX));

  delete [] vert;
}
Exemple #30
0
BOOL dx9vid_render()
{
   // clear the window to a deep blue
   d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
   d3ddev->BeginScene();    // begins the 3D scene
   g_screenSprite->Begin( 0 );

   d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
   d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
   d3ddev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

   g_screenSprite->Draw( g_screenTex, &srcRect, &vCenter, &vPosition,
                     D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );
   g_screenSprite->End();
   d3ddev->EndScene();    // ends the 3D scene
   d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
   return TRUE;
}