void ParticleData::Draw(float x, float y, float z, float theta, float size, bool init, float speed){
	GetShaderPointer();

	//このコンスタントバッファーをどのシェーダーで使うか
	dx->pDeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
	dx->pDeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);
	dx->pDeviceContext->GSSetConstantBuffers(0, 1, &pConstantBuffer);

	//バーテックスバッファーをセット(計算前)
	ID3D11Buffer* buffer[1] = { pMyVB };
	UINT stride = sizeof(PartPos);
	UINT offset = 0;
	dx->pDeviceContext->IASetVertexBuffers(0, 1, buffer, &stride, &offset);
	//使用する頂点インプットレイアウトをセット
	dx->pDeviceContext->IASetInputLayout(pVertexLayout);
	//プリミティブ・トポロジーをセット
	dx->pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	//使用するシェーダーのセット
	dx->pDeviceContext->VSSetShader(pVertexShaderSO, NULL, 0);
	dx->pDeviceContext->GSSetShader(pGeometryShaderSO, NULL, 0);
	//ストリーム出力先セット
	buffer[0] = pMyVB_SO;
	dx->pDeviceContext->SOSetTargets(1, buffer, &offset);
	//ピクセルシェーダー無効
	dx->pDeviceContext->PSSetShader(NULL, NULL, 0);

	//ストリーム出力
	if (Drawfirst){
		dx->pDeviceContext->Draw(ver, 0);
		Drawfirst = false;
	}
	else
		dx->pDeviceContext->DrawAuto();

	buffer[0] = NULL;
	dx->pDeviceContext->SOSetTargets(1, buffer, &offset);

	//新しく計算した頂点データを描画対象にする
	ID3D11Buffer *tmp = pMyVB;
	pMyVB = pMyVB_SO;
	pMyVB_SO = tmp;

	//バーテックスバッファーをセット(計算後)
	dx->pDeviceContext->IASetVertexBuffers(0, 1, &pMyVB, &stride, &offset);
	//使用する頂点インプットレイアウトをセット
	dx->pDeviceContext->IASetInputLayout(pVertexLayout);
	//プリミティブ・トポロジーをセット
	dx->pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);

	dx->pDeviceContext->VSSetShader(pVertexShader, NULL, 0);
	dx->pDeviceContext->PSSetShader(pPixelShader, NULL, 0);
	dx->pDeviceContext->GSSetShader(pGeometryShader, NULL, 0);

	MatrixMap(x, y, z, theta, size, init, speed);

	//描画
	dx->pDeviceContext->DrawAuto();

	//ジオメトリシェーダー無効
	dx->pDeviceContext->GSSetShader(NULL, NULL, 0);
}
Esempio n. 2
0
void DisplayList::SetCamera(SRECT* frame, SRECT* viewRct, BOOL smooth, int scaleMode)
{
	// Set up the camera
	SRECT viewPort = *viewRct;
	if ( smooth ) {
	 	viewPort.xmin *= 4;
	 	viewPort.ymin *= 4;
	 	viewPort.xmax *= 4;
	 	viewPort.ymax *= 4;
	}

	// Calculate the mapping
	//	src = frame
	//	dst = viewPort
	MATRIX newMat;
	#define minMapSize 0x10L
	FLASHASSERT(!RectIsEmpty(&viewPort) && !RectIsEmpty(frame));
	newMat.a = FixedDiv(FixedMax(RectWidth(&viewPort), minMapSize), FixedMax(RectWidth(frame), minMapSize));
	newMat.d = FixedDiv(FixedMax(RectHeight(&viewPort), minMapSize), FixedMax(RectHeight(frame), minMapSize));
	newMat.b = newMat.c = 0;

	// Adjust the scaling to maintain the aspect ratio
	switch ( scaleMode & scaleMask ) {
		case showAll:
			newMat.a = newMat.d = FixedMin(newMat.a, newMat.d);
			break;
		case noBorder:
			newMat.a = newMat.d = FixedMax(newMat.a, newMat.d);
			break;
		case exactFit:
			MatrixMap(frame, &viewPort, &newMat);
			break;
		case noScale:
			newMat.a = newMat.d = smooth ? 4*fixed_1/20 : fixed_1/20;
			break;
	}

	// Pick the alignment point
	SPOINT srcRef, dstRef;
	if ( scaleMode & alignLeft ) {
		srcRef.x = frame->xmin;
		dstRef.x = viewPort.xmin;
	} else if ( scaleMode & alignRight ) {
		srcRef.x = frame->xmax;
		dstRef.x = viewPort.xmax;
	} else {
		srcRef.x = FixedAverage(frame->xmin, frame->xmax);
		dstRef.x = FixedAverage(viewPort.xmin, viewPort.xmax);
	}
	if ( scaleMode & alignTop ) {
		srcRef.y = frame->ymin;
		dstRef.y = viewPort.ymin;
	} else if ( scaleMode & alignBottom ) {
		srcRef.y = frame->ymax;
		dstRef.y = viewPort.ymax;
	} else {
		srcRef.y = FixedAverage(frame->ymin, frame->ymax);
		dstRef.y = FixedAverage(viewPort.ymin, viewPort.ymax);
	}

	// Calculate the translation based on the alignment
	newMat.tx = dstRef.x - FixedMul(srcRef.x, newMat.a);
	newMat.ty = dstRef.y - FixedMul(srcRef.y, newMat.d);

	// Don't invalidate unless there was a change
	BOOL smoothBits = smooth && !faster;
	if ( newMat.a  != camera.mat.a  || newMat.b  != camera.mat.b ||
		 newMat.c  != camera.mat.c  || newMat.d  != camera.mat.d ||
		 newMat.tx != camera.mat.tx || newMat.ty != camera.mat.ty ||
		 antialias != smooth || raster.smoothBitmaps != smoothBits ) {
		antialias = smooth;
		camera.mat = newMat;
		raster.smoothBitmaps = smoothBits;
		raster.bitmapDither = antialias ? errorDiffusionDither : orderedDither;
		ModifyCamera();
	}
}