博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
render Target sample in UI
阅读量:4495 次
发布时间:2019-06-08

本文共 3422 字,大约阅读时间需要 11 分钟。

LPDIRECT3DDEVICE9 pd3dDevice;LPDIRECT3DTEXTURE9 pRenderTexture = NULL;LPDIRECT3DTEXTURE9 pPyramideTexture = NULL;    LPDIRECT3DSURFACE9 pRenderSurface = NULL,pBackBuffer = NULL;void init(){    pd3dDevice = g_pxD3d->GetDevice();    D3DXCreateTextureFromFile(pd3dDevice,L"UI_BG_PERSONSHOP.dds",&pPyramideTexture);    pd3dDevice->CreateTexture(512,        512,        1,        D3DUSAGE_RENDERTARGET,        D3DFMT_R5G6B5,        D3DPOOL_DEFAULT,        &pRenderTexture,        NULL);}void Render(){        D3DXMATRIX matProjection,matOldProjection;    VTXTYPE_2D_COLOR_TEX1 m_Vertices[4];        m_Vertices[0].x = 0;    m_Vertices[1].x = 500;    m_Vertices[2].x = m_Vertices[1].x;    m_Vertices[3].x = m_Vertices[0].x;    m_Vertices[0].y = 0;    m_Vertices[1].y = m_Vertices[0].y;    m_Vertices[2].y = 500;    m_Vertices[3].y = m_Vertices[2].y;    m_Vertices[0].z = 0;    m_Vertices[1].z = m_Vertices[0].z;    m_Vertices[2].z = m_Vertices[0].z;    m_Vertices[3].z = m_Vertices[0].z;    m_Vertices[0].tu = 0.0f; m_Vertices[0].tv = 0.0f;    m_Vertices[1].tu = 1.0f; m_Vertices[1].tv = 0.0f;    m_Vertices[2].tu = 1.0f; m_Vertices[2].tv = 1.0f;    m_Vertices[3].tu = 0.0f; m_Vertices[3].tv = 1.0f;    pRenderTexture->GetSurfaceLevel(0,&pRenderSurface);    //D3DXMatrixPerspectiveFovLH(&matProjection,D3DX_PI / 4.0f,1,1,100);    //pd3dDevice->GetTransform(D3DTS_PROJECTION,&matOldProjection);    pd3dDevice->GetRenderTarget(0,&pBackBuffer);    //render-to-texture    //set new render target    pd3dDevice->SetRenderTarget(0,pRenderSurface);    //clear texture    pd3dDevice->Clear(0,        NULL,        D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,        D3DCOLOR_XRGB(100,100,100),        1.0f,        0);    pd3dDevice->BeginScene();    pd3dDevice->SetTexture(0,pPyramideTexture);    /*D3DXMatrixRotationY(&matRotationY,fRotation);    D3DXMatrixTranslation(&matTranslation,0.0f,0.0f,5.0f);    pd3dDevice->SetTransform(D3DTS_WORLD,        &(matRotationY * matTranslation));*/    //set projection matrix    //pd3dDevice->SetTransform(D3DTS_PROJECTION,&matProjection);    //pd3dDevice->SetStreamSource(0,pTriangleVB,0,sizeof(D3DVERTEX));    pd3dDevice->SetFVF(VTXTYPE_2D_COLOR_TEX1::FVF);    pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, m_Vertices,    sizeof(VTXTYPE_2D_COLOR_TEX1));    pd3dDevice->EndScene();    //set back buffer    pd3dDevice->SetRenderTarget(0,pBackBuffer);    pd3dDevice->Clear(0,        NULL,        D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,        D3DCOLOR_XRGB(0,0,0),        1.0f,        0);    pd3dDevice->BeginScene();    //set rendered texture    pd3dDevice->SetTexture(0,pRenderTexture);    //pd3dDevice->SetTransform(D3DTS_WORLD,&matTranslation);    //restore projection matrix    //pd3dDevice->SetTransform(D3DTS_PROJECTION,&matOldProjection);    //pd3dDevice->SetStreamSource(0,pQuadVB,0,sizeof(D3DVERTEX));    //pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,0,2);    pd3dDevice->SetFVF(VTXTYPE_2D_COLOR_TEX1::FVF);    pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, m_Vertices,    sizeof(VTXTYPE_2D_COLOR_TEX1));    RenderText();    if(g_pTextRectItem)        g_pTextRectItem->render(pd3dDevice);    pd3dDevice->EndScene();    pd3dDevice->Present(NULL,NULL,NULL,NULL);}
void programExit(){    pRenderSurface->Release();    pRenderSurface = NULL;    pBackBuffer->Release();    pBackBuffer = NULL;        pRenderTexture->Release();}

转载于:https://www.cnblogs.com/oneDouble/archive/2012/06/21/2558097.html

你可能感兴趣的文章
【洛谷习题】灾后重建
查看>>
UVa 839 (递归方式读取二叉树) Not so Mobile
查看>>
iOS中获取文件保存目录路径的方法
查看>>
Semaphore信号量
查看>>
sql查询最大的见多了,查询第二的呢???
查看>>
Heimstaettenwegherb,村里最盛大的节日
查看>>
iOS 设置控件大小根据文本的大小
查看>>
MapReduce Design Patterns(7、输入输出模式)(十四)
查看>>
JS函数式编程【译】3.2 开发和生产环境
查看>>
火柴棍等式
查看>>
EasyUI中DataGrid构建复合表头
查看>>
[转]How to compile GDB for iOS!
查看>>
redis windows安装
查看>>
python有序字典OrderedDict()
查看>>
sql 检索字符串
查看>>
常用正则表达式
查看>>
HDU 4280 最大流Dinic算法优化
查看>>
八大排序算法
查看>>
why dropout work?
查看>>
小白成长记-----python实现注册的小程序
查看>>