Esempio n. 1
0
//==============================================================================
// draw
//------------------------------------------------------------------------------
void Parpix::draw(Renderer *renderer,Sprite2D* sprite) {
  const auto pDevice = renderer->getDevice();
  auto shader = renderer->getShader();

  shader->setPixShader("ps_parpix.cso");
  auto constTable = shader->getNowPixShader()->_constTable;

  pDevice->SetTexture(0,renderer->getNormalDepthTex());
  pDevice->SetTexture(1,renderer->getPosTex());
  pDevice->SetTexture(2,renderer->getColorTex());

  const SIZE size = App::instance().getWindowSize();
  const float w = (float)size.cx;
  const float h = (float)size.cy;

  Vec3 dir[4];
  Vec3 col[4];
  
  static float f = 0;

  f += 0.02f;

  col[0] = Vec3(1, 1, 0.1f);
  col[1] = Vec3(0.1f, 0.1f, 1);
  col[2] = Vec3(1, 1, 0.1f);
  col[3] = Vec3(0.3f, 0.3f, 1);

  for(int i = 0; i < 4; i++) {
    dir[i] = Vec3(cosf(f + D3DX_PI * 0.5f * i),1,sinf(f + D3DX_PI * 0.5f * i));
    dir[i]  *= 400;
    dir[i].y = 10;
  }

  constTable->SetFloatArray(pDevice,"gDLight",(float*)dir,sizeof(float) * 3 * 4);
  constTable->SetFloatArray(pDevice,"gDLightCol",(float*)col,sizeof(float) * 3 * 4);
  constTable->SetFloatArray(pDevice,"gCameraPos",(float*)&renderer->getCamera()->getCurrentCamera()->getPosP(),sizeof(float) * 3);
  constTable->SetFloat(pDevice,"gFar",2000);

  struct T4VERTEX {
    float p[4];
    float t[2];
  }  Vertex[4] = {
    {0.0f,0,0.1f,1.0f,0.0f,0.0f},
    {w,0,0.1f,1.0f,1.0f,0.0f},
    {w,h,0.1f,1.0f,1.0f,1.0f},
    {0.0f,h,0.1f,1.0f,0.0f,1.0f},
  };

  pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
  pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
  pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
  pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
  pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,Vertex,sizeof(T4VERTEX));
  pDevice->SetFVF(NULL);
  pDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);		// ソース
  pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);	// デスト
  pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
}
Esempio n. 2
0
// draw
void AnimationObject::Draw(void) {
  auto p_device = DeviceHolder::Instance().GetDevice();

  p_texture_animation_ -> UpdateAnimation();

  Vertex2D data[] ={
    {D3DXVECTOR3(pos_.x - size_.x / 2, pos_.y - size_.y / 2, 0.0f), 1.0f, 0xffffffff, D3DXVECTOR2(0.0f, 0.0f)},
    {D3DXVECTOR3(pos_.x + size_.x / 2, pos_.y - size_.y / 2, 0.0f), 1.0f, 0xffffffff, D3DXVECTOR2(1.0f, 0.0f)},
    {D3DXVECTOR3(pos_.x - size_.x / 2, pos_.y + size_.y / 2, 0.0f), 1.0f, 0xffffffff, D3DXVECTOR2(0.0f, 1.0f)},
    {D3DXVECTOR3(pos_.x + size_.x / 2, pos_.y + size_.y / 2, 0.0f), 1.0f, 0xffffffff, D3DXVECTOR2(1.0f, 1.0f)},
  };

  D3DXVECTOR2 texture_uv_ = p_texture_animation_ -> GetTextureUV();
  D3DXVECTOR2 texture_uv_offset_ = p_texture_animation_->GetTextureUVOffset();

  if (move_direction_ == DIRECTION_LEFT) {
    texture_uv_.x += texture_uv_offset_.x;
    texture_uv_offset_.x *= -1;
  }

  data[0].tex = D3DXVECTOR2(texture_uv_.x, texture_uv_.y);
  data[1].tex = D3DXVECTOR2(texture_uv_.x + texture_uv_offset_.x, texture_uv_.y);
  data[2].tex = D3DXVECTOR2(texture_uv_.x, texture_uv_.y + texture_uv_offset_.y);
  data[3].tex = D3DXVECTOR2(texture_uv_.x + texture_uv_offset_.x, texture_uv_.y + texture_uv_offset_.y);

  TextureManagerHolder::Instance().GetTextureManager().SetTexture(texture_id_);

  p_device->SetFVF(kVertexFVF2D);

  p_device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, data, sizeof(Vertex2D));
}
Esempio n. 3
0
void Screen3D::BlankArea( RECT& Dimensions)
{

	// Figure out the vertices for the main window
	ScreenVertex WindowVertices[4];

	WindowVertices[0].z   = 0;WindowVertices[1].z   = 0;WindowVertices[2].z   = 0;WindowVertices[3].z   = 0;
	WindowVertices[0].RHW = 1;	WindowVertices[1].RHW = 1; WindowVertices[2].RHW = 1; WindowVertices[3].RHW = 1;
	WindowVertices[0].color = D3DCOLOR_RGBA(R, G, B, 255);WindowVertices[1].color = D3DCOLOR_RGBA(R, G, B, 255);
	WindowVertices[2].color = D3DCOLOR_RGBA(R, G, B, 255);WindowVertices[3].color = D3DCOLOR_RGBA(R, G, B, 255);

	WindowVertices[0].x   = Dimensions.left;
	WindowVertices[0].y   = Dimensions.top;

	
	WindowVertices[1].x   = Dimensions.right;
	WindowVertices[1].y   = Dimensions.top;

	WindowVertices[2].x   = Dimensions.left;
	WindowVertices[2].y   = Dimensions.bottom;

	WindowVertices[3].x   = Dimensions.right;
	WindowVertices[3].y   = Dimensions.bottom;

	PolygonsRendered += 2;
	DrawCalls++;

	D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,   FALSE);
	D3DDevice->SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_SRCALPHA);
	D3DDevice->SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_INVSRCALPHA);
	SetFVF(D3DFVF_SCREENVERTEX);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, WindowVertices,  sizeof(ScreenVertex));

}
Esempio n. 4
0
void Arrow::draw() {
	auto device = ShaderDevise::device();

	device->SetTransform(D3DTS_WORLD, &world);
	device->SetFVF(D3DFVF_CUSTOMVERTEX);
	device->SetRenderState(D3DRS_LIGHTING, false);
	device->SetStreamSource(0, vbuf, 0, sizeof(CUSTOMVERTEX));
	device->DrawPrimitive(D3DPT_LINELIST, 0, 2);
	device->SetRenderState(D3DRS_LIGHTING, true);

}
Esempio n. 5
0
void Screen3D::DrawRectangle( int x, int y, int w, int h, D3DCOLOR color )
{
	ScreenVertex v[6];
	v[0] = ScreenVertex( x,    y,   1, color, 0, 0 );
	v[2] = ScreenVertex( x+w,  y+h, 1, color, 1, 1 );
	v[1] = ScreenVertex( x,    y+h, 1, color, 0, 1 );
	v[3] = ScreenVertex( x,    y,   1, color, 0, 0 );
	v[5] = ScreenVertex( x+w,  y,   1, color, 1, 0 );
	v[4] = ScreenVertex( x+w,  y+h, 1, color, 1, 1 );

	SetTexture(NULL, 0);
	SetFVF(D3DFVF_SCREENVERTEX);
	SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 2, v,  sizeof(ScreenVertex));
	ResetWireframeState();

}
Esempio n. 6
0
HRESULT Graphics::DrawSprite( CTexturePtr pTex, D3DXVECTOR2 pos, D3DXVECTOR2 size )
{
	SetTexture(0, pTex);
	float x0 = pos.x+.5f;
	float y0 = pos.y+.5f;
	float x1 = pos.x + size.x+.5f;
	float y1 = pos.y + size.y+.5f;
	VertPosTc v[] = 
	{
		VertPosTc(D3DXVECTOR3(x0, y0, 0), D3DXVECTOR2(0, 0)),
		VertPosTc(D3DXVECTOR3(x1, y0, 0), D3DXVECTOR2(1, 0)),
		VertPosTc(D3DXVECTOR3(x0, y1, 0), D3DXVECTOR2(0, 1)),
		VertPosTc(D3DXVECTOR3(x1, y1, 0), D3DXVECTOR2(1, 1))
	};
	SetFVF(D3DFVF_XYZ|D3DFVF_TEX1);
	return DPUP(D3DPT_TRIANGLESTRIP, 2/* 1 треугольник */,
		v /* данные брать отсюда*/, sizeof(VertPosTc)/*размер вертекса*/);
}
Esempio n. 7
0
void Screen3D::DrawSpritePoints( Point3D* pointlist, TextureHandle Image )
{

	SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );
	// Figure out the vertices for the main window
	ScreenVertex WindowVertices[4];

	WindowVertices[0].z   = 0;WindowVertices[1].z   = 0;WindowVertices[2].z   = 0;WindowVertices[3].z   = 0;
	WindowVertices[0].RHW = 1;	WindowVertices[1].RHW = 1; WindowVertices[2].RHW = 1; WindowVertices[3].RHW = 1;
	WindowVertices[0].color = D3DCOLOR_RGBA(255, 255, 255, 255);WindowVertices[1].color = D3DCOLOR_RGBA(255, 255, 255, 255);
	WindowVertices[2].color = D3DCOLOR_RGBA(255, 255, 255, 255);WindowVertices[3].color = D3DCOLOR_RGBA(255, 255, 255, 255);

	WindowVertices[0].x   = pointlist[0].x;
	WindowVertices[0].y   = pointlist[0].y;
	WindowVertices[1].x   = pointlist[1].x;
	WindowVertices[1].y   = pointlist[1].y;
	WindowVertices[2].x   = pointlist[2].x;
	WindowVertices[2].y   = pointlist[2].y;
	WindowVertices[3].x   = pointlist[3].x;
	WindowVertices[3].y   = pointlist[3].y;



	WindowVertices[0].tu  = 0;
	WindowVertices[0].tv  = 0;
	WindowVertices[1].tu  = 1;
	WindowVertices[1].tv  = 0;
	WindowVertices[2].tu  = 0;
	WindowVertices[2].tv  = 1;
	WindowVertices[3].tu  = 1;
	WindowVertices[3].tv  = 1;


	SetTexture(Image, 0);
	SetFVF(D3DFVF_SCREENVERTEX);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, WindowVertices,  sizeof(ScreenVertex));

	ResetWireframeState	();
}
Esempio n. 8
0
static GLboolean _gld_mesa_render_stage_run(
	struct gl_context *ctx,
	struct tnl_pipeline_stage *stage)
{
	GLD_context				*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx9			*gld	= GLD_GET_DX9_DRIVER(gldCtx);
		
