当前位置: 首页>>代码示例>>C++>>正文


C++ IDirect3DDevice9::SetSamplerState方法代码示例

本文整理汇总了C++中IDirect3DDevice9::SetSamplerState方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirect3DDevice9::SetSamplerState方法的具体用法?C++ IDirect3DDevice9::SetSamplerState怎么用?C++ IDirect3DDevice9::SetSamplerState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirect3DDevice9的用法示例。


在下文中一共展示了IDirect3DDevice9::SetSamplerState方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AcquireDevice

void MythRenderD3D9::Init2DState(void)
{
    IDirect3DDevice9* dev = AcquireDevice();
    if (!dev)
        return;

    dev->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    dev->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
    dev->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    dev->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    dev->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    dev->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
    dev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255,255,255));
    dev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    dev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    dev->SetRenderState(D3DRS_LIGHTING, FALSE);
    dev->SetRenderState(D3DRS_DITHERENABLE, TRUE);
    dev->SetRenderState(D3DRS_STENCILENABLE, FALSE);
    dev->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA);
    dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    dev->SetVertexShader(NULL);
    SetTextureVertices(dev, false);
    MultiTexturing(dev, false);
    EnableBlending(dev, false);

    ReleaseDevice();
}
开发者ID:DocOnDev,项目名称:mythtv,代码行数:29,代码来源:mythrender_d3d9.cpp

示例2: setCommonBlitState

void Blit::setCommonBlitState()
{
    IDirect3DDevice9 *device = getDevice();

    device->SetDepthStencilSurface(NULL);

    device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
    device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
    device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
    device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
    device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);

    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, FALSE);
    device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

    for (int i = 0; i < MAX_VERTEX_ATTRIBS+1; i++)
    {
        device->SetStreamSourceFreq(i, 1);
    }

    RECT scissorRect = {0};   // Scissoring is disabled for flipping, but we need this to capture and restore the old rectangle
    device->SetScissorRect(&scissorRect);
}
开发者ID:smoogipooo,项目名称:angle-fullscreen,代码行数:29,代码来源:Blit.cpp

示例3: setCommonBlitState

void Blit::setCommonBlitState()
{
    IDirect3DDevice9 *device = getDevice();

    device->SetDepthStencilSurface(NULL);

    device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
    device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
    device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
    device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
    device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);

    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_SRGBTEXTURE, FALSE);
    device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);

    for (int i = 0; i < MAX_VERTEX_ATTRIBS+1; i++)
    {
        device->SetStreamSourceFreq(i, 1);
    }
}
开发者ID:pelegri,项目名称:WebKit-PlayBook,代码行数:26,代码来源:Blit.cpp

示例4: Restore

