Changes

Jump to: navigation, search

GAM670/DPS905 Weekly Schedule 20121

830 bytes added, 09:07, 15 February 2012
This Week
* Vertex Shader Programming
** Host
:: APIPlatformSettings.h - Vertex Shader Identification- select between fixed function and programmable pipelines here
<pre>
// shader file data
#define VERTEX_SHADER_ENTRY_POINT "vertexShader"
</pre>
:: APIBase.h - pointers into the shader- APIBase is the base class for the graphics API classes
<pre>
static IDirect3DVertexShader9* vertexShader; // vertex shader
static ID3DXConstantTable* uniformVS; // for vertex shader
</pre>
:: APIBase.cpp - initialize the shader pointers
<pre>
IDirect3DVertexShader9* APIBase::vertexShader = nullptr; // vertex shader
ID3DXConstantTable* APIBase::uniformVS = nullptr; // for vertex shader
</pre>
:: APIDisplay.h- keeps track of the current projection matrix
<pre>
Matrix projection; // projection transformation
</pre>
:: APIDisplay.cpp - setup()- checks the shader version
<pre>
// points to compiled shader code
// check for minimum vertex shader version required
if (caps.VertexShaderVersion < D3DVS_VERSION(2,0))
error(L"DisplayAPIDisplay::09 Device does not support vertex shader 2_0");
</pre>
compiles the shader hlsl code, retrieves address of constant memory and vertex shader
<pre>
// compile the vertex shader source code
compiledCodeVS->Release();
</pre>
sets the current vertex shader
<pre>
d3dd->SetVertexShader(vertexShader);
</pre>
:: APIDisplay.cpp - setProjection()- stores the projection matrix
<pre>
this->projection = *((Matrix*)projection);
</pre>
:: APIDisplay.cpp - beginDrawFrame()- copies the view matrix and the camera heading to constant memory
<pre>
Matrix& v = *((Matrix*)view);
uniformVS->SetInt(d3dd, "noLights", 4);
</pre>
:: APIDisplay.cpp - set()- copies the lighting state to constant memory
<pre>
uniformVS->SetBool(d3dd, "lighting", b);
</pre>
:: APIDisplay.cpp - setWorld()- copies the world matrix to constant memory
<pre>
uniformVS->SetMatrix(d3dd, "world", (D3DXMATRIX*)world);
</pre>
:: APIDisplay.cpp - setReflectivity()- copies the reflectivity to constant memory
<pre>
uniformVS->SetFloatArray(d3dd, "material.ambient", (FLOAT*)&r.ambient, 4);
uniformVS->SetFloat (d3dd, "material.power", (FLOAT)r.power);
</pre>
:: APIDisplay.cpp - release()- releases constant memory and the vertex shader
<pre>
// release the shader COM objects
}
</pre>
:: APILight.cpp - setup()- copies the light properties to constant memory
<pre>
// Populate the vertex shader constant table
rc = true;
</pre>
:: APILight.cpp - turnOn()- repositions the light and turns it on
<pre>
char constantLightOn[] = "lightOn[0]";
uniformVS->SetBool(d3dd, constantLightOn, true);
</pre>
:: APILight.cpp - update()- repositions the light
<pre>
char constantLightOn[] = "lightOn[0]";
uniformVS->SetBool(d3dd, constantLightOn, true);
</pre>
:: APILight.cpp - turnOff()- turns off the light
<pre>
char constantLightOn[] = "lightOn[0]";
uniformVS->SetBool(d3dd, constantLightOn, false);
</pre>
:: APIGraphic.h - class APIXMesh- processes an X file mesh
<pre>
D3DXCOLOR* ambient;
FLOAT* power;
</pre>
:: APIGraphic.cpp - APIXMesh()- constructor
<pre>
ambient = nullptr;
power = nullptr;
</pre>
:: APIGraphic.cpp - APIXMesh()- copy constructor
<pre>
ambient = nullptr;
power = nullptr;
</pre>
:: APIGraphic.cpp - operator=()= assignment operator
<pre>
if (ambient)
}
</pre>
:: APIGraphic.cpp - setup()-
<pre>
ambient = new D3DXCOLOR[nSubsets];

Navigation menu