void RenderQuad() { // Setup texture g_pd3dDevice->SetTexture(0, g_pRenderTexture) ; g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP ); g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP ); // Set stream source g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) ); g_pd3dDevice->SetFVF(VertexFVF) ; g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ; }
VOID jcd3d::jcd3d_display(DWORD timeDelta) { if(lpd3dd) { lpd3dd->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x000000, 1.0f, 0); lpd3dd->BeginScene(); lpd3dd->SetStreamSource(0, lpd3dvb, 0, sizeof(JCVertex)); lpd3dd->SetFVF(JCVertex::fvf); lpd3dd->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); lpd3dd->EndScene(); lpd3dd->Present(NULL, NULL, NULL, NULL); } }
// @brief : 描画 // @param : 描画の種類 //-------------------------------------------------------------------- void Vertex3dCol::Draw(const TYPE &_type, const UINT &_prim_count) { const D3DPRIMITIVETYPE type[MAX_TYPE] = { D3DPT_POINTLIST, D3DPT_LINELIST, D3DPT_LINESTRIP, D3DPT_TRIANGLELIST, D3DPT_TRIANGLESTRIP }; HRESULT hr; LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device; hr = device->SetStreamSource(0,m_Buffer,0,sizeof(VERTEX_DX)); hr = device->SetFVF(FVF); hr = device->DrawPrimitive(type[_type],0,_prim_count); }
void RenderQuad() { // Setup texture g_pd3dDevice->SetTexture(0, g_pTexture) ; g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xffff0000) ; // border color: red g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, g_AddressMode ); g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, g_AddressMode ); // Set stream source g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) ); g_pd3dDevice->SetFVF(VertexFVF) ; g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ; }
void DxPoint::Draw( const float& positionX, const float& positionY, const float& positionZ, const float& scale, bool textureBlend) { LPDIRECT3DDEVICE9 pDevice = D3DManager::getInstance()->getDevice(); D3DXMATRIX matPos; D3DXMatrixTranslation(&matPos, positionX, positionY, positionZ); pDevice->SetTransform(D3DTS_WORLD, &matPos); pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE); pDevice->SetRenderState(D3DRS_POINTSCALE_A, 0); pDevice->SetRenderState(D3DRS_POINTSCALE_B, 0); pDevice->SetRenderState(D3DRS_POINTSCALE_C, 1036831949); pDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&scale)); if (textureBlend) { pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); } pDevice->SetStreamSource(0, mp_vertexBuffer, 0, sizeof(POINT_CUSTOMVERTEX)); pDevice->SetFVF(POINT_CUSTOMVERTEX::D3DFVF_POINT); if (mp_texture) { pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE); pDevice->SetTexture(0, mp_texture); } pDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1); if (mp_texture) { pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE); } pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE); if (textureBlend) { pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); } }
// this function renders the particle void Particles::render_particle(LPDIRECT3DDEVICE9 d3ddev, int a) { //d3ddev->SetFVF(CUSTOMFVF); if(a == 1){ d3ddev->SetStreamSource(0, f_buffer, 0, sizeof(CUSTOMVERTEX2)); } else{ d3ddev->SetStreamSource(0, t_buffer, 0, sizeof(CUSTOMVERTEX1)); } if(a == 1) d3ddev->SetTexture(0, texture1); else d3ddev->SetTexture(0, texture); d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1); return; }
void HealthBar::Render(LPDIRECT3DDEVICE9 pDevice) { pDevice->SetTexture(0, NULL); pDevice->SetRenderState(D3DRS_LIGHTING, FALSE); /*D3DMATERIAL9 material; ::memset(&material, 0, sizeof(D3DMATERIAL9)); material.Diffuse = D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f); pDevice->SetMaterial(&material);*/ pDevice->SetFVF(LITVERTEX::GetFVF()); pDevice->SetStreamSource(0, m_pVertBuf, 0, sizeof(LITVERTEX)); pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2); pDevice->SetRenderState(D3DRS_LIGHTING, TRUE); }
//**************************Render and display the scene in DirectX*********************** void RenderDX() { g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Rendering of scene objects can happen here g_pd3dDevice->SetStreamSource( 0, vbo, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); // End the scene g_pd3dDevice->EndScene(); } g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void DX9LineRenderer::render(const Group& group) { HRESULT hr; if( !DX9PrepareBuffers(group) ) return; if (!prepareBuffers(group)) return; initBlending(); if( group.getNbParticles() != 0 ) { for (size_t i = 0; i < group.getNbParticles(); ++i) { const Particle& particle = group.getParticle(i); D3DCOLOR c = D3DCOLOR_COLORVALUE(particle.getR(), particle.getG(), particle.getB(), particle.getParamCurrentValue(PARAM_ALPHA)); Assign((gpuIterator)->position, particle.position()); (gpuIterator++)->color = c; Assign((gpuIterator)->position, (particle.position() + particle.velocity() * length)); (gpuIterator++)->color = c; } void *ptr; if( DX9VertexBuffer->Lock(0, 0, &ptr, 0) == D3D_OK ) { std::memcpy(ptr, gpuBuffer, group.getNbParticles() * 2 * sizeof(LineVertex)); if( DX9VertexBuffer->Unlock() == D3D_OK ) { LPDIRECT3DDEVICE9 device = DX9Info::getDevice(); device->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE); device->SetStreamSource(0, DX9VertexBuffer, 0, sizeof(LineVertex)); device->DrawPrimitive(D3DPT_LINELIST, 0, group.getNbParticles()); } } } }
VOID Render() { if( !g_pd3dDevice ) return; LPDIRECT3DDEVICE9 d = g_pd3dDevice; d->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); if( SUCCEEDED( d->BeginScene() ) ) { SetupLights(); SetupMatrices(); d->SetStreamSource( 0, g_pVertexBuff, 0, sizeof(CUSTOMVERTEX) ); d->SetFVF( D3DFVF_CUSTOMVERTEX ); d->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 * 50 - 2 ); //d->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME ); d->EndScene(); } d->Present( NULL, NULL, NULL, NULL ); }
//*************************************************************** // 描画 // 引数: // LPDIRECT3DDEVICE9 pDevice:デバイスポインタ // 戻り値: // なし //*************************************************************** void CTitle2d::Draw(LPDIRECT3DDEVICE9 pDevice) { //テクスチャ取得変数 LPDIRECT3DTEXTURE9 Texture = CTexture::GetTexture(m_nTex); //アンロック変数 VERTEX_2D *pv; //ロック解除 m_pD3DVtxBuff->Lock(0,0,(void**)&pv,0); //画像の初期化の流れ //座標x,y,z pv[0].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x, m_Vertex_2d.vtx.y, 0.0f); pv[1].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x + m_Vertex_2d.Scail.x, m_Vertex_2d.vtx.y,0.0f); pv[2].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x, m_Vertex_2d.vtx.y + m_Vertex_2d.Scail.y,0.0f); pv[3].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x + m_Vertex_2d.Scail.x,m_Vertex_2d.vtx.y + m_Vertex_2d.Scail.y,0.0f); //頂点色(赤、緑、青) pv[0].diffuse = m_Vertex_2d.diffuse; pv[1].diffuse = m_Vertex_2d.diffuse; pv[2].diffuse = m_Vertex_2d.diffuse; pv[3].diffuse = m_Vertex_2d.diffuse; //ロック m_pD3DVtxBuff->Unlock(); //フォーマットの指定 pDevice->SetFVF(FVF_VERTEX_2D); //テクスチャ設定 pDevice->SetTexture(0, Texture); //頂点バッファの送信 pDevice->SetStreamSource(0,m_pD3DVtxBuff,0,sizeof(VERTEX_2D)); //画像表示 pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); }
// this is the function used to render a single frame void render_frame(void) { d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->BeginScene(); // select which vertex format we are using d3ddev->SetFVF(CUSTOMFVF); // select the vertex buffer to display d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); // copy the vertex buffer to the back buffer d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); }
VOID jcd3d::jcd3d_display(DWORD timeDelta) { if(lpd3dd) { if(GetAsyncKeyState('W') & 0x8000f ) { lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); } // set border color address mode if(GetAsyncKeyState('B') & 0x8000f ) { lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); lpd3dd->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0x000000ff); } // set clamp address mode if(GetAsyncKeyState('C') & 0x8000f ) { lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); } // set mirror address mode if(GetAsyncKeyState('M') & 0x8000f ) { lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR); lpd3dd->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR); } lpd3dd->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFFFFFFF, 1.0f, 0); lpd3dd->BeginScene(); lpd3dd->SetStreamSource(0, lpd3dvb, 0, sizeof(Vertex)); lpd3dd->SetFVF(Vertex::FVF); lpd3dd->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); lpd3dd->EndScene(); lpd3dd->Present(NULL, NULL, NULL, NULL); } }
//----------------------------------------------------------------------------- // Name: Render() // Desc: Draws the scene //----------------------------------------------------------------------------- VOID Render() { // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 ); D3DLOCKED_RECT locked; if(g_pTexture->LockRect(0, &locked, NULL, /*D3DLOCK_DISCARD*/0)==D3D_OK) { memcpy(locked.pBits, videoFrame, TEXTURE_WIDTH*TEXTURE_HEIGHT*3); g_pTexture->UnlockRect(0); } // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Setup the world, view, and projection matrices SetupMatrices(); // Setup our texture. Using textures introduces the texture stage states, // which govern how textures get blended together (in the case of multiple // textures) and lighting information. In this case, we are modulating // (blending) our texture with the diffuse color of the vertices. g_pd3dDevice->SetTexture( 0, g_pTexture ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); // Draws two triangles (makes a quad that will support our drone video picture) g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); // End the scene g_pd3dDevice->EndScene(); } // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void Render(float timeDelta) { if (!g_bActive) { Sleep(50) ; } SetupMatrix() ; // Clear the back-buffer to a RED color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Render state g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); g_pd3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE) ; g_pd3dDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE) ; g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, FtoDW(0.2f) ); // Set texture g_pd3dDevice->SetTexture(0, g_pTexture) ; // Draw points g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(POINTVERTEX)); g_pd3dDevice->SetFVF(D3DFVF_POINTVERTEX) ; g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, NUM_VERTEX) ; // Restore state g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ); // End the scene g_pd3dDevice->EndScene(); } // Present the back-buffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
// ポイントスプライトを描画する void Object::DrawPointSprite(Vertex3 point[], int numPoint, Texture &texture) { Vertex3 *vertex; pointBuffer->Lock(0, 0, (LPVOID*)&vertex, 0); for (int i = 0; i < numPoint; i++) { // ポイントスプライトの位置の計算 vertex[i].pos = point[i].pos; // ポイントスプライトのサイズを設定 vertex[i].size = point[i].size; // ポイントスプライトの色を設定 vertex[i].color = point[i].color; } pointBuffer->Unlock(); // テクスチャをパイプラインにセット d3dDevice->SetTexture(0, texture.texture); // ワールド変換マトリックスをパイプラインにセット D3DXMATRIX m_world; D3DXMatrixIdentity(&m_world); d3dDevice->SetTransform(D3DTS_WORLD, &m_world); //アルファブレンディングを行う d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); // ポイントスプライトの描画 d3dDevice->SetRenderState(D3DRS_ZENABLE, true); // Z比較を行わない d3dDevice->SetStreamSource(0, pointBuffer, 0, sizeof(Vertex3)); d3dDevice->SetFVF(VERTEX3_FVF); d3dDevice->DrawPrimitive(D3DPT_POINTLIST, 0, numPoint); d3dDevice->SetRenderState(D3DRS_ZENABLE, true); // Z比較を行う //アルファブレンドを終わらせる d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false); }
// @brief : 描画 //-------------------------------------------------------------------- void SpriteDx9::Draw( void ) { HRESULT hr; LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device; auto col = static_cast<D3DXCOLOR>(static_cast<Color>(PolygonColor)); VERTEX *vtx; m_VertexBuffer->Lock(0,0,(void**)&vtx,0); for( auto i = 0 ; i < 4 ; ++i ) { vtx[i].col = col; } m_VertexBuffer->Unlock(); ((Texture)Tex)->Set(); hr = device->SetStreamSource(0,m_VertexBuffer,0,sizeof(VERTEX)); hr = device->SetFVF(VERTEX_FVF); hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); }
void Plane::draw(LPDIRECT3DDEVICE9 device) { device->SetVertexShader(_vs); device->SetPixelShader(_ps); device->SetFVF(D3DFVF_CUSTOMVERTEX); //device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); const D3DXMATRIX& view = Camera::view(), projection = Camera::projection(); //D3DXMATRIX rot; //D3DXMatrixRotationAxis(&rot, &D3DXVECTOR3(0, 1, 0), angle); //world *= rot; D3DXMATRIX world_view_projection = world * view * projection; _vs_constant_table->SetMatrix(device, "g_world_view_projection", &world_view_projection); _vs_constant_table->SetMatrix(device, "g_world", &world); device->SetTexture(0, texture); device->SetStreamSource(0, vbuf, 0, sizeof(CUSTOMVERTEX)); device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); device->SetTexture(0, NULL); device->SetVertexShader(NULL); device->SetPixelShader(NULL); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); }
virtual void repaint() { if ( retry_count && !restore_objects() ) return; lpdev->Clear( 0L, NULL, D3DCLEAR_TARGET, 0x000000ff, 1.0f, 0L ); HRESULT rv = lpdev->BeginScene(); if( SUCCEEDED( rv ) ) { set_vertex( 0, 0, input_width, input_height, surface_width, surface_height, 0, 0, rcWindow.right, rcWindow.bottom ); lpdev->SetTexture( 0, lptex ); lpdev->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); lpdev->EndScene(); if ( lpdev->Present( NULL, NULL, NULL, NULL ) == D3DERR_DEVICELOST ) retry_count = 60; } else retry_count = 60; ValidateRect( hWnd, & rcWindow ); }
//----------------------------------------------------------------------------- // Desc: 渲染图形 //----------------------------------------------------------------------------- VOID Render() { //清空后台缓冲区 g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(45, 50, 170), 1.0f, 0 ); //开始在后台缓冲区绘制图形 if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { //在后台缓冲区绘制图形 g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); //结束在后台缓冲区绘制图形 g_pd3dDevice->EndScene(); } //将在后台缓冲区绘制的图形提交到前台缓冲区显示 g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
//*************************************************************** // 描画 //引数 //LPDIRECT3DDEVICE9 pDevice:デバイスポインタ //*************************************************************** void CFade::Draw(LPDIRECT3DDEVICE9 pDevice) { //テクスチャ取得変数 LPDIRECT3DTEXTURE9 Texture = CTexture::GetTexture(m_nTex); //描画タイプの変更 CRenderer::SetRenderType(CRenderer::NOMAL); //アンロック変数 VERTEX_2D *pv; //ロック解除 m_pD3DVtxBuff->Lock(0,0,(void**)&pv,0); //画像の初期化の流れ //座標x,y,z pv[0].vtx = D3DXVECTOR3(-SCREEN_WIDTH + m_Vertex_2d.vtx.x, 0, 0.0f); pv[1].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x, 0,0.0f); pv[2].vtx = D3DXVECTOR3(-SCREEN_WIDTH + m_Vertex_2d.vtx.x, SCREEN_HEIGHT,0.0f); pv[3].vtx = D3DXVECTOR3(m_Vertex_2d.vtx.x,SCREEN_HEIGHT,0.0f); m_pD3DVtxBuff->Unlock(); //フォーマットの指定 pDevice->SetFVF(FVF_VERTEX_2D); //テクスチャ設定 pDevice->SetTexture(0, Texture); //頂点バッファの送信 pDevice->SetStreamSource(0,m_pD3DVtxBuff,0,sizeof(VERTEX_2D)); //画像表示 pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2); }
void Render(float timeDelta) { if (!g_bActive) { Sleep(50) ; } SetupMatrix() ; // Clear the back-buffer to a RED color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Disable lighting, since we didn't specify color for vertex g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , FALSE ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Draw teapot g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); // 12 triangles forms six faces and a cube g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 12 ); // End the scene g_pd3dDevice->EndScene(); } // Present the back-buffer contents to the display HRESULT hr = g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); if (FAILED(hr)) { d3dpp.Windowed = TRUE; // use window mode, not full screen d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; ResetDevice(d3dpp); } }
//============================================================================= // 描画処理 //============================================================================= void DrawBotton(void) { LPDIRECT3DDEVICE9 pDevice = GetDevice(); // 頂点バッファをデバイスのデータストリームにバインド pDevice->SetStreamSource(0, g_pD3DVtxBuffBotton, 0, sizeof(VERTEX_2D)); // 頂点フォーマットの設定 pDevice->SetFVF(FVF_VERTEX_2D); for(int nCntBot = 0; nCntBot < MAX_BOTTON; nCntBot++) { if(g_aBotton[nCntBot].bUse == true) { // テクスチャの設定 pDevice->SetTexture(0, g_apD3DTextureBotton[g_aBotton[nCntBot].nType]); // ポリゴンの描画 pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, (nCntBot * 4), NUM_POLYGON); } } }
//描画 void Vertices::Draw(LPDIRECT3DDEVICE9 pD3DDevice, D3DXMATRIX *pmtrx) { if (!pD3DDevice || !pVertexBuffer) return; D3DXMATRIX mtrxOld; //ワールド変換行列保存用 pD3DDevice->GetTransform(D3DTS_WORLD, &mtrxOld); //ワールド行列を保存 pD3DDevice->SetTransform(D3DTS_WORLD, pmtrx); //デバイスにマトリックスを設定 pD3DDevice->SetStreamSource(0, pVertexBuffer, 0, sizeof(D3DVERTEX)); //頂点バッファをデバイスのストリームにセット if (pIndexBuffer) //インデックスバッファが存在する場合 { pD3DDevice->SetIndices(pIndexBuffer); //インデックスバッファをセット pD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, vectorD3DVERTEX.size(), 0, Primitives); //頂点インデックスありで描画 } else { //存在しない場合 pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, Primitives); //頂点インデックスなしで描画 } pD3DDevice->SetTransform(D3DTS_WORLD, &mtrxOld); //デバイスのワールド変換行列を復元 return; }
//============================================================================= // 描画処理 //============================================================================= void DrawPlaybar(void) { LPDIRECT3DDEVICE9 pDevice = GetDevice(); // 頂点バッファをデバイスのデータストリームにバインド pDevice->SetStreamSource(0, g_pD3DVtxBuffPlaybar, 0, sizeof(VERTEX_2D)); // 頂点フォーマットの設定 pDevice->SetFVF(FVF_VERTEX_2D); for(int nCntPlayBar = 0; nCntPlayBar < MAX_PLAYBAR; nCntPlayBar++) { if(g_aPlaybar[nCntPlayBar].bUse == true) { // テクスチャの設定 pDevice->SetTexture(0, g_apD3DTexturePlaybar[g_aPlaybar[nCntPlayBar].nType]); // ポリゴンの描画 pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, (nCntPlayBar * 4), NUM_POLYGON); } } }
VOID Render() { D3DLOCKED_RECT lr; if(SUCCEEDED(g_pTexture->LockRect(0,&lr,NULL,0))) { g_ogg.video_read((char*)lr.pBits,lr.Pitch); g_pTexture->UnlockRect(0); } if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { g_pd3dDevice->SetTexture(0,g_pTexture); g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 2 ); g_pd3dDevice->EndScene(); } g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
VOID Render() { // Clear the backbuffer to a black color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Setup the world, view, and projection matrices SetupMatrices(); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); // End the scene g_pd3dDevice->EndScene(); } // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
//----------------------------------------------------------------------------- // Desc: 渲染图形 //----------------------------------------------------------------------------- VOID Render() { //清空后台缓冲区 g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(60, 60, 60), 1.0f, 0 ); //开始在后台缓冲区绘制图形 if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { //在后台缓冲区绘制图形 g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); switch(g_iType) //选择绘制图元的类型 { case 1: //三角形条带 g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 4 ); break; case 2: //三角形列表 g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2 ); break; case 3: //线段条带 g_pd3dDevice->DrawPrimitive( D3DPT_LINESTRIP, 0, 5 ); break; case 4: //线段列表 g_pd3dDevice->DrawPrimitive( D3DPT_LINELIST, 0, 3 ); break; case 5: //点列表 g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, 6 ); break; case 6: g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 4); break; } //结束在后台缓冲区渲染图形 g_pd3dDevice->EndScene(); } //将在后台缓冲区绘制的图形提交到前台缓冲区显示 g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
void Menu::drawMenu(LPDIRECT3DDEVICE9 device) { if (!menuEnabled || !awesomiumReady) { return; } if (!texture) { device->CreateVertexBuffer(6 * sizeof(Vertex), D3DUSAGE_WRITEONLY, Vertex::FVF, D3DPOOL_DEFAULT, &quadVertexBuffer, 0); Vertex* v; quadVertexBuffer->Lock(0, 0, (void**)&v, 0); v[0] = { -1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f }; v[1] = { -1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f }; v[2] = { 1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f }; v[3] = { -1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f }; v[4] = { 1.0f, 1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f }; v[5] = { 1.0f, -1.0f, 1.25f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f }; quadVertexBuffer->Unlock(); D3DXCreateTexture(device, Callbacks::settings->HORIZONTAL_RESOLUTION, Callbacks::settings->VERTICAL_RESOLUTION, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8B8G8R8, D3DPOOL_DEFAULT, &texture); device->SetTexture(0, texture); } device->SetTexture(0, texture); // This needs to be called every EndScene call for some reason texture->LockRect(0, &lockRect, 0, 0); memcpy(lockRect.pBits, ((Awesomium::BitmapSurface*) webView->surface())->buffer(), 4 * Callbacks::settings->HORIZONTAL_RESOLUTION * Callbacks::settings->VERTICAL_RESOLUTION); texture->UnlockRect(0); device->SetStreamSource(0, quadVertexBuffer, 0, sizeof(Vertex)); device->SetFVF(Vertex::FVF); device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 4); }
//----------------------------------------------------------------------------- // Desc: 渲染图形 //----------------------------------------------------------------------------- VOID Render() { //清空后台缓冲区和深度缓冲区 g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(45, 50, 170), 1.0f, 0 ); //开始在后台缓冲区绘制图形 if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { //设置材料和灯光, 因为灯光属性不断变化,所以在此设置 SetupLights(); //在后台缓冲区绘制图形 g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2*50-2 ); //结束在后台缓冲区绘制图形 g_pd3dDevice->EndScene(); } //将在后台缓冲区绘制的图形提交到前台缓冲区显示 g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }