programming4us
programming4us
MULTIMEDIA

DirectX 10 Game Programming : Direct3D - Textures and Details (part 3) - Drawing the Textured Object

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Drawing the Textured Object

It might seem like a lot of work just to map a single texture to a 3D object, but once you have the changes made to the shader, that code can be reused, simplifying your job in the future.

At this point the vertex format has been changed to support texture coordinates, the texture is loaded, and the shader knows how to map that texture to the object; finally, you can see what it looks like.

The Render function that makes use of the changes you’ve already made is shown next, with the additional SetResource call made to update the texture with the shader.

/*******************************************************************
* Render
* All drawing happens in the Render function
* Inputs - void
* Outputs - void
*******************************************************************/
void Render()
{
if (pD3DDevice != NULL)
{
// clear the target buffer
pD3DDevice->ClearRenderTargetView(pRenderTargetView, D3DXCOLOR(0.0f,
1.0f, 1.0f, 0.0f));

// Set the input layout
pD3DDevice->IASetInputLayout(gModelObject.pVertexLayout);

// Set vertex buffer
UINT stride = sizeof(VertexPosUVStruct);
UINT offset = 0;
pD3DDevice->IASetVertexBuffers(0, 1, &gModelObject.pVertexBuffer,
&stride, &offset);

// Set primitive topology
pD3DDevice-
>IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);

// Set the texture resource view
pBaseTextureVariable->SetResource(pTextureRV);

// Render a model object
D3D10_TECHNIQUE_DESC techniqueDescription;
gModelObject.pTechnique->GetDesc(&techniqueDescription);

// Loop through the technique passes
for(UINT p=0; p < techniqueDescription.Passes; ++p)
{
gModelObject.pTechnique->GetPassByIndex(p)->Apply(0);
pD3DDevice->Draw(gModelObject.numVertices, 0);
}

// display the next item in the swap chain
pSwapChain->Present(0, 0);
}
}


Figure 3 shows what the texture-mapped quad should look like.

Figure 3. The texture-mapped quad.

Other  
  •  DirectX 10 Game Programming : Shaders and Effects - Geometry Shaders
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Working with Rendering Intents
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Changing from Additive (RGB) to Subtractive (CMYK) Color
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Setting Up Soft-Proof Colors
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Producing Consistent Color
  •  Adobe Flash Professional CS5 : Creating Frame-by-Frame Animation - Editing Keyframes
  •  Adobe Flash Professional CS5 : Creating Frame-by-Frame Animation - Clearing Keyframes Versus Removing Frames
  •  Adobe Flash Professional CS5 : Creating Frame-by-Frame Animation - Converting Frames to Keyframes, Using Frame-Based Versus Span-Based Selection
  •  Adobe Flash Professional CS5 : Creating Frame-by-Frame Animation - Creating Keyframes
  •  Adobe Flash Professional CS5 : Creating Frame-by-Frame Animation - Understanding Frame-by-Frame Animation
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us