	TNLcontext				*tnl = TNL_CONTEXT(ctx);
	struct vertex_buffer	*VB = &tnl->vb;
	tnl_render_func				*tab;
	GLint					pass = 0;
	GLD_pb_dx9				*gldPB;

	/* Allow the drivers to lock before projected verts are built so
    * that window coordinates are guarenteed not to change before
    * rendering.
    */
	ASSERT(tnl->Driver.Render.Start);
	
	tnl->Driver.Render.Start( ctx );
	
	// NOTE: Setting D3DRS_SOFTWAREVERTEXPROCESSING for a mixed-mode device resets
	//       stream, indices and shader to default values of NULL or 0.
/*	if ((ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE) &&
		gld->VStwosidelight.hShader &&
		!ctx->Fog.Enabled)
	{
		IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware);
		_GLD_DX9_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
		gldPB = &gld->PBtwosidelight;
		tnl->Driver.Render.Points	= gld_Points2DTwoside_DX9;
		if (ctx->_TriangleCaps & DD_FLATSHADE) {
			tnl->Driver.Render.Line		= gld_Line2DFlatTwoside_DX9;
			tnl->Driver.Render.Triangle	= gld_Triangle2DFlatTwoside_DX9;
			tnl->Driver.Render.Quad		= gld_Quad2DFlatTwoside_DX9;
		} else {
			tnl->Driver.Render.Line		= gld_Line2DSmoothTwoside_DX9;
			tnl->Driver.Render.Triangle	= gld_Triangle2DSmoothTwoside_DX9;
			tnl->Driver.Render.Quad		= gld_Quad2DSmoothTwoside_DX9;
		}
	} else {*/
//		IDirect3DDevice8_SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, TRUE);
		IDirect3DDevice9_SetSoftwareVertexProcessing(gld->pDev, TRUE);
		gldPB = &gld->PB2d;
		_GLD_DX9_DEV(SetVertexShader(gld->pDev, NULL));
		_GLD_DX9_DEV(SetFVF(gld->pDev, gldPB->dwFVF));
		tnl->Driver.Render.Points	= _gldSetupPoints[gld->iSetupFunc];
		tnl->Driver.Render.Line		= _gldSetupLine[gld->iSetupFunc];
		tnl->Driver.Render.Triangle	= _gldSetupTriangle[gld->iSetupFunc];
		tnl->Driver.Render.Quad		= _gldSetupQuad[gld->iSetupFunc];
//	}

