Okay, fixed that issue ran into a whole new issue. Everything is running fine until I try to render a set of 8 cubes. Currently all that shows up are my FPS displays and camera displays. Nothing else. Massive dump of code incoming.
DirectX 10 Initialization Code
int g_DXInit::initD3D10(HWND* hWnd)
{
//Create a pointer to the window handle. Why? Because hWnd is not part of g_DXInit and we need it for the swapChain.
InitHW = hWnd;
GetClientRect(*InitHW, &RC);
gameState = CONTROLLOCK;
D3DXMatrixIdentity(&gWorld);
width = RC.right - RC.left;
height = RC.bottom - RC.top;
if(!initSwapChain()) return 1;
gShader.gShaderHandle::gShaderHandle(&pD3DDevice, true);
if(!gShader.buildFX(L"test.hlsl")) return 6;
gShader.buildVertexLayouts();
if(!setViewports()) return 2;
if(!setupRasterize()) return 5;
if(!readyRenderTarget()) return 3;
font = D3DFonts.InitFont(font, pD3DDevice);
if(font == NULL)
{
return 4;
}
D3DX10CreateSprite(pD3DDevice, 0, &p_Sprite);
testWorld.planetOctree::planetOctree(&pD3DDevice);
//testWorld.getChild(7,7,7);
testWorld.generateChildren();
gEffect = gShader.returnEffect();
gTech = gShader.returnTech();
gfxWVP = gEffect->GetVariableByName("gWVP")->AsMatrix();
pD3DDevice->RSSetState(solidRS);
pD3DDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
pD3DDevice->IASetInputLayout(gShader.returnInputL());
gameState = GAMENORMAL;
renderList = testWorld.returnAllMesh();
return 0;
}
bool g_DXInit::initSwapChain()
{
DXGI_SWAP_CHAIN_DESC swapChainDesc;
ZeroMemory(&swapChain, sizeof(swapChain));
//Buffer Settings
swapChainDesc.BufferCount = 2;
swapChainDesc.BufferDesc.Width = width;
swapChainDesc.BufferDesc.Height = height;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
//Refresh Rate
swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
//Swap Chain Sample Settings
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
//Outputting Window Handle
swapChainDesc.OutputWindow = *InitHW;
swapChainDesc.Windowed = true;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDesc.Flags = 0;
swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
if( FAILED(D3D10CreateDeviceAndSwapChain( NULL,
D3D10_DRIVER_TYPE_HARDWARE,
NULL,
D3D10_CREATE_DEVICE_DEBUG,
D3D10_SDK_VERSION,
&swapChainDesc,
&swapChain,
&pD3DDevice))) return false;
return true;
}
bool g_DXInit::readyRenderTarget()
{
//Setup Back Buffer and render targets. Shadow Mapping is kept separate for readability
backBuffer = 0;
if( FAILED(swapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*) &backBuffer))) return false;
if( FAILED(pD3DDevice->CreateRenderTargetView(backBuffer, 0, &pRTV))) return false;
//Re;ease Back Buffer now that swapChain and D3D10 Device have used it.
backBuffer->Release();
//Ready Render Target, specifically create 2D Texture and depth stencil view
D3D10_TEXTURE2D_DESC depthStencil;
depthStencil.Width = width;
depthStencil.Height = height;
depthStencil.MipLevels = 1;
depthStencil.ArraySize = 1;
depthStencil.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencil.SampleDesc.Count = 1;
depthStencil.SampleDesc.Quality = 0;
depthStencil.Usage = D3D10_USAGE_DEFAULT;
depthStencil.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencil.CPUAccessFlags = 0;
depthStencil.MiscFlags = 0;
//depth stencil done, use it now
D3D10_DEPTH_STENCIL_VIEW_DESC depthView;
depthView.Format = depthStencil.Format;
depthView.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
depthView.Texture2D.MipSlice = 0;
if(FAILED(pD3DDevice->CreateTexture2D(&depthStencil, 0, &depthStencilTex))) return false;
if(FAILED(pD3DDevice->CreateDepthStencilView(depthStencilTex, &depthView, &depthSV))) return false;
pD3DDevice->OMSetRenderTargets(1, &pRTV, depthSV);
return true;
}
bool g_DXInit::setViewports()
{
//Setup Viewport
D3D10_VIEWPORT viewPort;
viewPort.TopLeftX = 0;
viewPort.TopLeftY = 0;
viewPort.Width = width;
viewPort.Height = height;
viewPort.MinDepth = 0;
viewPort.MaxDepth = 1.0f;
//ViewPort setup, finalize by running magic functions of D3D10!
pD3DDevice->RSSetViewports(1, &viewPort);
return true;
}
bool g_DXInit::setupRasterize()
{
D3D10_RASTERIZER_DESC rsDesc;
ZeroMemory(&rsDesc, sizeof(D3D10_RASTERIZER_DESC));
rsDesc.FillMode = D3D10_FILL_SOLID;
rsDesc.CullMode = D3D10_CULL_NONE;
rsDesc.FrontCounterClockwise = true;
rsDesc.DepthBias = false;
rsDesc.DepthBiasClamp = 0;
rsDesc.SlopeScaledDepthBias = 0;
rsDesc.DepthClipEnable = true;
rsDesc.ScissorEnable = false;
rsDesc.MultisampleEnable = false;
rsDesc.AntialiasedLineEnable = true;
pD3DDevice->CreateRasterizerState(&rsDesc, &noCullRS);
return true;
}
If any other parts are needed just let me know, Effect files info is already in the OP.
Once again already fixed, the sprite I was drawing text info to was messing with the viewport or covering up what I was rendering or something.
Edited by darkreign, 01 May 2012 - 10:44 AM.