1 / 8

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics. 2D Rendering. Goals. Learn the basic states used in 2D rendering See how to render 2D images on the screen Review the fixed function pixel pipeline. D3D Calls. Typical global configuration.

ava-holt
Download Presentation

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UW ExtensionCertificate Program inGame Development 2nd quarter:Advanced Graphics 2D Rendering

  2. Goals • Learn the basic states used in 2D rendering • See how to render 2D images on the screen • Review the fixed function pixel pipeline

  3. D3D Calls

  4. Typical global configuration • Disable Z-buffering and stencil • SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); • SetRenderState(D3DRS_ZWRITEENABLE, FALSE); • SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); • Disable pixel shader (will use the texture stage states) • SetPixelShader(NULL); • Normal shading and no culling • SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

  5. Typical global configuration (cont.) • Enable alpha-blending • SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); • SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); • SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); • SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); • SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); • Disable alpha-testing • SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);

  6. Basic primitive: the rectangle • Create the vertices • Vertex const vertices[4] = { • { 20, 20, 0, 1, … }, • { 100, 20, 0, 1, … }, • { 20, 100, 0, 1, … }, • { 100, 100, 0, 1, … }, }; • Set up the vertex format (must match the data!) • SetFVF(D3DFVF_XYZRHW | …); • And render • DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertices, sizeof(vertices[0]));

  7. Textures • Select the texture image: • SetTexture(0, pTexture); • Select the sampling settings: • SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); • SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); • SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); • SetSamplerState(0, D3DSAMP_ADDRESSU, D3DADDRESS_CLAMP); • SetSamplerState(0, D3DSAMP_ADDRESSV, D3DADDRESS_CLAMP);

  8. Texture calculations • Perform custom calculations for every pixel. For instance: • SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); • SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); • SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); • SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); • SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT); • SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0); • Disable the first one that’s not needed • SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); • SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

More Related