	_GLD_DX9_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
	gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
	// Allocate primitive pointers
	// gldPB->pPoints is always first
	gldPB->pLines		= gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
	gldPB->pTriangles	= gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);

	ASSERT(tnl->Driver.Render.BuildVertices);
	ASSERT(tnl->Driver.Render.PrimitiveNotify);
	ASSERT(tnl->Driver.Render.Points);
	ASSERT(tnl->Driver.Render.Line);
	ASSERT(tnl->Driver.Render.Triangle);
	ASSERT(tnl->Driver.Render.Quad);
	ASSERT(tnl->Driver.Render.ResetLineStipple);
	ASSERT(tnl->Driver.Render.Interp);
	ASSERT(tnl->Driver.Render.CopyPV);
	ASSERT(tnl->Driver.Render.ClippedLine);
	ASSERT(tnl->Driver.Render.ClippedPolygon);
	ASSERT(tnl->Driver.Render.Finish);
	
	tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
	
	if (VB->ClipOrMask) {
		tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
		clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
	}
	else {
		tab = (VB->Elts ? 
			tnl->Driver.Render.PrimTabElts : 
		tnl->Driver.Render.PrimTabVerts);
	}
	
	do {
		GLuint i, length, flags = 0;
		for (i = 0 ; !(flags & PRIM_END) ; i += length) {
			flags = VB->Primitive[i].mode;
			length= VB->Primitive[i].count;
			ASSERT(length || (flags & PRIM_END));
			ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
			if (length)
				tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
		}
	} while (tnl->Driver.Render.Multipass &&
		tnl->Driver.Render.Multipass( ctx, ++pass ));
	
	
