commit 0067982d791c359f357692bc2057c9d3fe593c95
parent a8c44e6dc461b61635b1292021a7fbbba43ae4e5
Author: Brian Swetland <swetland@frotz.net>
Date: Sat, 2 Feb 2013 03:40:38 -0800
more compact data format
Diffstat:
3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/common/dxapp.cc b/common/dxapp.cc
@@ -193,7 +193,8 @@ int App::reconfigure(int init) {
td.Height = height;
td.MipLevels = 1;
td.ArraySize = 1;
- td.Format = DXGI_FORMAT_D32_FLOAT;
+// td.Format = DXGI_FORMAT_D32_FLOAT;
+ td.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; // NVIDIA suggested
td.SampleDesc.Count = 1;
td.SampleDesc.Quality = 0;
td.Usage = D3D10_USAGE_DEFAULT;
diff --git a/hello/SimpleVS.hlsl b/hello/SimpleVS.hlsl
@@ -14,10 +14,12 @@ VS_OUTPUT main(
float4 Position : POSITION,
float4 Normal : NORMAL,
float2 TexCoord : TEXCOORD,
- float4 Location : LOCATION) {
+ float4 Location : LOCATION
+ ) {
VS_OUTPUT output = (VS_OUTPUT) 0;
- Position.xyz += Location.xyz;
+
+ Position.xyz += Location.xyz * float3(127,127,127);
float3 mvPosition = mul(MV, Position).xyz;
float3 mvNormal = mul(MV, float4(Normal.xyz,0.0)).xyz;
diff --git a/hello/hello.cc b/hello/hello.cc
@@ -24,7 +24,7 @@ static D3D10_INPUT_ELEMENT_DESC obj_layout[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 },
- { "LOCATION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
+ { "LOCATION", 0, DXGI_FORMAT_R8G8B8A8_SNORM, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
};
static float locationx[] = {
@@ -35,7 +35,7 @@ static float locationx[] = {
4, 0, 0,
};
-static float location[8*8*8*3];
+static char location[8*8*8*4];
static float lcount = 0;
class TestApp : public App {
@@ -105,10 +105,11 @@ int TestApp::init(void) {
for (z = -4; z < 4; z++) {
for (y = -4; y < 4; y++) {
for (x = -4; x < 4; x++) {
- location[n+0] = (float) x;
- location[n+1] = (float) y;
- location[n+2] = (float) z;
- n += 3;
+ location[n+0] = x;
+ location[n+1] = y;
+ location[n+2] = z;
+ location[n+3] = 1;
+ n += 4;
}
}
}
@@ -122,7 +123,7 @@ int TestApp::init(void) {
return -1;
if (createIdxBuffer(m->idx, sizeof(short) * m->icount, &idxbuf))
return -1;
- if (createVtxBuffer(location, 8*8*8*12, &ibuf))
+ if (createVtxBuffer(location, 8*8*8*4, &ibuf))
return -1;
if (!(data = load_png_rgba("cube-texture.png", &dw, &dh, 0)))
@@ -157,7 +158,7 @@ void TestApp::render(void) {
UINT offset = 0;
device->IASetInputLayout(layout);
device->IASetVertexBuffers(0, 1, &vtxbuf, &stride, &offset);
- stride = 12;
+ stride = 4;
offset = 0;
device->IASetVertexBuffers(1, 1, &ibuf, &stride, &offset);
device->IASetIndexBuffer(idxbuf, DXGI_FORMAT_R16_UINT, 0);