Jump to content
  • Advertisement

darkrei9n

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

100 Neutral

About darkrei9n

  • Rank
    Member
  1. darkrei9n

    Trouble With D3DX10CreateEffectFromFile

    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.
  2. darkrei9n

    Trouble With D3DX10CreateEffectFromFile

    It is made with the DEBUG flag enabled and the d3dx10d.lib is linked. Still fails without placing a proper error message in ID3D10Blob.
  3. Alright, i'm using D3DX10CreateEffectFromFile and its returning E_FAIL. However the issue arises with the ID3D10Blob output on the function, its returning nothing. I don't know whether this means somethings wrong with the arguments I'm passing or that DirectX just really does not like me. Here is the code if anyone can help. Specific function where its called. bool gShaderHandle::buildFX(LPCWSTR filename) { HRESULT hr = NULL; ID3D10Blob* errorTwo = 0; hr = D3DX10CreateEffectFromFile(filename, NULL, NULL, "fx_4_0", D3D10_SHADER_DEBUG, 0, device, 0, 0, &gEffect, &errorTwo, 0); if(FAILED(hr)) { if(errorTwo) { MessageBoxA(0, (char*)errorTwo->GetBufferPointer(), 0, 0); errorTwo->Release(); } } gTech = gEffect->GetTechniqueByName("techPass"); return true; } Class its part of class gShaderHandle { private: ID3D10Effect* gEffect; ID3D10EffectTechnique* gTech; ID3D10InputLayout* gVertexLayout; ID3D10Device* device; public: bool buildFX(LPCWSTR filename); bool buildVertexLayouts(); ID3D10Effect* returnEffect(); ID3D10EffectTechnique* returnTech(); gShaderHandle(ID3D10Device* *device = NULL); gShaderHandle(ID3D10Device* *device, bool WTF); void modDevice(ID3D10Device* *d3ddevice); }; Effect File cbuffer cbPerObject { float4x4 gWVP; }; void vs(float3 iPosL : POSITION, float4 iColor : COLOR, out float4 oPosH : SV_POSITION, out float4 oColor : COLOR) { oPosH = mul(float4(iPosL, 1.0f), gWVP); oColor = iColor; } float4 ps(float4 posH : SV_POSITION, float4 color : COLOR) : SV_Target { return color; } technique10 techPass { pass P0 { SetVertexShader( CompileShader( vs_4_0, vs() ) ); SetGeometryShader( NULL ); SetPixelShader( CompileShader( ps_4_0, ps() ) ); } }
  4. darkrei9n

    Indices and me probably being an idiot

    Once again I fixed the issue through some really odd tinkering. This time I changed when I used my matrix projectionMatrix and it worked... Also, my mesh cube is more... diamond shaped than cube.
  5. darkrei9n

    Indices and me probably being an idiot

    The thing is that near and far plane are set to 1 and 1000 respectively. Its not the far and near plane. Last time I had this issue it had to do with my world and projection matrix and I mixed them up or something. Can't remember how I fixed it though.
  6. darkrei9n

    Indices and me probably being an idiot

    Well, I ran into another issue after moving over to a mesh format and implementing lighting. I had this issue before and I fixed it but I can't remember how. However the issue now is that it draws (correctly from what I can see) but its only drawing part of it. If I move my camera around it sort of cuts off everything past a certain distance and for some reason that distance is about an inch from the camera.
  7. darkrei9n

    Indices and me probably being an idiot

    Dunno. I copy and pasted a backup's code over all my initialization stuff. I can't remember changing anything there so I can't imagine what it was.
  8. darkrei9n

    Indices and me probably being an idiot

    Fixed it. moved to a backup of my original and apparently I changed something earlier on in the code that effected it.
  9. darkrei9n

    Indices and me probably being an idiot

    I've beginning to notice that the major issue is with the left face, no matter what, one point is always connected to vertex 4. Issue is far from my code, I'm beginning to think either my computer is racist towards cubes, or I messed up something earlier on in the code. I just took code out of a book I have for drawing a cube and the same crap is also happening.
  10. darkrei9n

    Indices and me probably being an idiot

    No luck with any of those, it still is messed up. I think the coordinates themselves are messed up.
  11. darkrei9n

    Indices and me probably being an idiot

    I tried drawing it out on paper. No luck. Infact that was the first thing I tried.
  12. Alright I'm having an issue with indices and freaking drawing a simple cube. Either me or the indices are being retarded about this. Its probably me. I think maybe I got the addition for coordinates messed up. const int size = 2; UINT numVertices = 24; vertex* v = NULL; pVertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**) &v ); //vertices for a cube v[0] = vertex( D3DXVECTOR3(x,y+size,z), D3DXVECTOR4(1,0,0,1) ); //front top left v[1] = vertex( D3DXVECTOR3(x+size,y+size,z), D3DXVECTOR4(0,1,0,1) ); //front top right v[2] = vertex( D3DXVECTOR3(x,y,z), D3DXVECTOR4(0,0,1,1) ); //front bottom left v[3] = vertex( D3DXVECTOR3(x+size,y,z), D3DXVECTOR4(1,1,0,1) ); //front bottom right v[4] = vertex( D3DXVECTOR3(x,y+size,z+size), D3DXVECTOR4(1,0,0,1) ); //back top left v[5] = vertex( D3DXVECTOR3(x+size,y+size,z+size), D3DXVECTOR4(0,1,0,1) ); //back top right v[6] = vertex( D3DXVECTOR3(x,y,z+size), D3DXVECTOR4(0,0,1,1) ); //back bottom left v[7] = vertex( D3DXVECTOR3(x+size,y,z+size), D3DXVECTOR4(1,1,0,1) ); //back bottom right pVertexBuffer->Unmap(); //create indexes for a cube unsigned int* i = NULL; pIndexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**) &i ); //front face i[0] = 0; i[1] = 1; i[2] = 3; i[3] = 2; i[4] = 0xffffffff; //start new strip //right face i[5] = 0; i[6] = 2; i[7] = 6; i[8] = 4; i[9] = 0xffffffff; //left face i[10] = 5; i[11] = 7; i[12] = 3; i[13] = 1; i[14] = 0xffffffff; //back face i[15] = 6; i[16] = 4; i[17] = 5; i[18] = 7; i[19] = 0xffffffff; //top face i[20] = 0; i[21] = 4; i[22] = 1; i[23] = 5; i[24] = 0xffffffff; //bottom face i[25] = 6; i[26] = 2; i[27] = 3; i[28] = 7; pIndexBuffer->Unmap();
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!