//	tnl->Driver.Render.Finish( ctx );
	
	_GLD_DX9_VB(Unlock(gldPB->pVB));

	_GLD_DX9_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, 0, gldPB->dwStride));

	if (gldPB->nPoints) {
		_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
		gldPB->nPoints = 0;
	}

	if (gldPB->nLines) {
		_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
		gldPB->nLines = 0;
	}

	if (gldPB->nTriangles) {
		_GLD_DX9_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
		gldPB->nTriangles = 0;
	}

	return GL_FALSE;		/* finished the pipe */
}
Esempio n. 9
0
void gld_update_state_DX9(
	struct gl_context *ctx,
	GLuint new_state)
{
	GLD_context		*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx9	*gld	= GLD_GET_DX9_DRIVER(gldCtx);
	TNLcontext		*tnl = TNL_CONTEXT(ctx);
	GLD_pb_dx9		*gldPB;

	if (!gld || !gld->pDev)
		return;

	_swsetup_InvalidateState( ctx, new_state );
	_vbo_InvalidateState( ctx, new_state );
	_tnl_InvalidateState( ctx, new_state );

	// SetupIndex will be used in the pipelines for choosing setup function
	if ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE | DD_SEPARATE_SPECULAR)) ||
		(ctx->Fog.Enabled))
	{
		if (ctx->_TriangleCaps & DD_FLATSHADE)
			gld->iSetupFunc = GLD_SI_FLAT_EXTRAS;
		else
			gld->iSetupFunc = GLD_SI_SMOOTH_EXTRAS;
	} else {
		if (ctx->_TriangleCaps & DD_FLATSHADE)
			gld->iSetupFunc = GLD_SI_FLAT;	// Setup flat shade + texture
		else
			gld->iSetupFunc = GLD_SI_SMOOTH; // Setup smooth shade + texture
	}

	gld->bUseMesaTnL = _gldChooseInternalPipeline(ctx, gld);
	if (gld->bUseMesaTnL) {
		gldPB = &gld->PB2d;
		_GLD_DX9_DEV(SetSoftwareVertexProcessing(gld->pDev, TRUE));
		_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_CLIPPING, FALSE));
		_GLD_DX9_DEV(SetVertexShader(gld->pDev, NULL));
		_GLD_DX9_DEV(SetFVF(gld->pDev, gldPB->dwFVF));
	} else {
		gldPB = &gld->PB3d;
		_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_CLIPPING, TRUE));