void CState::Restore()
{
	// viewport
	m_D3DDev->SetViewport(&m_Vp);

	// render states
	m_D3DDev->SetRenderState(D3DRS_ZENABLE, m_Z);
	m_D3DDev->SetRenderState(D3DRS_CULLMODE, m_CullMode);
	m_D3DDev->SetRenderState(D3DRS_ALPHATESTENABLE, m_AlphaTest);
	m_D3DDev->SetRenderState(D3DRS_ALPHABLENDENABLE, m_AlphaBlend);
	m_D3DDev->SetRenderState(D3DRS_BLENDOP, m_BlendOp);
	m_D3DDev->SetRenderState(D3DRS_SRCBLEND, m_SrcBlend);
	m_D3DDev->SetRenderState(D3DRS_DESTBLEND, m_DstBlend);
	m_D3DDev->SetRenderState(D3DRS_CLIPPLANEENABLE, m_ClipPlane);
	m_D3DDev->SetRenderState(D3DRS_FILLMODE, m_FillMode);
	m_D3DDev->SetRenderState(D3DRS_LASTPIXEL, m_LastPixel);
	m_D3DDev->SetRenderState(D3DRS_FOGENABLE, m_Fog);
	m_D3DDev->SetRenderState(D3DRS_STENCILENABLE, m_Stencil);
	m_D3DDev->SetRenderState(D3DRS_COLORWRITEENABLE, m_ColorWrite);
	m_D3DDev->SetRenderState(D3DRS_SCISSORTESTENABLE, m_Scissor);
	if( m_Caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND )
		m_D3DDev->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, m_SeparateAlphaBlend);
	//if( m_Caps.LineCaps & D3DLINECAPS_ANTIALIAS )
		m_D3DDev->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, m_AntiAliasedLine);

	// primitive
	m_D3DDev->SetFVF(m_FVF);
	m_D3DDev->SetStreamSource(0, m_StreamData, m_StreamOffset, m_StreamStride);
	if( m_StreamData )
		m_StreamData->Release();
	m_D3DDev->SetVertexShader(m_VertexShader);
	if( m_VertexShader )
		m_VertexShader->Release();

	// texture
	m_D3DDev->SetTexture(0, m_Tex);
	if( m_Tex )
		m_Tex->Release();
	m_D3DDev->SetPixelShader(m_PixelShader);
	if( m_PixelShader )
		m_PixelShader->Release();

	// texture stage states
	m_D3DDev->SetTextureStageState(0, D3DTSS_COLOROP, m_ColorOp);
	m_D3DDev->SetTextureStageState(0, D3DTSS_COLORARG1, m_ColorArg1);
	m_D3DDev->SetTextureStageState(0, D3DTSS_COLORARG2, m_ColorArg2);
	m_D3DDev->SetTextureStageState(0, D3DTSS_ALPHAOP, m_AlphaOp);
	m_D3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, m_AlphaArg1);
	m_D3DDev->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, m_TexCoordIndex);
	m_D3DDev->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, m_TexTransfFlags);
	m_D3DDev->SetSamplerState(0, D3DSAMP_ADDRESSU, m_AddressU);
	m_D3DDev->SetSamplerState(0, D3DSAMP_ADDRESSV, m_AddressV);
	m_D3DDev->SetSamplerState(0, D3DSAMP_MAGFILTER, m_MagFilter);
	m_D3DDev->SetSamplerState(0, D3DSAMP_MINFILTER, m_MinFilter);
	m_D3DDev->SetSamplerState(0, D3DSAMP_MIPFILTER, m_MipFilter);
}
开发者ID:Mashewnutz,项目名称:Slo,代码行数:56,代码来源:TwDirect3D9.cpp

示例5: boxFilter

bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = copySurfaceToTexture(source, getSurfaceRect(source));
    if (!texture)
    {
        return false;
    }

    IDirect3DDevice9 *device = getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setVertexShader(SHADER_VS_STANDARD);
    setPixelShader(SHADER_PS_PASSTHROUGH);

    setCommonBlitState();
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

    setViewport(getSurfaceRect(dest), 0, 0);

    render();

    texture->Release();

    restoreState();

    return true;
}
开发者ID:smoogipooo,项目名称:angle-fullscreen,代码行数:32,代码来源:Blit.cpp

示例6: Error

gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = NULL;
    gl::Error error = copySurfaceToTexture(source, getSurfaceRect(source), &texture);
    if (error.isError())
    {
        return error;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setVertexShader(SHADER_VS_STANDARD);
    setPixelShader(SHADER_PS_PASSTHROUGH);

    setCommonBlitState();
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

    setViewport(getSurfaceRect(dest), 0, 0);

    render();

    SafeRelease(texture);

    restoreState();

    return gl::Error(GL_NO_ERROR);
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:33,代码来源:Blit9.cpp

示例7: WinMain

int WINAPI WinMain(HINSTANCE hist,HINSTANCE phist,LPSTR cmd,int show)
{
	srand((unsigned int)time(0));
	WinInfo info;
	if (!initWindow(800,600,false,"my game",hist,&info))
	{
		return -1;
	}

	DxParam param = {info.isFullScreen,info.width,info.height,info.hwnd};
	DxFw df;
	if (!df.initDx(param))
	{
		MessageBox(0,"fuck","",MB_OK);
	}

	if (!df.initInput(info.hwnd,info.hist,false))
	{
		MessageBox(0,"input failed","",MB_OK);
	}

	registAllDefaultAffectos();

	df.getRenderer()->setAsPerspectiveProjection(PI_OVER_2,800.0f / 600.0f,1.0f,1000.0f);

	SceneNodeContainer c;
	SceneNode* n = c.createNode("test");
	XModel x;
	x.mXmodel = df.getResourceManager()->loadXModel(DEFAULT_GROUP_NAME,"ship.x");
	n->attach(&x);
	MSG msg;

	D3DLIGHT9 light;
	::ZeroMemory(&light, sizeof(light));
	light.Type      = D3DLIGHT_DIRECTIONAL;
	light.Ambient   = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	light.Diffuse   = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	light.Specular  = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);
	light.Direction = D3DXVECTOR3(1.0f, -1.0f, 0.0f);

	IDirect3DDevice9* device = df.getDevice();

	device->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
	device->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
	device->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_POINT);

	df.getRenderer()->setLight(0,&light);

	Node camera;
	camera.setPosition(0.0f,100.0f,0.0f);
	camera.lookAt(Vector3(0.0f,0.0f,0.0f));

	n->yaw(PI);

	//Device->SetRenderState(D3DRS_NORMALIZENORMALS, true);
	//Device->SetRenderState(D3DRS_SPECULARENABLE, true);

	GUISystem* guisys = GUISystem::getSingletonPtr();
	guisys->initOnce(df);

	//Route r(new LinearPathRel(Vector3(10.0f,0.0f,10.0f),0.5),true);
	//r.addPath(new LinearPathRel(Vector3(-10.0f,0.0f,10.0f),0.5));

	//TranslateToAction action(n,Vector3(10.0f,0.0f,0.0f),1.0,Node::TS_PARENT);
	//guisys->load("media/gui/dx.xml");
	//GUIButton* btn = (GUIButton*) guisys->getLayout(0)->getControlById(0);

	//btn->setClickListener(fuck);

	//GUIImage* img = layout->createImage(0,0,800,600,2);
	//img->setImage("menu/mainMenu.jpg");

	GUILayout* layout = guisys->createLayout(0);
	DxFont* font = guisys->createFont("",15,false,15,0);
	GUILabel* label = layout->createLabel(0,0,800,600,0,0);
	label->setColor(0xffff0000);
	guisys->changeCurrentLayout(0);
	loggingInit(label);

	DxParticleSystem ps;
	loadParticleSystem(&ps,&df,"media/particle/particl_1.lua");
	//ps.init(&df,5012,"media/tex/smoke000.tga");

	/*
	DxParticleEmitter* em = new DxParticleEmitter;
	
	DxColorValue e = {0.7f,0.7f,0.8f,0.7f};
	DxColorValue b = {0.7f,0.7f,0.8f,0.7f};
 	em->colorBegine = b;
	em->colorEnd = e;
	
	em->angle = 0.0f;
	em->up = Vector3::UNIT_Y;
	em->direction = Vector3::UNIT_Z;
	em->duration = 0.0f;
	em->emitRate = 1000.0f;
	em->maxPosition = Vector3(1.0f,10.0f,2.0f);
	em->minPosition = Vector3(-1.0f,0.0f,-1.0f);
	em->minVelocity = 50.0f;
	em->maxVelocity = 80.0f;
//.........这里部分代码省略.........
开发者ID:wtmsuperman,项目名称:DxFw,代码行数:101,代码来源:test_main.cpp

示例8: float

// parameters should be validated/clamped by caller
EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{
    if (!mSwapChain)
    {
        return EGL_SUCCESS;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    // Disable all pipeline operations
    device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
    device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
    device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
    device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
    device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
    device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
    device->SetPixelShader(NULL);
    device->SetVertexShader(NULL);

    device->SetRenderTarget(0, mBackBuffer);
    device->SetDepthStencilSurface(NULL);

    device->SetTexture(0, mOffscreenTexture);
    device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
    device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);

    for (UINT streamIndex = 0; streamIndex < gl::MAX_VERTEX_ATTRIBS; streamIndex++)
    {
        device->SetStreamSourceFreq(streamIndex, 1);
    }

    D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
    device->SetViewport(&viewport);

    float x1 = x - 0.5f;
    float y1 = (mHeight - y - height) - 0.5f;
    float x2 = (x + width) - 0.5f;
    float y2 = (mHeight - y) - 0.5f;

    float u1 = x / float(mWidth);
    float v1 = y / float(mHeight);
    float u2 = (x + width) / float(mWidth);
    float v2 = (y + height) / float(mHeight);

    float quad[4][6] = {{x1, y1, 0.0f, 1.0f, u1, v2},
                        {x2, y1, 0.0f, 1.0f, u2, v2},
                        {x2, y2, 0.0f, 1.0f, u2, v1},
                        {x1, y2, 0.0f, 1.0f, u1, v1}};   // x, y, z, rhw, u, v

    mRenderer->startScene();
    device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float));
    mRenderer->endScene();

    device->SetTexture(0, NULL);

    RECT rect =
    {
        x, mHeight - y - height,
        x + width, mHeight - y
    };

    HRESULT result = mSwapChain->Present(&rect, &rect, NULL, NULL, 0);

    mRenderer->markAllStateDirty();

    if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
    {
        return EGL_BAD_ALLOC;
    }

    // On Windows 8 systems, IDirect3DSwapChain9::Present sometimes returns 0x88760873 when the windows is
    // in the process of entering/exiting fullscreen. This code doesn't seem to have any documentation.  The
    // device appears to be ok after emitting this error so simply return a failure to swap.
    if (result == 0x88760873)
    {
        return EGL_BAD_NATIVE_WINDOW;
    }

    // http://crbug.com/313210
    // If our swap failed, trigger a device lost event. Resetting will work around an AMD-specific
    // device removed bug with lost contexts when reinstalling drivers.
    if (FAILED(result))
    {
        mRenderer->notifyDeviceLost();
        return EGL_CONTEXT_LOST;
    }

    return EGL_SUCCESS;
}
开发者ID:zanxi,项目名称:bitpop,代码行数:100,代码来源:SwapChain9.cpp

示例9: float

// parameters should be validated/clamped by caller
EGLint SwapChain9::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{
    if (!mSwapChain)
    {
        return EGL_SUCCESS;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    // Disable all pipeline operations
    device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
    device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
    device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
    device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
    device->SetRenderState(D3DRS_STENCILENABLE, FALSE);
    device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0);
    device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
    device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);
    device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
    device->SetPixelShader(NULL);
    device->SetVertexShader(NULL);

    device->SetRenderTarget(0, mBackBuffer);
    device->SetDepthStencilSurface(NULL);

    device->SetTexture(0, mOffscreenTexture);
    device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
    device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    device->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);

    D3DVIEWPORT9 viewport = {0, 0, mWidth, mHeight, 0.0f, 1.0f};
    device->SetViewport(&viewport);

    float x1 = x - 0.5f;
    float y1 = (mHeight - y - height) - 0.5f;
    float x2 = (x + width) - 0.5f;
    float y2 = (mHeight - y) - 0.5f;

    float u1 = x / float(mWidth);
    float v1 = y / float(mHeight);
    float u2 = (x + width) / float(mWidth);
    float v2 = (y + height) / float(mHeight);

    float quad[4][6] = {{x1, y1, 0.0f, 1.0f, u1, v2},
                        {x2, y1, 0.0f, 1.0f, u2, v2},
                        {x2, y2, 0.0f, 1.0f, u2, v1},
                        {x1, y2, 0.0f, 1.0f, u1, v1}};   // x, y, z, rhw, u, v

    mRenderer->startScene();
    device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float));
    mRenderer->endScene();

    device->SetTexture(0, NULL);

    RECT rect =
    {
        x, mHeight - y - height,
        x + width, mHeight - y
    };

    HRESULT result = mSwapChain->Present(&rect, &rect, NULL, NULL, 0);

    mRenderer->markAllStateDirty();

    if (d3d9::isDeviceLostError(result))
    {
        return EGL_CONTEXT_LOST;
    }

    if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY || result == D3DERR_DRIVERINTERNALERROR)
    {
        return EGL_BAD_ALLOC;
    }

    ASSERT(SUCCEEDED(result));

    return EGL_SUCCESS;
}
开发者ID:BenHollandDev,项目名称:webkit.js,代码行数:85,代码来源:SwapChain9.cpp

示例10: if

HRESULT _stdcall MGEProxyD3D::CreateDevice(UINT a, D3DDEVTYPE b, HWND c, DWORD d, D3DPRESENT_PARAMETERS8 *e, IDirect3DDevice8 **f)
{
    LOG::logline(">> D3D Proxy CreateDevice");

    if(e->Windowed)
    {
        HWND hMainWnd = GetParent(c);
        int wx = std::max(0, (GetSystemMetrics(SM_CXSCREEN) - (int)e->BackBufferWidth) / 2);
        int wy = std::max(0, (GetSystemMetrics(SM_CYSCREEN) - (int)e->BackBufferHeight) / 2);

        if(Configuration.Borderless)
        {
            // Remove non-client window parts and move window flush to screen edge / centre if smaller than display
            SetWindowLong(hMainWnd, GWL_STYLE, WS_VISIBLE);
            SetWindowPos(hMainWnd, NULL, wx, wy, e->BackBufferWidth, e->BackBufferHeight, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOZORDER);
        }
        else
        {
            // Move window to top, with client area centred on one axis
            RECT rect = { wx, wy, e->BackBufferWidth, e->BackBufferHeight };
            AdjustWindowRect(&rect, GetWindowLong(hMainWnd, GWL_STYLE), FALSE);
            SetWindowPos(hMainWnd, NULL, rect.left, 0, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOZORDER);
        }
    }

    // Map 16x antialiasing to equivalent CSAA
    D3DMULTISAMPLE_TYPE msaaSamples = (Configuration.AALevel == 16) ? D3DMULTISAMPLE_8_SAMPLES : (D3DMULTISAMPLE_TYPE)Configuration.AALevel;
    DWORD msaaQuality = (Configuration.AALevel == 16) ? 2 : 0;

    // Override device parameters
    // Note that Morrowind will look at the modified parameters
    if(e->Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER)
        e->Flags ^= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

    e->MultiSampleType = msaaSamples;
    e->AutoDepthStencilFormat = (D3DFORMAT)Configuration.ZBufFormat;
    e->FullScreen_RefreshRateInHz = (!e->Windowed) ? Configuration.RefreshRate : 0;
    e->FullScreen_PresentationInterval = (Configuration.VWait == 255) ? D3DPRESENT_INTERVAL_IMMEDIATE : Configuration.VWait;

    // Convert presentation parameters to DX9
    D3DPRESENT_PARAMETERS9 pp;

    pp.BackBufferWidth = e->BackBufferWidth;
    pp.BackBufferHeight = e->BackBufferHeight;
    pp.BackBufferFormat = e->BackBufferFormat;
    pp.BackBufferCount = e->BackBufferCount;
    pp.MultiSampleType = e->MultiSampleType;
    pp.MultiSampleQuality = msaaQuality;
    pp.SwapEffect = e->SwapEffect;
    pp.hDeviceWindow = e->hDeviceWindow;
    pp.Windowed = e->Windowed;
    pp.Flags = e->Flags;
    pp.EnableAutoDepthStencil = e->EnableAutoDepthStencil;
    pp.AutoDepthStencilFormat = e->AutoDepthStencilFormat;
    pp.FullScreen_RefreshRateInHz = e->FullScreen_RefreshRateInHz;
    pp.PresentationInterval = e->FullScreen_PresentationInterval;

    // Create device in the same manner as the proxy
    IDirect3DDevice9 *realDevice = NULL;
    HRESULT hr = realD3D->CreateDevice(a, b, c, d, &pp, &realDevice);

    if(hr != D3D_OK)
    {
        LOG::logline("!! D3D Proxy CreateDevice failure");
        return hr;
    }

    *f = factoryProxyDevice(realDevice);

    // Set up default render states
    Configuration.ScaleFilter = (Configuration.AnisoLevel > 0) ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR;
    Configuration.MipFilter = D3DTEXF_LINEAR;

    for(int i = 0; i != 4; ++i)
    {
        realDevice->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, Configuration.AnisoLevel);
        realDevice->SetSamplerState(i, D3DSAMP_MINFILTER, Configuration.ScaleFilter);
        realDevice->SetSamplerState(i, D3DSAMP_MIPMAPLODBIAS, *(DWORD *)&Configuration.LODBias);
    }

    // Set variables dependent on configuration
    DWORD FogPixelMode, FogVertexMode, RangedFog;
    if(Configuration.FogMode == 2)
    {
            FogVertexMode = D3DFOG_LINEAR;
            FogPixelMode = D3DFOG_NONE;
            RangedFog = 1;
    }
    else if(Configuration.FogMode == 1)
    {
            FogVertexMode = D3DFOG_LINEAR;
            FogPixelMode = D3DFOG_NONE;
            RangedFog = 0;
    }
    else
    {
            FogVertexMode = D3DFOG_NONE;
            FogPixelMode = D3DFOG_LINEAR;
            RangedFog = 0;
    }
//.........这里部分代码省略.........
开发者ID:Petethegoat,项目名称:MGE-XE,代码行数:101,代码来源:mgedirect3d8.cpp

示例11: Init

HRESULT APPLICATION::Init(HINSTANCE hInstance, int width, int height, bool windowed)
{
	debug.Print("Application initiated");

	//Create Window Class
	WNDCLASS wc;
	memset(&wc, 0, sizeof(WNDCLASS));
	wc.style         = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = (WNDPROC)::DefWindowProc; 
	wc.hInstance     = hInstance;
	wc.lpszClassName = "D3DWND";

	//Register Class and Create new Window
	RegisterClass(&wc);
	m_mainWindow = CreateWindow("D3DWND", "Example 5.6: Frustum Culling", WS_EX_TOPMOST, 0, 0, width, height, 0, 0, hInstance, 0); 
	SetCursor(NULL);
	ShowWindow(m_mainWindow, SW_SHOW);
	UpdateWindow(m_mainWindow);

	//Create IDirect3D9 Interface
	IDirect3D9* d3d9 = Direct3DCreate9(D3D_SDK_VERSION);

    if(d3d9 == NULL)
	{
		debug.Print("Direct3DCreate9() - FAILED");
		return E_FAIL;
	}

	//Check that the Device supports what we need from it
	D3DCAPS9 caps;
	d3d9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);

	//Hardware Vertex Processing or not?
	int vp = 0;
	if(caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
		vp = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else vp = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

	//Check vertex & pixelshader versions
	if(caps.VertexShaderVersion < D3DVS_VERSION(2, 0) || caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
	{
		debug.Print("Warning - Your graphic card does not support vertex and pixelshaders version 2.0");
	}

	//Set D3DPRESENT_PARAMETERS
	D3DPRESENT_PARAMETERS d3dpp;
	d3dpp.BackBufferWidth            = width;
	d3dpp.BackBufferHeight           = height;
	d3dpp.BackBufferFormat           = D3DFMT_A8R8G8B8;
	d3dpp.BackBufferCount            = 1;
	d3dpp.MultiSampleType            = D3DMULTISAMPLE_NONE;
	d3dpp.MultiSampleQuality         = 0;
	d3dpp.SwapEffect                 = D3DSWAPEFFECT_DISCARD; 
	d3dpp.hDeviceWindow              = m_mainWindow;
	d3dpp.Windowed                   = windowed;
	d3dpp.EnableAutoDepthStencil     = true; 
	d3dpp.AutoDepthStencilFormat     = D3DFMT_D24S8;
	d3dpp.Flags                      = 0;
	d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
	d3dpp.PresentationInterval       = D3DPRESENT_INTERVAL_IMMEDIATE;

	//Create the IDirect3DDevice9
	if(FAILED(d3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_mainWindow,
								 vp, &d3dpp, &m_pDevice)))
	{
		debug.Print("Failed to create IDirect3DDevice9");
		return E_FAIL;
	}

	//Release IDirect3D9 interface
	d3d9->Release();

	D3DXCreateFont(m_pDevice, 18, 0, 0, 1, false,  
				   DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
				   DEFAULT_PITCH | FF_DONTCARE, "Arial", &m_pFont);

	//Create m_light
	::ZeroMemory(&m_light, sizeof(m_light));
	m_light.Type      = D3DLIGHT_DIRECTIONAL;
	m_light.Ambient   = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	m_light.Diffuse   = D3DXCOLOR(0.9f, 0.9f, 0.9f, 1.0f);
	m_light.Specular  = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	m_light.Direction = D3DXVECTOR3(0.0f, -1.0f, 0.0f);
	m_pDevice->SetLight(0, &m_light);
	m_pDevice->LightEnable(0, true);

	//Set sampler state
	for(int i=0;i<4;i++)
	{
		m_pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		m_pDevice->SetSamplerState(i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		m_pDevice->SetSamplerState(i, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
	}

	//Init camera
	m_camera.Init(m_pDevice);	

	//Load objects
	LoadObjectResources(m_pDevice);

//.........这里部分代码省略.........
开发者ID:Alriightyman,项目名称:RTS,代码行数:101,代码来源:app.cpp

示例12: vEyePt


//.........这里部分代码省略.........

	CGraphicsManager *pGraphicsManager = CGraphicsManager::GetInstance();
	IDirect3DDevice9 *pDevice = pGraphicsManager->GetDevice();
	CCamera * pCamera = CCamera::GetInstance();

	hr = pDevice->SetTransform(D3DTS_WORLD, &identityTransform);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set world transform", hr);
		return false;
	}
		
	D3DXMATRIX camViewMat = pCamera->GetViewMatrix();
	hr = pDevice->SetTransform(D3DTS_VIEW, &camViewMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set view transform", hr);
		return false;
	}

	D3DXMATRIX camProjMat = pCamera->GetProjectionMatrix();
	hr = pDevice->SetTransform(D3DTS_PROJECTION, &camProjMat);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set projection transform", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set cull mode render state", hr);
		return false;
	}

	hr = pDevice->SetLight(0, &light);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set light 0", hr);
		return false;
	}

	hr = pDevice->SetMaterial(&mtrl);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set material", hr);
		return false;
	}

	hr = pDevice->LightEnable(0, TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable light", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_AMBIENT, 0x00202020);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set ambient color", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to enable z", hr);
		return false;
	}

	hr = pDevice->SetRenderState(D3DRS_ZWRITEENABLE , TRUE);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set z write enabled", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MINFILTER", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MAGFILTER", hr);
		return false;
	}

	hr = pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	if(FAILED(hr))
	{
		LogErrorHr("Failed to set sampler state - MIPFILTER", hr);
		return false;
	}

	return true;
}
开发者ID:svdmaar,项目名称:Coop,代码行数:101,代码来源:Screen.cpp


注:本文中的IDirect3DDevice9::SetSamplerState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。