Jump to content
  • Advertisement

paperplane

Member
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

379 Neutral

About paperplane

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. paperplane

    Vertex Data Structures

      The current implementation (Vertex Structs) has produced a bit of a mess, because there were different types of structs (containing different kind of elements) and I run into problems when I'm trying to do something to a set of vertices, create shapes and similar because I end up with code duplication for different kind of vertices. I tried to implement some conversions between the types, but that also created different set of problems (for example, what to do with the color of vertices when converting from a type that doesn't have color to one that does? I ended up coding the color in the part of the code that should be vertex-type agnostic). But, I do agree that there is a big advantage to being able to see what is the type of vertex from the structure name and accessing the elements easy. I'll probably stick to that for now, and clean the code up a bit. Most of the problems can probably be solved with better application design. Thanks for the answer. 
  2. paperplane

    Vertex Data Structures

      So, if I understood you well, I should create a simple mesh format (internal for my application) and I could avoid using any vertex structures in code? I will look into the topic, although it seems a bit too complex for my current time schedule. Thanks for the answer!
  3. Hello, I am improving some code I have for my DirectX 11 college assignment and one of the things I want to take care of is the way my code deals with vertices.  I have a couple of types of vertices that are simply defined like this: struct VertexColorPosition { DirectX::XMFLOAT4 Position; DirectX::XMFLOAT4 Color; }; So, for the moment I'm relying on templates to do everything about vertices, but this approach often seems to get inconvenient.  Is there a more clever way to deal with vertices?  I found things like D3DFVF (but it seems to be a part of DX9). Thanks in advance for answer!  
  4.   Thanks a lot! It's working now.
  5. Hello, I have a problem with creation of depthstencil view. When creating DXGI_SWAP_CHAIN_DESC, I set the following:  sd.SampleDesc.Count = 4; sd.SampleDesc.Quality = m_4xMSaaQuality - 1; After that, if I put the following: D3D11_TEXTURE2D_DESC depthStencilDesc; depthStencilDesc.SampleDesc.Count = 4; depthStencilDesc.SampleDesc.Quality = m_4xMSaaQuality - 1;  CreateDepthStencilView() fails, and HRESULT is E_INVALIDARG One or more arguments are invalid.     If I set SampleDesc.Count = 1 and SampleDesc.Quality = 0 in both places everything works properly.   Also, some code that might matter:   Microsoft::WRL:: ComPtr<ID3D11Texture2D> mDepthStencilBufer; CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDescription(D3D11_DSV_DIMENSION_TEXTURE2D); HRESULT dsHR = m_d3dDevice->CreateTexture2D(&depthStencilDesc, 0, mDepthStencilBufer.GetAddressOf()); dsHR = m_d3dDevice->CreateDepthStencilView(mDepthStencilBufer.Get(), &depthStencilViewDescription, m_depthStencilView.GetAddressOf()); Thanks in advance for help!
  6. paperplane

    How to compile shaders in DX11

      Ok, nevermind, I found the problem, forgot to set the inputlayout. 
  7. paperplane

    How to compile shaders in DX11

    Hello,  So, I tried to create a simple triangle renderer with the info that I got here (again, thank you all ) and I can't get it working properly. I took the code from Microsoft tutorial (https://code.msdn.microsoft.com/windowsdesktop/Direct3D-Tutorial-Win32-829979ef) and it compiled just fine, but when I try to load shaders from compiled .cso files (instead of the way they do it in that sample) my triangle doesn't get rendered. Everything compiles, none of the HRESULT returning functions fail but all I see is empty screen.     struct SimpleVertex { XMFLOAT3 Pos; }; ID3D11VertexShader* vShader; ID3DBlob* vShaderBlob; D3DReadFileToBlob(L"SimpleVertexShader.cso", &vShaderBlob); devRes->getDevice()->CreateVertexShader(vShaderBlob->GetBufferPointer(), vShaderBlob->GetBufferSize(), nullptr, &vShader); ID3D11PixelShader *pShader; ID3DBlob* pShaderBlob; D3DReadFileToBlob(L"SimplePixelShader.cso", &pShaderBlob); devRes->getDevice()->CreatePixelShader(pShaderBlob->GetBufferPointer(), pShaderBlob->GetBufferSize(), nullptr, &pShader); ID3D11InputLayout* inputLayout = nullptr; D3D11_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; UINT numElements = ARRAYSIZE(layout); devRes->getDevice()->CreateInputLayout(layout, numElements, vShaderBlob->GetBufferPointer(), vShaderBlob->GetBufferSize(), &inputLayout); SimpleVertex vertices[] = { XMFLOAT3(0.0f, 0.5f, 0.5f), XMFLOAT3(0.5f, -0.5f, 0.5f), XMFLOAT3(-0.5f, -0.5f, 0.5f), }; D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_DEFAULT; bd.ByteWidth = sizeof(SimpleVertex) * 3; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA InitData; ZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = vertices; ID3D11Buffer*   g_pVertexBuffer = nullptr; devRes->getDevice()->CreateBuffer(&bd, &InitData, &g_pVertexBuffer); UINT stride = sizeof(SimpleVertex); UINT offset = 0; devRes->getContext()->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset); // Set primitive topology devRes->getContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); devRes->getContext()->VSSetShader(vShader, nullptr, 0); devRes->getContext()->PSSetShader(pShader, nullptr, 0); devRes->getContext()->Draw(3, 0); SwapChain->Present() is done elsewhere, and I know that works because I can use it with Context->ClearRenderTargetView() to change the background color.     Any clues what's wrong?
  8. paperplane

    How to compile shaders in DX11

      When you say effects 11, do you mean this? https://github.com/Microsoft/FX11 So, I can just include it in my VS project and compile the effects code from the FL's book without changes? Thanks for the reply!
  9. paperplane

    How to compile shaders in DX11

    If you are using Visual Studio, yes. But there's a little detail: you need to specify what profile you want the shader to compile to (what kind of shader and what version of HLSL). That's pretty easy, you just need to go to the properties of the HLSL file (right-click the file in the solution explorer and click properties) and set it up. If you need any help and you can't find it on Google or MSDN, just ask. EDIT: Take a look at this. Look for "Shader type" and "Shader model". EDIT2: Also, you either need to name your main function "main" or you must set the Entrypoint name parameter to whatever you're using (like PSTextured), so the compiler knows where your code starts from.   Thanks a lot for your answer, that link was very informative! I hope I won't have to ask too many questions (although, some of these things are really hard to google). 
  10. paperplane

    How to compile shaders in DX11

    So i just have to create *.hlsl files and read the binaries from *.cso? That is way easier than I hoped...    Thank you both for your answers!
  11. Hello and sorry if this is a stupid question, I am new to DirectX. I am working on a project for college (a simple DX11 application) and I'm using Frank Luna's Intro to Game programming with DX11. The thing is, he uses Effects framework and my professor referred to that framework as being old (I may have misunderstood that, but I don't think I did). I found some materials that don't use effects framework, but all those were for Windows Metro applications (I am building a win32 application). So, do I have to download DirectX SDK and use effects framework, or can I get around that with something from Windows SDK?   Thanks for reply and I sorry for any typos, grammar errors (not a native English speaker)
  • 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!