//		if (gld->TnLPipeline == GLD_PIPELINE_D3D_VS_TWOSIDE) {
//			_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, !gld->VStwosidelight.bHardware));
//			_GLD_DX9_DEV(SetVertexShader(gld->pDev, gld->VStwosidelight.hShader));
//		} else {
//			_GLD_DX9_DEV(SetRenderState(gld->pDev, D3DRS_SOFTWAREVERTEXPROCESSING, !gld->bHasHWTnL));
			_GLD_DX9_DEV(SetSoftwareVertexProcessing(gld->pDev, !gld->bHasHWTnL));
			_GLD_DX9_DEV(SetVertexShader(gld->pDev, NULL));
			_GLD_DX9_DEV(SetFVF(gld->pDev, gldPB->dwFVF));
//		}
	}

#define _GLD_TEST_STATE(a)		\
	if (new_state & (a)) {		\
		gld##a(ctx);			\
		new_state &= ~(a);		\
	}

#define _GLD_TEST_STATE_DX9(a)	\
	if (new_state & (a)) {		\
		gld##a##_DX9(ctx);		\
		new_state &= ~(a);		\
	}

#define _GLD_IGNORE_STATE(a) new_state &= ~(a);

//	if (!gld->bUseMesaTnL) {
		// Not required if Mesa is doing the TnL.
	// Problem: If gld->bUseMesaTnL is TRUE when these are signaled,
	// then we'll miss updating the D3D TnL pipeline.
	// Therefore, don't test for gld->bUseMesaTnL
	_GLD_TEST_STATE(_NEW_MODELVIEW);
	_GLD_TEST_STATE(_NEW_PROJECTION);
//	}

	_GLD_TEST_STATE_DX9(_NEW_TEXTURE); // extern, so guard with _DX9
	_GLD_TEST_STATE(_NEW_COLOR);
	_GLD_TEST_STATE(_NEW_DEPTH);
	_GLD_TEST_STATE(_NEW_POLYGON);
	_GLD_TEST_STATE(_NEW_STENCIL);
	_GLD_TEST_STATE(_NEW_FOG);
	_GLD_TEST_STATE(_NEW_LIGHT);
	_GLD_TEST_STATE(_NEW_VIEWPORT);

	_GLD_IGNORE_STATE(_NEW_TRANSFORM);

	// Scissor Test: New for DX9
	_GLD_TEST_STATE(_NEW_SCISSOR);

// Stubs for future use.
/*	_GLD_TEST_STATE(_NEW_TEXTURE_MATRIX);
	_GLD_TEST_STATE(_NEW_COLOR_MATRIX);
	_GLD_TEST_STATE(_NEW_EVAL);
	_GLD_TEST_STATE(_NEW_HINT);
	_GLD_TEST_STATE(_NEW_LINE);
	_GLD_TEST_STATE(_NEW_PIXEL);
	_GLD_TEST_STATE(_NEW_POINT);
	_GLD_TEST_STATE(_NEW_POLYGONSTIPPLE);
	_GLD_TEST_STATE(_NEW_PACKUNPACK);
	_GLD_TEST_STATE(_NEW_ARRAY);
	_GLD_TEST_STATE(_NEW_RENDERMODE);
	_GLD_TEST_STATE(_NEW_BUFFERS);
	_GLD_TEST_STATE(_NEW_MULTISAMPLE);
*/

// For debugging.
#if 0
#define _GLD_TEST_UNHANDLED_STATE(a)									\
	if (new_state & (a)) {									\
		gldLogMessage(GLDLOG_ERROR, "Unhandled " #a "\n");	\
	}
	_GLD_TEST_UNHANDLED_STATE(_NEW_TEXTURE_MATRIX);
	_GLD_TEST_UNHANDLED_STATE(_NEW_COLOR_MATRIX);
	_GLD_TEST_UNHANDLED_STATE(_NEW_EVAL);
	_GLD_TEST_UNHANDLED_STATE(_NEW_HINT);
	_GLD_TEST_UNHANDLED_STATE(_NEW_LINE);
	_GLD_TEST_UNHANDLED_STATE(_NEW_PIXEL);
	_GLD_TEST_UNHANDLED_STATE(_NEW_POINT);
	_GLD_TEST_UNHANDLED_STATE(_NEW_POLYGONSTIPPLE);
//	_GLD_TEST_UNHANDLED_STATE(_NEW_SCISSOR);
	_GLD_TEST_UNHANDLED_STATE(_NEW_PACKUNPACK);
	_GLD_TEST_UNHANDLED_STATE(_NEW_ARRAY);
	_GLD_TEST_UNHANDLED_STATE(_NEW_RENDERMODE);
	_GLD_TEST_UNHANDLED_STATE(_NEW_BUFFERS);
	_GLD_TEST_UNHANDLED_STATE(_NEW_MULTISAMPLE);
#undef _GLD_UNHANDLED_STATE
#endif

#undef _GLD_TEST_STATE
}
Esempio n. 10
0
void Screen3D::DrawSprite( int x, int y, Texture* Image, int alpha)
{
	SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );

	Texture* T = Image;
	Real texturewidth=1, textureheight=1;
	if(T)
	{
		texturewidth  = T->GetWidth();
		textureheight = T->GetHeight();
	}

	//float jiggle= (rand() % 10000) - 5000;
	//jiggle /= 5000.0f;
	float jiggle = 0.5f;

	if( alpha != 255 )
		jiggle = 0;
	x--;
	y--;
	

	ScreenVertex v[6];
	D3DCOLOR color = D3DCOLOR_ARGB( alpha, 255, 255, 255 );
	v[0] = ScreenVertex( x+jiggle,   y+jiggle,   1,					color, 0, 0 );
	v[2] = ScreenVertex( x+jiggle+texturewidth, y+textureheight, 1, color, 1, 1 );
	v[1] = ScreenVertex( x+jiggle,   y+jiggle+textureheight, 1,		color, 0, 1 );
	v[3] = ScreenVertex( x+jiggle,   y+jiggle, 1,					color, 0, 0 );
	v[5] = ScreenVertex( x+jiggle+texturewidth, y+jiggle,   1,		color, 1, 0 );
	v[4] = ScreenVertex( x+jiggle+texturewidth, y+textureheight+jiggle, 1, color, 1, 1 );

	SetTexture(Image, 0);
	SetFVF(D3DFVF_SCREENVERTEX);
	SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	
//	D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,   TRUE);
//	D3DDevice->SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_SRCALPHA);
	//D3DDevice->SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_INVSRCALPHA);
	
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 2, v,  sizeof(ScreenVertex));

	ResetWireframeState();

		// Figure out the vertices for the main window
	/*ScreenVertex WindowVertices[4];

	WindowVertices[0].z   = 0;WindowVertices[1].z   = 0;WindowVertices[2].z   = 0;WindowVertices[3].z   = 0;
	WindowVertices[0].RHW = 1;	WindowVertices[1].RHW = 1; WindowVertices[2].RHW = 1; WindowVertices[3].RHW = 1;
	WindowVertices[0].color = D3DCOLOR_RGBA(255, 255, 255, alpha);WindowVertices[1].color = D3DCOLOR_RGBA(255, 255, 255, alpha);
	WindowVertices[2].color = D3DCOLOR_RGBA(255, 255, 255, alpha);WindowVertices[3].color = D3DCOLOR_RGBA(255, 255, 255, alpha);

	WindowVertices[0].x   = x;
	WindowVertices[0].y   = y;
	WindowVertices[1].x   = x+texturewidth;
	WindowVertices[1].y   = y;
	WindowVertices[2].x   = x;
	WindowVertices[2].y   = y+textureheight;
	WindowVertices[3].x   = x+texturewidth;
	WindowVertices[3].y   = y+textureheight;



	WindowVertices[0].tu  = 0;
	WindowVertices[0].tv  = 0;
	WindowVertices[1].tu  = 1;
	WindowVertices[1].tv  = 0;
	WindowVertices[2].tu  = 0;
	WindowVertices[2].tv  = 1;
	WindowVertices[3].tu  = 1;
	WindowVertices[3].tv  = 1;


	SetTexture(Image, 0);
	D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,   TRUE);
	D3DDevice->SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_SRCALPHA);
	D3DDevice->SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_INVSRCALPHA);
	SetFVF(D3DFVF_SCREENVERTEX);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, WindowVertices,  sizeof(ScreenVertex));*/
}
Esempio n. 11
0
void Screen3D::DrawSpriteNoHandle( RECT& Dimensions, Texture* Image, bool StretchTexture, D3DCOLOR color, bool SetAlphaStates)
{
	SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );
	//Figure out the size of the texture (if there is a texture)
	Texture* T = Image;
	Real texturewidth=1, textureheight=1;
	if(T)
	{
		texturewidth  = T->GetWidth();
		textureheight = T->GetHeight();
	}


	// Figure out the vertices for the main window
	ScreenVertex WindowVertices[4];

	WindowVertices[0].z   = 0;WindowVertices[1].z   = 0;WindowVertices[2].z   = 0;WindowVertices[3].z   = 0;
	WindowVertices[0].RHW = 1;	WindowVertices[1].RHW = 1; WindowVertices[2].RHW = 1; WindowVertices[3].RHW = 1;
	WindowVertices[0].color = color;WindowVertices[1].color = color;
	WindowVertices[2].color = color;WindowVertices[3].color = color;

	WindowVertices[0].x   = Dimensions.left;
	WindowVertices[0].y   = Dimensions.top;

	
	WindowVertices[1].x   = Dimensions.right;
	WindowVertices[1].y   = Dimensions.top;

	WindowVertices[2].x   = Dimensions.left;
	WindowVertices[2].y   = Dimensions.bottom;

	WindowVertices[3].x   = Dimensions.right;
	WindowVertices[3].y   = Dimensions.bottom;


	if( StretchTexture )
	{
		WindowVertices[0].tu  = 0;
		WindowVertices[0].tv  = 0;
		WindowVertices[1].tu  = 1;
		WindowVertices[1].tv  = 0;
		WindowVertices[2].tu  = 0;
		WindowVertices[2].tv  = 1;
		WindowVertices[3].tu  = 1;
		WindowVertices[3].tv  = 1;
	}
	else
	{
		WindowVertices[0].tu  = 0;
		WindowVertices[0].tv  = 0;
		WindowVertices[1].tu  = (Dimensions.right-Dimensions.left) / texturewidth;
		WindowVertices[1].tv  = 0;
		WindowVertices[2].tu  = 0;
		WindowVertices[2].tv  = (Dimensions.bottom-Dimensions.top) / textureheight;
		WindowVertices[3].tu  = (Dimensions.right-Dimensions.left) / texturewidth;
		WindowVertices[3].tv  = (Dimensions.bottom-Dimensions.top) / textureheight;
	}

	PolygonsRendered += 2;
	DrawCalls++;

	SetTexture(Image, 0);
	if(SetAlphaStates)
	{
		D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,   TRUE);
		D3DDevice->SetRenderState(D3DRS_SRCBLEND,           D3DBLEND_SRCALPHA);
		D3DDevice->SetRenderState(D3DRS_DESTBLEND,          D3DBLEND_INVSRCALPHA);
	}
	SetFVF(D3DFVF_SCREENVERTEX);
	D3DDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, WindowVertices,  sizeof(ScreenVertex));

}